2005-11-10 13:18:10 -06:00
|
|
|
#include <libnotify/notify.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static int count = 0;
|
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
static void
|
|
|
|
on_exposed(GtkWidget *widget, GdkEventExpose *ev, void *user_data)
|
|
|
|
{
|
|
|
|
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
g_signal_handlers_disconnect_by_func(widget, on_exposed, user_data);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
notify_notification_show(n, NULL);
|
2005-11-10 13:18:10 -06:00
|
|
|
}
|
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
static void
|
|
|
|
on_clicked(GtkButton *button, void *user_data)
|
|
|
|
{
|
|
|
|
gchar *buf;
|
|
|
|
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
count++;
|
|
|
|
buf = g_strdup_printf("You clicked the button %i times", count);
|
|
|
|
notify_notification_update(n, "Widget Attachment Test", buf, NULL);
|
|
|
|
g_free(buf);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
notify_notification_show(n, NULL);
|
2005-11-10 13:18:10 -06:00
|
|
|
}
|
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
NotifyNotification *n;
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
notify_init("Replace Test");
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
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);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
gtk_widget_show_all(window);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
n = notify_notification_new("Widget Attachment Test",
|
|
|
|
"Button has not been clicked yet",
|
|
|
|
NULL, //no icon
|
|
|
|
button); //attach to button
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
notify_notification_set_timeout(n, 0); //don't timeout
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
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);
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
gtk_main();
|
2005-11-10 13:18:10 -06:00
|
|
|
|
2006-01-09 12:16:48 -06:00
|
|
|
return 0;
|
2005-11-10 13:18:10 -06:00
|
|
|
}
|