ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #03395
[Merge] lp:~pitti/indicator-session/extra-launcher-dir into lp:indicator-session
Martin Pitt has proposed merging lp:~pitti/indicator-session/extra-launcher-dir into lp:indicator-session.
Requested reviews:
Ted Gould (ted)
Related bugs:
Bug #727823 in Session Menu: "Enable Gnome-Control-Center in Unity, and add "System Settings" link to the session indicator menu"
https://bugs.launchpad.net/indicator-session/+bug/727823
For more details, see:
https://code.launchpad.net/~pitti/indicator-session/extra-launcher-dir/+merge/52813
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?
--
https://code.launchpad.net/~pitti/indicator-session/extra-launcher-dir/+merge/52813
Your team ayatana-commits is subscribed to branch lp:indicator-session.
=== modified file 'src/session-service.c'
--- src/session-service.c 2010-08-12 14:17:03 +0000
+++ src/session-service.c 2011-03-10 10:18:55 +0000
@@ -55,6 +55,7 @@
#define UP_INTERFACE "org.freedesktop.UPower"
#define DESKTOP_FILE "/usr/share/applications/indicator-session-extra.desktop"
+#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications"
#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch"
@@ -517,6 +518,19 @@
return;
}
+static void
+add_extra_separator_once (DbusmenuMenuitem *menu)
+{
+ static gboolean added = FALSE;
+
+ if (!added) {
+ DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_child_append(menu, separator);
+ added = TRUE;
+ }
+}
+
/* Builds up the menu for us */
static void
rebuild_items (DbusmenuMenuitem *root,
@@ -529,6 +543,8 @@
gboolean can_activate;
gboolean can_lockscreen;
GList *children;
+ GDir *extra_launchers_dir;
+ const gchar *extra_launcher_file;
/* Make sure we have a valid GConf client, and build one
if needed */
@@ -713,14 +729,34 @@
update_menu_entries(restart_shutdown_logout_mi);
+ /* now add extra launchers */
+
if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) {
GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE));
if (appinfo != NULL) {
- DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append(root, separator);
-
+ add_extra_separator_once (root);
+ DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo));
+ g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo);
+ dbusmenu_menuitem_child_append(root, desktop_mi);
+ }
+ }
+
+ extra_launchers_dir = g_dir_open (EXTRA_LAUNCHER_DIR, 0, NULL);
+ if (extra_launchers_dir != NULL) {
+ for (;;) {
+ extra_launcher_file = g_dir_read_name (extra_launchers_dir);
+ if (extra_launcher_file == NULL)
+ break;
+ if (!g_str_has_suffix (extra_launcher_file, ".desktop"))
+ continue;
+
+ gchar *full_path = g_build_filename (EXTRA_LAUNCHER_DIR, extra_launcher_file, NULL);
+ GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename (full_path));
+ g_free (full_path);
+
+ add_extra_separator_once (root);
DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo));
g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo);
Follow ups