Merge lp:~pitti/indicator-session/extra-launcher-dir into lp:indicator-session/0.1

Proposed by Martin Pitt
Status: Merged
Merged at revision: 140
Proposed branch: lp:~pitti/indicator-session/extra-launcher-dir
Merge into: lp:indicator-session/0.1
Diff against target: 71 lines (+31/-9)
1 file modified
src/session-service.c (+31/-9)
To merge this branch: bzr merge lp:~pitti/indicator-session/extra-launcher-dir
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+52813@code.launchpad.net

Description of the change

Hardcoding a single extra launcher path is impractical for distributions, as multiple packages would collide on the name and wouldn't give any extra customization possibility for OEMs.

This branch adds support for reading /usr/share/indicators/session/applications/*.desktop and appending them to the session indicator. This will allow us to implement bug 727823 for Ubuntu while retaining the OEM customization possibility.

/usr/share/applications/indicator-session-extra.desktop should be obsoleted. I didn't rip out the code for this yet, do you want me to?

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

> /usr/share/applications/indicator-session-extra.desktop should be obsoleted. I didn't rip out the code for this yet, do you want me to?

Now done, as discussed on IRC.

141. By Martin Pitt

Drop support for indicator-session-extra.desktop

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/session-service.c'
2--- src/session-service.c 2010-08-12 14:17:03 +0000
3+++ src/session-service.c 2011-03-10 15:25:14 +0000
4@@ -54,7 +54,7 @@
5 #define UP_OBJECT "/org/freedesktop/UPower"
6 #define UP_INTERFACE "org.freedesktop.UPower"
7
8-#define DESKTOP_FILE "/usr/share/applications/indicator-session-extra.desktop"
9+#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications"
10
11 #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch"
12
13@@ -517,6 +517,19 @@
14 return;
15 }
16
17+static void
18+add_extra_separator_once (DbusmenuMenuitem *menu)
19+{
20+ static gboolean added = FALSE;
21+
22+ if (!added) {
23+ DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
24+ dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
25+ dbusmenu_menuitem_child_append(menu, separator);
26+ added = TRUE;
27+ }
28+}
29+
30 /* Builds up the menu for us */
31 static void
32 rebuild_items (DbusmenuMenuitem *root,
33@@ -529,6 +542,8 @@
34 gboolean can_activate;
35 gboolean can_lockscreen;
36 GList *children;
37+ GDir *extra_launchers_dir;
38+ const gchar *extra_launcher_file;
39
40 /* Make sure we have a valid GConf client, and build one
41 if needed */
42@@ -713,14 +728,21 @@
43
44 update_menu_entries(restart_shutdown_logout_mi);
45
46- if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) {
47- GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE));
48-
49- if (appinfo != NULL) {
50- DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
51- dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
52- dbusmenu_menuitem_child_append(root, separator);
53-
54+ /* now add extra launchers */
55+ extra_launchers_dir = g_dir_open (EXTRA_LAUNCHER_DIR, 0, NULL);
56+ if (extra_launchers_dir != NULL) {
57+ for (;;) {
58+ extra_launcher_file = g_dir_read_name (extra_launchers_dir);
59+ if (extra_launcher_file == NULL)
60+ break;
61+ if (!g_str_has_suffix (extra_launcher_file, ".desktop"))
62+ continue;
63+
64+ gchar *full_path = g_build_filename (EXTRA_LAUNCHER_DIR, extra_launcher_file, NULL);
65+ GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename (full_path));
66+ g_free (full_path);
67+
68+ add_extra_separator_once (root);
69 DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new();
70 dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo));
71 g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo);

Subscribers

People subscribed via source and target branches