summaryrefslogtreecommitdiff
path: root/src/yelp-application.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-11-09 00:45:54 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-04-05 13:42:54 -0400
commit875daa13aa64d5c35b1e87de9f8a8cec245ea690 (patch)
treec55ae159dec2efb3ed49ad204838889aa05dec0c /src/yelp-application.c
parent1797783946c86bcea0cd36a8ca5c281c35b03dcb (diff)
downloadyelp-875daa13aa64d5c35b1e87de9f8a8cec245ea690.tar.gz
Add an app menu
And provide some other GNOME 3 application style tweaks. The titlebar is now hidden when maximized, the prev/next buttons use the raised button style and there is a gears menu to take up the window-specific parts of the menu bar, which is gone.
Diffstat (limited to 'src/yelp-application.c')
-rw-r--r--src/yelp-application.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/yelp-application.c b/src/yelp-application.c
index e6696611..800d187f 100644
--- a/src/yelp-application.c
+++ b/src/yelp-application.c
@@ -244,6 +244,27 @@ yelp_application_cmdline (GApplication *app,
}
static void
+new_activated (GSimpleAction *action, GVariant *parameter, gpointer user_data)
+{
+ YelpApplication *app = user_data;
+
+ yelp_application_new_window (app, NULL);
+}
+
+static void
+quit_activated (GSimpleAction *action, GVariant *parameter, gpointer user_data)
+{
+ YelpApplication *app = user_data;
+
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "new", new_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL },
+};
+
+static void
yelp_application_startup (GApplication *application)
{
YelpApplication *app = YELP_APPLICATION (application);
@@ -251,6 +272,7 @@ yelp_application_startup (GApplication *application)
gchar *keyfile;
YelpSettings *settings;
GtkAction *action;
+ GtkBuilder *builder;
g_set_application_name (N_("Help"));
@@ -258,6 +280,28 @@ yelp_application_startup (GApplication *application)
G_APPLICATION_CLASS (yelp_application_parent_class)
->startup (application);
+ g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder,
+ "<interface>"
+ " <menu id='app-menu'>"
+ " <section>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_New Window</attribute>"
+ " <attribute name='action'>app.new</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;n</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Quit</attribute>"
+ " <attribute name='action'>app.quit</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;q</attribute>"
+ " </item>"
+ " </section>"
+ " </menu>"
+ "</interface>", -1, NULL);
+ gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
+ g_object_unref (builder);
+
settings = yelp_settings_get_default ();
if (editor_mode)
yelp_settings_set_editor_mode (settings, TRUE);