From 184a04a0f101e4005794ea72217dda0f452ae97d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 08:17:37 -0600 Subject: Adding in a time property function --- libindicate/indicator.c | 11 +++++++++++ libindicate/indicator.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index c6df80a..3b6581b 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -244,6 +244,17 @@ indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar } +void +indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time) +{ + gchar * timestr = g_time_val_to_iso8601(time); + if (timestr != NULL) { + indicate_indicator_set_property(indicator, key, timestr); + g_free(timestr); + } + return; +} + const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key) { diff --git a/libindicate/indicator.h b/libindicate/indicator.h index 5423247..5faea3c 100644 --- a/libindicate/indicator.h +++ b/libindicate/indicator.h @@ -99,6 +99,7 @@ void indicate_indicator_user_display (IndicateIndicator * indicator); /* Properties handling */ void indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data); void indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data); +void indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time); const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key); GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator); -- cgit v1.2.3 From 31d107e227f9e6d663ab43bfbecdc5b81bc3ae64 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 08:20:29 -0600 Subject: Using the time property function --- tests/im-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/im-client.c b/tests/im-client.c index db04b8e..255ca37 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -45,10 +45,12 @@ main (int argc, char ** argv) indicator = indicate_indicator_message_new(); indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im"); indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "Ted Gould"); - indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "time", "11:11"); + GTimeVal time; g_get_current_time(&time); + indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time); indicate_indicator_show(INDICATE_INDICATOR(indicator)); - indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "time", "11:12"); + g_get_current_time(&time); + indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time); g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAY, G_CALLBACK(display), NULL); -- cgit v1.2.3 From e1c5a98895875aaa39aeb274e631f19fb0cb6414 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 08:24:36 -0600 Subject: Adding in a timer function to change the time every three minutes or so in order to test modifying times. --- tests/im-client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/im-client.c b/tests/im-client.c index 255ca37..3670bfa 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -23,6 +23,20 @@ with this program. If not, see . #include "libindicate/server.h" #include "libindicate/indicator-message.h" +static gboolean +timeout_cb (gpointer data) +{ + g_debug("Modifying time"); + + IndicateIndicator * indicator = INDICATE_INDICATOR(data); + + GTimeVal time; + g_get_current_time(&time); + indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time); + + return TRUE; +} + static void display (IndicateIndicator * indicator, gpointer data) { @@ -54,6 +68,8 @@ 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_main_loop_run(g_main_loop_new(NULL, FALSE)); return 0; -- cgit v1.2.3 From 8a2cf3491cfd800cf6525b4d9180136976809311 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 08:31:14 -0600 Subject: Setting the properties property and picking up Empathy's desktop file --- docs/reference/libindicate-decl.txt | 5 +++++ tests/im-client.c | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/reference/libindicate-decl.txt b/docs/reference/libindicate-decl.txt index 7143c16..b9657c5 100644 --- a/docs/reference/libindicate-decl.txt +++ b/docs/reference/libindicate-decl.txt @@ -124,6 +124,11 @@ IndicateIndicator * indicator, const gchar * key, const gchar * data IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data +indicate_indicator_set_property_time +void +IndicateIndicator * indicator, const gchar * key, GTimeVal * time + + indicate_indicator_get_property const gchar * IndicateIndicator * indicator, const gchar * key diff --git a/tests/im-client.c b/tests/im-client.c index 3670bfa..0731468 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -49,10 +49,8 @@ main (int argc, char ** argv) g_type_init(); IndicateServer * server = indicate_server_ref_default(); - GValue value = {0}; - g_value_init(&value, G_TYPE_STRING); - g_value_set_static_string(&value, "message.im"); - g_object_set_property(G_OBJECT(server), "type", &value); + indicate_server_set_type(server, "message.im"); + indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop"); IndicateIndicatorMessage * indicator; -- cgit v1.2.3 From ee2747416fa823d805af6d417dcd5f6159399f11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 10:47:54 -0600 Subject: Rebuilding the way that priorities get done so that we can handle a time and icon version of the functions so that apps don't have to worry about those details. --- libindicate/listener.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- libindicate/listener.h | 16 ++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 4da6d59..f641b56 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -650,14 +650,22 @@ proxy_indicators_free (gpointer data) return; } +typedef enum _get_property_type get_property_type; +enum _get_property_type { + PROPERTY_TYPE_STRING, + PROPERTY_TYPE_TIME, + PROPERTY_TYPE_ICON +}; + typedef struct _get_property_t get_property_t; struct _get_property_t { - indicate_listener_get_property_cb cb; + GCallback cb; gpointer data; IndicateListener * listener; IndicateListenerServer * server; IndicateListenerIndicator * indicator; gchar * property; + get_property_type type; }; static void @@ -671,7 +679,19 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us return; } - get_property_data->cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, OUT_value, get_property_data->data); + switch (get_property_data->type) { + case PROPERTY_TYPE_STRING: { + indicate_listener_get_property_cb cb = (indicate_listener_get_property_cb)get_property_data->cb; + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, OUT_value, get_property_data->data); + break; + } + case PROPERTY_TYPE_ICON: { + break; + } + case PROPERTY_TYPE_TIME: { + break; + } + } g_free(get_property_data->property); g_free(get_property_data); @@ -679,8 +699,8 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us return; }; -void -indicate_listener_get_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_cb callback, gpointer data) +static void +get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type) { /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); @@ -703,6 +723,24 @@ indicate_listener_get_property (IndicateListener * listener, IndicateListenerSer return; } +void +indicate_listener_get_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_cb callback, gpointer data) +{ + return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_STRING); +} + +void +indicate_listener_get_property_time (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_time_cb callback, gpointer data) +{ + return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_TIME); +} + +void +indicate_listener_get_property_icon (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_icon_cb callback, gpointer data) +{ + return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_ICON); +} + static void listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata) { diff --git a/libindicate/listener.h b/libindicate/listener.h index 3d8c7ef..ed40630 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -33,6 +33,8 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include + #include "indicator.h" #include "server.h" @@ -79,6 +81,8 @@ struct _IndicateListenerClass { GType indicate_listener_get_type (void) G_GNUC_CONST; typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data); +typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data); +typedef void (*indicate_listener_get_property_icon_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data); typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); /* Create a new listener */ @@ -90,6 +94,18 @@ void indicate_listener_get_property (IndicateListener * l gchar * property, indicate_listener_get_property_cb callback, gpointer data); +void indicate_listener_get_property_time (IndicateListener * listener, + IndicateListenerServer * server, + IndicateListenerIndicator * indicator, + gchar * property, + indicate_listener_get_property_time_cb callback, + gpointer data); +void indicate_listener_get_property_icon (IndicateListener * listener, + IndicateListenerServer * server, + IndicateListenerIndicator * indicator, + gchar * property, + indicate_listener_get_property_icon_cb callback, + gpointer data); void indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator); -- cgit v1.2.3 From c3964b3bdbd6ccfe97d6b0387f6784e891df8552 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 12:15:09 -0600 Subject: Adding in the code for handling icons and time --- libindicate/listener.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index f641b56..3b1e3ea 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -686,9 +686,39 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us break; } case PROPERTY_TYPE_ICON: { + indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; + + GInputStream * input = g_memory_input_stream_new_from_data(OUT_value, strlen(OUT_value) - 1, NULL); + if (input == NULL) { + g_warning("Cound not create input stream from icon property data"); + break; + } + + GError * error = NULL; + GdkPixbuf * icon = gdk_pixbuf_new_from_stream(input, NULL, &error); + if (icon != NULL) { + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, icon, get_property_data->data); + } + + if (error != NULL) { + g_warning("Unable to build Pixbuf from icon data: %s", error->message); + g_error_free(error); + } + + error = NULL; + g_input_stream_close(input, NULL, error); + if (error != NULL) { + g_warning("Unable to close input stream: %s", error->message); + g_error_free(error); + } break; } case PROPERTY_TYPE_TIME: { + indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; + GTimeVal time; + if (g_time_val_from_iso8601(OUT_value, &time)) { + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data); + } break; } } -- cgit v1.2.3 From b94d3a706d4f3e93e4e23dd908ffc0704add19f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 12:31:08 -0600 Subject: Seeing what happens if I turn on "sign always" in Bazaar. --- libindicate/listener.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 3b1e3ea..4dc874d 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -887,3 +887,4 @@ indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListe { return get_server_property(listener, server, callback, "desktop", data); } + -- cgit v1.2.3 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(+) 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 From 8b91e1dd1bcd3f72cd414244ed434cc98227de5d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 13:34:24 -0600 Subject: Adding in some debug messages and making the signal use the original key to broadcast itself. --- libindicate/indicator.c | 4 +++- libindicate/server.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index 3b6581b..1c6225e 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -293,9 +293,11 @@ set_property (IndicateIndicator * indicator, const gchar * key, const gchar * da if (current == NULL || strcmp(current, data)) { /* If the value has changed or there is no value */ gchar * newkey = g_strdup(key); + /* g_debug("What is newkey? %s", newkey); */ g_hash_table_insert(priv->properties, newkey, g_strdup(data)); if (indicate_indicator_is_visible(indicator)) { - g_signal_emit(indicator, signals[MODIFIED], 0, newkey, TRUE); + /* g_debug("Indicator property modified: %s %s", key, data); */ + g_signal_emit(indicator, signals[MODIFIED], 0, key, TRUE); } } diff --git a/libindicate/server.c b/libindicate/server.c index 0c74376..ee20321 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -352,6 +352,7 @@ indicator_hide_cb (IndicateIndicator * indicator, IndicateServer * server) static void indicator_modified_cb (IndicateIndicator * indicator, gchar * property, IndicateServer * server) { + /* g_debug("Indicator Modified: %d %s", indicate_indicator_get_id(indicator), property); */ g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, indicate_indicator_get_id(indicator), property, TRUE); } -- cgit v1.2.3 From e921d552aff2da24cacd119e24bc73a90133c4d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 13:44:45 -0600 Subject: Fixing some prototypes to fix warnings and errors we haven't yet encountered. Also setting the type so that our switch statement actually works. --- libindicate/listener.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 4dc874d..c4b1882 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -706,7 +706,7 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us } error = NULL; - g_input_stream_close(input, NULL, error); + g_input_stream_close(input, NULL, &error); if (error != NULL) { g_warning("Unable to close input stream: %s", error->message); g_error_free(error); @@ -714,7 +714,7 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us break; } case PROPERTY_TYPE_TIME: { - indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; + indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb; GTimeVal time; if (g_time_val_from_iso8601(OUT_value, &time)) { cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data); @@ -732,6 +732,7 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us static void get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type) { + /* g_debug("get_property_helper: %s %d", property, prop_type); */ /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); @@ -748,6 +749,7 @@ get_property_helper (IndicateListener * listener, IndicateListenerServer * serve get_property_data->server = server; get_property_data->indicator = indicator; get_property_data->property = g_strdup(property); + get_property_data->type = prop_type; org_freedesktop_indicator_get_indicator_property_async (proxyt->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data); return; -- cgit v1.2.3 From 52cd253079f2d50f0b14e4369f0604fd1ff6ab64 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 13:47:24 -0600 Subject: Seems like a better name --- tests/im-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/im-client.c b/tests/im-client.c index 0731468..aa2ef8c 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -56,7 +56,7 @@ main (int argc, char ** argv) indicator = indicate_indicator_message_new(); indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im"); - indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "Ted Gould"); + indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test"); GTimeVal time; g_get_current_time(&time); indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time); indicate_indicator_show(INDICATE_INDICATOR(indicator)); -- cgit v1.2.3 From 1a8b895c2815ad2055fbd579df4f6f53189f702c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 14:03:52 -0600 Subject: Changing the icon data to be base64 encoded, should have done that originally, how silly. --- libindicate/listener.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index c4b1882..b704236 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -687,10 +687,14 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us } case PROPERTY_TYPE_ICON: { indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; + + gsize length = 0; + guchar * icondata = g_base64_decode(OUT_value, &length); - GInputStream * input = g_memory_input_stream_new_from_data(OUT_value, strlen(OUT_value) - 1, NULL); + GInputStream * input = g_memory_input_stream_new_from_data(icondata, length, NULL); if (input == NULL) { g_warning("Cound not create input stream from icon property data"); + g_free(icondata); break; } @@ -711,6 +715,7 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us g_warning("Unable to close input stream: %s", error->message); g_error_free(error); } + g_free(icondata); break; } case PROPERTY_TYPE_TIME: { -- cgit v1.2.3 From a2e77d6839d9236118886f2cdc761ff298ff43c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 14:17:18 -0600 Subject: Adding in the function to take a pixbuf, turn it into a png, base64 encode it and then send it across the wire. --- libindicate/indicator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index 1c6225e..d647930 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -240,8 +240,24 @@ indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * ke void indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data) { + GOutputStream * output = g_memory_output_stream_new(NULL, 0, g_realloc, g_free); + if (!gdk_pixbuf_save_to_stream(data, output, "png", NULL, NULL, "compress", 9)) { + g_output_stream_close(output, NULL, NULL); + g_warning("Unable to create pixbuf data stream"); + return; + } + + gpointer png_data = g_memory_output_stream_get_data(output); + gsize png_data_len = g_memory_output_stream_get_data_size(output); + gchar * prop_str = g_base64_encode(png_data, png_data_len); + indicate_indicator_set_property(indicator, key, prop_str); + + g_free(prop_str); + g_output_stream_close(output, NULL, NULL); + + return; } void -- cgit v1.2.3 From 6b3a32c443111a23d2953d85be2f2f3b930ed405 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 16:43:00 -0600 Subject: Changing from using a memory stream to using a buffer, the memory stream one seems to be broken. --- libindicate/indicator.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index d647930..e4bae76 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -240,22 +240,32 @@ indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * ke void indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data) { - GOutputStream * output = g_memory_output_stream_new(NULL, 0, g_realloc, g_free); - - if (!gdk_pixbuf_save_to_stream(data, output, "png", NULL, NULL, "compress", 9)) { - g_output_stream_close(output, NULL, NULL); - g_warning("Unable to create pixbuf data stream"); + if (!GDK_IS_PIXBUF(data)) { + g_warning("Invalide GdkPixbuf"); return; } - gpointer png_data = g_memory_output_stream_get_data(output); - gsize png_data_len = g_memory_output_stream_get_data_size(output); + GError * error = NULL; + gchar * png_data; + gsize png_data_len; + + if (!gdk_pixbuf_save_to_buffer(data, &png_data, &png_data_len, "png", &error, NULL)) { + if (error == NULL) { + g_warning("Unable to create pixbuf data stream: %d", png_data_len); + } else { + g_warning("Unable to create pixbuf data stream: %s", error->message); + g_error_free(error); + error = NULL; + } + + return; + } gchar * prop_str = g_base64_encode(png_data, png_data_len); indicate_indicator_set_property(indicator, key, prop_str); g_free(prop_str); - g_output_stream_close(output, NULL, NULL); + g_free(png_data); return; } -- cgit v1.2.3 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 From 2c157aa63cbc5904ca8ae1481a705309be6b7ed2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Feb 2009 16:44:59 -0600 Subject: Forgot to set the timer back to something reasonable! --- tests/im-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/im-client.c b/tests/im-client.c index d47903b..3419a9d 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -82,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(10, timeout_cb, indicator); + g_timeout_add_seconds(180, timeout_cb, indicator); g_main_loop_run(g_main_loop_new(NULL, FALSE)); -- cgit v1.2.3