[Xfce4-commits] <xfce4-panel:master> Add logout to plugin menu and drop quit and restart.

Nick Schermer noreply at xfce.org
Sun Jun 13 14:14:01 CEST 2010


Updating branch refs/heads/master
         to c6d5ba57471e9b092111eb1499569b871b92dfaf (commit)
       from 3682854d3ffc23fbc19f9deda2e58a676227230b (commit)

commit c6d5ba57471e9b092111eb1499569b871b92dfaf
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Jun 13 14:08:41 2010 +0200

    Add logout to plugin menu and drop quit and restart.
    
    In 4.6 the quit action also showed the logout dialog, instead of
    quiting the panel. Also drop the restart option since it is not
    suitable for normal users (xfce4-panel -r still exists).
    This makes it harder to accidentally remove the panel from the
    session, if you want that, run xfce4-panel -q (normal quit).

 libxfce4panel/xfce-panel-plugin-provider.h |    3 +-
 libxfce4panel/xfce-panel-plugin.c          |   35 +++++----------------------
 panel/panel-application.c                  |   29 ++++++++++++++++++++---
 panel/panel-application.h                  |    2 +
 panel/panel-window.c                       |   27 +++------------------
 5 files changed, 39 insertions(+), 57 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 1949b04..141f450 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -83,8 +83,7 @@ typedef enum /*< skip >*/
   PROVIDER_SIGNAL_REMOVE_PLUGIN,
   PROVIDER_SIGNAL_ADD_NEW_ITEMS,
   PROVIDER_SIGNAL_PANEL_PREFERENCES,
-  PROVIDER_SIGNAL_PANEL_QUIT,
-  PROVIDER_SIGNAL_PANEL_RESTART,
+  PROVIDER_SIGNAL_PANEL_LOGOUT,
   PROVIDER_SIGNAL_PANEL_ABOUT,
   PROVIDER_SIGNAL_PANEL_HELP,
   PROVIDER_SIGNAL_SHOW_CONFIGURE,
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 9c3a712..9298ad8 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -912,29 +912,15 @@ xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin)
 
 
 static void
-xfce_panel_plugin_menu_panel_quit (XfcePanelPlugin *plugin)
+xfce_panel_plugin_menu_panel_logout (XfcePanelPlugin *plugin)
 {
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
   panel_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
 
-  /* quit the panel/session */
+  /* logout the session */
   xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
-                                          PROVIDER_SIGNAL_PANEL_QUIT);
-}
-
-
-
-static void
-xfce_panel_plugin_menu_panel_restart (XfcePanelPlugin *plugin)
-{
-  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
-  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
-  panel_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
-
-  /* restart the panel */
-  xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
-                                          PROVIDER_SIGNAL_PANEL_RESTART);
+                                          PROVIDER_SIGNAL_PANEL_LOGOUT);
 }
 
 
@@ -1106,21 +1092,14 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
           gtk_widget_show (item);
         }
 
-      /* quit item */
-      item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
-      g_signal_connect_swapped (G_OBJECT (item), "activate",
-          G_CALLBACK (xfce_panel_plugin_menu_panel_quit), plugin);
-      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
-      gtk_widget_show (item);
-
-      /* restart item */
-      item = gtk_image_menu_item_new_with_mnemonic (_("_Restart"));
+      /* logout item */
+      item = gtk_image_menu_item_new_with_mnemonic (_("Log _Out"));
       g_signal_connect_swapped (G_OBJECT (item), "activate",
-          G_CALLBACK (xfce_panel_plugin_menu_panel_restart), plugin);
+          G_CALLBACK (xfce_panel_plugin_menu_panel_logout), plugin);
       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
       gtk_widget_show (item);
 
-      image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU);
+      image = gtk_image_new_from_icon_name ("system-log-out", GTK_ICON_SIZE_MENU);
       gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
       gtk_widget_show (image);
 
diff --git a/panel/panel-application.c b/panel/panel-application.c
index ae3eb75..4f9dd73 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -550,10 +550,9 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider       *provide
       panel_preferences_dialog_show (window);
       break;
 
-    case PROVIDER_SIGNAL_PANEL_QUIT:
-    case PROVIDER_SIGNAL_PANEL_RESTART:
-      /* quit or restart */
-      panel_dbus_service_exit_panel (provider_signal == PROVIDER_SIGNAL_PANEL_RESTART);
+    case PROVIDER_SIGNAL_PANEL_LOGOUT:
+      /* logout */
+      panel_application_logout ();
       break;
 
     case PROVIDER_SIGNAL_PANEL_ABOUT:
@@ -1409,3 +1408,25 @@ panel_application_get_locked (PanelApplication *application)
    * locked but maybe not all the plugins) */
   return TRUE;
 }
+
+
+
+void
+panel_application_logout (void)
+{
+  XfceSMClient *sm_client;
+  GError       *error = NULL;
+
+  /* first try to session client to logout else fallback and spawn xfce4-session-logout */
+  sm_client = xfce_sm_client_get ();
+  if (xfce_sm_client_is_connected (sm_client))
+    {
+      xfce_sm_client_request_shutdown (sm_client, XFCE_SM_CLIENT_SHUTDOWN_HINT_ASK);
+    }
+  else if (!g_spawn_command_line_async ("xfce4-session-logout", &error))
+    {
+      xfce_dialog_show_error (NULL, error, _("Failed to execute command \"%s\""),
+                              "xfce4-session-logout");
+      g_error_free (error);
+    }
+}
diff --git a/panel/panel-application.h b/panel/panel-application.h
index 0e77284..cc250df 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -70,6 +70,8 @@ void              panel_application_windows_sensitive (PanelApplication  *applic
 
 gboolean          panel_application_get_locked        (PanelApplication  *application);
 
+void              panel_application_logout            (void);
+
 G_END_DECLS
 
 #endif /* !__PANEL_APPLICATION_H__ */
diff --git a/panel/panel-window.c b/panel/panel-window.c
index c13e340..ccaf2fc 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -2042,14 +2042,6 @@ panel_window_set_autohide (PanelWindow *window,
 
 
 static void
-panel_window_menu_quit (gpointer boolean)
-{
-  panel_dbus_service_exit_panel (GPOINTER_TO_UINT (boolean) == 1);
-}
-
-
-
-static void
 panel_window_menu_help (void)
 {
   panel_utils_show_help (NULL, NULL, NULL);
@@ -2129,28 +2121,17 @@ panel_window_menu_popup (PanelWindow *window,
       gtk_widget_show (item);
     }
 
-  /* quit item */
-  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
-  g_signal_connect_swapped (G_OBJECT (item), "activate",
-      G_CALLBACK (panel_window_menu_quit), GUINT_TO_POINTER (0));
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_show (item);
-
-  /* restart item */
-  item = gtk_image_menu_item_new_with_mnemonic (_("_Restart"));
+  /* logout item */
+  item = gtk_image_menu_item_new_with_mnemonic (_("Log _Out"));
   g_signal_connect_swapped (G_OBJECT (item), "activate",
-      G_CALLBACK (panel_window_menu_quit), GUINT_TO_POINTER (1));
+      G_CALLBACK (panel_application_logout), NULL);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
 
-  image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU);
+  image = gtk_image_new_from_icon_name ("system-log-out", GTK_ICON_SIZE_MENU);
   gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
   gtk_widget_show (image);
 
-  item = gtk_separator_menu_item_new ();
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_show (item);
-
   /* help item */
   item = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
   g_signal_connect (G_OBJECT (item), "activate",



More information about the Xfce4-commits mailing list