aboutsummaryrefslogtreecommitdiff
path: root/src/messages-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-21 15:56:16 -0500
committerTed Gould <ted@canonical.com>2009-08-21 15:56:16 -0500
commit1827c88f591eeefa129b700c0eb4b1710f712272 (patch)
tree6452841c926fa06fae2d466eaabde55d4343e995 /src/messages-service.c
parent50a2c4e02d275a88e5c917e4946410383c44b3ed (diff)
downloadayatana-indicator-messages-1827c88f591eeefa129b700c0eb4b1710f712272.tar.gz
ayatana-indicator-messages-1827c88f591eeefa129b700c0eb4b1710f712272.tar.bz2
ayatana-indicator-messages-1827c88f591eeefa129b700c0eb4b1710f712272.zip
The launcher creation didn't test to see if it already exists. Now we keep one launcher per desktop file. Makes sense, eh? That's what we're going for.
Diffstat (limited to 'src/messages-service.c')
-rw-r--r--src/messages-service.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index 3a145d6..41afb6b 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -147,6 +147,7 @@ imList_sort (gconstpointer a, gconstpointer b)
typedef struct _launcherList_t launcherList_t;
struct _launcherList_t {
LauncherMenuItem * menuitem;
+ GList * appdiritems;
};
static gint
@@ -832,7 +833,6 @@ build_launcher (gpointer data)
gchar * desktop = NULL;
g_file_get_contents(path, &desktop, NULL, NULL);
- g_free(path);
if (desktop == NULL) {
return FALSE;
@@ -842,20 +842,37 @@ build_launcher (gpointer data)
g_free(desktop);
g_debug("\tcontents: %s", trimdesktop);
- /* Build the item */
- launcherList_t * ll = g_new0(launcherList_t, 1);
- ll->menuitem = launcher_menu_item_new(trimdesktop);
- g_free(trimdesktop);
+ /* 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)) {
+ break;
+ }
+ }
- /* Add it to the list */
- launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort);
+ if (listitem == NULL) {
+ /* 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);
- /* Add it to the menu */
- dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem));
- resort_menu(root_menuitem);
+ /* Add it to the list */
+ launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort);
- if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem))) {
- launcher_menu_item_set_eclipsed(ll->menuitem, TRUE);
+ /* Add it to the menu */
+ dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem));
+ resort_menu(root_menuitem);
+
+ if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem))) {
+ launcher_menu_item_set_eclipsed(ll->menuitem, TRUE);
+ }
+ } else {
+ /* If so add ourselves */
+ launcherList_t * ll = (launcherList_t *)listitem->data;
+ ll->appdiritems = g_list_append(ll->appdiritems, path);
}
return FALSE;