From 596a5dbe3fce033ed7465b514d49c4485884bc02 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 17:34:45 -0500 Subject: Adding show hide server test from Eitan on bug 351537 --- tests/Makefile.am | 14 +++++++++++++- tests/show-hide-server.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/show-hide-server.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 4a8f962..862046e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,8 @@ libexec_PROGRAMS = \ indicate-and-crash \ indicate-alot \ listen-and-print \ - im-client + im-client \ + show-hide-server indicate_and_crash_SOURCES = \ indicate-and-crash.c @@ -49,6 +50,17 @@ im_client_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) +show_hide_server_SOURCES = \ + show-hide-server.c + +show_hide_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(LIBINDICATE_CFLAGS) + +show_hide_server_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + examplesdir = $(docdir)/examples/ examples_DATA = \ diff --git a/tests/show-hide-server.c b/tests/show-hide-server.c new file mode 100644 index 0000000..23c1ea1 --- /dev/null +++ b/tests/show-hide-server.c @@ -0,0 +1,44 @@ +/* From LP: #351537 */ + +#include +#include "libindicate/server.h" +#include "libindicate/indicator-message.h" + +gboolean hidden = TRUE; + +static gboolean +timeout_cb (gpointer data) +{ + IndicateServer * server = INDICATE_SERVER(data); + + if (hidden) { + printf("showing... "); + indicate_server_show(server); + printf("ok\n"); + hidden = FALSE; + } else { + printf("hiding... "); + indicate_server_hide(server); + printf("ok\n"); + hidden = TRUE; + } + + return TRUE; +} + + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicateServer * server = indicate_server_ref_default(); + indicate_server_set_type(server, "message.im"); + indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop"); + g_timeout_add_seconds(1, timeout_cb, server); + + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + + return 0; +} + -- cgit v1.2.3 From 3e1e51261167c74fa81819cebaafce944e14b310 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 17:40:25 -0500 Subject: Making it so that we don't register the object twice. This is really a work around, but it's atleast fixes the crasher. Which sucked. We need to work with the dbus folks to make this better. --- libindicate/server.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libindicate/server.c b/libindicate/server.c index ed81d54..1be8ee5 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -84,6 +84,7 @@ struct _IndicateServerPrivate GSList * indicators; gboolean visible; guint current_id; + gboolean registered; gchar * desktop; gchar * type; @@ -260,6 +261,7 @@ indicate_server_init (IndicateServer * server) priv->indicators = NULL; priv->num_hidden = 0; priv->visible = FALSE; + priv->registered = FALSE; priv->current_id = 0; priv->type = NULL; priv->desktop = NULL; @@ -371,9 +373,13 @@ indicate_server_show (IndicateServer * server) priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(priv->connection, - priv->path, - G_OBJECT(server)); + if (!priv->registered) { + dbus_g_connection_register_g_object(priv->connection, + priv->path, + G_OBJECT(server)); + priv->registered = TRUE; + } + priv->visible = TRUE; g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE); -- cgit v1.2.3 From eba8697a790029397d771a3871f431abc4fc0029 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 20:52:05 -0500 Subject: Patch from Eitan Isaacson to remove a ref/unref infinite loop that effectively made it so that we kept our objects forever. While we love them, at some point we need to say goodbye. --- libindicate/server.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libindicate/server.c b/libindicate/server.c index 1be8ee5..e5bf731 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -610,8 +610,10 @@ indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indi { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); - g_object_ref(indicator); - priv->indicators = g_slist_prepend(priv->indicators, indicator); + if (g_slist_find (priv->indicators, indicator) != NULL) + return; + + priv->indicators = g_slist_prepend(priv->indicators, indicator); if (!indicate_indicator_is_visible(indicator)) { priv->num_hidden++; @@ -631,6 +633,9 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + if (g_slist_find (priv->indicators, indicator) == NULL) + return; + priv->indicators = g_slist_remove(priv->indicators, indicator); if (indicate_indicator_is_visible(indicator)) { g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); @@ -642,7 +647,6 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server); g_signal_handlers_disconnect_by_func(indicator, indicator_modified_cb, server); - g_object_unref(indicator); return; } -- cgit v1.2.3 From 7115f7706baaf7ac83c11ddc089ff7202a0a6c9b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:02:08 -0500 Subject: Ignoring our new test --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index a4c17ca..3548564 100644 --- a/.bzrignore +++ b/.bzrignore @@ -54,3 +54,4 @@ tests/im-client tests/indicate-alot tests/indicate-and-crash tests/listen-and-print +tests/show-hide-server -- cgit v1.2.3 From 9a7bcf39b419f9ac30eb44c14e5f7f17a34cc15b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:08:27 -0500 Subject: Patch from Eitan Isaacson to correct prototype. Had to be adjusted slightly as the prototypes had moved. --- libindicate/server.c | 8 ++++---- libindicate/server.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libindicate/server.c b/libindicate/server.c index e5bf731..9e33516 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -114,7 +114,7 @@ static void indicate_server_finalize (GObject * obj); static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error); static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -136,7 +136,7 @@ static void indicate_server_interested_folks_destroy(IndicateServerInterestedFol gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -798,7 +798,7 @@ get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** err } static gboolean -get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); @@ -994,7 +994,7 @@ _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicato } gboolean -_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); diff --git a/libindicate/server.h b/libindicate/server.h index 0db5bef..cfb4334 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -80,7 +80,7 @@ struct _IndicateServerClass { gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error); gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error); - gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); + gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); -- cgit v1.2.3 From 75002ffd6068873af92d3f8f2c687415f0325e1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:13:07 -0500 Subject: Clearing another warning. Shame gdk doesn't do this one for us. --- libindicate/indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index e4bae76..9427d03 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -249,7 +249,7 @@ indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar gchar * png_data; gsize png_data_len; - if (!gdk_pixbuf_save_to_buffer(data, &png_data, &png_data_len, "png", &error, NULL)) { + if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)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 { -- cgit v1.2.3 From c1955c5ca3f460f0ac8fc7de84325345b60b8919 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 22:22:53 -0500 Subject: Added in an 'icon-name' to make the about dialog have a proper icon. --- src/applet-main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/applet-main.c b/src/applet-main.c index e08dc1e..310cfe9 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -150,6 +150,7 @@ about_cb (BonoboUIComponent *ui_container, "wrap-license", TRUE, "translator-credits", _("translator-credits"), "logo-icon-name", "indicator-applet", + "icon-name", "indicator-applet", "website", "http://launchpad.net/indicator-applet", "website-label", _("Indicator Applet Website"), NULL -- cgit v1.2.3