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 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libindicate/indicator.c') 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) { -- 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(-) (limited to 'libindicate/indicator.c') 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 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(+) (limited to 'libindicate/indicator.c') 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(-) (limited to 'libindicate/indicator.c') 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