Repository: beeware/toga

Issue:
Menubar / Appmenu inconsistencies X11 vs Wayland, Gnome shell
## Expected Behavior
All menu items are visible, on a menubar (or hamburger menu equivalent) - something like:
![Screenshot from 2020-04-27 12-51-16](https://user-images.githubusercontent.com/421383/80324622-d8599980-8885-11ea-8f8f-e2133a783779.png)

## Current Behavior
<!--- If you're describing a bug, what currently happens? -->
The Appmenu is deprecated in latest GTK style guide.  
Currently it is not consistently shown.  Its visibility can be turned off, and apps need to be
able to show it some other way.


859a80226b8dfa7529e41ebb21e29df2ff61e2b4

The other application menus also sometimes don't show up.

Behaviour varies depending on whether X11 or Wayland is being used.


## Steps to reproduce
<!--- Provide a set of steps describing how to reproduce this bug. If you have a live example, provide the link below -->
Gnome appmenu enabled

`GDK_BACKEND=wayland python -m box`
![Screenshot from 2020-04-27 12-43-45](https://user-images.githubusercontent.com/421383/80324391-c7f4ef00-8884-11ea-961d-2ca09f74b90e.png)
Note that with wayland, the name and icon in the appmenu are also wrong (x11 OK)

`GDK_BACKEND=x11 python -m box`
![Screenshot from 2020-04-27 12-43-27](https://user-images.githubusercontent.com/421383/80324392-c9261c00-8884-11ea-9bb4-adbc5300f84e.png)

Gnome appmenu disabled
`GDK_BACKEND=wayland python -m box`
![Screenshot from 2020-04-27 12-42-45](https://user-images.githubusercontent.com/421383/80324393-c9261c00-8884-11ea-92cd-f7b58dd77938.png)

`GDK_BACKEND=x11 python -m box`
![Screenshot from 2020-04-27 12-42-14](https://user-images.githubusercontent.com/421383/80324394-c9beb280-8884-11ea-8fbb-0787f4403a8a.png)


## Your Environment
<!--- Provide details on your current environment you found the bug in -->

* Python Version (list the specific version number)
3.7.3
* Operating System and Version (select from the following and list the specific version number; if your OS is not listed, list that as well)

  - [ ] macOS - version:
  - [x] Linux - Debian 10
  - [ ] Windows - version:
  - [ ] Other - name:  - version:

* Toga Version (list the specific version number or git hash)
2020-04-26
859a80226b8dfa7529e41ebb21e29df2ff61e2b4

* Toga Target (the type of app you are trying to generate)

  - [ ] android
  - [ ] cocoa
  - [ ] django
  - [x] gtk
  - [ ] iOS
  - [ ] tvOS
  - [ ] watchOS
  - [ ] winforms
  - [ ] win32
  - [ ] Other (please specify)



Discussion:

Resolving patch:
diff --git a/src/gtk/toga_gtk/app.py b/src/gtk/toga_gtk/app.py
--- a/src/gtk/toga_gtk/app.py
+++ b/src/gtk/toga_gtk/app.py
@@ -73,12 +73,13 @@ def create(self):
         self.actions = None
 
     def gtk_startup(self, data=None):
+        # Set up the default commands for the interface.
         self.interface.commands.add(
-            Command(None, 'About ' + self.interface.name, group=toga.Group.APP),
+            Command(None, 'About ' + self.interface.name, group=toga.Group.HELP),
             Command(None, 'Preferences', group=toga.Group.APP),
             # Quit should always be the last item, in a section on it's own
             Command(
-                lambda widget, data: self.exit(),
+                lambda widget: self.exit(),
                 'Quit ' + self.interface.name,
                 shortcut=toga.Key.MOD_1 + 'q',
                 group=toga.Group.APP,
@@ -94,7 +95,14 @@ def gtk_startup(self, data=None):
         # then force the creation of the menus.
         self._actions = {}
         self.create_menus()
-        # self.interface.main_window._impl.create_toolbar()
+
+        # Now that we have menus, make the app take responsibility for
+        # showing the menubar.
+        # This is required because of inconsistencies in how the Gnome
+        # shell operates on different windowing environments;
+        # see #872 for details.
+        settings = Gtk.Settings.get_default()
+        settings.set_property("gtk-shell-shows-menubar", False)
 
     def _create_app_commands(self):
         # No extra menus
@@ -117,9 +125,8 @@ def create_menus(self):
                         submenu.append_section(None, section)
 
                     if label == '*':
-                        self.native.set_app_menu(submenu)
-                    else:
-                        menubar.append_submenu(label, submenu)
+                        label = self.interface.name
+                    menubar.append_submenu(label, submenu)
 
                     label = None
                     submenu = None
@@ -160,9 +167,8 @@ def create_menus(self):
 
             if submenu:
                 if label == '*':
-                    self.native.set_app_menu(submenu)
-                else:
-                    menubar.append_submenu(label, submenu)
+                    label = self.interface.name
+                menubar.append_submenu(label, submenu)
 
             # Set the menu for the app.
             self.native.set_menubar(menubar)


Test patch: