aboutsummaryrefslogtreecommitdiff
path: root/src/session-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-12 21:54:12 -0600
committerTed Gould <ted@gould.cx>2010-03-12 21:54:12 -0600
commit501c8a7e9add926f34b6dbbcce9d9e6f81706445 (patch)
treecbb8a384f2d74251e59348b44be46bcb2643b216 /src/session-service.c
parent7810d87175072ed195fdde952d140f23150ac342 (diff)
downloadayatana-indicator-session-501c8a7e9add926f34b6dbbcce9d9e6f81706445.tar.gz
ayatana-indicator-session-501c8a7e9add926f34b6dbbcce9d9e6f81706445.tar.bz2
ayatana-indicator-session-501c8a7e9add926f34b6dbbcce9d9e6f81706445.zip
Looking for a desktop file, and if it exists, putting it as a final menu item.
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 51a930a..c98ecff 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>
@@ -50,6 +51,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"
@@ -415,6 +418,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,
@@ -580,6 +593,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;
}