summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2012-05-06 02:57:51 +0200
committerFlorian Müllner <fmuellner@gnome.org>2012-05-18 18:48:38 +0200
commitc626ba5cdfa037fc68c6db517084fe8a3a0de6c8 (patch)
tree70b22e59f720ffe6acb43c481ed54059e9611e3a
parentad4da161269a991153408227ae9c665956fec9e6 (diff)
downloadgnome-control-center-c626ba5cdfa037fc68c6db517084fe8a3a0de6c8.tar.gz
shell: Add application menu
Add a simple application menu containing just "Help" and "Quit". https://bugzilla.gnome.org/show_bug.cgi?id=675471
-rw-r--r--shell/control-center.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/shell/control-center.c b/shell/control-center.c
index d2fc61d17..a3f020b9f 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
*/
}