aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-04-07 22:25:24 -0500
committerTed Gould <ted@canonical.com>2009-04-07 22:25:24 -0500
commita8ab75df408384d4dc0995ac00db27c4fbb46c76 (patch)
treecc74c0de021d6ad30b06e81b715524a44146be2d
parent13aa4e53918e0dc6cbc90e01ce0297ad18bc6aaf (diff)
parentc1955c5ca3f460f0ac8fc7de84325345b60b8919 (diff)
downloadlibayatana-indicator-a8ab75df408384d4dc0995ac00db27c4fbb46c76.tar.gz
libayatana-indicator-a8ab75df408384d4dc0995ac00db27c4fbb46c76.tar.bz2
libayatana-indicator-a8ab75df408384d4dc0995ac00db27c4fbb46c76.zip
Lots of fixes from trunk
-rw-r--r--.bzrignore1
-rw-r--r--libindicate/indicator.c2
-rw-r--r--libindicate/server.c30
-rw-r--r--libindicate/server.h2
-rw-r--r--src/applet-main.c1
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/show-hide-server.c44
7 files changed, 81 insertions, 13 deletions
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
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 {
diff --git a/libindicate/server.c b/libindicate/server.c
index ed81d54..9e33516 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;
@@ -113,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);
@@ -135,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);
@@ -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);
@@ -604,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++;
@@ -625,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);
@@ -636,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;
}
@@ -788,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);
@@ -984,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);
diff --git a/src/applet-main.c b/src/applet-main.c
index 43125a0..df93b27 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
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 <glib.h>
+#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;
+}
+