[Xfce4-commits] r30400 - in xfce4-session/trunk: . panel-plugin po

Brian Tarricone kelnos at xfce.org
Mon Jul 27 04:14:51 CEST 2009


Author: kelnos
Date: 2009-07-27 02:14:51 +0000 (Mon, 27 Jul 2009)
New Revision: 30400

Added:
   xfce4-session/trunk/panel-plugin/
   xfce4-session/trunk/panel-plugin/Makefile.am
   xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-4.6.desktop.in.in
   xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-ui.xml
   xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.c
   xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.desktop.in.in
Modified:
   xfce4-session/trunk/Makefile.am
   xfce4-session/trunk/configure.in.in
   xfce4-session/trunk/po/POTFILES.in
Log:
add panel plugin that lists shutdown/logout actions

Modified: xfce4-session/trunk/Makefile.am
===================================================================
--- xfce4-session/trunk/Makefile.am	2009-07-27 02:14:40 UTC (rev 30399)
+++ xfce4-session/trunk/Makefile.am	2009-07-27 02:14:51 UTC (rev 30400)
@@ -10,8 +10,13 @@
 	xfce4-session							\
 	xfce4-session-logout						\
 	xfce4-tips							\
-	xfsm-shutdown-helper
+	xfsm-shutdown-helper						\
+	$(panel_plugin_dir)
 
+if HAVE_LIBXFCE4PANEL
+panel_plugin_dir = panel-plugin
+endif
+
 EXTRA_DIST =								\
 	BUGS								\
 	ChangeLog.pre-xfce-devel					\

Modified: xfce4-session/trunk/configure.in.in
===================================================================
--- xfce4-session/trunk/configure.in.in	2009-07-27 02:14:40 UTC (rev 30399)
+++ xfce4-session/trunk/configure.in.in	2009-07-27 02:14:51 UTC (rev 30400)
@@ -71,12 +71,24 @@
 dnl Check for required packages
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.6.0])
 XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.6.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
 XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [2.12])
 XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.0.0])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.73])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0])
 XDT_CHECK_PACKAGE([LIBGLADE], [libglade-2.0], [2.0.0])
 
+dnl we provide a panel plugin now
+XDT_CHECK_OPTIONAL_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.6.0],
+                           [panel-plugin], [Panel logout menu button], [yes])
+if test "x$LIBXFCE4PANEL_FOUND" = "xyes"; then
+    PANEL_MINOR=`echo $LIBXFCE4PANEL_VERSION | cut -d. -f2`
+    if test $PANEL_MINOR -lt 7; then
+        old_panel_plugin=yes
+    fi
+fi
+AM_CONDITIONAL([BUILD_OLD_PANEL_PLUGIN], [test "x$old_panel_plugin" = "xyes"])
+
 dnl Check for gnome support
 XDT_CHECK_OPTIONAL_PACKAGE([GNOME], [gconf-2.0], [2.4.0], [gnome],
                            [Assistive technologies support], [no])
@@ -164,6 +176,7 @@
 icons/scalable/Makefile
 libxfsm/Makefile
 libxfsm/xfce4-session-2.0.pc
+panel-plugin/Makefile
 po/Makefile.in
 settings/Makefile
 xfce4-session/Makefile

