From 1a5e21eb86c396d5535bfa4f74255740c8ee25d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 13:10:19 -0600 Subject: Added in a way to print the values of properties while they change. More later, but a start. --- tests/listen-and-print.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests') diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c index 6e1104d..dca299b 100644 --- a/tests/listen-and-print.c +++ b/tests/listen-and-print.c @@ -22,10 +22,61 @@ with this program. If not, see . #include #include "libindicate/listener.h" +static void +show_property_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) +{ + g_debug("Indicator Property: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, propertydata); + return; +} + +static void +show_property_time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data) +{ + time_t timet; + struct tm * structtm; + + timet = propertydata->tv_sec; + structtm = localtime(&timet); + + gchar timestring[80]; + strftime(timestring, 80, "%I:%M", structtm); + + g_debug("Indicator Property: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, timestring); + return; +} + +static void +show_property_icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data) +{ + + +} + +static void +show_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property) +{ + if (!strcmp(property, "icon")) { + indicate_listener_get_property_icon(listener, server, indicator, property, show_property_icon_cb, NULL); + } else if (!strcmp(property, "time")) { + indicate_listener_get_property_time(listener, server, indicator, property, show_property_time_cb, NULL); + } else { + indicate_listener_get_property(listener, server, indicator, property, show_property_cb, NULL); + } + + return; +} + +static void +get_properties (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator) +{ + //TODO: Not in API yet. +} + static void indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) { g_debug("Indicator Added: %s %d %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type); + get_properties(listener, server, indicator); } static void @@ -38,6 +89,7 @@ static void indicator_modified (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property, gpointer data) { g_debug("Indicator Modified: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type, property); + show_property(listener, server, indicator, property); } static void -- cgit v1.2.3