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> Tue Dec 13 2005 John (J5) Palmieri <johnp@redhat.com>
* Release 0.3.0 * 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@ # @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -15,6 +15,8 @@
@SET_MAKE@ @SET_MAKE@
SOURCES = $(libnotify_la_SOURCES)
srcdir = @srcdir@ srcdir = @srcdir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
VPATH = @srcdir@ VPATH = @srcdir@

View File

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

View File

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

View File

@ -26,7 +26,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#define DBUS_API_SUBJECT_TO_CHANGE 1 #define DBUS_API_SUBJECT_TO_CHANGE
#include <glib.h> #include <glib.h>
#include <dbus/dbus.h> #include <dbus/dbus.h>
@ -59,7 +59,8 @@ main()
n = notify_notification_new ("Matt is online", "", NULL, NULL); n = notify_notification_new ("Matt is online", "", NULL, NULL);
notify_notification_set_timeout (n, NOTIFY_TIMEOUT_NEVER); 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"); notify_notification_set_category (n, "presence.online");
if (!notify_notification_show (n, NULL)) { if (!notify_notification_show (n, NULL)) {

View File

@ -1,12 +1,12 @@
/* /*
* @file tests/test-image.c Unit test: images * @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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -31,7 +31,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#define DBUS_API_SUBJECT_TO_CHANGE 1 #define DBUS_API_SUBJECT_TO_CHANGE
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -42,72 +42,78 @@
GMainLoop *loop; GMainLoop *loop;
NotifyNotification *n; NotifyNotification *n;
int main(int argc, char *argv[]) { int
main(int argc, char *argv[])
{
char file[PATH_MAX]; char file[PATH_MAX];
int size; int size;
char *uri; char *uri;
GdkPixbuf *icon; GdkPixbuf *icon;
gchar *buf;
gsize buf_size;
GtkWidget *helper; 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, "x", 300);
notify_notification_set_hint_int32 (n, "y", 24); 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"); fprintf(stderr, "failed to send notification\n");
return 1; return 1;
} }
g_usleep (5000000); //5 seconds g_usleep(5000000); // 5 seconds
size = readlink("/proc/self/cwd", file, PATH_MAX - 1); size = readlink("/proc/self/cwd", file, PATH_MAX - 1);
file[size] = '\0'; 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); 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"); fprintf(stderr, "failed to send notification\n");
return 1; 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 * This is just a hack to get a stock icon's pixbuf in a realworld app
you would know the file location and open it up with * if you were sending bitmapped data you would know the file location
a method that could generate a bmp for you*/ * and open it up with a method that could generate a bmp for you
*/
helper = gtk_button_new(); helper = gtk_button_new();
icon = gtk_widget_render_icon (helper, icon = gtk_widget_render_icon(helper,
GTK_STOCK_DIALOG_QUESTION, GTK_STOCK_DIALOG_QUESTION,
GTK_ICON_SIZE_DIALOG, GTK_ICON_SIZE_DIALOG,
""); "");
notify_notification_set_icon_data_from_pixbuf(n, icon);
notify_notification_set_icon_data_from_pixbuf (n, if (!notify_notification_show(n, NULL))
icon); {
if (!notify_notification_show (n, NULL)) {
fprintf(stderr, "failed to send notification\n"); fprintf(stderr, "failed to send notification\n");
return 1; return 1;
} }
gtk_widget_destroy (helper); gtk_widget_destroy(helper);
g_object_unref ((GObject *)icon); g_object_unref(G_OBJECT(icon));
g_usleep(5000000); // 5 seconds
g_usleep (5000000); //5 seconds
return 0; return 0;
} }

View File

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

View File

@ -4,59 +4,61 @@
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
static int count = 0; static int count = 0;
void on_exposed (GtkWidget *widget, GdkEventExpose *ev, void *user_data) { static void
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data); 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); 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);
} }
int main(int argc, char *argv[]) { static void
NotifyNotification *n; on_clicked(GtkButton *button, void *user_data)
GtkWidget *window; {
GtkWidget *button; gchar *buf;
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
GError *error; count++;
error = NULL; 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_notification_show(n, NULL);
notify_init("Replace Test"); }
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); int
button = gtk_button_new_with_label ("click here to change notification"); main(int argc, char *argv[])
gtk_container_add (GTK_CONTAINER(window), button); {
NotifyNotification *n;
gtk_widget_show_all (window); GtkWidget *window;
GtkWidget *button;
n = notify_notification_new ("Widget Attachment Test", "Button has not been clicked yet", gtk_init(&argc, &argv);
NULL, //no icon notify_init("Replace Test");
button); //attach to button
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("click here to change notification");
notify_notification_set_timeout (n, 0); //don't timeout gtk_container_add(GTK_CONTAINER(window), button);
g_signal_connect (button, "clicked", (GCallback *)on_clicked, n); gtk_widget_show_all(window);
g_signal_connect_after (button, "expose-event", (GCallback *)on_exposed, n);
n = notify_notification_new("Widget Attachment Test",
gtk_main(); "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 * @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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -26,40 +26,39 @@
#include <dbus/dbus.h> #include <dbus/dbus.h>
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
static void static void
_handle_closed (GObject *o) _handle_closed(GObject *obj)
{ {
g_message ("closing"); g_message("closing");
g_object_unref (o); g_object_unref(obj);
} }
static void static void
emit_notification(int x, int y) emit_notification(int x, int y)
{ {
static char buffer[BUFSIZ]; char *buffer;
NotifyNotification *n; NotifyNotification *n;
g_snprintf(buffer, sizeof(buffer), buffer = g_strdup_printf("This notification should point to %d, %d.",
"This notification should point to %d, %d.", x, y); x, y);
n = notify_notification_new ("X, Y Test", n = notify_notification_new("X, Y Test", buffer, NULL, NULL);
buffer, g_free(buffer);
NULL, NULL);
notify_notification_set_hint_int32 (n, "x", x); notify_notification_set_hint_int32(n, "x", x);
notify_notification_set_hint_int32 (n, "y", y); 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"); fprintf(stderr, "failed to send notification\n");
return 1;
}
} }
static gboolean static gboolean
_popup_random_bubble (void) _popup_random_bubble(gpointer unused)
{ {
GdkDisplay *display; GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
@ -72,8 +71,8 @@ _popup_random_bubble (void)
screen_x2 = gdk_screen_get_width(screen) - 1; screen_x2 = gdk_screen_get_width(screen) - 1;
screen_y2 = gdk_screen_get_height(screen) - 1; screen_y2 = gdk_screen_get_height(screen) - 1;
x = g_random_int_range (0, screen_x2); x = g_random_int_range(0, screen_x2);
y = g_random_int_range (0, screen_y2); y = g_random_int_range(0, screen_y2);
emit_notification(x, y); emit_notification(x, y);
return TRUE; return TRUE;
@ -82,19 +81,20 @@ _popup_random_bubble (void)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
GMainLoop *loop; GMainLoop *loop;
DBusConnection *conn; DBusConnection *conn;
gdk_init(&argc, &argv); gdk_init(&argc, &argv);
notify_init("XY"); 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); return 0;
g_main_loop_run (loop);
} }