Added: xfce4-session/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-session/trunk/panel-plugin/Makefile.am	                        (rev 0)
+++ xfce4-session/trunk/panel-plugin/Makefile.am	2009-07-27 02:14:51 UTC (rev 30400)
@@ -0,0 +1,89 @@
+plugindir = $(libdir)/xfce4/panel-plugins
+
+plugin_sources = \
+	xfsm-logout-plugin.c \
+	xfsm-logout-plugin-ui.h
+
+plugin_cflags = \
+	$(LIBX11_CFLAGS) \
+	$(LIBXFCE4PANEL_CFLAGS) \
+	$(LIBXFCE4UTIL_CFLAGS) \
+	$(LIBXFCEGUI4_CFLAGS) \
+	$(GTK_CFLAGS) \
+	$(DBUS_GLIB_CFLAGS) \
+	-DLOCALEDIR=\"$(localedir)\"
+
+plugin_libs = \
+	$(LIBX11_LIBS) \
+	$(LIBXFCE4PANEL_LIBS) \
+	$(LIBXFCE4UTIL_LIBS) \
+	$(LIBXFCEGUI4_LIBS) \
+	$(GTK_LIBS) \
+	$(DBUS_GLIB_LIBS)
+
+if BUILD_OLD_PANEL_PLUGIN
+
+plugin_PROGRAMS = xfsm-logout-plugin
+
+xfsm_logout_plugin_SOURCES = $(plugin_sources)
+xfsm_logout_plugin_CFLAGS = $(plugin_cflags)
+xfsm_logout_plugin_LDADD = $(plugin_libs)
+
+else
+
+plugin_LTLIBRARIES = libxfsm-logout-plugin.la
+
+libxfsm_logout_plugin_la_SOURCES = $(plugin_sources)
+libxfsm_logout_plugin_la_CFLAGS = $(plugin_cflags)
+libxfsm_logout_plugin_la_LIBADD = $(plugin_libs)
+libxfsm_logout_plugin_la_LDFLAGS = \
+	-avoid-version \
+	-export-dynamic \
+	-module \
+	-shared
+
+endif
+
+# .desktop file
+#
+# Some automake trickery here. Because we cannot use $(libexecdir) in the
+# automake stage, we'll use sed to get the full path into the .desktop file.
+# We also need to let intltool merge the translated fields, so we add an
+# additional level of indirection: a <name>.desktop.in.in file.
+#
+if BUILD_OLD_PANEL_PLUGIN
+dfile = xfsm-logout-plugin-4.6.desktop.in.in
+else
+dfile = xfsm-logout-plugin.desktop.in.in
+endif
+
+desktop_in_in_files = $(dfile)
+desktop_in_files = xfsm-logout-plugin.desktop.in
+
+desktopdir = $(datadir)/xfce4/panel-plugins
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ at INTLTOOL_DESKTOP_RULE@
+
+# get full path into .desktop file
+xfsm-logout-plugin.desktop.in: $(srcdir)/$(dfile)
+	sed -e "s,\@plugindir\@,$(plugindir)," $< > $@
+
+if MAINTAINER_MODE
+
+xfsm-logout-plugin-ui.h: $(srcdir)/xfsm-logout-plugin-ui.xml Makefile
+	exo-csource --static --name=logout_plugin_ui $< > $@
+
+BUILT_SOURCES = xfsm-logout-plugin-ui.h
+
+MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+
+endif
+
+EXTRA_DIST = \
+	xfsm-logout-plugin.desktop.in.in \
+	xfsm-logout-plugin-4.6.desktop.in.in \
+	xfsm-logout-plugin-ui.xml
+
+DISTCLEANFILES = \
+	$(desktop_DATA) \
+	$(desktop_in_files)

Added: xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-4.6.desktop.in.in
===================================================================
--- xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-4.6.desktop.in.in	                        (rev 0)
+++ xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-4.6.desktop.in.in	2009-07-27 02:14:51 UTC (rev 30400)
@@ -0,0 +1,7 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+Encoding=UTF-8
+_Name=Session Menu
+_Comment=Shows a menu with options to lock the screen, suspend, shutdown, or log out
+Icon=xfce4-session
+X-XFCE-Exec=@plugindir@/xfsm-logout-plugin

Added: xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-ui.xml
===================================================================
--- xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-ui.xml	                        (rev 0)
+++ xfce4-session/trunk/panel-plugin/xfsm-logout-plugin-ui.xml	2009-07-27 02:14:51 UTC (rev 30400)
@@ -0,0 +1,15 @@
+<ui>
+    <menubar name="main-menubar">
+        <menu action="session-menu">
+            <menuitem action="lock-screen"/>
+            <separator/>
+            <menuitem action="suspend"/>
+            <menuitem action="hibernate"/>
+            <separator/>
+            <menuitem action="reboot"/>
+            <menuitem action="shutdown"/>
+            <separator/>
+            <menuitem action="logout"/>
+        </menu>
+    </menubar>
+</ui>

