commit a03e0fb0721faf1e353932a8f407a498ccd992a3
Author: Egmont Koblinger <egmont@gmail.com>
Date:   Wed Jan 31 22:21:00 2018 +0100

    poc doesn't work

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2432f679..d532595e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -17,7 +17,7 @@ src/terminal-app.c
 src/terminal.c
 src/terminal-encoding.c
 src/terminal-mdi-container.c
-[type: gettext/glade]src/terminal-menubar.ui
+[type: gettext/glade]src/terminal-menubar.ui.in
 src/terminal-menu-button.c
 src/terminal-nautilus.c
 src/terminal-notebook.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 101367db..7c7459b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,6 +167,12 @@ terminal-gdbus-generated.c terminal-gdbus-generated.h: org.gnome.Terminal.xml Ma
 			--generate-c-code terminal-gdbus-generated \
 			$<
 
+terminal-menubar-with-mnemonics.ui: terminal-menubar.ui.in
+	sed -e 's,<WITH_MNEMONIC>,,g' -e 's,</WITH_MNEMONIC>,,g' -e 's,<WITHOUT_MNEMONIC>,<!-- ,g' -e 's,</WITHOUT_MNEMONIC>, -->,g' $< > $@
+
+terminal-menubar-without-mnemonics.ui: terminal-menubar.ui.in
+	sed -e 's,<WITH_MNEMONIC>,<!-- ,g' -e 's,</WITH_MNEMONIC>, -->,g' -e 's,<WITHOUT_MNEMONIC>,,g' -e 's,</WITHOUT_MNEMONIC>,,g' $< > $@
+
 terminal-resources.h terminal-resources.c: terminal.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/terminal.gresource.xml)
 	$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate --c-name terminal $<
 
@@ -354,7 +360,7 @@ CLEANFILES = \
 EXTRA_DIST = \
 	terminal.about \
 	terminal-appmenu.ui \
-	terminal-menubar.ui \
+	terminal-menubar.ui.in \
 	terminal-notebook-menu.ui \
 	terminal-window.ui \
 	terminal.gresource.xml \
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 5e782d9f..2cc0499c 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -671,6 +671,47 @@ terminal_app_activate (GApplication *application)
   /* No-op required because GApplication is stupid */
 }
 
+static void
+terminal_app_menubar (GApplication *application)
+{
+  TerminalApp *app = TERMINAL_APP (application);
+
+//  gtk_application_set_menubar (GTK_APPLICATION (app), NULL);
+
+  g_clear_object (&app->menubar);
+  g_clear_object (&app->menubar_new_terminal_section);
+  g_clear_object (&app->menubar_set_profile_section);
+  g_clear_object (&app->menubar_set_encoding_submenu);
+  g_clear_object (&app->set_profile_menu);
+
+  gboolean enable_mnemonics = g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_ENABLE_MNEMONICS_KEY);
+fprintf(stderr, "mnemonics %sabled  app = %p\n", enable_mnemonics ? "EN" : "DIS", app);
+  terminal_util_load_objects_resource (enable_mnemonics ? "/org/gnome/terminal/ui/menubar-with-mnemonics.ui"
+                                                        : "/org/gnome/terminal/ui/menubar-without-mnemonics.ui",
+                                       "menubar", &app->menubar,
+                                       "new-terminal-section", &app->menubar_new_terminal_section,
+                                       "set-profile-section", &app->menubar_set_profile_section,
+                                       "set-encoding-submenu", &app->menubar_set_encoding_submenu,
+                                       NULL);
+
+  /* Create dynamic menus and keep them updated */
+  terminal_app_update_profile_menus (app);
+  g_signal_connect_swapped (app->profiles_list, "children-changed",
+                            G_CALLBACK (terminal_app_update_profile_menus), app);
+
+  /* Install the encodings submenu */
+  terminal_encodings_append_menu (app->menubar_set_encoding_submenu);
+
+  /* If the shell wants to show the menubar, make it available */
+  gboolean shell_shows_menubar;
+  g_object_get (gtk_settings_get_default (),
+                "gtk-shell-shows-menubar", &shell_shows_menubar,
+                NULL);
+fprintf(stderr, "shell_shows_menubar = %d,  menubar = %p\n", shell_shows_menubar, app->menubar);
+  if (shell_shows_menubar)
+    gtk_application_set_menubar (GTK_APPLICATION (app), app->menubar);
+}
+
 static void
 terminal_app_startup (GApplication *application)
 {
@@ -702,31 +743,17 @@ terminal_app_startup (GApplication *application)
   fill_new_terminal_section (appmenu_new_terminal_section, NULL, 0); /* no submenu */
 
   /* Menubar */
-  terminal_util_load_objects_resource ("/org/gnome/terminal/ui/menubar.ui",
-                                       "menubar", &app->menubar,
-                                       "new-terminal-section", &app->menubar_new_terminal_section,
-                                       "set-profile-section", &app->menubar_set_profile_section,
-                                       "set-encoding-submenu", &app->menubar_set_encoding_submenu,
-                                       NULL);
-
-  /* Create dynamic menus and keep them updated */
-  terminal_app_update_profile_menus (app);
-  g_signal_connect_swapped (app->profiles_list, "children-changed",
-                            G_CALLBACK (terminal_app_update_profile_menus), app);
+  terminal_app_menubar (application);
+  g_signal_connect_swapped (app->global_settings, "changed::" TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
+                            G_CALLBACK (terminal_app_menubar), application);
 
-  /* Install the encodings submenu */
-  terminal_encodings_append_menu (app->menubar_set_encoding_submenu);
-
-  /* If the shell wants to show the appmenu/menubar, make it available */
-  gboolean shell_shows_appmenu, shell_shows_menubar;
+  /* If the shell wants to show the appmenu, make it available */
+  gboolean shell_shows_appmenu;
   g_object_get (gtk_settings_get_default (),
                 "gtk-shell-shows-app-menu", &shell_shows_appmenu,
-                "gtk-shell-shows-menubar", &shell_shows_menubar,
                 NULL);
   if (!shell_shows_appmenu)
     gtk_application_set_app_menu (GTK_APPLICATION (app), NULL);
-  if (shell_shows_menubar)
-    gtk_application_set_menubar (GTK_APPLICATION (app), app->menubar);
 
   _terminal_debug_print (TERMINAL_DEBUG_SERVER, "Startup complete\n");
 }
