From 3eb4043f4a65d15996b8463502bef5b680019a57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 16:43:32 -0600 Subject: Adding in support for icons, specifically passing them back and forth on the bus --- tests/im-client.c | 20 ++++++++++++++++++-- tests/listen-and-print.c | 5 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/im-client.c b/tests/im-client.c index aa2ef8c..d47903b 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -23,10 +23,14 @@ with this program. If not, see . #include "libindicate/server.h" #include "libindicate/indicator-message.h" +gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png"; +gchar * pathb = "/usr/share/icons/hicolor/22x22/apps/empathy.png"; +gchar * lastpath = NULL; + static gboolean timeout_cb (gpointer data) { - g_debug("Modifying time"); + g_debug("Modifying properties"); IndicateIndicator * indicator = INDICATE_INDICATOR(data); @@ -34,6 +38,18 @@ timeout_cb (gpointer data) g_get_current_time(&time); indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time); + if (lastpath == patha) { + lastpath = pathb; + } else { + lastpath = patha; + } + + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(lastpath, NULL); + g_return_val_if_fail(pixbuf != NULL, TRUE); + + indicate_indicator_set_property_icon(INDICATE_INDICATOR(indicator), "icon", pixbuf); + g_object_unref(G_OBJECT(pixbuf)); + return TRUE; } @@ -66,7 +82,7 @@ main (int argc, char ** argv) g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAY, G_CALLBACK(display), NULL); - g_timeout_add_seconds(180, timeout_cb, indicator); + g_timeout_add_seconds(10, timeout_cb, indicator); g_main_loop_run(g_main_loop_new(NULL, FALSE)); diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c index dca299b..a4c8c25 100644 --- a/tests/listen-and-print.c +++ b/tests/listen-and-print.c @@ -48,8 +48,9 @@ show_property_time_cb (IndicateListener * listener, IndicateListenerServer * ser static void show_property_icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data) { - - + g_debug("Indicator Property: %s %d %s %dx%d", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, gdk_pixbuf_get_width(propertydata), gdk_pixbuf_get_height(propertydata)); + g_object_unref(G_OBJECT(propertydata)); + return; } static void -- cgit v1.2.3