[Xfce4-commits] <xfce4-panel:devel> * Add submenu to the panel plugin for all the Xfce Panel action and add Quit, Restart and About. Make the signals work in the application code.

Nick Schermer nick at xfce.org
Tue Aug 11 20:26:24 CEST 2009


Updating branch refs/heads/devel
         to 2eeaa3c7f3dbe62fa732c68469bba4eeedd000c1 (commit)
       from 18e547a4faec5ef6a076b2895d5735f07dee3683 (commit)

commit 2eeaa3c7f3dbe62fa732c68469bba4eeedd000c1
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Dec 10 21:40:20 2008 +0100

    * Add submenu to the panel plugin for all the Xfce Panel action
      and add Quit, Restart and About. Make the signals work in the
      application code.

 libxfce4panel/xfce-panel-plugin-provider.h |    3 +
 libxfce4panel/xfce-panel-plugin.c          |   84 +++++++++++++++++++++++++++-
 panel/panel-application.c                  |   23 ++++++-
 3 files changed, 103 insertions(+), 7 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 733adfe..f8863fd 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -78,6 +78,9 @@ enum _XfcePanelPluginProviderSignal
   PROVIDER_SIGNAL_REMOVE_PLUGIN,
   PROVIDER_SIGNAL_ADD_NEW_ITEMS,
   PROVIDER_SIGNAL_PANEL_PREFERENCES,
+  PROVIDER_SIGNAL_PANEL_QUIT,
+  PROVIDER_SIGNAL_PANEL_RESTART,
+  PROVIDER_SIGNAL_PANEL_ABOUT,
   PROVIDER_SIGNAL_SHOW_CONFIGURE,
   PROVIDER_SIGNAL_SHOW_ABOUT
 };
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 90705ea..32a700f 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -657,10 +657,49 @@ xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin)
 
 
 
+static void
+xfce_panel_plugin_menu_panel_quit (XfcePanelPlugin *plugin)
+{
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
+
+  /* quit the panel/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));
+
+  /* restart the panel */
+  xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+                                          PROVIDER_SIGNAL_PANEL_RESTART);
+}
+
+
+
+static void
+xfce_panel_plugin_menu_panel_about (XfcePanelPlugin *plugin)
+{
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
+
+  /* open the about dialog of the panel */
+  xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+                                          PROVIDER_SIGNAL_PANEL_ABOUT);
+}
+
+
+
 static GtkMenu *
 xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
 {
-  GtkWidget *menu;
+  GtkWidget *menu, *submenu;
   GtkWidget *item;
   GtkWidget *image;
 
@@ -727,10 +766,17 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
       gtk_widget_show (item);
 
+      /* create a panel submenu item */
+      submenu = gtk_menu_new ();
+      item = gtk_image_menu_item_new_with_mnemonic (_("_Xfce Panel"));
+      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
+      gtk_widget_show (item);
+
       /* add new items */
       item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
       g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
       gtk_widget_show (item);
 
       image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
@@ -740,13 +786,45 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
       /* customize panel */
       item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
       g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
       gtk_widget_show (item);
 
       image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
       gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
       gtk_widget_show (image);
 
+      /* separator */
+      item = gtk_separator_menu_item_new ();
+      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
+      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"));
+      g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_restart), 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);
+      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+      gtk_widget_show (image);
+
+      /* separator */
+      item = gtk_separator_menu_item_new ();
+      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
+      gtk_widget_show (item);
+
+      /* about item */
+      item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+      g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_about), plugin);
+      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
+      gtk_widget_show (item);
+
       /* set panel menu */
       plugin->priv->menu = GTK_MENU (menu);
     }
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 7e5e103..969328d 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -357,10 +357,11 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider       *provide
                                           XfcePanelPluginProviderSignal  signal,
                                           PanelApplication              *application)
 {
-  GtkWidget   *itembar;
-  PanelWindow *window;
-  gchar       *property;
-  gchar       *path, *filename;
+  GtkWidget       *itembar;
+  PanelWindow     *window;
+  gchar           *property;
+  gchar           *path, *filename;
+  extern gboolean  dbus_quit_with_restart;
 
   panel_return_if_fail (PANEL_IS_APPLICATION (application));
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
@@ -433,6 +434,20 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider       *provide
         panel_preferences_dialog_show (window);
         break;
 
+      case PROVIDER_SIGNAL_PANEL_QUIT:
+      case PROVIDER_SIGNAL_PANEL_RESTART:
+        /* set the restart boolean */
+        dbus_quit_with_restart = !!(signal == PROVIDER_SIGNAL_PANEL_RESTART);
+
+        /* quit the main loop */
+        gtk_main_quit ();
+        break;
+
+      case PROVIDER_SIGNAL_PANEL_ABOUT:
+        /* show the panel about dialog */
+        panel_dialogs_show_about ();
+        break;
+
       default:
         break;
     }



More information about the Xfce4-commits mailing list