Added: xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.c
===================================================================
--- xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.c	                        (rev 0)
+++ xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.c	2009-07-27 02:14:51 UTC (rev 30400)
@@ -0,0 +1,406 @@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+#include <dbus/dbus-glib.h>
+
+#include <gtk/gtk.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4panel/libxfce4panel.h>
+
+#include "xfsm-logout-plugin-ui.h"
+
+#define BORDER           12
+#define DEFAULT_TIMEOUT  30
+
+/* FIXME: don't copy this */
+typedef enum
+{
+  XFSM_SHUTDOWN_ASK = 0,
+  XFSM_SHUTDOWN_LOGOUT,
+  XFSM_SHUTDOWN_HALT,
+  XFSM_SHUTDOWN_REBOOT,
+  XFSM_SHUTDOWN_SUSPEND,
+  XFSM_SHUTDOWN_HIBERNATE,
+} XfsmShutdownType;
+
+
+typedef struct
+{
+    GtkActionGroup *action_group;
+
+    GtkWidget *dialog;
+    GtkWidget *dialog_label;
+    gchar *dialog_text_fmt;
+    guint time_left;
+    guint time_left_id;
+    gboolean allow_save;
+} XfsmLogoutPlugin;
+
+
+static void xfsm_logout_plugin_lock_screen(GtkAction *action,
+                                           gpointer user_data);
+static void xfsm_logout_plugin_do_something(GtkAction *action,
+                                            gpointer user_data);
+
+/* FIXME: replace with xdg spec icon names where appropriate */
+static const GtkActionEntry action_entries[] =
+{
+    { "session-menu", NULL, N_("Session"), NULL, NULL, NULL },
+    { "lock-screen", "system-lock-screen", N_("Loc_k screen"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_lock_screen) },
+    { "suspend", "xfsm-suspend", N_("_Suspend"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_do_something) },
+    { "hibernate", "xfsm-hibernate", N_("_Hibernate"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_do_something) },
+    { "reboot", "xfsm-reboot", N_("_Reboot"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_do_something) },
+    { "shutdown", "system-shutdown", N_("Shut _down"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_do_something) },
+    { "logout", "system-log-out", N_("_Log out"), NULL, NULL, G_CALLBACK(xfsm_logout_plugin_do_something) },
+};
+
+static const struct
+{
+    const gchar *primary;
+    const gchar *secondary;
+    const gchar *button_text;
+    const gchar *button_icon_name;
+    const gchar *error_text;
+} dialog_strings[] = {
+    { NULL, NULL, NULL, NULL }, /* XFSM_SHUTDOWN_ASK */
+    {   /* XFSM_SHUTDOWN_LOGOUT */
+        N_("Are you sure you want to log out?"),
+        N_("You will be logged out in %u seconds."),
+        N_("_Log out"),
+        "system-log-out",
+        N_("Failed to log out.")
+    },
+    {   /* XFSM_SHUTDOWN_HALT */
+        N_("Are you sure you want to shut down?"),
+        N_("Your system will shut down in %u seconds."),
+        N_("Shut _down"),
+        "system-shutdown",
+        N_("Failed to shut down.")
+    },
+    {   /* XFSM_SHUTDOWN_REBOOT */
+        N_("Are you sure you want to reboot?"),
+        N_("Your system will reboot in %u seconds."),
+        N_("_Reboot"),
+        "xfsm-reboot",
+        N_("Failed to reboot.")
+    },
+    {   /* XFSM_SHUTDOWN_SUSPEND */
+        NULL,
+        NULL,
+        N_("_Suspend"),
+        "xfsm-suspend",
+        N_("Failed to suspend")
+    },
+    {   /* XFSM_SHUTDOWN_HIBERNATE */
+        NULL,
+        NULL,
+        N_("_Hibernate"),
+        "xfsm-hibernate",
+        N_("Failed to hibernate")
+    }, 
+};
+
+static void
+xfsm_logout_plugin_lock_screen(GtkAction *action,
+                          gpointer user_data)
+{
+    xfce_exec("xflock4", FALSE, FALSE, NULL);
+}
+
+static gboolean
+xfsm_logout_plugin_do_dbus_call(XfsmLogoutPlugin *logout_plugin,
+                                XfsmShutdownType type,
+                                GError **error)
+{
+    DBusGConnection *conn;
+    DBusGProxy *proxy;
+    gboolean ret;
+
+    g_return_val_if_fail(logout_plugin != NULL, FALSE);
+    g_return_val_if_fail(type >= XFSM_SHUTDOWN_LOGOUT && type <= XFSM_SHUTDOWN_HIBERNATE, FALSE);
+    g_return_val_if_fail(!error || !*error, FALSE);
+
+    conn = dbus_g_bus_get(DBUS_BUS_SESSION, error);
+    if(!conn)
+        return FALSE;
+
+    proxy = dbus_g_proxy_new_for_name(conn, "org.xfce.SessionManager",
+                                      "/org/xfce/SessionManager",
+                                      "org.xfce.Session.Manager");
+    ret = dbus_g_proxy_call(proxy, "Shutdown", error,
+                            G_TYPE_UINT, type,
+                            G_TYPE_BOOLEAN, logout_plugin->allow_save,
+                            G_TYPE_INVALID);
+    g_object_unref(G_OBJECT(proxy));
+
+    return ret;
+}
+
+static gboolean
+xfsm_logout_dialog_update_time_left(gpointer data)
+{
+    XfsmLogoutPlugin *logout_plugin = data;
+    gchar *text;
+
+    if(--logout_plugin->time_left == 0) {
+        /* unattended shutdown, so don't allow apps to cancel shutdown */
+        logout_plugin->allow_save = FALSE;
+        logout_plugin->time_left_id = 0;
+        gtk_dialog_response(GTK_DIALOG(logout_plugin->dialog),
+                            GTK_RESPONSE_ACCEPT);
+        return FALSE;
+    }
+
+    text = g_strdup_printf(logout_plugin->dialog_text_fmt,
+                           logout_plugin->time_left);
+    gtk_label_set_markup(GTK_LABEL(logout_plugin->dialog_label), text);
+    g_free(text);
+
+    return TRUE;
+}
+
+static void
+xfsm_logout_plugin_show_confirmation_dialog(XfsmLogoutPlugin *logout_plugin,
+                                            XfsmShutdownType type)
+{
+    gint resp = GTK_RESPONSE_ACCEPT;
+
+    g_return_if_fail(logout_plugin != NULL);
+    g_return_if_fail(type >= XFSM_SHUTDOWN_LOGOUT && type <= XFSM_SHUTDOWN_HIBERNATE);
+
+    logout_plugin->allow_save = TRUE;
+
+    if(type != XFSM_SHUTDOWN_SUSPEND && type != XFSM_SHUTDOWN_HIBERNATE) {
+        GtkWidget *dialog, *topvbox, *hbox, *image, *label;
+        GtkWidget *button, *btn_hbox, *align;
+        gchar *text;
+
+        dialog = gtk_dialog_new_with_buttons(_("Close Session"), NULL,
+                                             GTK_DIALOG_NO_SEPARATOR,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                             NULL);
+        gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+        gtk_window_stick(GTK_WINDOW(dialog));
+        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
+        gtk_container_set_border_width(GTK_CONTAINER(dialog), BORDER/6);
+
+        button = gtk_button_new();
+        GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+        gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button,
+                                     GTK_RESPONSE_ACCEPT);
+
+        align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+        gtk_container_add(GTK_CONTAINER(button), align);
+
+        btn_hbox = gtk_hbox_new(FALSE, BORDER/6);
+        gtk_container_add(GTK_CONTAINER(align), btn_hbox);
+
+        image = gtk_image_new_from_icon_name(dialog_strings[type].button_icon_name,
+                                             GTK_ICON_SIZE_BUTTON);
+        gtk_box_pack_start(GTK_BOX(btn_hbox), image, FALSE, FALSE, 0);
+
+        label = gtk_label_new_with_mnemonic(_(dialog_strings[type].button_text));
+        gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
+        gtk_box_pack_end(GTK_BOX(btn_hbox), label, FALSE, FALSE, 0);
+
+        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+
+#if GTK_CHECK_VERSION(2, 14, 0)
+        topvbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+#else
+        topvbox = GTK_DIALOG(dialog)->vbox;
+#endif
+
+        hbox = gtk_hbox_new(FALSE, BORDER);
+        gtk_container_set_border_width(GTK_CONTAINER(hbox), BORDER/2);
+        gtk_box_pack_start(GTK_BOX(topvbox), hbox, FALSE, FALSE, 0);
+
+        image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
+                                         GTK_ICON_SIZE_DIALOG);
+        gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+        gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, FALSE, 0);
+
+        logout_plugin->dialog_text_fmt = g_strdup_printf("<span weight='bold' size='larger'>%s</span>\n\n%s",
+                                                         _(dialog_strings[type].primary),
+                                                         _(dialog_strings[type].secondary));
+        text = g_strdup_printf(logout_plugin->dialog_text_fmt, DEFAULT_TIMEOUT);
+
+        label = gtk_label_new(NULL);
+        gtk_label_set_markup(GTK_LABEL(label), text);
+        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+        gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+
+        g_free(text);
+
+        logout_plugin->dialog = dialog;
+        logout_plugin->dialog_label = label;
+        logout_plugin->time_left = DEFAULT_TIMEOUT;
+        logout_plugin->time_left_id = g_timeout_add_seconds(1,
+                                                            xfsm_logout_dialog_update_time_left,
+                                                            logout_plugin);
+
+        gtk_widget_show_all(dialog);
+        resp = gtk_dialog_run(GTK_DIALOG(dialog));
+
+        if(logout_plugin->time_left_id) {
+            g_source_remove(logout_plugin->time_left_id);
+            logout_plugin->time_left_id = 0;
+        }
+
+        g_free(logout_plugin->dialog_text_fmt);
+        logout_plugin->dialog_text_fmt = NULL;
+
+        gtk_widget_destroy(dialog);
+        logout_plugin->dialog = NULL;
+        logout_plugin->dialog_label = NULL;
+
+        /* get the dialog to go away */
+        while(gtk_events_pending())
+            gtk_main_iteration();
+    }
+
+    if(resp == GTK_RESPONSE_ACCEPT) {
+        GError *error = NULL;
+
+        if(!xfsm_logout_plugin_do_dbus_call(logout_plugin, type, &error)) {
+            xfce_message_dialog(NULL, _("Session Error"),
+                                GTK_STOCK_DIALOG_ERROR,
+                                _(dialog_strings[type].error_text),
+                                error->message,
+                                GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
+                                NULL);
+            g_error_free(error);
+        }
+    }
+}
+
+static void
+xfsm_logout_plugin_do_something(GtkAction *action,
+                                gpointer user_data)
+{
+    XfsmLogoutPlugin *plugin = user_data;
+    const gchar *name;
+    XfsmShutdownType type = XFSM_SHUTDOWN_ASK;
+
+    name = gtk_action_get_name(action);
+    if(!strcmp(name, "logout"))
+        type = XFSM_SHUTDOWN_LOGOUT;
+    else if(!strcmp(name, "reboot"))
+        type = XFSM_SHUTDOWN_REBOOT;
+    else if(!strcmp(name, "shutdown"))
+        type = XFSM_SHUTDOWN_HALT;
+    else if(!strcmp(name, "suspend"))
+        type = XFSM_SHUTDOWN_SUSPEND;
+    else if(!strcmp(name, "hibernate"))
+        type = XFSM_SHUTDOWN_HIBERNATE;
+    else {
+        g_critical(G_STRLOC ": Invalid action \"%s\"", name);
+        return;
+    }
+
+    xfsm_logout_plugin_show_confirmation_dialog(plugin, type);
+}
+
+static void
+xfsm_logout_plugin_size_changed(XfcePanelPlugin *plugin,
+                                gint size,
+                                gpointer user_data)
+{
+    GtkWidget *menubar = user_data;
+
+    if(xfce_panel_plugin_get_orientation(plugin) == GTK_ORIENTATION_HORIZONTAL)
+        gtk_widget_set_size_request(menubar, -1, size);
+    else
+        gtk_widget_set_size_request(menubar, size, -1);
+}
+
+static void
+xfsm_logout_plugin_free_data(XfcePanelPlugin *plugin,
+                             gpointer user_data)
+{
+    XfsmLogoutPlugin *logout_plugin = user_data;
+
+    if(logout_plugin->dialog) {
+        /* this will take care of cleaning up the timeout source as
+         * well as destroying the dialog */
+        gtk_dialog_response(GTK_DIALOG(logout_plugin->dialog),
+                            GTK_RESPONSE_CANCEL);
+    }
+
+    g_object_unref(G_OBJECT(logout_plugin->action_group));
+
+    g_free(logout_plugin);
+}
+
+static void
+xfsm_logout_plugin_construct(XfcePanelPlugin *plugin)
+{
+    XfsmLogoutPlugin *logout_plugin;
+    GtkUIManager *uimgr;
+    GtkWidget *menubar, *mi, *label, *submenu;
+    struct passwd *pwent;
+
+    xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
+
+    gdk_set_sm_client_id("fake-client-id-xfsm-logout-plugin");
+    gtk_window_set_default_icon_name("xfce4-session");
+    /* obey Fitt's law */
+    gtk_rc_parse_string("style \"menubar-style\" {\n"
+                        "    GtkMenuBar::shadow-type = GTK_SHADOW_NONE\n"
+                        "}\n"
+                        "class \"GtkMenuBar\" style \"menubar-style\"");
+
+    logout_plugin = g_new0(XfsmLogoutPlugin, 1);
+
+    logout_plugin->action_group = gtk_action_group_new("logout-plugin");
+    gtk_action_group_set_translation_domain(logout_plugin->action_group,
+                                            GETTEXT_PACKAGE);
+    gtk_action_group_add_actions(logout_plugin->action_group, action_entries,
+                                 G_N_ELEMENTS(action_entries),
+                                 logout_plugin);
+
+    uimgr = gtk_ui_manager_new();
+    gtk_ui_manager_insert_action_group(uimgr, logout_plugin->action_group, 0);
+    gtk_ui_manager_add_ui_from_string(uimgr, logout_plugin_ui,
+                                      logout_plugin_ui_length, NULL);
+
+    mi = gtk_ui_manager_get_widget(uimgr, "/main-menubar/session-menu");
+
+    pwent = getpwuid(geteuid());
+    if(pwent) {
+        label = gtk_bin_get_child(GTK_BIN(mi));
+        gtk_label_set_text(GTK_LABEL(label), pwent->pw_name);
+    }
+
+    menubar = gtk_ui_manager_get_widget(uimgr, "/main-menubar");
+    gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
+    gtk_container_add(GTK_CONTAINER(plugin), menubar);
+    xfce_panel_plugin_add_action_widget(plugin, menubar);
+
+    submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(mi));
+    xfce_panel_plugin_register_menu(plugin, GTK_MENU(submenu));
+
+    /* annoyingly, handling size-changed is required even if we don't
+     * do anything special.  otherwise we get truncated. */
+    g_signal_connect(plugin, "size-changed",
+                     G_CALLBACK(xfsm_logout_plugin_size_changed), menubar);
+    g_signal_connect(plugin, "free-data",
+                     G_CALLBACK(xfsm_logout_plugin_free_data), logout_plugin);
+
+    gtk_widget_show_all(GTK_WIDGET(plugin));
+    g_object_unref(G_OBJECT(uimgr));
+}
+
+#ifdef XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL  /* panel <= 4.6 */
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(xfsm_logout_plugin_construct)
+#else  /* panel >= 4.7  */
+XFCE_PANEL_PLUGIN_REGISTER(xfsm_logout_plugin_construct)
+#endif

