From 035f56558cccf52c5c2052bb1f80a4b7519ed4c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 6 Feb 2010 11:55:50 -0800 Subject: Changing the type of the property and setting it with boxed --- src/libappindicator/app-indicator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 908684f..2befb34 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -215,10 +215,10 @@ app_indicator_class_init (AppIndicatorClass *klass) g_object_class_install_property(object_class, PROP_MENU, - g_param_spec_string (PROP_MENU_S, + g_param_spec_boxed (PROP_MENU_S, "The object path of the menu on DBus.", "A method for getting the menu path as a string for DBus.", - NULL, + DBUS_TYPE_G_OBJECT_PATH, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, @@ -541,14 +541,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa break; case PROP_MENU: - if (G_VALUE_HOLDS_STRING(value)) { - if (priv->menuservice != NULL) { - g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, value); - } - } else { - WARN_BAD_TYPE(PROP_MENU_S, value); - } - break; + if (priv->menuservice != NULL) { + GValue strval = {0}; + g_value_init(&strval, G_TYPE_STRING); + g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strvalue); + g_value_set_boxed(value, g_value_get_string(&strvalue)); + g_value_unset(&strvalue); + } + break; case PROP_CONNECTED: g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); -- cgit v1.2.3 From 28b0ba50227548758db097d0c6097b1a394e413f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 6 Feb 2010 11:58:19 -0800 Subject: Ready to recieve the boxed type on the other side. --- src/application-service-appstore.c | 5 ++++- src/libappindicator/app-indicator.c | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 70fab18..5e0c601 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -222,7 +222,10 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app_lru_file_touch(priv->lrufile, app->id, app->category); app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); - app->menu = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU)); + + GValue * menuval = (GValue *)g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU); + app->menu = g_strdup((gchar *)g_value_get_boxed(menuval)); + if (g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_AICON_NAME) != NULL) { app->aicon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); } diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 2befb34..19b4fd9 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -544,9 +544,9 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa if (priv->menuservice != NULL) { GValue strval = {0}; g_value_init(&strval, G_TYPE_STRING); - g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strvalue); - g_value_set_boxed(value, g_value_get_string(&strvalue)); - g_value_unset(&strvalue); + g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); + g_value_set_boxed(value, g_value_get_string(&strval)); + g_value_unset(&strval); } break; -- cgit v1.2.3 From 8be6fe7ae76d822cc8737f60b3c0ad930f371eb0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 08:30:42 -0600 Subject: Falling back on string if that's what we get. Makes things compatible. --- src/application-service-appstore.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5e0c601..5e6a356 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -224,7 +224,13 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); GValue * menuval = (GValue *)g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU); - app->menu = g_strdup((gchar *)g_value_get_boxed(menuval)); + if (G_VALUE_TYPE(menuval) == G_TYPE_STRING) { + /* This is here to support an older version where we + were using strings instea of object paths. */ + app->menu = g_value_dup_string(menuval); + } else { + app->menu = g_strdup((gchar *)g_value_get_boxed(menuval)); + } if (g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_AICON_NAME) != NULL) { app->aicon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); -- cgit v1.2.3 From 370c87f0cfa8364d3efd66e229772e2db94b13dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 08:43:35 -0600 Subject: Moving the registration of the object to when we want to connect everything, and making the path include the item ID to ensure it's unique. --- src/libappindicator/app-indicator.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 540620c..fb6e7dc 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -332,11 +332,7 @@ app_indicator_init (AppIndicator *self) } dbus_g_connection_ref(priv->connection); - dbus_g_connection_register_g_object(priv->connection, - DEFAULT_ITEM_PATH, - G_OBJECT(self)); - - self->priv = priv; + self->priv = priv; return; } @@ -584,6 +580,12 @@ check_connect (AppIndicator *self) if (priv->icon_name == NULL) return; if (priv->id == NULL) return; + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->id); + dbus_g_connection_register_g_object(priv->connection, + path, + G_OBJECT(self)); + g_free(path); + GError * error = NULL; priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection, NOTIFICATION_WATCHER_DBUS_ADDR, -- cgit v1.2.3 From f5b69fe95891fd20bdce7100701799c3f997f1d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 08:44:09 -0600 Subject: Making it so that you can't set an ID twice instead of just issuing a warning. --- src/libappindicator/app-indicator.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index fb6e7dc..ea823ff 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -441,16 +441,15 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu switch (prop_id) { case PROP_ID: - if (priv->id != NULL) { - g_warning ("Resetting ID value when I already had a value of: %s", priv->id); - g_free (priv->id); - priv->id = NULL; - } + if (priv->id != NULL) { + g_warning ("Resetting ID value when I already had a value of: %s", priv->id); + break; + } - priv->id = g_strdup (g_value_get_string (value)); + priv->id = g_strdup (g_value_get_string (value)); - check_connect (self); - break; + check_connect (self); + break; case PROP_CATEGORY: enum_val = g_enum_get_value_by_nick ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), -- cgit v1.2.3 From 907253f5ea802c1161bd718f8c9649c416e77bf2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 08:47:34 -0600 Subject: Making the menu path also include the ID --- src/libappindicator/app-indicator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index ea823ff..b5512c5 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -115,9 +115,8 @@ enum { #define APP_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_INDICATOR_TYPE, AppIndicatorPrivate)) -/* Default Paths */ +/* Default Path */ #define DEFAULT_ITEM_PATH "/org/ayatana/NotificationItem" -#define DEFAULT_MENU_PATH "/org/ayatana/NotificationItem/Menu" /* More constants */ #define DEFAULT_FALLBACK_TIMER 100 /* in milliseconds */ @@ -1221,7 +1220,9 @@ setup_dbusmenu (AppIndicator *self) root); if (priv->menuservice == NULL) { - priv->menuservice = dbusmenu_server_new (DEFAULT_MENU_PATH); + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->id); + priv->menuservice = dbusmenu_server_new (path); + g_free(path); } dbusmenu_server_set_root (priv->menuservice, root); -- cgit v1.2.3 From aafaa311dfe8548c8e2680ab98ee865ea75abc63 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 09:15:04 -0600 Subject: Creating a clean ID that doesn't take any illegal dbus characters and using that in the path. --- src/libappindicator/app-indicator.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index b5512c5..cfc6377 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -59,6 +59,7 @@ License version 3 and version 2.1 along with this program. If not, see struct _AppIndicatorPrivate { /* Properties */ gchar *id; + gchar *clean_id; AppIndicatorCategory category; AppIndicatorStatus status; gchar *icon_name; @@ -306,6 +307,7 @@ app_indicator_init (AppIndicator *self) AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(self); priv->id = NULL; + priv->clean_id = NULL; priv->category = APP_INDICATOR_CATEGORY_OTHER; priv->status = APP_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; @@ -408,6 +410,11 @@ app_indicator_finalize (GObject *object) priv->id = NULL; } + if (priv->clean_id != NULL) { + g_free(priv->clean_id); + priv->clean_id = NULL; + } + if (priv->icon_name != NULL) { g_free(priv->icon_name); priv->icon_name = NULL; @@ -578,11 +585,18 @@ check_connect (AppIndicator *self) if (priv->icon_name == NULL) return; if (priv->id == NULL) return; - gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->id); + priv->clean_id = g_strdup(priv->id); + gchar * cleaner; + for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { + if (!g_ascii_isalnum(*cleaner)) { + *cleaner = '_'; + } + } + + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); dbus_g_connection_register_g_object(priv->connection, path, G_OBJECT(self)); - g_free(path); GError * error = NULL; priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection, @@ -595,11 +609,13 @@ check_connect (AppIndicator *self) it's not a warning anymore. */ g_error_free(error); start_fallback_timer(self, FALSE); + g_free(path); return; } g_signal_connect(G_OBJECT(priv->watcher_proxy), "destroy", G_CALLBACK(watcher_proxy_destroyed), self); - org_freedesktop_StatusNotifierWatcher_register_status_notifier_item_async(priv->watcher_proxy, DEFAULT_ITEM_PATH, register_service_cb, self); + org_freedesktop_StatusNotifierWatcher_register_status_notifier_item_async(priv->watcher_proxy, path, register_service_cb, self); + g_free(path); return; } @@ -1220,7 +1236,7 @@ setup_dbusmenu (AppIndicator *self) root); if (priv->menuservice == NULL) { - gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->id); + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); priv->menuservice = dbusmenu_server_new (path); g_free(path); } -- cgit v1.2.3 From 8418f3a96bd138f89e392b2604aabf9bbda3d88a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 10:37:53 -0600 Subject: Changing to ID based naming and setting a menu to get init --- tests/test-libappindicator-dbus-client.c | 2 +- tests/test-libappindicator-dbus-server.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/test-libappindicator-dbus-client.c b/tests/test-libappindicator-dbus-client.c index 5a7107f..6125d36 100644 --- a/tests/test-libappindicator-dbus-client.c +++ b/tests/test-libappindicator-dbus-client.c @@ -200,7 +200,7 @@ main (gint argc, gchar * argv[]) DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, ":1.0", - "/org/ayatana/NotificationItem", + "/org/ayatana/NotificationItem/my_id", DBUS_INTERFACE_PROPERTIES, &error); if (error != NULL) { diff --git a/tests/test-libappindicator-dbus-server.c b/tests/test-libappindicator-dbus-server.c index cc072aa..76f0e50 100644 --- a/tests/test-libappindicator-dbus-server.c +++ b/tests/test-libappindicator-dbus-server.c @@ -23,7 +23,7 @@ with this program. If not, see . #include #include -#include +#include #include #include "test-defines.h" @@ -39,13 +39,19 @@ kill_func (gpointer userdata) gint main (gint argc, gchar * argv[]) { - g_type_init(); + gtk_init(&argc, &argv); g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); AppIndicator * ci = app_indicator_new (TEST_ID, TEST_ICON_NAME, TEST_CATEGORY); - app_indicator_set_status (ci, TEST_STATE); - app_indicator_set_attention_icon (ci, TEST_ATTENTION_ICON_NAME); + app_indicator_set_status (ci, TEST_STATE); + app_indicator_set_attention_icon (ci, TEST_ATTENTION_ICON_NAME); + + GtkMenu * menu = GTK_MENU(gtk_menu_new()); + GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Label")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); + + app_indicator_set_menu(ci, menu); g_timeout_add_seconds(2, kill_func, NULL); -- cgit v1.2.3 From cc9f01437a15cee6d180a4cd2f6c5a32a210e3b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 10:38:13 -0600 Subject: Moving the clean_id code to get set when we set the ID and checking for it when building the menu. --- src/libappindicator/app-indicator.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index cfc6377..0ca68d4 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -454,6 +454,14 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->id = g_strdup (g_value_get_string (value)); + priv->clean_id = g_strdup(priv->id); + gchar * cleaner; + for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { + if (!g_ascii_isalnum(*cleaner)) { + *cleaner = '_'; + } + } + check_connect (self); break; @@ -585,14 +593,6 @@ check_connect (AppIndicator *self) if (priv->icon_name == NULL) return; if (priv->id == NULL) return; - priv->clean_id = g_strdup(priv->id); - gchar * cleaner; - for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { - if (!g_ascii_isalnum(*cleaner)) { - *cleaner = '_'; - } - } - gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); dbus_g_connection_register_g_object(priv->connection, path, @@ -1262,6 +1262,7 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (GTK_IS_MENU (menu)); + g_return_if_fail (self->priv->clean_id != NULL); priv = self->priv; -- cgit v1.2.3 From 6f79c17699cc45ea58491f9da176783264746179 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 10:51:28 -0600 Subject: Building a menu so this item will show --- tests/test-libappindicator-status-server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test-libappindicator-status-server.c b/tests/test-libappindicator-status-server.c index 9e58ba9..79b1759 100644 --- a/tests/test-libappindicator-status-server.c +++ b/tests/test-libappindicator-status-server.c @@ -55,7 +55,7 @@ toggle (gpointer userdata) gint main (gint argc, gchar * argv[]) { - g_type_init(); + gtk_init(&argc, &argv); g_usleep(100000); @@ -64,6 +64,12 @@ main (gint argc, gchar * argv[]) AppIndicator * ci = app_indicator_new ("my-id", "my-icon-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_attention_icon (ci, "my-attention-icon"); + GtkMenu * menu = GTK_MENU(gtk_menu_new()); + GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Label")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); + + app_indicator_set_menu(ci, menu); + g_timeout_add(50, toggle, ci); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From ec5e7ea86df0da2859bfe4de9d668ce66987d8ab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Feb 2010 10:53:00 -0600 Subject: Making sure our new tests with gtk_init() in them have an X server to talk to. --- tests/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 03e2091..d42ed2b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -158,14 +158,16 @@ DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) libappindicator-tests-gtester DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf test-libappindicator-dbus: test-libappindicator-dbus-client test-libappindicator-dbus-server Makefile.am - @echo "#!/bin/sh" > test-libappindicator-dbus + @echo "#!/bin/bash" > test-libappindicator-dbus + @echo . $(srcdir)/run-xvfb.sh >> $@ @echo $(DBUS_RUNNER) --task ./test-libappindicator-dbus-client --task-name Client --task ./test-libappindicator-dbus-server --task-name Server --ignore-return >> test-libappindicator-dbus @chmod +x test-libappindicator-dbus TESTS += test-libappindicator-dbus test-libappindicator-status: test-libappindicator-status-client test-libappindicator-status-server Makefile.am - @echo "#!/bin/sh" > test-libappindicator-status + @echo "#!/bin/bash" > test-libappindicator-status + @echo . $(srcdir)/run-xvfb.sh >> $@ @echo $(DBUS_RUNNER) --task ./test-libappindicator-status-client --task-name Client --task ./test-libappindicator-status-server --task-name Server --ignore-return >> test-libappindicator-status @chmod +x test-libappindicator-status -- cgit v1.2.3 From 14abe9ad1ff1b09526b6f0f6410c2783e6dbd501 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 10:19:50 -0600 Subject: 0.0.13 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 152b91b..51ebf3e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-application, 0.0.12, ted@canonical.com) +AC_INIT(indicator-application, 0.0.13, ted@canonical.com) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-application, 0.0.12) +AM_INIT_AUTOMAKE(indicator-application, 0.0.13) AM_MAINTAINER_MODE -- cgit v1.2.3 From f7b909ce3b94c2afb8e8b8a31b63f579c8bcb92e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 10:41:56 -0600 Subject: releasing version 0.0.13-0ubuntu1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3fe50a0..6a3bbbf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -indicator-application (0.0.13-0ubuntu1) UNRELEASED; urgency=low +indicator-application (0.0.13-0ubuntu1) lucid; urgency=low * Upstream release 0.0.13 * Changing the menu property to be a proper DBus object path * Make object paths unique by including application IDs in them - -- Ted Gould Thu, 11 Feb 2010 10:35:52 -0600 + -- Ted Gould Thu, 11 Feb 2010 10:41:53 -0600 indicator-application (0.0.12-0ubuntu1) lucid; urgency=low -- cgit v1.2.3