From 5adf6408be296a141e044937e0fac617520f764b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 9 Feb 2010 13:30:17 -0600 Subject: Disconnecting the signal handler attached to the listener when we go away. --- src/app-menu-item.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 71860ea..2bdb7b1 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -116,6 +116,7 @@ app_menu_item_dispose (GObject *object) AppMenuItem * self = APP_MENU_ITEM(object); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); g_object_unref(priv->listener); G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object); -- cgit v1.2.3 From dcdb9f78884979c5e38a81fb222ae642fe99d142 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 9 Feb 2010 13:32:28 -0600 Subject: Some comments. --- src/app-menu-item.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 2bdb7b1..5fc2a9c 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -110,6 +110,7 @@ app_menu_item_init (AppMenuItem *self) return; } +/* Disconnect the count_changed signal and unref the listener */ static void app_menu_item_dispose (GObject *object) { @@ -122,6 +123,8 @@ app_menu_item_dispose (GObject *object) G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object); } +/* Free the memory used by our type, desktop file and application + info structures. */ static void app_menu_item_finalize (GObject *object) { -- cgit v1.2.3 From 9c60e05653c79d4f231f100f0cc35966e6738f54 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Feb 2010 12:04:26 -0600 Subject: Adding in the ability to use keyfiles for the black list --- src/messages-service.c | 79 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index ca9e799..fa2a9f6 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -48,6 +48,8 @@ static GMainLoop * mainloop = NULL; static MessageServiceDbus * dbus_interface = NULL; +#define DESKTOP_FILE_GROUP "Messaging Menu" +#define DESKTOP_FILE_KEY_DESKTOP "DesktopFile" static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); @@ -60,6 +62,8 @@ static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); +static gboolean blacklist_keyfile_add (gpointer udata); +static void blacklist_add_core (gchar * desktop, gchar * definition); static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); @@ -241,7 +245,11 @@ blacklist_init (gpointer data) while ((filename = g_dir_read_name(dir)) != NULL) { g_debug("Found file: %s", filename); gchar * path = g_build_filename(blacklistdir, filename, NULL); - g_idle_add(blacklist_add, path); + if (g_str_has_suffix(path, "keyfile")) { + g_idle_add(blacklist_keyfile_add, path); + } else { + g_idle_add(blacklist_add, path); + } } g_dir_close(dir); @@ -250,6 +258,42 @@ blacklist_init (gpointer data) return FALSE; } +/* Parses through a keyfile to find the desktop file entry and + pushes them into the blacklist. */ +static gboolean +blacklist_keyfile_add (gpointer udata) +{ + gchar * definition_file = (gchar *)udata; + GKeyFile * keyfile = g_key_file_new(); + GError * error = NULL; + + if (!g_key_file_load_from_file(keyfile, definition_file, G_KEY_FILE_NONE, &error)) { + g_warning("Unable to load keyfile '%s' because: %s", definition_file, error == NULL ? "unknown" : error->message); + g_error_free(error); + g_key_file_free(keyfile); + return FALSE; + } + + if (!g_key_file_has_group(keyfile, DESKTOP_FILE_GROUP)) { + g_warning("Unable to use keyfile '%s' as it has no '" DESKTOP_FILE_GROUP "' group.", definition_file); + g_key_file_free(keyfile); + return FALSE; + } + + if (!g_key_file_has_key(keyfile, DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DESKTOP, &error)) { + g_warning("Unable to use keyfile '%s' as there is no key '" DESKTOP_FILE_KEY_DESKTOP "' in the group '" DESKTOP_FILE_GROUP "' because: %s", definition_file, error == NULL ? "unknown" : error->message); + g_error_free(error); + g_key_file_free(keyfile); + return FALSE; + } + + gchar * desktopfile = g_key_file_get_string(keyfile, DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DESKTOP, &error); + blacklist_add_core(desktopfile, definition_file); + + g_key_file_free(keyfile); + return FALSE; +} + /* Add a definition file into the black list and eclipse and launchers that have the same file. */ static gboolean @@ -268,38 +312,51 @@ blacklist_add (gpointer udata) gchar * trimdesktop = pango_trim_string(desktop); g_free(desktop); + blacklist_add_core(trimdesktop, definition_file); + g_free(trimdesktop); + + return FALSE; +} + +/* This takes a desktop file and tries to add it to the black + list for applications in the messaging menu. If it can, + then the launcher item gets marked as eclipsed and hidden + from the user. */ +static void +blacklist_add_core (gchar * desktop, gchar * definition) +{ /* Check for conflicts */ - gpointer data = g_hash_table_lookup(blacklist, trimdesktop); + gpointer data = g_hash_table_lookup(blacklist, desktop); if (data != NULL) { gchar * oldfile = (gchar *)data; - if (!g_strcmp0(oldfile, definition_file)) { + if (!g_strcmp0(oldfile, definition)) { g_warning("Already added file '%s'", oldfile); } else { - g_warning("Already have desktop file '%s' in blacklist file '%s' not adding from '%s'", trimdesktop, oldfile, definition_file); + g_warning("Already have desktop file '%s' in blacklist file '%s' not adding from '%s'", desktop, oldfile, definition); } - g_free(trimdesktop); - g_free(definition_file); - return FALSE; + return; } /* Actually blacklist this thing */ - g_hash_table_insert(blacklist, trimdesktop, definition_file); - g_debug("Adding Blacklist item '%s' for desktop '%s'", definition_file, trimdesktop); + g_hash_table_insert(blacklist, desktop, definition); + g_debug("Adding Blacklist item '%s' for desktop '%s'", definition, desktop); /* Go through and eclipse folks */ GList * launcher; for (launcher = launcherList; launcher != NULL; launcher = launcher->next) { launcherList_t * item = (launcherList_t *)launcher->data; - if (!g_strcmp0(trimdesktop, launcher_menu_item_get_desktop(item->menuitem))) { + if (!g_strcmp0(desktop, launcher_menu_item_get_desktop(item->menuitem))) { launcher_menu_item_set_eclipsed(item->menuitem, TRUE); dbusmenu_menuitem_property_set(item->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); } } check_hidden(); + /* Shouldn't need a resort here as hiding shouldn't cause things to + move other than this item disappearing. */ - return FALSE; + return; } /* Remove a black list item based on the definition file -- cgit v1.2.3 From 0abfced4567f713a6bb2cd60a5d02c875765e2b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Feb 2010 12:44:17 -0600 Subject: Abstracting out the keyfile handling stuff. --- src/messages-service.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index fa2a9f6..40c06bb 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -62,6 +62,7 @@ static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); +static gchar * desktop_file_from_keyfile (const gchar * definition_file); static gboolean blacklist_keyfile_add (gpointer udata); static void blacklist_add_core (gchar * desktop, gchar * definition); static gboolean blacklist_remove (gpointer data); @@ -264,6 +265,19 @@ static gboolean blacklist_keyfile_add (gpointer udata) { gchar * definition_file = (gchar *)udata; + gchar * desktopfile = desktop_file_from_keyfile(definition_file); + if (desktopfile != NULL) { + blacklist_add_core(desktopfile, definition_file); + g_free(desktopfile); + } + return FALSE; +} + +/* Takes a keyfile and finds the desktop file in it for + us. With some error handling. */ +static gchar * +desktop_file_from_keyfile (const gchar * definition_file) +{ GKeyFile * keyfile = g_key_file_new(); GError * error = NULL; @@ -271,27 +285,30 @@ blacklist_keyfile_add (gpointer udata) g_warning("Unable to load keyfile '%s' because: %s", definition_file, error == NULL ? "unknown" : error->message); g_error_free(error); g_key_file_free(keyfile); - return FALSE; + return NULL; } if (!g_key_file_has_group(keyfile, DESKTOP_FILE_GROUP)) { g_warning("Unable to use keyfile '%s' as it has no '" DESKTOP_FILE_GROUP "' group.", definition_file); g_key_file_free(keyfile); - return FALSE; + return NULL; } if (!g_key_file_has_key(keyfile, DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DESKTOP, &error)) { g_warning("Unable to use keyfile '%s' as there is no key '" DESKTOP_FILE_KEY_DESKTOP "' in the group '" DESKTOP_FILE_GROUP "' because: %s", definition_file, error == NULL ? "unknown" : error->message); g_error_free(error); g_key_file_free(keyfile); - return FALSE; + return NULL; } gchar * desktopfile = g_key_file_get_string(keyfile, DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DESKTOP, &error); - blacklist_add_core(desktopfile, definition_file); + gchar * desktop = NULL; + if (desktopfile != NULL) { + desktop = g_strdup(desktopfile); + } g_key_file_free(keyfile); - return FALSE; + return desktop; } /* Add a definition file into the black list and eclipse -- cgit v1.2.3 From 2edf04c593023c304c486c6cb9bc5d091a76368c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Feb 2010 13:09:26 -0600 Subject: Spliting out the launchers into the keyfiles --- src/messages-service.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 40c06bb..ff6c62d 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -59,6 +59,8 @@ static void indicator_removed (IndicateListener * listener, IndicateListenerServ static void check_eclipses (AppMenuItem * ai); static void remove_eclipses (AppMenuItem * ai); static gboolean build_launcher (gpointer data); +static gboolean build_launcher_keyfile (gpointer data); +static void build_launcher_core (const gchar * desktop); static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); @@ -1193,11 +1195,34 @@ build_launcher (gpointer data) g_free(desktop); g_debug("\tcontents: %s", trimdesktop); + build_launcher_core(trimdesktop); + g_free(trimdesktop); + return FALSE; +} + +/* Use a key file to find the desktop file. */ +static gboolean +build_launcher_keyfile (gpointer data) +{ + gchar * path = (gchar *)data; + gchar * desktop = desktop_file_from_keyfile (path); + if (desktop != NULL) { + build_launcher_core(desktop); + g_free(desktop); + } + return FALSE; +} + +/* The core action of dealing with a desktop file that should + be a launcher */ +static void +build_launcher_core (const gchar * desktop) +{ /* Check to see if we already have a launcher */ GList * listitem; for (listitem = launcherList; listitem != NULL; listitem = listitem->next) { launcherList_t * li = (launcherList_t *)listitem->data; - if (!g_strcmp0(launcher_menu_item_get_desktop(li->menuitem), trimdesktop)) { + if (!g_strcmp0(launcher_menu_item_get_desktop(li->menuitem), desktop)) { break; } } @@ -1206,9 +1231,8 @@ build_launcher (gpointer data) /* If not */ /* Build the item */ launcherList_t * ll = g_new0(launcherList_t, 1); - ll->menuitem = launcher_menu_item_new(trimdesktop); - g_free(trimdesktop); - ll->appdiritems = g_list_append(NULL, path); + ll->menuitem = launcher_menu_item_new(desktop); + ll->appdiritems = g_list_append(NULL, g_strdup(desktop)); /* Build a separator */ ll->separator = dbusmenu_menuitem_new(); @@ -1234,10 +1258,10 @@ build_launcher (gpointer data) } else { /* If so add ourselves */ launcherList_t * ll = (launcherList_t *)listitem->data; - ll->appdiritems = g_list_append(ll->appdiritems, path); + ll->appdiritems = g_list_append(ll->appdiritems, g_strdup(desktop)); } - return FALSE; + return; } /* This function goes through all the launchers that we're -- cgit v1.2.3 From 20698c326aa8ae2bc4061d77d79b3554cf32ccbc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Feb 2010 13:22:45 -0600 Subject: If we see a keyfile, use the keyfile processing. --- src/messages-service.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index ff6c62d..52e9a48 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -1057,7 +1057,11 @@ app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFile case G_FILE_MONITOR_EVENT_CREATED: { gchar * path = g_file_get_path(file); g_debug("\tCreate: %s", path); - g_idle_add(build_launcher, path); + if (g_str_has_suffix(path, "keyfile")) { + g_idle_add(build_launcher_keyfile, path); + } else { + g_idle_add(build_launcher, path); + } break; } default: @@ -1295,7 +1299,11 @@ build_launchers (gpointer data) while ((filename = g_dir_read_name(dir)) != NULL) { g_debug("Found file: %s", filename); gchar * path = g_build_filename(directory, filename, NULL); - g_idle_add(build_launcher, path); + if (g_str_has_suffix(path, "keyfile")) { + g_idle_add(build_launcher_keyfile, path); + } else { + g_idle_add(build_launcher, path); + } } g_dir_close(dir); -- cgit v1.2.3 From 890a69be7f8df0137a55405afe915627599b3808 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 11:56:03 -0600 Subject: Adding a function to get the items that are in the desktop file. --- src/launcher-menu-item.c | 6 ++++++ src/launcher-menu-item.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 50e8ce6..089402d 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -214,3 +214,9 @@ launcher_menu_item_get_eclipsed (LauncherMenuItem * li) } return FALSE; } + +GList * +launcher_menu_item_get_items (LauncherMenuItem * li) +{ + return NULL; +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 3e031d5..9aed0a7 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -59,6 +59,7 @@ const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); const gchar * launcher_menu_item_get_description (LauncherMenuItem * li); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li); +GList * launcher_menu_item_get_items (LauncherMenuItem * li); G_END_DECLS -- cgit v1.2.3 From cccb9bc5f977a9d11ec3ee9b9055bbee3b2b6738 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:02:23 -0600 Subject: Adding in shortcuts and ids private variables. Full lifecycle. --- src/launcher-menu-item.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 089402d..238c4cf 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -27,6 +27,7 @@ with this program. If not, see . #include #include #include +#include #include "launcher-menu-item.h" #include "dbus-data.h" @@ -42,6 +43,8 @@ struct _LauncherMenuItemPrivate { GAppInfo * appinfo; gchar * desktop; + IndicatorDesktopShortcuts * ids; + GList * shortcuts; }; #define LAUNCHER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemPrivate)) @@ -86,20 +89,21 @@ launcher_menu_item_init (LauncherMenuItem *self) priv->appinfo = NULL; priv->desktop = NULL; + priv->ids = NULL; + priv->shortcuts = NULL; + return; } static void -launcher_menu_item_dispose (GObject *object) +func_unref (gpointer data, gpointer user_data) { - // LauncherMenuItem * self = LAUNCHER_MENU_ITEM(object); - // LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); - - G_OBJECT_CLASS (launcher_menu_item_parent_class)->dispose (object); + g_object_unref(G_OBJECT(data)); + return; } static void -launcher_menu_item_finalize (GObject *object) +launcher_menu_item_dispose (GObject *object) { LauncherMenuItem * self = LAUNCHER_MENU_ITEM(object); LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); @@ -109,6 +113,26 @@ launcher_menu_item_finalize (GObject *object) priv->appinfo = NULL; } + if (priv->ids != NULL) { + g_object_unref(priv->ids); + priv->ids = NULL; + } + + if (priv->shortcuts != NULL) { + g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_free(priv->shortcuts); + priv->shortcuts = NULL; + } + + G_OBJECT_CLASS (launcher_menu_item_parent_class)->dispose (object); +} + +static void +launcher_menu_item_finalize (GObject *object) +{ + LauncherMenuItem * self = LAUNCHER_MENU_ITEM(object); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + if (priv->desktop != NULL) { g_free(priv->desktop); priv->desktop = NULL; -- cgit v1.2.3 From 379d88af9fd622801b4143169ec44c867d5cd533 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:31:25 -0600 Subject: Build us some shortcut menuitems --- src/launcher-menu-item.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 238c4cf..c186e45 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -55,6 +55,7 @@ static void launcher_menu_item_init (LauncherMenuItem *self); static void launcher_menu_item_dispose (GObject *object); static void launcher_menu_item_finalize (GObject *object); static void activate_cb (LauncherMenuItem * self, guint timestamp, gpointer data); +static void nick_activate_cb (LauncherMenuItem * self, guint timestamp, gpointer data); G_DEFINE_TYPE (LauncherMenuItem, launcher_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -151,9 +152,12 @@ launcher_menu_item_new (const gchar * desktop_file) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + /* Parse the desktop file we've been given. */ priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file)); priv->desktop = g_strdup(desktop_file); + /* Set the appropriate values on this menu item based on the + app info that we've parsed */ g_debug("\tName: %s", launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, LAUNCHER_MENUITEM_TYPE); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); @@ -161,6 +165,21 @@ launcher_menu_item_new (const gchar * desktop_file) g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); + /* Start to build static shortcuts */ + priv->ids = indicator_desktop_shortcuts_new(priv->desktop, "Messaging Menu"); + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(priv->ids); + gint i; + for (i = 0; nicks[i] != NULL; i++) { + DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); + g_object_set_data(G_OBJECT(mi), "ids-nick", (gpointer)nicks[i]); + + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i])); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self); + + priv->shortcuts = g_list_append(priv->shortcuts, mi); + } + + /* Check to see if we should be eclipsed */ if (priv->appinfo == NULL) { launcher_menu_item_set_eclipsed(self, TRUE); } @@ -180,6 +199,13 @@ launcher_menu_item_get_name (LauncherMenuItem * appitem) } } +/* Respond to one of the shortcuts getting clicked on. */ +static void +nick_activate_cb (LauncherMenuItem * self, guint timestamp, gpointer data) +{ + +} + /* When the menu item is clicked on it tries to launch the application that is represented by the desktop file */ static void -- cgit v1.2.3 From ca4026eca162910c907fb3224658491335bd98cf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:39:01 -0600 Subject: Responding to clicking on the shortcuts --- src/launcher-menu-item.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index c186e45..f24dfa9 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -49,6 +49,8 @@ struct _LauncherMenuItemPrivate #define LAUNCHER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemPrivate)) +#define NICK_DATA "ids-nick-data" + /* Prototypes */ static void launcher_menu_item_class_init (LauncherMenuItemClass *klass); static void launcher_menu_item_init (LauncherMenuItem *self); @@ -171,7 +173,7 @@ launcher_menu_item_new (const gchar * desktop_file) gint i; for (i = 0; nicks[i] != NULL; i++) { DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); - g_object_set_data(G_OBJECT(mi), "ids-nick", (gpointer)nicks[i]); + g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]); dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i])); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self); @@ -203,7 +205,21 @@ launcher_menu_item_get_name (LauncherMenuItem * appitem) static void nick_activate_cb (LauncherMenuItem * self, guint timestamp, gpointer data) { + gchar * nick = (gchar *)g_object_get_data(G_OBJECT(self), NICK_DATA); + LauncherMenuItem * lmi = LAUNCHER_MENU_ITEM(data); + + g_return_if_fail(nick != NULL); + g_return_if_fail(lmi != NULL); + + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(lmi); + + g_return_if_fail(priv->ids != NULL); + if (!indicator_desktop_shortcuts_nick_exec(priv->ids, nick)) { + g_warning("Unable to execute nick '%s' for desktop file '%s'", nick, priv->desktop); + } + + return; } /* When the menu item is clicked on it tries to launch -- cgit v1.2.3 From 05436b2d6a483ea791b5a1ec396493ed08830b25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:45:44 -0600 Subject: Making visible use boolean properties. --- src/launcher-menu-item.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index f24dfa9..a65aed0 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -263,22 +263,16 @@ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, eclipsed ? "false" : "true"); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, !eclipsed); return; } gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { - const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE); - if (show == NULL) { - return FALSE; - } - g_debug("Launcher check eclipse: %s", show); - if (!g_strcmp0(show, "false")) { - return TRUE; - } - return FALSE; + gboolean show = dbusmenu_menuitem_property_get_bool(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE); + g_debug("Launcher check eclipse: %s", show ? "false" : "true"); + return !show; } GList * -- cgit v1.2.3 From 5da2f0c0661f6d5ebced459ec677aa86441894b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:50:12 -0600 Subject: Applying the eclipsed value to the shortcuts that are associted with this launcher. --- src/launcher-menu-item.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index a65aed0..e961573 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -257,13 +257,32 @@ launcher_menu_item_get_description (LauncherMenuItem * li) return g_app_info_get_description(priv->appinfo); } +/* Apply the eclipse value to all the shortcuts */ +static void +eclipse_shortcuts_cb (gpointer data, gpointer user_data) +{ + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); + g_return_if_fail(mi != NULL); + + gboolean eclipsed = GPOINTER_TO_UINT(user_data); + + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !eclipsed); + return; +} + /* Hides the menu item based on whether it is eclipsed or not. */ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { + g_return_if_fail(IS_LAUNCHER_MENU_ITEM(li)); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(li); + g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, !eclipsed); + + g_list_foreach(priv->shortcuts, eclipse_shortcuts_cb, GINT_TO_POINTER(eclipsed)); + return; } -- cgit v1.2.3 From 3d07cf168800200269449e1d5d2b3e682c8fc033 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 12:53:03 -0600 Subject: Fleshing out the get_items function --- src/launcher-menu-item.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index e961573..d542e11 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -286,6 +286,7 @@ launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) return; } +/* Check to see if this item is eclipsed */ gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { @@ -294,8 +295,12 @@ launcher_menu_item_get_eclipsed (LauncherMenuItem * li) return !show; } +/* Gets the shortcuts that are associated with this + launcher. They're a list of DbusmenuMenuitems */ GList * launcher_menu_item_get_items (LauncherMenuItem * li) { - return NULL; + g_return_val_if_fail(IS_LAUNCHER_MENU_ITEM(li), NULL); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(li); + return priv->shortcuts; } -- cgit v1.2.3 From c271f6dbdc98ab96f10b4f1cbe82e3133c8254dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 13:09:06 -0600 Subject: Adding the shortcuts into the menuhandling code. --- src/messages-service.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 52e9a48..2893313 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -800,6 +800,15 @@ resort_menu (DbusmenuMenuitem * menushell) dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->menuitem), position); position++; + /* Inserting the shortcuts from the launcher */ + GList * shortcuts = launcher_menu_item_get_items(li->menuitem); + while (shortcuts != NULL) { + g_debug("\t\tMoving shortcut to position %d", position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(shortcuts->data), position); + position++; + shortcuts = g_list_next(shortcuts); + } + /* Putting the launcher separator in */ g_debug("\tMoving launcher separator to position %d", position); dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->separator), position); @@ -856,6 +865,15 @@ resort_menu (DbusmenuMenuitem * menushell) dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->menuitem), position); position++; + /* Inserting the shortcuts from the launcher */ + GList * shortcuts = launcher_menu_item_get_items(li->menuitem); + while (shortcuts != NULL) { + g_debug("\t\tMoving shortcut to position %d", position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(shortcuts->data), position); + position++; + shortcuts = g_list_next(shortcuts); + } + /* Putting the launcher separator in */ g_debug("\tMoving launcher separator to position %d", position); dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->separator), position); @@ -1247,6 +1265,11 @@ build_launcher_core (const gchar * desktop) /* Add it to the menu */ dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); + GList * shortcuts = launcher_menu_item_get_items(li->menuitem); + while (shortcuts != NULL) { + dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(shortcuts->data)); + shortcuts = g_list_next(shortcuts); + } dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->separator)); /* If we're in the black list or we've gotten eclipsed -- cgit v1.2.3 From 6a2abb99760ff8395a3e22dabbebf60b98c99f16 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 13:13:37 -0600 Subject: Switching over to using _bool for the visible property --- src/messages-service.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 2893313..585589a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -367,7 +367,7 @@ blacklist_add_core (gchar * desktop, gchar * definition) launcherList_t * item = (launcherList_t *)launcher->data; if (!g_strcmp0(desktop, launcher_menu_item_get_desktop(item->menuitem))) { launcher_menu_item_set_eclipsed(item->menuitem, TRUE); - dbusmenu_menuitem_property_set(item->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(item->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } } @@ -416,7 +416,7 @@ blacklist_remove (gpointer data) } if (serveritem == NULL) { launcher_menu_item_set_eclipsed(li->menuitem, FALSE); - dbusmenu_menuitem_property_set(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "true"); + dbusmenu_menuitem_property_set_bool(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } } @@ -702,14 +702,14 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* If there is a menu item, let's get rid of it. */ if (sltp->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); g_object_unref(G_OBJECT(sltp->menuitem)); } /* If there is a separator, let's get rid of it. */ if (sltp->separator != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->separator), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->separator), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->separator)); g_object_unref(G_OBJECT(sltp->separator)); } @@ -814,7 +814,7 @@ resort_menu (DbusmenuMenuitem * menushell) dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->separator), position); if (!launcher_menu_item_get_eclipsed(li->menuitem)) { /* Only clear the visiblity if we're not eclipsed */ - dbusmenu_menuitem_property_set(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "true"); + dbusmenu_menuitem_property_set_bool(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); last_separator = li->separator; } position++; @@ -850,7 +850,7 @@ resort_menu (DbusmenuMenuitem * menushell) if (si->separator != NULL) { g_debug("\tMoving app %s separator to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(si->server), position); dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->separator), position); - dbusmenu_menuitem_property_set(si->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "true"); + dbusmenu_menuitem_property_set_bool(si->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); position++; last_separator = si->separator; } @@ -879,7 +879,7 @@ resort_menu (DbusmenuMenuitem * menushell) dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->separator), position); if (!launcher_menu_item_get_eclipsed(li->menuitem)) { /* Only clear the visiblity if we're not eclipsed */ - dbusmenu_menuitem_property_set(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "true"); + dbusmenu_menuitem_property_set_bool(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); last_separator = li->separator; } position++; @@ -888,7 +888,7 @@ resort_menu (DbusmenuMenuitem * menushell) } if (last_separator != NULL) { - dbusmenu_menuitem_property_set(last_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(last_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } else { g_warning("No last separator on resort"); } @@ -1047,7 +1047,7 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, /* Hide the item immediately, and then remove it which might take a little longer. */ - dbusmenu_menuitem_property_set(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), menuitem); removed = TRUE; } @@ -1108,7 +1108,7 @@ check_eclipses (AppMenuItem * ai) if (!g_strcmp0(aidesktop, lidesktop)) { launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); - dbusmenu_menuitem_property_set(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); break; } } @@ -1133,7 +1133,7 @@ remove_eclipses (AppMenuItem * ai) if (!g_strcmp0(aidesktop, lidesktop)) { launcher_menu_item_set_eclipsed(ll->menuitem, FALSE); - dbusmenu_menuitem_property_set(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "true"); + dbusmenu_menuitem_property_set_bool(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); break; } } @@ -1185,7 +1185,7 @@ destroy_launcher (gpointer data) g_list_free(li->appdiritems); if (li->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem)); g_object_unref(G_OBJECT(li->menuitem)); li->menuitem = NULL; @@ -1265,7 +1265,7 @@ build_launcher_core (const gchar * desktop) /* Add it to the menu */ dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); - GList * shortcuts = launcher_menu_item_get_items(li->menuitem); + GList * shortcuts = launcher_menu_item_get_items(ll->menuitem); while (shortcuts != NULL) { dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(shortcuts->data)); shortcuts = g_list_next(shortcuts); @@ -1277,7 +1277,7 @@ build_launcher_core (const gchar * desktop) if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem)) || launcher_menu_item_get_eclipsed(ll->menuitem)) { launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); - dbusmenu_menuitem_property_set(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); + dbusmenu_menuitem_property_set_bool(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } resort_menu(root_menuitem); -- cgit v1.2.3 From abedb35f468b736aaa4d6f53b8270adb3109e107 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 13:40:20 -0600 Subject: Explicitly setting the visible property so we call pull it later. --- src/launcher-menu-item.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index d542e11..d6386a3 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -164,6 +164,7 @@ launcher_menu_item_new (const gchar * desktop_file) dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, LAUNCHER_MENUITEM_TYPE); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_description(self)); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From 3c93168a4518426fb28f06c3635b7f32fad2f6a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 13:48:53 -0600 Subject: Adding API for getting items --- src/app-menu-item.c | 8 ++++++++ src/app-menu-item.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5fc2a9c..b1b2a02 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -309,3 +309,11 @@ app_menu_item_get_desktop (AppMenuItem * appitem) AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); return priv->desktop; } + +/* Get the dynamic items added onto the end of + and app entry. */ +GList * +app_menu_item_get_items (AppMenuItem * appitem) +{ + return NULL; +} diff --git a/src/app-menu-item.h b/src/app-menu-item.h index 583d50d..fe16c75 100644 --- a/src/app-menu-item.h +++ b/src/app-menu-item.h @@ -60,6 +60,7 @@ guint app_menu_item_get_count (AppMenuItem * appitem); IndicateListenerServer * app_menu_item_get_server (AppMenuItem * appitem); const gchar * app_menu_item_get_name (AppMenuItem * appitem); const gchar * app_menu_item_get_desktop (AppMenuItem * appitem); +GList * app_menu_item_get_items (AppMenuItem * appitem); G_END_DECLS -- cgit v1.2.3 From d307fee44ed8e2588c23a9461a44b0d86362e53c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:17:18 -0600 Subject: Fleshing out menu_cb, lots of avenues for expantion in other directions now. --- src/app-menu-item.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index b1b2a02..ece5a83 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -26,6 +26,7 @@ with this program. If not, see . #include #include +#include #include "app-menu-item.h" #include "dbus-data.h" @@ -48,6 +49,9 @@ struct _AppMenuItemPrivate GAppInfo * appinfo; gchar * desktop; guint unreadcount; + + DbusmenuClient * client; + DbusmenuMenuitem * root; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -60,6 +64,7 @@ static void app_menu_item_finalize (GObject *object); static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data); static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data); static void count_cb (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data); +static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data); static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); static void update_label (AppMenuItem * self); @@ -168,6 +173,7 @@ app_menu_item_new (IndicateListener * listener, IndicateListenerServer * server) /* Get the values we care about from the server */ indicate_listener_server_get_desktop(listener, server, desktop_cb, self); indicate_listener_server_get_count(listener, server, count_cb, self); + indicate_listener_server_get_menu(listener, server, menu_cb, self); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -262,6 +268,27 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar return; } +static void +root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user_data) +{ + + +} + +/* Gets the path to menuitems if there are some. Now we need to + make them special. */ +static void +menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) +{ + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + priv->client = dbusmenu_client_new(indicate_listener_server_get_dbusname(server), menupath); + g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), self); + + return; +} + static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data) { -- cgit v1.2.3 From 1728c0be0db166c30a2e2b2a5373d135b404d3ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:22:15 -0600 Subject: Init and cleanup the client and root private properties. --- src/app-menu-item.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index ece5a83..67f616a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -112,6 +112,9 @@ app_menu_item_init (AppMenuItem *self) priv->desktop = NULL; priv->unreadcount = 0; + priv->client = NULL; + priv->root = NULL; + return; } @@ -122,8 +125,20 @@ app_menu_item_dispose (GObject *object) AppMenuItem * self = APP_MENU_ITEM(object); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); - g_object_unref(priv->listener); + if (priv->listener != NULL) { + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); + g_object_unref(priv->listener); + } + + if (priv->root != NULL) { + g_object_unref(priv->root); + priv->root = NULL; + } + + if (priv->client != NULL) { + g_object_unref(priv->client); + priv->client = NULL; + } G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object); } -- cgit v1.2.3 From de7363b6804d843f9c8c9a692297570bf1a19cfe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:56:52 -0600 Subject: Handling root item changes. Mostly. --- src/app-menu-item.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 67f616a..5d53053 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -27,6 +27,7 @@ with this program. If not, see . #include #include #include +#include #include "app-menu-item.h" #include "dbus-data.h" @@ -51,7 +52,7 @@ struct _AppMenuItemPrivate guint unreadcount; DbusmenuClient * client; - DbusmenuMenuitem * root; + DbusmenuMenuitemProxy * root; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -284,10 +285,63 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar } static void -root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user_data) +child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { + return; +} + +static void +child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +{ + + return; +} +static void +child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) +{ + + return; +} + +/* We've got a new root. We need to proxy it and handle it's children + if that's a relevant thing to do. */ +static void +root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data) +{ + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + gboolean change_time = FALSE; + + if (priv->root != NULL) { + if (dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)) != NULL) { + change_time = TRUE; + } + g_object_unref(priv->root); + priv->root = NULL; + } + + /* We need to proxy the new root across to the old + world of indicator land. */ + priv->root = dbusmenu_menuitem_proxy_new(newroot); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added_cb), self); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(child_removed_cb), self); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved_cb), self); + + /* See if we have any menuitems to worry about, + otherwise we'll just move along. */ + GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); + if (children != NULL) { + change_time = TRUE; + } + + if (change_time) { + /* Signal that something has changed */ + change_time = FALSE; + } + + return; } /* Gets the path to menuitems if there are some. Now we need to -- cgit v1.2.3 From 958bb92e0346294d34d7628061faf134f1043621 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:01:13 -0600 Subject: Adding in a shortcuts changed signal --- src/app-menu-item.c | 8 ++++++++ src/app-menu-item.h | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5d53053..e9ba0f1 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -34,6 +34,7 @@ with this program. If not, see . enum { COUNT_CHANGED, NAME_CHANGED, + SHORTCUTS_CHANGED, LAST_SIGNAL }; @@ -96,6 +97,13 @@ app_menu_item_class_init (AppMenuItemClass *klass) NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + signals[SHORTCUTS_CHANGED] = g_signal_new(APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppMenuItemClass, shortcuts_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); return; } diff --git a/src/app-menu-item.h b/src/app-menu-item.h index fe16c75..48a7cfa 100644 --- a/src/app-menu-item.h +++ b/src/app-menu-item.h @@ -37,8 +37,9 @@ G_BEGIN_DECLS #define IS_APP_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_MENU_ITEM_TYPE)) #define APP_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_MENU_ITEM_TYPE, AppMenuItemClass)) -#define APP_MENU_ITEM_SIGNAL_COUNT_CHANGED "count-changed" -#define APP_MENU_ITEM_SIGNAL_NAME_CHANGED "name-changed" +#define APP_MENU_ITEM_SIGNAL_COUNT_CHANGED "count-changed" +#define APP_MENU_ITEM_SIGNAL_NAME_CHANGED "name-changed" +#define APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED "shortcuts-changed" typedef struct _AppMenuItem AppMenuItem; typedef struct _AppMenuItemClass AppMenuItemClass; @@ -48,6 +49,7 @@ struct _AppMenuItemClass { void (* count_changed) (guint count); void (* name_changed) (gchar * name); + void (* shortcuts_changed) (void); }; struct _AppMenuItem { -- cgit v1.2.3 From ed9e77cb4d6bf3359138c28153a316ad5418be83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:03:21 -0600 Subject: Emitting the new signal all over the place. --- src/app-menu-item.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index e9ba0f1..59b435a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -292,24 +292,30 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } @@ -345,8 +351,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data } if (change_time) { - /* Signal that something has changed */ - change_time = FALSE; + g_signal_emit(G_OBJECT(self), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); } return; -- cgit v1.2.3 From 7c08cb9a551c4c9c58bf7ebc1b591471479e9d73 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:20:24 -0600 Subject: Oops, wrong signal name for this function. --- src/app-menu-item.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 59b435a..2f96c49 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -297,7 +297,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -306,7 +306,7 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -315,7 +315,7 @@ child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer us static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -351,7 +351,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data } if (change_time) { - g_signal_emit(G_OBJECT(self), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(self), signals[SHORTCUTS_CHANGED], 0, TRUE); } return; -- cgit v1.2.3 From 3bd80ee8e9bfa1c2b50225b67349eaff8bbeafa2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:41:38 -0600 Subject: Adding a list to put the shortcuts in --- src/app-menu-item.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 2f96c49..58c8a02 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -54,6 +54,7 @@ struct _AppMenuItemPrivate DbusmenuClient * client; DbusmenuMenuitemProxy * root; + GList * shortcuts; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -123,10 +124,19 @@ app_menu_item_init (AppMenuItem *self) priv->client = NULL; priv->root = NULL; + priv->shortcuts = NULL; return; } +/* A wrapper to make the prototypes work for GFunc */ +static void +func_unref (gpointer data, gpointer user_data) +{ + g_object_unref(G_OBJECT(data)); + return; +} + /* Disconnect the count_changed signal and unref the listener */ static void app_menu_item_dispose (GObject *object) @@ -139,6 +149,13 @@ app_menu_item_dispose (GObject *object) g_object_unref(priv->listener); } + if (priv->shortcuts != NULL) { + g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_free(priv->shortcuts); + priv->shortcuts = NULL; + g_signal_emit(object, signals[SHORTCUTS_CHANGED], 0, TRUE); + } + if (priv->root != NULL) { g_object_unref(priv->root); priv->root = NULL; -- cgit v1.2.3 From 072da6cccd26225f1528bf09917dd38006f9bd7d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 16:10:18 -0600 Subject: Realized that we can't proxy the root as the items can't then have two parents, and they need to exist with a parent in the menu that we're building. So we have to leave the proxy items unparented until they get picked up in the service themselves. --- src/app-menu-item.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 58c8a02..53d4afa 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -53,7 +53,7 @@ struct _AppMenuItemPrivate guint unreadcount; DbusmenuClient * client; - DbusmenuMenuitemProxy * root; + DbusmenuMenuitem * root; GList * shortcuts; }; @@ -312,27 +312,70 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) +child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child); + + priv->shortcuts = g_list_insert(priv->shortcuts, mip, position); + + g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + GList * pitems = priv->shortcuts; + while (pitems != NULL) { + DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(pitems->data); + + if (dbusmenu_menuitem_proxy_get_wrapped(mip) == child) { + break; + } + + pitems = g_list_next(pitems); + } + + if (pitems != NULL) { + DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(pitems->data); + g_object_unref(mip); + priv->shortcuts = g_list_remove(priv->shortcuts, mip); + + g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); + } + return; } /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) +child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(g_list_nth_data(priv->shortcuts, oldpos)); + + if (mip != NULL) { + if (dbusmenu_menuitem_proxy_get_wrapped(mip) != child) { + mip = NULL; + } + } + + if (mip != NULL) { + priv->shortcuts = g_list_remove(priv->shortcuts, mip); + priv->shortcuts = g_list_insert(priv->shortcuts, mip, newpos); + g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); + } + return; } @@ -348,6 +391,9 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data if (priv->root != NULL) { if (dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)) != NULL) { change_time = TRUE; + g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_free(priv->shortcuts); + priv->shortcuts = NULL; } g_object_unref(priv->root); priv->root = NULL; @@ -355,7 +401,8 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data /* We need to proxy the new root across to the old world of indicator land. */ - priv->root = dbusmenu_menuitem_proxy_new(newroot); + priv->root = newroot; + g_object_ref(priv->root); g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added_cb), self); g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(child_removed_cb), self); g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved_cb), self); @@ -365,6 +412,10 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); if (children != NULL) { change_time = TRUE; + while (children != NULL) { + DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); + priv->shortcuts = g_list_append(priv->shortcuts, mip); + } } if (change_time) { -- cgit v1.2.3 From aa1f03448025d8a0be2a84db6a07430f9b26e941 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 16:40:47 -0600 Subject: Getting the shortcuts in, and handling changes of them. --- src/messages-service.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 585589a..6b4f7c6 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -31,6 +31,7 @@ with this program. If not, see . #include #include +#include #include "im-menu-item.h" #include "app-menu-item.h" @@ -51,6 +52,7 @@ static MessageServiceDbus * dbus_interface = NULL; #define DESKTOP_FILE_GROUP "Messaging Menu" #define DESKTOP_FILE_KEY_DESKTOP "DesktopFile" +static void server_shortcuts_changed (AppMenuItem * appitem, gpointer data); static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); @@ -582,11 +584,20 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Connect the signals up to the menu item */ g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_COUNT_CHANGED, G_CALLBACK(server_count_changed), sl_item); g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_NAME_CHANGED, G_CALLBACK(server_name_changed), menushell); + g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, G_CALLBACK(server_shortcuts_changed), menushell); /* Put our new menu item in, with the separator behind it. resort_menu will take care of whether it should be hidden or not. */ dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); + + GList * shortcuts = app_menu_item_get_items(sl_item->menuitem); + while (shortcuts != NULL) { + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data); + dbusmenu_menuitem_child_append(menushell, mi); + shortcuts = g_list_next(shortcuts); + } + dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(sl_item->separator)); resort_menu(menushell); @@ -595,6 +606,46 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha return; } +/* The shortcuts have changed, let's just remove them and put + the back. */ +static void +server_shortcuts_changed (AppMenuItem * appitem, gpointer data) +{ + DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data); + gboolean appitemfound = FALSE; + GList * children = dbusmenu_menuitem_get_children(shell); + GList * removelist = NULL; + + while (children != NULL) { + if (!appitemfound && children->data != appitem) { + children = g_list_next(children); + continue; + } + appitemfound = TRUE; + + if (!DBUSMENU_IS_MENUITEM_PROXY(children->data)) { + break; + } + + removelist = g_list_prepend(removelist, children->data); + } + + GList * removeitem; + for (removeitem = removelist; removeitem != NULL; removeitem = g_list_next(removeitem)) { + dbusmenu_menuitem_child_delete(shell, DBUSMENU_MENUITEM(removeitem->data)); + } + g_list_free(removeitem); + + GList * shortcuts = app_menu_item_get_items(appitem); + while (shortcuts != NULL) { + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data); + dbusmenu_menuitem_child_append(shell, mi); + shortcuts = g_list_next(shortcuts); + } + + return; +} + /* The name of a server has changed, we probably need to reorder the menu to keep it in alphabetical order. This happens often after we read the destkop -- cgit v1.2.3 From 09c3405e449b936d3fce4fd85618dd4e60aaa77c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 16:43:04 -0600 Subject: Moving the shortcuts along with the app item --- src/messages-service.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 6b4f7c6..c1af270 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -882,6 +882,15 @@ resort_menu (DbusmenuMenuitem * menushell) g_debug("\tMoving app %s to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(si->server), position); dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->menuitem), position); position++; + + /* Inserting the shortcuts from the launcher */ + GList * shortcuts = app_menu_item_get_items(si->menuitem); + while (shortcuts != NULL) { + g_debug("\t\tMoving shortcut to position %d", position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(shortcuts->data), position); + position++; + shortcuts = g_list_next(shortcuts); + } } /* Putting all the indicators that are related to this application -- cgit v1.2.3 From bcc596a2912f66658058d14f8e30b04cb67915e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:31:16 -0600 Subject: Adding some debug messages --- src/app-menu-item.c | 2 ++ src/messages-service.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 53d4afa..57a4e6a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -384,6 +384,7 @@ child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, static void root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data) { + g_debug("Root Changed"); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); gboolean change_time = FALSE; @@ -412,6 +413,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); if (children != NULL) { change_time = TRUE; + g_debug("\tProcessing %d children", g_list_length(children)); while (children != NULL) { DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); priv->shortcuts = g_list_append(priv->shortcuts, mip); diff --git a/src/messages-service.c b/src/messages-service.c index c1af270..0cbb91a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -594,6 +594,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha GList * shortcuts = app_menu_item_get_items(sl_item->menuitem); while (shortcuts != NULL) { DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data); + g_debug("\tAdding shortcut: %s", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL)); dbusmenu_menuitem_child_append(menushell, mi); shortcuts = g_list_next(shortcuts); } @@ -611,6 +612,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha static void server_shortcuts_changed (AppMenuItem * appitem, gpointer data) { + g_debug("Application Shortcuts changed"); DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data); gboolean appitemfound = FALSE; GList * children = dbusmenu_menuitem_get_children(shell); @@ -639,6 +641,7 @@ server_shortcuts_changed (AppMenuItem * appitem, gpointer data) GList * shortcuts = app_menu_item_get_items(appitem); while (shortcuts != NULL) { DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data); + g_debug("\tAdding shortcut: %s", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL)); dbusmenu_menuitem_child_append(shell, mi); shortcuts = g_list_next(shortcuts); } -- cgit v1.2.3 From 0d8b02c5c23e4e66d99481888e8e82baa937ce8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:31:48 -0600 Subject: If we already have children, make sure to process them right away. --- src/app-menu-item.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 57a4e6a..19179c8 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -432,12 +432,18 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) { + g_debug("Got Menu: %s", menupath); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); priv->client = dbusmenu_client_new(indicate_listener_server_get_dbusname(server), menupath); g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), self); + DbusmenuMenuitem * root = dbusmenu_client_get_root(priv->client); + if (root != NULL) { + root_changed(priv->client, root, self); + } + return; } -- cgit v1.2.3 From 1df34439fe9a32a2f9f3288d500fdb8a53046185 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:41:56 -0600 Subject: Eh, forgot to flesh out the lists --- src/app-menu-item.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 19179c8..e24d43b 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -500,5 +500,7 @@ app_menu_item_get_desktop (AppMenuItem * appitem) GList * app_menu_item_get_items (AppMenuItem * appitem) { - return NULL; + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); + return priv->shortcuts; } -- cgit v1.2.3 From 88f7d844a5bfbbd3797fef798086d0cd3ea1a59c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:47:52 -0600 Subject: Did I ever talk to you about why I hate while loops? I have to stop using them. They just lead to bugs. --- src/app-menu-item.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index e24d43b..b55de2f 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -417,6 +417,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data while (children != NULL) { DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); priv->shortcuts = g_list_append(priv->shortcuts, mip); + children = g_list_next(children); } } -- cgit v1.2.3 From 17b4a50fb7468506c371ae6429238afc9fdcfb2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:59:29 -0600 Subject: Do a resort after adding new items. --- src/messages-service.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 0cbb91a..1a5a196 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -646,6 +646,8 @@ server_shortcuts_changed (AppMenuItem * appitem, gpointer data) shortcuts = g_list_next(shortcuts); } + resort_menu(shell); + return; } -- cgit v1.2.3 From cac9ec783a2fd4a15635ebf015eb5a775711ed78 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 21:33:57 -0600 Subject: Switch to having a launcher be a standard item with an icon. --- src/launcher-menu-item.c | 21 ++++++++++++++++++--- src/launcher-menu-item.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 50e8ce6..1573367 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -131,9 +131,10 @@ launcher_menu_item_new (const gchar * desktop_file) priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, LAUNCHER_MENUITEM_TYPE); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_description(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); + gchar * iconstr = launcher_menu_item_get_icon(self); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_NAME, iconstr); + g_free(iconstr); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -156,6 +157,20 @@ launcher_menu_item_get_name (LauncherMenuItem * appitem) } } +gchar * +launcher_menu_item_get_icon (LauncherMenuItem * appitem) +{ + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(appitem); + + if (priv->appinfo == NULL) { + return NULL; + } else { + GIcon * icon = g_app_info_get_icon(priv->appinfo); + gchar * iconstr = g_icon_to_string(icon); + return iconstr; + } +} + /* When the menu item is clicked on it tries to launch the application that is represented by the desktop file */ static void diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 3e031d5..7403bc7 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -57,6 +57,7 @@ LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); const gchar * launcher_menu_item_get_description (LauncherMenuItem * li); +gchar * launcher_menu_item_get_icon (LauncherMenuItem * appitem); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li); -- cgit v1.2.3 From 4149cfe250b6434170cc863f49d92eefb4e57138 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 21:36:33 -0600 Subject: Removing the launcher custom menu type --- src/dbus-data.h | 4 ---- src/indicator-messages.c | 35 ----------------------------------- 2 files changed, 39 deletions(-) diff --git a/src/dbus-data.h b/src/dbus-data.h index 9f53f94..e3d9fd5 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -8,10 +8,6 @@ #define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service" #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" -#define LAUNCHER_MENUITEM_TYPE "launcher-item" -#define LAUNCHER_MENUITEM_PROP_APP_NAME "application-name" -#define LAUNCHER_MENUITEM_PROP_APP_DESC "application-description" - #define APPLICATION_MENUITEM_TYPE "application-item" #define APPLICATION_MENUITEM_PROP_NAME "app-name" #define APPLICATION_MENUITEM_PROP_COUNT "app-count" diff --git a/src/indicator-messages.c b/src/indicator-messages.c index acb2e68..3f533a5 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -337,40 +337,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm return TRUE; } -static gboolean -new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) -{ - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); - g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - /* Note: not checking parent, it's reasonable for it to be NULL */ - - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - - GtkWidget * vbox = gtk_vbox_new(TRUE, 2); - - GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); - gtk_misc_set_alignment(GTK_MISC(app_label), 0.0, 0.5); - GtkWidget * dsc_label = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(dsc_label), 0.0, 0.5); - gtk_label_set_ellipsize(GTK_LABEL(dsc_label), PANGO_ELLIPSIZE_END); - gtk_widget_set_size_request(dsc_label, 200, -1); - gchar * markup = g_markup_printf_escaped("%s", dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); - gtk_label_set_markup(GTK_LABEL(dsc_label), markup); - g_free(markup); - - gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0); - gtk_widget_show(app_label); - gtk_box_pack_start(GTK_BOX(vbox), dsc_label, FALSE, FALSE, 0); - gtk_widget_show(dsc_label); - - gtk_container_add(GTK_CONTAINER(gmi), GTK_WIDGET(vbox)); - gtk_widget_show(GTK_WIDGET(vbox)); - - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); - - return TRUE; -} - static GtkImage * get_icon (IndicatorObject * io) { @@ -409,7 +375,6 @@ get_menu (IndicatorObject * io) DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), LAUNCHER_MENUITEM_TYPE, new_launcher_item); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, new_indicator_item); return GTK_MENU(menu); -- cgit v1.2.3 From 256417a46e8798eb32d025081aa205efce8cbebe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 21:45:29 -0600 Subject: Put the icons into the active items. --- src/app-menu-item.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5fc2a9c..b302eee 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -257,6 +257,12 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar priv->desktop = g_strdup(value); update_label(self); + + GIcon * icon = g_app_info_get_icon(priv->appinfo); + gchar * iconstr = g_icon_to_string(icon); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_NAME, iconstr); + g_free(iconstr); + g_signal_emit(G_OBJECT(self), signals[NAME_CHANGED], 0, app_menu_item_get_name(self), TRUE); return; -- cgit v1.2.3 From acf4ac493ef07280293e65ce1da99132f675b431 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 22:59:43 -0600 Subject: Adding in an application-running icon --- data/icons/16x16/status/Makefile.am | 1 + data/icons/16x16/status/application-running.png | Bin 0 -> 586 bytes data/icons/24x24/status/Makefile.am | 1 + data/icons/24x24/status/application-running.png | Bin 0 -> 774 bytes data/icons/32x32/status/Makefile.am | 1 + data/icons/32x32/status/application-running.png | Bin 0 -> 996 bytes data/icons/48x48/status/Makefile.am | 1 + data/icons/48x48/status/application-running.png | Bin 0 -> 1513 bytes data/icons/scalable/status/Makefile.am | 1 + data/icons/scalable/status/application-running.svg | 179 +++++++++++++++++++++ 10 files changed, 184 insertions(+) create mode 100644 data/icons/16x16/status/application-running.png create mode 100644 data/icons/24x24/status/application-running.png create mode 100644 data/icons/32x32/status/application-running.png create mode 100644 data/icons/48x48/status/application-running.png create mode 100644 data/icons/scalable/status/application-running.svg diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am index e9fdeed..e9c66f1 100644 --- a/data/icons/16x16/status/Makefile.am +++ b/data/icons/16x16/status/Makefile.am @@ -2,6 +2,7 @@ iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/status icons_DATA = \ + application-running.png \ indicator-messages.png \ indicator-messages-new.png diff --git a/data/icons/16x16/status/application-running.png b/data/icons/16x16/status/application-running.png new file mode 100644 index 0000000..2c86d7e Binary files /dev/null and b/data/icons/16x16/status/application-running.png differ diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am index 71378be..7686c0e 100644 --- a/data/icons/24x24/status/Makefile.am +++ b/data/icons/24x24/status/Makefile.am @@ -2,6 +2,7 @@ iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/status icons_DATA = \ + application-running.png \ indicator-messages.png \ indicator-messages-new.png diff --git a/data/icons/24x24/status/application-running.png b/data/icons/24x24/status/application-running.png new file mode 100644 index 0000000..5eb2466 Binary files /dev/null and b/data/icons/24x24/status/application-running.png differ diff --git a/data/icons/32x32/status/Makefile.am b/data/icons/32x32/status/Makefile.am index e34608b..84d9609 100644 --- a/data/icons/32x32/status/Makefile.am +++ b/data/icons/32x32/status/Makefile.am @@ -2,6 +2,7 @@ iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/status icons_DATA = \ + application-running.png \ indicator-messages.png \ indicator-messages-new.png diff --git a/data/icons/32x32/status/application-running.png b/data/icons/32x32/status/application-running.png new file mode 100644 index 0000000..a7770ae Binary files /dev/null and b/data/icons/32x32/status/application-running.png differ diff --git a/data/icons/48x48/status/Makefile.am b/data/icons/48x48/status/Makefile.am index 69c0996..ee7eb74 100644 --- a/data/icons/48x48/status/Makefile.am +++ b/data/icons/48x48/status/Makefile.am @@ -2,6 +2,7 @@ iconsdir = $(INDICATORICONSDIR)/hicolor/48x48/status icons_DATA = \ + application-running.png \ indicator-messages.png \ indicator-messages-new.png diff --git a/data/icons/48x48/status/application-running.png b/data/icons/48x48/status/application-running.png new file mode 100644 index 0000000..5266e22 Binary files /dev/null and b/data/icons/48x48/status/application-running.png differ diff --git a/data/icons/scalable/status/Makefile.am b/data/icons/scalable/status/Makefile.am index 263735a..060b479 100644 --- a/data/icons/scalable/status/Makefile.am +++ b/data/icons/scalable/status/Makefile.am @@ -2,6 +2,7 @@ iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/status icons_DATA = \ + application-running.svg \ indicator-messages.svg \ indicator-messages-new.svg diff --git a/data/icons/scalable/status/application-running.svg b/data/icons/scalable/status/application-running.svg new file mode 100644 index 0000000..9b5c195 --- /dev/null +++ b/data/icons/scalable/status/application-running.svg @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + August 2006 + + + Andreas Nilsson + + + + + Jakub Steiner + + + http://www.gnome.org + + + next + arrow + go + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 536034bb020f39dcf45d9a0d636f3f5dbd55deb7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 08:38:39 -0600 Subject: Setting the listener to NULL after unrefing it. --- src/app-menu-item.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index b55de2f..8e1c50f 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -147,6 +147,7 @@ app_menu_item_dispose (GObject *object) if (priv->listener != NULL) { g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); g_object_unref(priv->listener); + priv->listener = NULL; } if (priv->shortcuts != NULL) { -- cgit v1.2.3 From 06a4fba68ccbdc5b490cd8a9709e4426ec80a0ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 08:41:56 -0600 Subject: Adding protection from data fields by checking to ensure they're AppMenuItems --- src/app-menu-item.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 8e1c50f..2fb24f6 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -254,6 +254,7 @@ update_label (AppMenuItem * self) static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -282,6 +283,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, guint va static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -315,6 +317,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child); @@ -330,6 +333,7 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -360,6 +364,7 @@ child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer da static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -435,6 +440,7 @@ static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) { g_debug("Got Menu: %s", menupath); + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); -- cgit v1.2.3 From aa159e9d19cdb95a6334f429fd4b022f2c0144cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 08:44:13 -0600 Subject: Use the string allocate by g_key_file instead of creating a new one --- src/messages-service.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 585589a..cdfdb34 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -304,13 +304,8 @@ desktop_file_from_keyfile (const gchar * definition_file) } gchar * desktopfile = g_key_file_get_string(keyfile, DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DESKTOP, &error); - gchar * desktop = NULL; - if (desktopfile != NULL) { - desktop = g_strdup(desktopfile); - } - g_key_file_free(keyfile); - return desktop; + return desktopfile; } /* Add a definition file into the black list and eclipse -- cgit v1.2.3 From 7ad997f0f52e57a775fa3e56d7f0c57cc3b7c331 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 11:07:50 -0600 Subject: Bumping libindicator to 0.3.3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 47261ec..9a906ec 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ GTK_REQUIRED_VERSION=2.12 GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.3.0 -INDICATOR_REQUIRED_VERSION=0.3.0 +INDICATOR_REQUIRED_VERSION=0.3.3 DBUSMENUGTK_REQUIRED_VERSION=0.2.2 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION -- cgit v1.2.3 From 8faa2e2c57e7e152029e93adb06aa576180e24be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 11:15:10 -0600 Subject: Upping dbusmenu dep to 0.2.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 47261ec..8d24f20 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.3.0 INDICATOR_REQUIRED_VERSION=0.3.0 -DBUSMENUGTK_REQUIRED_VERSION=0.2.2 +DBUSMENUGTK_REQUIRED_VERSION=0.2.5 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION -- cgit v1.2.3 From b9713df6cd2898e5f86d8dcf1f39634bc1cc6736 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 12:15:43 -0600 Subject: 0.3.2 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0932e1d..38ddccd 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-messages, 0.3.1) +AM_INIT_AUTOMAKE(indicator-messages, 0.3.2) AM_MAINTAINER_MODE -- cgit v1.2.3 From 701de5aaff48a629cc3ed506f5d8a376fc5a9a5f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 12:22:26 -0600 Subject: * debian/control: * libindicator build dependency to 0.3.3 * dbusmenu build dependency to 0.2.5 --- debian/changelog | 3 +++ debian/control | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 154e966..3320938 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ indicator-messages (0.3.2-0ubuntu1~ppa1) UNRELEASED; urgency=low * Adding dynamic application menuitems * Switching application menu items to remove descriptions and add in application icons + * debian/control: + * libindicator build dependency to 0.3.3 + * dbusmenu build dependency to 0.2.5 -- Ted Gould Thu, 18 Feb 2010 12:18:27 -0600 diff --git a/debian/control b/debian/control index f622dd2..99aff27 100644 --- a/debian/control +++ b/debian/control @@ -11,9 +11,9 @@ Build-Depends: debhelper (>= 5.0), intltool, libindicate-dev (>= 0.3.0), libindicate-gtk-dev (>= 0.3.0), - libindicator-dev (>= 0.3.0), - libdbusmenu-gtk-dev (>= 0.2.2), - libdbusmenu-glib-dev (>= 0.2.2) + libindicator-dev (>= 0.3.3), + libdbusmenu-gtk-dev (>= 0.2.5), + libdbusmenu-glib-dev (>= 0.2.5) Standards-Version: 3.8.0 Homepage: https://launchpad.net/indicator-applet Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-desktop/indicator-messages/ubuntu -- cgit v1.2.3 From f2de1dabf2160af485c16c8985fcbea89d487f9e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 12:23:31 -0600 Subject: releasing version 0.3.2-0ubuntu1~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3320938..fc5680d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-messages (0.3.2-0ubuntu1~ppa1) UNRELEASED; urgency=low +indicator-messages (0.3.2-0ubuntu1~ppa1) lucid; urgency=low * Upstream release 0.3.2 * Removing extra ref @@ -13,7 +13,7 @@ indicator-messages (0.3.2-0ubuntu1~ppa1) UNRELEASED; urgency=low * libindicator build dependency to 0.3.3 * dbusmenu build dependency to 0.2.5 - -- Ted Gould Thu, 18 Feb 2010 12:18:27 -0600 + -- Ted Gould Thu, 18 Feb 2010 12:23:29 -0600 indicator-messages (0.3.1-0ubuntu2) lucid; urgency=low -- cgit v1.2.3