From e1477b02a786d6a82bb37d5f4074a929fe564457 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 27 Mar 2018 22:06:37 +0200 Subject: Use application menu only if it will be used be the desktop environment --- src/colloquium.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'src/colloquium.c') 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) " <Primary>n" " " " " - " _Open" + " _Open..." " app.open" " <Primary>o" " " " " - " Preferences..." + " Preferences" " app.prefs" " " " " @@ -346,6 +348,19 @@ static void colloquium_startup(GApplication *papp) " " " " " File" + + "
" + " " + " _New" + " app.new" + " <Primary>n" + " " + " " + " _Open..." + " app.open" + " <Primary>o" + " " + "
" "
" " " " _Save" @@ -369,14 +384,21 @@ static void colloquium_startup(GApplication *papp) "
" "
" " " - " Load stylesheet" + " Load stylesheet..." " win.loadstyle" " " " " - " Save stylesheet" + " Save stylesheet..." " win.savestyle" " " "
" + "
" + " " + " _Quit" + " app.quit" + " <Primary>q" + " " + "
" "
" " " @@ -424,9 +446,11 @@ static void colloquium_startup(GApplication *papp) " Edit stylesheet..." " win.stylesheet" " " + " " + "
" " " - " Change stylesheet..." - " win.loadstylesheet" + " Preferences" + " app.prefs" " " "
" "
" @@ -461,7 +485,7 @@ static void colloquium_startup(GApplication *papp) " win.startslideshownoslides" " " " " - " Presentation clock..." + " Presentation clock" " win.clock" " " " " @@ -470,16 +494,35 @@ static void colloquium_startup(GApplication *papp) " " " " " " + + " " + " Help" + "
" + " " + " About" + " app.about" + " " + "
" + "
" "
" "", -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); -- cgit v1.2.3