Added: xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.desktop.in.in
===================================================================
--- xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.desktop.in.in	                        (rev 0)
+++ xfce4-session/trunk/panel-plugin/xfsm-logout-plugin.desktop.in.in	2009-07-27 02:14:51 UTC (rev 30400)
@@ -0,0 +1,9 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+Encoding=UTF-8
+_Name=Session Menu
+_Comment=Shows a menu with options to lock the screen, suspend, shutdown, or log out
+Icon=xfce4-session
+X-XFCE-Module=xfsm-logout-plugin
+X-XFCE-Module-Path=@plugindir@
+X-XFCE-Internal=FALSE

Modified: xfce4-session/trunk/po/POTFILES.in
===================================================================
--- xfce4-session/trunk/po/POTFILES.in	2009-07-27 02:14:40 UTC (rev 30399)
+++ xfce4-session/trunk/po/POTFILES.in	2009-07-27 02:14:51 UTC (rev 30400)
@@ -4,6 +4,7 @@
 engines/balou/config.c
 engines/mice/mice.c
 engines/simple/simple.c
+panel-plugin/xfsm-logout-plugin.c
 settings/main.c
 settings/session-editor.c
 settings/splash-settings.c
@@ -26,6 +27,7 @@
 
 
 # files added by intltool-prepare.
+panel-plugin/xfsm-logout-plugin.desktop.in
 settings/xfce-session-settings.desktop.in
 settings/xfce4-session-settings.glade
 xfce4-tips/xfce4-tips-autostart.desktop.in




More information about the Xfce4-commits mailing list