[gnome-control-center] shell: Add application menu



commit c626ba5cdfa037fc68c6db517084fe8a3a0de6c8
Author: Florian MÃllner <fmuellner gnome org>
Date:   Sun May 6 02:57:51 2012 +0200

    shell: Add application menu
    
    Add a simple application menu containing just "Help" and "Quit".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675471

 shell/control-center.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/shell/control-center.c b/shell/control-center.c
index d2fc61d..a3f020b 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -164,10 +164,59 @@ application_command_line_cb (GApplication  *application,
 }
 
 static void
+help_activated (GSimpleAction *action,
+                GVariant      *parameter,
+                gpointer       user_data)
+{
+  GnomeControlCenter *shell = user_data;
+  CcPanel *panel = cc_shell_get_active_panel (CC_SHELL (shell));
+  GtkWidget *window = cc_shell_get_toplevel (CC_SHELL (shell));
+  const char *uri = NULL;
+
+  if (panel)
+    uri = cc_panel_get_help_uri (panel);
+
+  gtk_show_uri (gtk_widget_get_screen (window),
+                uri ? uri : "help:gnome-help/prefs",
+                GDK_CURRENT_TIME, NULL);
+}
+
+static void
+quit_activated (GSimpleAction *action,
+                GVariant      *parameter,
+                gpointer       user_data)
+{
+  GnomeControlCenter *shell = user_data;
+  g_object_unref (shell);
+}
+
+static void
 application_startup_cb (GApplication       *application,
                         GnomeControlCenter *shell)
 {
-  /* nothing to do here, we don't want to show a window before
+  GMenu *menu, *section;
+  GAction *action;
+
+  action = G_ACTION (g_simple_action_new ("help", NULL));
+  g_action_map_add_action (G_ACTION_MAP (application), action);
+  g_signal_connect (action, "activate", G_CALLBACK (help_activated), shell);
+
+  action = G_ACTION (g_simple_action_new ("quit", NULL));
+  g_action_map_add_action (G_ACTION_MAP (application), action);
+  g_signal_connect (action, "activate", G_CALLBACK (quit_activated), shell);
+
+  menu = g_menu_new ();
+
+  section = g_menu_new ();
+  g_menu_append (section, _("Help"), "app.help");
+  g_menu_append (section, _("Quit"), "app.quit");
+
+  g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
+
+  gtk_application_set_app_menu (GTK_APPLICATION (application),
+                                G_MENU_MODEL (menu));
+
+  /* nothing else to do here, we don't want to show a window before
    * we've looked at the commandline
    */
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]