diff options
author | Ted Gould <ted@canonical.com> | 2009-02-12 16:46:31 -0600 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-02-12 16:46:31 -0600 |
commit | a7d062ccbb160119819da8e3f01cdaadc922c24e (patch) | |
tree | f4e403b6e267e437659d850567b02ed2a0861256 /tests/listen-and-print.c | |
parent | 24fd755fa2347344ab7491f387ce3771a825bd7e (diff) | |
parent | 2c157aa63cbc5904ca8ae1481a705309be6b7ed2 (diff) | |
download | libayatana-indicator-a7d062ccbb160119819da8e3f01cdaadc922c24e.tar.gz libayatana-indicator-a7d062ccbb160119819da8e3f01cdaadc922c24e.tar.bz2 libayatana-indicator-a7d062ccbb160119819da8e3f01cdaadc922c24e.zip |
Making time and icons happy and work well. Also adding lots of fun tests for them.
Diffstat (limited to 'tests/listen-and-print.c')
-rw-r--r-- | tests/listen-and-print.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c index 6e1104d..a4c8c25 100644 --- a/tests/listen-and-print.c +++ b/tests/listen-and-print.c @@ -23,9 +23,61 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #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) +{ + 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 +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 +90,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 |