diff --git a/src/terminal-menubar.ui b/src/terminal-menubar.ui.in
similarity index 86%
rename from src/terminal-menubar.ui
rename to src/terminal-menubar.ui.in
index 57d1f3d4..b86d0a3d 100644
--- a/src/terminal-menubar.ui
+++ b/src/terminal-menubar.ui.in
@@ -18,7 +18,8 @@
 <interface>
   <menu id="menubar">
     <submenu>
-      <attribute name="label" translatable="yes">_File</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_File</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">File</attribute></WITHOUT_MNEMONIC>
       <section id="new-terminal-section" />
       <section>
         <item>
@@ -55,7 +56,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">_Edit</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_Edit</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">Edit</attribute></WITHOUT_MNEMONIC>
       <section>
         <item>
           <attribute name="label" translatable="yes">_Copy</attribute>
@@ -95,7 +97,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">_View</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_View</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">View</attribute></WITHOUT_MNEMONIC>
       <section>
         <item>
           <attribute name="label" translatable="yes">Show _Menubar</attribute>
@@ -123,7 +126,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">_Search</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_Search</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">Search</attribute></WITHOUT_MNEMONIC>
       <section>
         <item>
           <attribute name="label" translatable="yes">_Find…</attribute>
@@ -144,7 +148,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">_Terminal</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_Terminal</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">Terminal</attribute></WITHOUT_MNEMONIC>
       <section>
         <section id="set-profile-section" />
         <item>
@@ -198,7 +203,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">Ta_bs</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">Ta_bs</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">Tabs</attribute></WITHOUT_MNEMONIC>
       <attribute name="action">win.tabs-menu</attribute>
       <attribute name="hidden-when">action-disabled</attribute>
       <section>
@@ -229,7 +235,8 @@
       </section>
     </submenu>
     <submenu>
-      <attribute name="label" translatable="yes">_Help</attribute>
+      <WITH_MNEMONIC><attribute name="label" translatable="yes">_Help (mnemonics ENabled)</attribute></WITH_MNEMONIC>
+      <WITHOUT_MNEMONIC><attribute name="label" translatable="yes">Help (mnemonics DISabled)</attribute></WITHOUT_MNEMONIC>
       <section>
         <item>
           <attribute name="label" translatable="yes">_Contents</attribute>
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 8a1bf178..1f7234ef 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -2067,12 +2067,6 @@ terminal_window_screen_update (TerminalWindow *window,
                           gtk_settings,
                           (GDestroyNotify) app_setting_notify_destroy_cb);
 
-  g_settings_bind (settings,
-                   TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
-                   gtk_settings,
-                   "gtk-enable-mnemonics",
-                   G_SETTINGS_BIND_GET);
-
   g_settings_bind (settings,
                    TERMINAL_SETTING_ENABLE_SHORTCUTS_KEY,
                    gtk_settings,
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index 411c570a..94d84110 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -19,7 +19,8 @@
   <gresource prefix="/org/gnome/terminal">
     <file alias="css/terminal.css" compressed="true">terminal.common.css</file>
     <file alias="gtk/menus.ui" compressed="true" preprocess="xml-stripblanks">terminal-appmenu.ui</file>
-    <file alias="ui/menubar.ui" compressed="true" preprocess="xml-stripblanks">terminal-menubar.ui</file>
+    <file alias="ui/menubar-with-mnemonics.ui" compressed="true" preprocess="xml-stripblanks">terminal-menubar-with-mnemonics.ui</file>
+    <file alias="ui/menubar-without-mnemonics.ui" compressed="true" preprocess="xml-stripblanks">terminal-menubar-without-mnemonics.ui</file>
     <file alias="ui/notebook-menu.ui" compressed="true" preprocess="xml-stripblanks">terminal-notebook-menu.ui</file>
     <file alias="ui/preferences.ui" compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
     <file alias="ui/profile-preferences.ui" compressed="true" preprocess="xml-stripblanks">profile-preferences.ui</file>
