aboutsummaryrefslogtreecommitdiff
path: root/src/colloquium.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-27 22:06:37 +0200
committerThomas White <taw@physics.org>2018-03-27 22:06:37 +0200
commite1477b02a786d6a82bb37d5f4074a929fe564457 (patch)
tree777b86842e71b2359bcee26d1c18139794f9573c /src/colloquium.c
parent9aee366ba67bff4abd7d61971d2a281df363961c (diff)
Use application menu only if it will be used be the desktop environment
Diffstat (limited to 'src/colloquium.c')
-rw-r--r--src/colloquium.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index 1963780..122feae 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -301,6 +301,8 @@ static void colloquium_startup(GApplication *papp)
{
Colloquium *app = COLLOQUIUM(papp);
GtkBuilder *builder;
+ GtkSettings *settings;
+ gboolean app_menu_shown;
const char *configdir;
char *tmp;
@@ -321,12 +323,12 @@ static void colloquium_startup(GApplication *papp)
" <attribute name='accel'>&lt;Primary&gt;n</attribute>"
" </item>"
" <item>"
- " <attribute name='label'>_Open</attribute>"
+ " <attribute name='label'>_Open...</attribute>"
" <attribute name='action'>app.open</attribute>"
" <attribute name='accel'>&lt;Primary&gt;o</attribute>"
" </item>"
" <item>"
- " <attribute name='label'>Preferences...</attribute>"
+ " <attribute name='label'>Preferences</attribute>"
" <attribute name='action'>app.prefs</attribute>"
" </item>"
" </section>"
@@ -346,6 +348,19 @@ static void colloquium_startup(GApplication *papp)
" <menu id='menubar'>"
" <submenu>"
" <attribute name='label' translatable='yes'>File</attribute>"
+
+ " <section>"
+ " <item>"
+ " <attribute name='label'>_New</attribute>"
+ " <attribute name='action'>app.new</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;n</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>_Open...</attribute>"
+ " <attribute name='action'>app.open</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;o</attribute>"
+ " </item>"
+ " </section>"
" <section>"
" <item>"
" <attribute name='label'>_Save</attribute>"
@@ -369,14 +384,21 @@ static void colloquium_startup(GApplication *papp)
" </section>"
" <section>"
" <item>"
- " <attribute name='label'>Load stylesheet</attribute>"
+ " <attribute name='label'>Load stylesheet...</attribute>"
" <attribute name='action'>win.loadstyle</attribute>"
" </item>"
" <item>"
- " <attribute name='label'>Save stylesheet</attribute>"
+ " <attribute name='label'>Save stylesheet...</attribute>"
" <attribute name='action'>win.savestyle</attribute>"
" </item>"
" </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>_Quit</attribute>"
+ " <attribute name='action'>app.quit</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;q</attribute>"
+ " </item>"
+ " </section>"
" </submenu>"
" <submenu>"
@@ -424,9 +446,11 @@ static void colloquium_startup(GApplication *papp)
" <attribute name='label'>Edit stylesheet...</attribute>"
" <attribute name='action'>win.stylesheet</attribute>"
" </item>"
+ " </section>"
+ " <section>"
" <item>"
- " <attribute name='label'>Change stylesheet...</attribute>"
- " <attribute name='action'>win.loadstylesheet</attribute>"
+ " <attribute name='label'>Preferences</attribute>"
+ " <attribute name='action'>app.prefs</attribute>"
" </item>"
" </section>"
" </submenu>"
@@ -461,7 +485,7 @@ static void colloquium_startup(GApplication *papp)
" <attribute name='action'>win.startslideshownoslides</attribute>"
" </item>"
" <item>"
- " <attribute name='label'>Presentation clock...</attribute>"
+ " <attribute name='label'>Presentation clock</attribute>"
" <attribute name='action'>win.clock</attribute>"
" </item>"
" <item>"
@@ -470,16 +494,35 @@ static void colloquium_startup(GApplication *papp)
" </item>"
" </section>"
" </submenu>"
+
+ " <submenu>"
+ " <attribute name='label' translatable='yes'>Help</attribute>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>About</attribute>"
+ " <attribute name='action'>app.about</attribute>"
+ " </item>"
+ " </section>"
+ " </submenu>"
" </menu>"
"</interface>", -1, NULL);
- gtk_application_set_app_menu(GTK_APPLICATION(app),
- G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu")));
gtk_application_set_menubar(GTK_APPLICATION(app),
G_MENU_MODEL(gtk_builder_get_object(builder, "menubar")));
g_object_unref(builder);
+ settings = gtk_settings_get_for_screen(gdk_screen_get_default());
+ g_object_get(G_OBJECT(settings), "gtk-shell-shows-app-menu", &app_menu_shown, NULL);
+ if ( app_menu_shown ) {
+ /* Set the application menu only if it will be shown by the
+ * desktop environment. All the entries are already in the
+ * normal menus, so don't let GTK create a fallback menu in the
+ * menu bar. */
+ GMenuModel *mmodel = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu"));
+ gtk_application_set_app_menu(GTK_APPLICATION(app), mmodel);
+ }
+
configdir = g_get_user_config_dir();
app->mydir = malloc(strlen(configdir)+14);
strcpy(app->mydir, configdir);