From de1ea7a175f0913b5a5421e666dd2d38d864fe47 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:19:19 -0500 Subject: Adding an API function to build the menu from a desktop file --- src/app-indicator.c | 15 +++++++++++++++ src/app-indicator.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 4f7daa8..4734b80 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2106,3 +2106,18 @@ app_indicator_get_ordering_index (AppIndicator *self) } } +/** + app_indicator_build_menu_from_desktop: + @self: The #AppIndicator object to use + @desktop_file: A path to the desktop file to build the menu from + + This function allows for building the Application Indicator menu + from a static desktop file. +*/ +void +app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file) +{ + + + +} diff --git a/src/app-indicator.h b/src/app-indicator.h index ce152bb..cfc9565 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -280,6 +280,10 @@ const gchar * app_indicator_get_label (AppIndicator * const gchar * app_indicator_get_label_guide (AppIndicator *self); guint32 app_indicator_get_ordering_index (AppIndicator *self); +/* Helpers */ +void app_indicator_build_menu_from_desktop (AppIndicator * self, + const gchar * desktop_file); + G_END_DECLS /** -- cgit v1.2.3 From d2427bba3a731af3db25878f7e63fd2a83a3243e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:25:40 -0500 Subject: Adding the profile in there --- src/app-indicator.c | 2 +- src/app-indicator.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 4734b80..1805bd5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2115,7 +2115,7 @@ app_indicator_get_ordering_index (AppIndicator *self) from a static desktop file. */ void -app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file) +app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { diff --git a/src/app-indicator.h b/src/app-indicator.h index cfc9565..3e159db 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -282,7 +282,8 @@ guint32 app_indicator_get_ordering_index (AppIndicator * /* Helpers */ void app_indicator_build_menu_from_desktop (AppIndicator * self, - const gchar * desktop_file); + const gchar * desktop_file, + const gchar * desktop_profile); G_END_DECLS -- cgit v1.2.3 From 8d9b6e921d45ba5f4153e7c1fd784eef64c3d80e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:47:52 -0500 Subject: Adding in a couple of desktop tests --- tests/test-libappindicator.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 8d12ac5..202c5e1 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -291,6 +291,22 @@ test_libappindicator_label_signals (void) g_assert(label_signals_count == 1); return; +} + +void +test_libappindicator_desktop_menu (void) +{ + + + +} + +void +test_libappindicator_desktop_menu_bad (void) +{ + + + } void @@ -302,6 +318,8 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); + g_test_add_func ("/indicator-application/libappindicator/desktop_menu", test_libappindicator_desktop_menu); + g_test_add_func ("/indicator-application/libappindicator/desktop_menu_bad",test_libappindicator_desktop_menu_bad); return; } -- cgit v1.2.3 From 145fd40be09045eb775dd5cdf754623ae7fc210b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:49:27 -0500 Subject: Adding a desktop file for testing --- tests/Makefile.am | 4 +++- tests/test-libappindicator.desktop | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/test-libappindicator.desktop diff --git a/tests/Makefile.am b/tests/Makefile.am index f2bdbb2..f52b78b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,7 +13,9 @@ check_PROGRAMS = \ TESTS = DISTCLEANFILES = $(TESTS) -EXTRA_DIST = run-xvfb.sh +EXTRA_DIST = \ + run-xvfb.sh \ + test-libappindicator.desktop ######################################### ## test-libappindicator diff --git a/tests/test-libappindicator.desktop b/tests/test-libappindicator.desktop new file mode 100644 index 0000000..59be810 --- /dev/null +++ b/tests/test-libappindicator.desktop @@ -0,0 +1,23 @@ +[Desktop Entry] +Name=AppIndicator Test +GenericName=Test +Comment=This is only a test +Exec=/usr/bin/false +Terminal=false +Type=Application +X-Ayatana-Desktop-Shortcuts=Short1;Short2;Short3; + +[Short1 Shortcut Group] +Name=Shortcut 1 +Exec=/usr/bin/true +OnlyShowIn=Test Program; + +[Short2 Shortcut Group] +Name=Shortcut 2 +Exec=/usr/bin/true +OnlyShowIn=Test Program; + +[Short3 Shortcut Group] +Name=Shortcut 3 +Exec=/usr/bin/true +OnlyShowIn=Test Program; -- cgit v1.2.3 From 2e1b3533b988c227f5699bc88dc5df0e67669430 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:49:47 -0500 Subject: Adding the srcdir to the build command line --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index f52b78b..9cecd5e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ test_libappindicator_SOURCES = \ test_libappindicator_CFLAGS = \ $(INDICATOR_CFLAGS) \ + -DSRCDIR="\"$(srcdir)\"" \ -Wall -Werror \ -I$(top_srcdir)/src -- cgit v1.2.3 From 52c706605c23a2b3b06e5f4262d5ea1ab1577567 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 12:10:46 -0500 Subject: Adding a test to check the number of items in the desktop file --- tests/test-libappindicator.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 202c5e1..f340a67 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -296,9 +296,26 @@ test_libappindicator_label_signals (void) void test_libappindicator_desktop_menu (void) { + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + app_indicator_build_menu_from_desktop(ci, SRCDIR "/test-libappindicator.desktop", "Test Program"); + GtkMenu * menu = app_indicator_get_menu(ci); + g_assert(menu != NULL); + + GList * children = gtk_container_get_children(GTK_CONTAINER(menu)); + g_assert(children != NULL); + g_assert(g_list_length(children) == 3); + + g_object_unref(G_OBJECT(ci)); + + return; } void -- cgit v1.2.3 From 8eb4f8efd00978a1680ac7ebdd1907aa55eaba30 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 16:22:22 -0600 Subject: Adding a dependency for the library on libindicator --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index f1ae2ea..cabaedd 100644 --- a/configure.ac +++ b/configure.ac @@ -53,6 +53,7 @@ AC_SUBST(INDICATOR_CFLAGS) AC_SUBST(INDICATOR_LIBS) PKG_CHECK_MODULES(LIBRARY, gtk+-2.0 >= $GTK_REQUIRED_VERSION + indicator >= $INDICATOR_REQUIRED_VERSION dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION) -- cgit v1.2.3 From 9f0ec1f915156311d8de7a629782252a4bce6e41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 16:57:22 -0600 Subject: Start to flesh out the nicks side of building the menu items --- src/app-indicator.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 1805bd5..dc88e9b 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -37,6 +37,8 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include + #include "app-indicator.h" #include "app-indicator-enum-types.h" #include "application-service-marshal.h" @@ -2106,6 +2108,18 @@ app_indicator_get_ordering_index (AppIndicator *self) } } +#define APP_INDICATOR_SHORTY_NICK "app-indicator-shorty-nick" + +/* Callback when an item from the desktop shortcuts gets + called. */ +static void +shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + + + return; +} + /** app_indicator_build_menu_from_desktop: @self: The #AppIndicator object to use @@ -2118,6 +2132,30 @@ void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { + /* Build a new shortcuts object */ + IndicatorDesktopShortcuts * shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); + g_return_if_fail(shorties != NULL); + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(shorties); + int nick_num; + /* Place the items on a dbusmenu */ + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + + for (nick_num = 0; nicks[nick_num] != NULL; nick_num++) { + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + g_object_set_data(G_OBJECT(item), APP_INDICATOR_SHORTY_NICK, (gpointer)nicks[nick_num]); + + gchar * name = indicator_desktop_shortcuts_nick_get_name(shorties, nicks[nick_num]); + dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); + g_free(name); + + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(shorty_activated_cb), self); + + dbusmenu_menuitem_child_append(root, item); + } + + /* Swap it if needed */ + + return; } -- cgit v1.2.3 From 1ec2b70ac16b031a4c7cc5398e9fb7a17bef4e4c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 20:10:54 -0600 Subject: Create a property for the dbusmenu server --- src/app-indicator.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 4f7daa8..25599a7 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include #include #include @@ -121,7 +122,8 @@ enum { PROP_X_LABEL, PROP_X_LABEL_GUIDE, PROP_ORDERING_INDEX, - PROP_X_ORDERING_INDEX + PROP_X_ORDERING_INDEX, + PROP_DBUS_MENU_SERVER }; /* The strings so that they can be slowly looked up. */ @@ -139,6 +141,7 @@ enum { #define PROP_X_LABEL_GUIDE_S ("x-ayatana-" PROP_LABEL_GUIDE_S) #define PROP_ORDERING_INDEX_S "ordering-index" #define PROP_X_ORDERING_INDEX_S ("x-ayatana-" PROP_ORDERING_INDEX_S) +#define PROP_DBUS_MENU_SERVER_S "dbus-menu-server" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -406,6 +409,19 @@ app_indicator_class_init (AppIndicatorClass *klass) "A wrapper, please don't use.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:dbus-menu-server: + + A way to get the internal dbusmenu server if it is available. + This should only be used for testing. + */ + g_object_class_install_property(object_class, + PROP_DBUS_MENU_SERVER, + g_param_spec_object (PROP_DBUS_MENU_SERVER_S, + "The internal DBusmenu Server", + "DBusmenu server which is available for testing the application indicators.", + DBUSMENU_TYPE_MENUITEM, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From 00758f364ae486352c0e2aa076710ae74e3ce190 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 20:17:51 -0600 Subject: Set and Get for the dbusmenu server property --- src/app-indicator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 25599a7..fd035ac 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -810,6 +810,14 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->ordering_index = g_value_get_uint(value); break; + case PROP_DBUS_MENU_SERVER: + if (priv->menuservice != NULL) { + g_object_unref (priv->menuservice); + } + gpointer val = g_value_dup_object(value); + priv->menuservice = DBUSMENU_SERVER(val); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -882,6 +890,10 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_uint(value, priv->ordering_index); break; + case PROP_DBUS_MENU_SERVER: + g_value_set_object(value, priv->menuservice); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From 53d10c22f2df62a7ee96f7effa9f641bf638a627 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:05:29 -0600 Subject: Test setting the menu and verify it comes out --- tests/test-libappindicator.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 8d12ac5..7a1976c 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -25,6 +25,9 @@ with this program. If not, see . #include +#include +#include + void test_libappindicator_prop_signals_status_helper (AppIndicator * ci, gchar * status, gboolean * signalactivated) { @@ -224,6 +227,50 @@ test_libappindicator_set_label (void) return; } +void +test_libappindicator_set_menu (void) +{ + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + + GtkMenu * menu = GTK_MENU(gtk_menu_new()); + + GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Test Label")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); + gtk_widget_show(GTK_WIDGET(item)); + + app_indicator_set_menu(ci, menu); + + g_assert(app_indicator_get_menu(ci) != NULL); + + GValue serverval = {0}; + g_value_init(&serverval, DBUSMENU_TYPE_SERVER); + g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); + + DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); + g_assert(server != NULL); + + GValue rootval = {0}; + g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); + g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); + DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); + g_assert(root != NULL); + + GList * children = dbusmenu_menuitem_get_children(root); + g_assert(children != NULL); + g_assert(g_list_length(children) == 1); + + const gchar * label = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(children->data), DBUSMENU_MENUITEM_PROP_LABEL); + g_assert(label != NULL); + g_assert(g_strcmp0(label, "Test Label") == 0); + + g_object_unref(G_OBJECT(ci)); + return; +} + void label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data) { @@ -301,6 +348,7 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); + g_test_add_func ("/indicator-application/libappindicator/set_menu", test_libappindicator_set_menu); g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); return; -- cgit v1.2.3 From 8b57d12c54ec1befb09711439e40eac7ed93dbcd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:05:39 -0600 Subject: Set the property type correctly. --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index fd035ac..78d784a 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -420,7 +420,7 @@ app_indicator_class_init (AppIndicatorClass *klass) g_param_spec_object (PROP_DBUS_MENU_SERVER_S, "The internal DBusmenu Server", "DBusmenu server which is available for testing the application indicators.", - DBUSMENU_TYPE_MENUITEM, + DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From d089c385b260d54d7521c277ebc875a3017d7f96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:25:00 -0600 Subject: Switching to be dbusmenu based instead of GTK menu based --- tests/test-libappindicator.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 82f3d05..00a8f19 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -353,15 +353,26 @@ test_libappindicator_desktop_menu (void) app_indicator_build_menu_from_desktop(ci, SRCDIR "/test-libappindicator.desktop", "Test Program"); - GtkMenu * menu = app_indicator_get_menu(ci); - g_assert(menu != NULL); + GValue serverval = {0}; + g_value_init(&serverval, DBUSMENU_TYPE_SERVER); + g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); + + DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); + g_assert(server != NULL); + + GValue rootval = {0}; + g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); + g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); + DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); + g_assert(root != NULL); - GList * children = gtk_container_get_children(GTK_CONTAINER(menu)); + GList * children = dbusmenu_menuitem_get_children(root); g_assert(children != NULL); g_assert(g_list_length(children) == 3); - g_object_unref(G_OBJECT(ci)); + + g_object_unref(G_OBJECT(ci)); return; } -- cgit v1.2.3 From 1d3ca65fb6f35c8b25f373d988d777fd6f8ce6f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:32:01 -0600 Subject: Adding shorties as a private variable --- src/app-indicator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 318a056..138498c 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -91,6 +91,9 @@ struct _AppIndicatorPrivate { DBusGProxy *watcher_proxy; DBusGConnection *connection; DBusGProxy * dbus_proxy; + + /* Might be used */ + IndicatorDesktopShortcuts * shorties; }; /* Signals Stuff */ @@ -568,6 +571,8 @@ app_indicator_init (AppIndicator *self) priv->status_icon = NULL; priv->fallback_timer = 0; + priv->shorties = NULL; + /* Put the object on DBus */ GError * error = NULL; priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); @@ -594,6 +599,11 @@ app_indicator_dispose (GObject *object) AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; + if (priv->shorties != NULL) { + g_object_unref(G_OBJECT(priv->shorties)); + priv->shorties = NULL; + } + if (priv->status != APP_INDICATOR_STATUS_PASSIVE) { app_indicator_set_status(self, APP_INDICATOR_STATUS_PASSIVE); } -- cgit v1.2.3 From 5c687d9de8dd774742a6a0e06ea443042fe91541 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:37:18 -0600 Subject: Switching to use the private variable for the shorties --- src/app-indicator.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 138498c..4643931 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2169,12 +2169,18 @@ shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { + g_return_if_fail(IS_APP_INDICATOR(self)); + AppIndicatorPrivate *priv = self->priv; /* Build a new shortcuts object */ - IndicatorDesktopShortcuts * shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); - g_return_if_fail(shorties != NULL); + if (priv->shorties != NULL) { + g_object_unref(priv->shorties); + priv->shorties = NULL; + } + priv->shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); + g_return_if_fail(priv->shorties != NULL); - const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(shorties); + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(priv->shorties); int nick_num; /* Place the items on a dbusmenu */ @@ -2184,7 +2190,7 @@ app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * deskto DbusmenuMenuitem * item = dbusmenu_menuitem_new(); g_object_set_data(G_OBJECT(item), APP_INDICATOR_SHORTY_NICK, (gpointer)nicks[nick_num]); - gchar * name = indicator_desktop_shortcuts_nick_get_name(shorties, nicks[nick_num]); + gchar * name = indicator_desktop_shortcuts_nick_get_name(priv->shorties, nicks[nick_num]); dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); g_free(name); -- cgit v1.2.3 From 2d87c7a295d0eb4681ed65a709c77ef47a421bf7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:48:35 -0600 Subject: Setup the menu as a dbusmenu if we build it --- src/app-indicator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 4643931..ee18cad 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2200,6 +2200,18 @@ app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * deskto } /* Swap it if needed */ + if (priv->menuservice == NULL) { + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); + priv->menuservice = dbusmenu_server_new (path); + g_free(path); + } + + dbusmenu_server_set_root (priv->menuservice, root); + + if (priv->menu != NULL) { + g_object_unref(G_OBJECT(priv->menu)); + priv->menu = NULL; + } return; } -- cgit v1.2.3 From 9bde70f2f1b96fe335dc11c941f64784c8f258f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:52:59 -0600 Subject: Filling out the activate function. --- src/app-indicator.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index ee18cad..199e256 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2153,7 +2153,16 @@ app_indicator_get_ordering_index (AppIndicator *self) static void shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { + gchar * nick = g_object_get_data(G_OBJECT(mi), APP_INDICATOR_SHORTY_NICK); + g_return_if_fail(nick != NULL); + g_return_if_fail(IS_APP_INDICATOR(user_data)); + AppIndicator * self = APP_INDICATOR(user_data); + AppIndicatorPrivate *priv = self->priv; + + g_return_if_fail(priv->shorties != NULL); + + indicator_desktop_shortcuts_nick_exec(priv->shorties, nick); return; } -- cgit v1.2.3 From 178f821b27fd31a5059d76a9ccc0cf9ff551e35b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 22:11:03 -0600 Subject: Clearing the events before unrefing --- tests/test-libappindicator.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 7a1976c..ece2df0 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -267,6 +267,13 @@ test_libappindicator_set_menu (void) g_assert(label != NULL); g_assert(g_strcmp0(label, "Test Label") == 0); + /* Interesting, eh? We need this because we send out events on the bus + but they don't come back until the idle is run. So we need those + events to clear before removing the object */ + while (g_main_context_pending(NULL)) { + g_main_context_iteration(NULL, TRUE); + } + g_object_unref(G_OBJECT(ci)); return; } -- cgit v1.2.3 From ca62d8c2fa745e4d033a9b6c79b146b1bbb86a2f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 22:18:55 -0600 Subject: Changing the ID to ensure we get different paths --- tests/test-libappindicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 3860b69..46460f0 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -350,7 +350,7 @@ test_libappindicator_label_signals (void) void test_libappindicator_desktop_menu (void) { - AppIndicator * ci = app_indicator_new ("my-id", + AppIndicator * ci = app_indicator_new ("my-id-desktop-menu", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); -- cgit v1.2.3 From aad192611ca84bfabc036658066ea584385f0982 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 22:21:11 -0600 Subject: Fleshing out a function to see if an invalid name results in no entries --- tests/test-libappindicator.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 46460f0..cadf783 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -386,9 +386,34 @@ test_libappindicator_desktop_menu (void) void test_libappindicator_desktop_menu_bad (void) { + AppIndicator * ci = app_indicator_new ("my-id-desktop-menu-bad", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_build_menu_from_desktop(ci, SRCDIR "/test-libappindicator.desktop", "Not Test Program"); + + GValue serverval = {0}; + g_value_init(&serverval, DBUSMENU_TYPE_SERVER); + g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); + DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); + g_assert(server != NULL); + GValue rootval = {0}; + g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); + g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); + DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); + g_assert(root != NULL); + + GList * children = dbusmenu_menuitem_get_children(root); + g_assert(g_list_length(children) == 0); + g_object_unref(G_OBJECT(ci)); + return; } void -- cgit v1.2.3 From c2e08e008bd9ea4f43a15390e6e4116cc714521a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 22:29:42 -0600 Subject: Documentation fixes for distcheck --- docs/reference/libappindicator-sections.txt | 1 + src/app-indicator.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index e0effd1..41ff7fa 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -38,5 +38,6 @@ app_indicator_get_menu app_indicator_get_label app_indicator_get_label_guide app_indicator_get_ordering_index +app_indicator_build_menu_from_desktop diff --git a/src/app-indicator.c b/src/app-indicator.c index 199e256..146bee2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2171,6 +2171,7 @@ shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) app_indicator_build_menu_from_desktop: @self: The #AppIndicator object to use @desktop_file: A path to the desktop file to build the menu from + @desktop_profile: Which entries should be used from the desktop file This function allows for building the Application Indicator menu from a static desktop file. -- cgit v1.2.3