Clean up lots of warnings.

This commit is contained in:
Christian Hammond 2006-01-09 18:16:48 +00:00
parent 83f6529c18
commit fb513c854d
9 changed files with 175 additions and 141 deletions

View File

@ -1,3 +1,17 @@
Mon Jan 09 10:15:57 PST 2006 Christian Hammond <chipx86@chipx86.com>
* libnotify/Makefile.in:
* libnotify/notify.c:
* libnotify/notifynotification.c:
* tests/test-default-action.c:
* tests/test-image.c:
* tests/test-multi-actions.c:
* tests/test-replace-widget.c:
* tests/test-xy-stress.c:
- Clean up lots of warnings.
========================= 0.3.0 =========================
Tue Dec 13 2005 John (J5) Palmieri <johnp@redhat.com>
* Release 0.3.0

View File

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -15,6 +15,8 @@
@SET_MAKE@
SOURCES = $(libnotify_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@

View File

@ -46,6 +46,7 @@ static gchar *_app_name = NULL;
# define format_func
#endif
#if 0
static void format_func
print_error (char *message, ...)
{
@ -59,6 +60,7 @@ print_error (char *message, ...)
fprintf (stderr, "%s(%d): libnotify: %s",
(getenv ("_") ? getenv ("_") : ""), getpid (), buf);
}
#endif
gboolean
notify_init (const char *app_name)

View File

@ -474,11 +474,9 @@ _notify_notification_show_internal (NotifyNotification *notification,
NotifyNotificationPrivate *priv;
GError *tmp_error;
gchar **action_array;
int i;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = notification->priv;
tmp_error = NULL;

View File

@ -26,7 +26,7 @@
#include <assert.h>
#include <string.h>
#define DBUS_API_SUBJECT_TO_CHANGE 1
#define DBUS_API_SUBJECT_TO_CHANGE
#include <glib.h>
#include <dbus/dbus.h>
@ -59,7 +59,8 @@ main()
n = notify_notification_new ("Matt is online", "", NULL, NULL);
notify_notification_set_timeout (n, NOTIFY_TIMEOUT_NEVER);
notify_notification_add_action (n, "default", "Do Default Action", callback);
notify_notification_add_action (n, "default", "Do Default Action",
(NotifyActionCallback)callback);
notify_notification_set_category (n, "presence.online");
if (!notify_notification_show (n, NULL)) {

View File

@ -1,12 +1,12 @@
/*
* @file tests/test-image.c Unit test: images
*
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -31,7 +31,7 @@
#include <unistd.h>
#include <fcntl.h>
#define DBUS_API_SUBJECT_TO_CHANGE 1
#define DBUS_API_SUBJECT_TO_CHANGE
#include <glib.h>
#include <gtk/gtk.h>
@ -42,72 +42,78 @@
GMainLoop *loop;
NotifyNotification *n;
int main(int argc, char *argv[]) {
int
main(int argc, char *argv[])
{
char file[PATH_MAX];
int size;
char *uri;
char *uri;
GdkPixbuf *icon;
gchar *buf;
gsize buf_size;
GtkWidget *helper;
gtk_init (&argc, &argv);
gtk_init(&argc, &argv);
if (!notify_init("Images Test")) exit(1);
if (!notify_init("Images Test"))
exit(1);
n = notify_notification_new ("Icon Test", "Testing stock icon", "stock_help", NULL);
n = notify_notification_new("Icon Test", "Testing stock icon",
"stock_help", NULL);
notify_notification_set_hint_int32 (n, "x", 300);
notify_notification_set_hint_int32 (n, "y", 24);
notify_notification_set_hint_int32(n, "x", 300);
notify_notification_set_hint_int32(n, "y", 24);
notify_notification_set_timeout(n, NOTIFY_TIMEOUT_NEVER);
notify_notification_set_timeout (n, NOTIFY_TIMEOUT_NEVER);
if (!notify_notification_show (n, NULL)) {
if (!notify_notification_show(n, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
g_usleep (5000000); //5 seconds
g_usleep(5000000); // 5 seconds
size = readlink("/proc/self/cwd", file, PATH_MAX - 1);
file[size] = '\0';
uri = g_strdup_printf ("file://%s/%s", file, "applet-critical.png");
uri = g_strdup_printf("file://%s/%s", file, "applet-critical.png");
printf("sending %s\n", uri);
notify_notification_update (n, "Alert!", "Testing URI icons", uri);
notify_notification_update(n, "Alert!", "Testing URI icons", uri);
if (!notify_notification_show (n, NULL)) {
if (!notify_notification_show(n, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
g_usleep (5000000); //5 seconds
g_usleep(5000000); // 5 seconds
notify_notification_update (n, "Raw image test", "Testing sending raw pixbufs", NULL);
notify_notification_update(n, "Raw image test",
"Testing sending raw pixbufs", NULL);
/* This is just a hack to get a stock icon's pixbuf
in a realworld app if you were sending bitmapped data
you would know the file location and open it up with
a method that could generate a bmp for you*/
/*
* This is just a hack to get a stock icon's pixbuf in a realworld app
* if you were sending bitmapped data you would know the file location
* and open it up with a method that could generate a bmp for you
*/
helper = gtk_button_new();
icon = gtk_widget_render_icon (helper,
icon = gtk_widget_render_icon(helper,
GTK_STOCK_DIALOG_QUESTION,
GTK_ICON_SIZE_DIALOG,
"");
notify_notification_set_icon_data_from_pixbuf(n, icon);
notify_notification_set_icon_data_from_pixbuf (n,
icon);
if (!notify_notification_show (n, NULL)) {
if (!notify_notification_show(n, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
gtk_widget_destroy (helper);
g_object_unref ((GObject *)icon);
gtk_widget_destroy(helper);
g_object_unref(G_OBJECT(icon));
g_usleep(5000000); // 5 seconds
g_usleep (5000000); //5 seconds
return 0;
}

View File

@ -1,12 +1,12 @@
/*
* @file tests/test-multi-actions.c Unit test: multiple actions
*
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -23,22 +23,22 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define DBUS_API_SUBJECT_TO_CHANGE 1
#define DBUS_API_SUBJECT_TO_CHANGE
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
GMainLoop *loop;
static GMainLoop *loop;
static void help_callback(NotifyNotification *n, const char *action)
static void
help_callback(NotifyNotification *n, const char *action)
{
assert( action != NULL );
assert( strcmp (action, "help") == 0 );
g_assert(action != NULL);
g_assert(strcmp(action, "help") == 0);
printf("You clicked Help\n");
@ -47,10 +47,11 @@ static void help_callback(NotifyNotification *n, const char *action)
g_main_loop_quit(loop);
}
static void ignore_callback(NotifyNotification *n, const char *action)
static void
ignore_callback(NotifyNotification *n, const char *action)
{
assert( action != NULL );
assert( strcmp (action, "ignore") == 0 );
g_assert(action != NULL);
g_assert(strcmp(action, "ignore") == 0);
printf("You clicked Ignore\n");
@ -59,11 +60,11 @@ static void ignore_callback(NotifyNotification *n, const char *action)
g_main_loop_quit(loop);
}
static void empty_callback(NotifyNotification *n, const char *action)
static void
empty_callback(NotifyNotification *n, const char *action)
{
assert( action != NULL );
assert( strcmp (action, "empty") == 0 );
g_assert(action != NULL);
g_assert(strcmp(action, "empty") == 0);
printf("You clicked Empty Trash\n");
@ -73,27 +74,35 @@ static void empty_callback(NotifyNotification *n, const char *action)
}
int main() {
NotifyNotification *n;
int
main(int argc, char **argv)
{
NotifyNotification *n;
DBusConnection *conn;
if (!notify_init("Multi Action Test")) exit(1);
if (!notify_init("Multi Action Test"))
exit(1);
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
loop = g_main_loop_new(NULL, FALSE);
dbus_connection_setup_with_g_main(conn, NULL);
n = notify_notification_new ("Low disk space",
"You can free up some disk space by "
"emptying the trash can.",
NULL, NULL);
notify_notification_set_timeout (n, NOTIFY_TIMEOUT_NEVER);
notify_notification_add_action (n, "help", "Help", help_callback);
notify_notification_add_action (n, "ignore", "Ignore", ignore_callback);
notify_notification_add_action (n, "empty", "Empty Trash", empty_callback);
notify_notification_set_category (n, "device");
n = notify_notification_new("Low disk space",
"You can free up some disk space by "
"emptying the trash can.",
NULL, NULL);
notify_notification_set_timeout(n, NOTIFY_TIMEOUT_NEVER);
notify_notification_add_action(n, "help", "Help",
(NotifyActionCallback)help_callback);
notify_notification_add_action(n, "ignore", "Ignore",
(NotifyActionCallback)ignore_callback);
notify_notification_add_action(n, "empty", "Empty Trash",
(NotifyActionCallback)empty_callback);
notify_notification_set_category(n, "device");
if (!notify_notification_show (n, NULL)) {
if (!notify_notification_show(n, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}

View File

@ -4,59 +4,61 @@
#include <glib.h>
#include <gtk/gtk.h>
static int count = 0;
void on_exposed (GtkWidget *widget, GdkEventExpose *ev, void *user_data) {
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
static void
on_exposed(GtkWidget *widget, GdkEventExpose *ev, void *user_data)
{
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
g_signal_handlers_disconnect_by_func(widget, on_exposed, user_data);
g_signal_handlers_disconnect_by_func(widget, on_exposed, user_data);
notify_notification_show (n, NULL);
}
void on_clicked (GtkButton *button, void *user_data) {
GError *error;
gchar *buf;
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
count++;
buf = g_strdup_printf ("You clicked the button %i times", count);
notify_notification_update (n, "Widget Attachment Test",
buf, NULL);
notify_notification_show (n, NULL);
g_free (buf);
notify_notification_show(n, NULL);
}
int main(int argc, char *argv[]) {
NotifyNotification *n;
GtkWidget *window;
GtkWidget *button;
static void
on_clicked(GtkButton *button, void *user_data)
{
gchar *buf;
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
GError *error;
error = NULL;
count++;
buf = g_strdup_printf("You clicked the button %i times", count);
notify_notification_update(n, "Widget Attachment Test", buf, NULL);
g_free(buf);
gtk_init (&argc, &argv);
notify_init("Replace Test");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label ("click here to change notification");
gtk_container_add (GTK_CONTAINER(window), button);
gtk_widget_show_all (window);
n = notify_notification_new ("Widget Attachment Test", "Button has not been clicked yet",
NULL, //no icon
button); //attach to button
notify_notification_set_timeout (n, 0); //don't timeout
g_signal_connect (button, "clicked", (GCallback *)on_clicked, n);
g_signal_connect_after (button, "expose-event", (GCallback *)on_exposed, n);
gtk_main();
notify_notification_show(n, NULL);
}
int
main(int argc, char *argv[])
{
NotifyNotification *n;
GtkWidget *window;
GtkWidget *button;
gtk_init(&argc, &argv);
notify_init("Replace Test");
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("click here to change notification");
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show_all(window);
n = notify_notification_new("Widget Attachment Test",
"Button has not been clicked yet",
NULL, //no icon
button); //attach to button
notify_notification_set_timeout(n, 0); //don't timeout
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(on_clicked), n);
g_signal_connect_after(G_OBJECT(button), "expose-event",
G_CALLBACK(on_exposed), n);
gtk_main();
return 0;
}

View File

@ -1,12 +1,12 @@
/*
* @file tests/test-xy.c Unit test: X, Y hints
*
* @Copyright (C) 2005 Christian Hammond <chipx86@chipx86.com>
* @Copyright(C) 2005 Christian Hammond <chipx86@chipx86.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -26,40 +26,39 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
static void
_handle_closed (GObject *o)
_handle_closed(GObject *obj)
{
g_message ("closing");
g_object_unref (o);
g_message("closing");
g_object_unref(obj);
}
static void
emit_notification(int x, int y)
{
static char buffer[BUFSIZ];
char *buffer;
NotifyNotification *n;
g_snprintf(buffer, sizeof(buffer),
"This notification should point to %d, %d.", x, y);
buffer = g_strdup_printf("This notification should point to %d, %d.",
x, y);
n = notify_notification_new ("X, Y Test",
buffer,
NULL, NULL);
n = notify_notification_new("X, Y Test", buffer, NULL, NULL);
g_free(buffer);
notify_notification_set_hint_int32 (n, "x", x);
notify_notification_set_hint_int32 (n, "y", y);
notify_notification_set_hint_int32(n, "x", x);
notify_notification_set_hint_int32(n, "y", y);
g_signal_connect (n, "closed", _handle_closed, NULL);
g_signal_connect(G_OBJECT(n), "closed",
G_CALLBACK(_handle_closed), NULL);
if (!notify_notification_show (n, NULL)) {
if (!notify_notification_show(n, NULL))
fprintf(stderr, "failed to send notification\n");
return 1;
}
}
static gboolean
_popup_random_bubble (void)
_popup_random_bubble(gpointer unused)
{
GdkDisplay *display;
GdkScreen *screen;
@ -72,8 +71,8 @@ _popup_random_bubble (void)
screen_x2 = gdk_screen_get_width(screen) - 1;
screen_y2 = gdk_screen_get_height(screen) - 1;
x = g_random_int_range (0, screen_x2);
y = g_random_int_range (0, screen_y2);
x = g_random_int_range(0, screen_x2);
y = g_random_int_range(0, screen_y2);
emit_notification(x, y);
return TRUE;
@ -82,19 +81,20 @@ _popup_random_bubble (void)
int
main(int argc, char **argv)
{
GMainLoop *loop;
DBusConnection *conn;
GMainLoop *loop;
DBusConnection *conn;
gdk_init(&argc, &argv);
notify_init("XY");
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
dbus_connection_setup_with_g_main(conn, NULL);
dbus_connection_setup_with_g_main (conn, NULL);
g_timeout_add(1000, _popup_random_bubble, NULL);
g_timeout_add (1000, _popup_random_bubble, NULL);
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
return 0;
}