aboutsummaryrefslogtreecommitdiff
path: root/src/session-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/session-service.c')
-rw-r--r--src/session-service.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/session-service.c b/src/session-service.c
index ace4a7d..f6b666f 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -28,6 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ compare_users_by_username (const gchar *a,
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 @@ rebuild_items (DbusmenuMenuitem *root,
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;
}