← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/indicator-session/desktop-file into lp:indicator-session

 

Ted Gould has proposed merging lp:~ted/indicator-session/desktop-file into lp:indicator-session.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


Allow for a desktop file to have it's entry placed at the end of the
menu.
-- 
https://code.launchpad.net/~ted/indicator-session/desktop-file/+merge/21305
Your team ayatana-commits is subscribed to branch lp:indicator-session.
=== modified file 'configure.ac'
--- configure.ac	2010-03-12 22:26:12 +0000
+++ configure.ac	2010-03-13 04:25:22 +0000
@@ -39,6 +39,7 @@
 DBUSMENUGLIB_REQUIRED_VERSION=0.1.1
 
 PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION
+                                  gio-unix-2.0
                                   indicator >= $INDICATOR_REQUIRED_VERSION)
 
 AC_SUBST(SESSIONERVICE_CFLAGS)

=== modified file 'src/session-service.c'
--- src/session-service.c	2010-03-12 23:33:49 +0000
+++ src/session-service.c	2010-03-13 04:25:22 +0000
@@ -28,6 +28,7 @@
 
 #include <glib/gi18n.h>
 #include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-bindings.h>
@@ -51,6 +52,8 @@
 #define UP_OBJECT     "/org/freedesktop/UPower"
 #define UP_INTERFACE  "org.freedesktop.UPower"
 
+#define DESKTOP_FILE  "/usr/share/applications/indicator-session-extra.desktop"
+
 #define GUEST_SESSION_LAUNCHER  "/usr/share/gdm/guest-session/guest-session-launch"
 
 #define LOCKDOWN_DIR  "/desktop/gnome/lockdown"
@@ -417,6 +420,16 @@
   return retval;
 }
 
+/* Take a desktop file and execute it */
+static void
+desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data)
+{
+	GAppInfo * appinfo = G_APP_INFO(data);
+	g_return_if_fail(appinfo != NULL);
+	g_app_info_launch(appinfo, NULL, NULL, NULL);
+	return;
+}
+
 /* Builds up the menu for us */
 static void
 rebuild_items (DbusmenuMenuitem *root,
@@ -582,6 +595,21 @@
 
 	update_menu_entries(restart_shutdown_logout_mi);
 
+	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);
+
+			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);
+		}
+	}
+
 	return;
 }
 


Follow ups