After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732655 - Don't use app menu / HeaderBar on shells that don't support it well
Don't use app menu / HeaderBar on shells that don't support it well
Status: RESOLVED FIXED
Product: gnome-mines
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-mines-maint
gnome-mines-maint
Depends on: 732658
Blocks:
 
 
Reported: 2014-07-02 22:54 UTC by Robert Ancell
Modified: 2014-07-09 19:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't show HeaderBar / app menu on shells that don't support it (5.47 KB, patch)
2014-07-02 22:57 UTC, Robert Ancell
none Details | Review
screenshot of header bars in unity (329.57 KB, image/png)
2014-07-02 23:59 UTC, Michael Catanzaro
  Details
screenshot of Mines, before patch (384.24 KB, image/png)
2014-07-03 00:30 UTC, Michael Catanzaro
  Details
screenshot of menu, before patch (363.32 KB, image/png)
2014-07-03 00:33 UTC, Michael Catanzaro
  Details
Don't show HeaderBar / app menu on shells that don't support it (4.99 KB, patch)
2014-07-03 00:52 UTC, Robert Ancell
none Details | Review
Don't show HeaderBar / app menu on shells that don't support it (9.57 KB, patch)
2014-07-03 01:10 UTC, Robert Ancell
needs-work Details | Review
fallback app menu screenshot (not used in Unity) (28.75 KB, image/png)
2014-07-03 02:12 UTC, Michael Catanzaro
  Details
Don't show HeaderBar / app menu on shells that don't support it (4.05 KB, patch)
2014-07-03 03:40 UTC, Robert Ancell
needs-work Details | Review
Don't show HeaderBar / app menu on shells that don't support it (4.99 KB, patch)
2014-07-04 04:47 UTC, Robert Ancell
reviewed Details | Review

Description Robert Ancell 2014-07-02 22:54:32 UTC
Currently Mines uses an application menu / GtkHeaderBar which looks great in GNOME but not necessarily great in other shells (e.g. Unity). In those shells a traditional menubar / decorations fit in better.
Comment 1 Robert Ancell 2014-07-02 22:57:22 UTC
Created attachment 279802 [details] [review]
Don't show HeaderBar / app menu on shells that don't support it

This is the patch we're shipping in Ubuntu so we can have new Mines and it fit into the Unity shell. For those running GNOME it looks the same as current master.

I appreciate this might not fit in with the goals of the Mines project so I'll leave it to the maintainers to decide if this is an appropriate upstream addition. Obviously it adds some extra code / testing but I think it will probably not grow in complexity over time.
Comment 2 Michael Catanzaro 2014-07-02 23:25:37 UTC
Review of attachment 279802 [details] [review]:

Guess it's time to figure out how to handle this at last. Goals we probably(?) both agree on:

a) Mines and all our other GNOME games must continue to look good in future versions of Ubuntu.
b) We should handle this consistently between all GNOME games at the least, and preferably between all GNOME apps (but that's not likely to happen).

More probable(?) points of agreement:

c) Downstream patches are OK, but not good.
d) Having two different title bar and menu structures for each game is OK, but not good.
e) 100 extra lines of code is not a big deal.

I don't want to do this, but it's probably the only way to meet goal (a), short of convincing you that header bars are cool (which I guess is not very likely).

Some initial thoughts -- not changing the patch status since the whole team needs to discuss this.

::: src/gnome-mines.vala
@@ +202,3 @@
+        if (!has_app_menu ())
+        {
+            var menubar = new Gtk.MenuBar ();

Can this please go in a UI file instead?

@@ +307,3 @@
+        gtk_settings.get ("gtk-shell-shows-app-menu", &show_app_menu, "gtk-shell-shows-menubar", &show_menubar, null);
+
+        return show_app_menu && !show_menubar;

I definitely do not want to show a menu bar anywhere besides Unity. Nowadays we show the app menu with a menu button in the header bar, which I strongly prefer to a menu bar. So please just directly store Gtk.Settings.get_default ().get ("gtk_shell_shows_menu_bar") into a bool member variable has_global_menu (instead of has_app_menu) and use that to determine which menu structure to use.

I said the same in Bug #712831 -- I definitely should have CCed you there, sorry.
Comment 3 Michael Catanzaro 2014-07-02 23:34:11 UTC
Opinions?
Comment 4 Michael Catanzaro 2014-07-02 23:46:39 UTC
Oh, and what about preferences dialogs -- not an issue for Mines, but for other games. I guess you want those header bars to be conditional as well?  Do you want the Close buttons in the action area that we've gotten rid of, or will the window manager's close button suffice?
Comment 5 Michael Catanzaro 2014-07-02 23:59:46 UTC
Created attachment 279805 [details]
screenshot of header bars in unity

jhbuild-built Chess and Calculator in 14.04.  I honestly think this is very close to OK, except for the incorrect minimize/maximize/close buttons (which is configurable).

Other issues: corners of the header bar aren't rounded, the title is in a different font (and centered rather than left-aligned, but I think we're stuck with that), and the minimize/maximize/close buttons need to be hidden when the window is maximized (probably not currently possible, haven't investigated).
Comment 6 Michael Catanzaro 2014-07-03 00:30:48 UTC
Created attachment 279807 [details]
screenshot of Mines, before patch

Mostly I'm grateful that the board looks right. Wasn't really sure what to expect.
Comment 7 Robert Ancell 2014-07-03 00:32:57 UTC
See bug #732658 for the same thing in Mahjongg.
Comment 8 Michael Catanzaro 2014-07-03 00:33:32 UTC
Created attachment 279809 [details]
screenshot of menu, before patch
Comment 9 Robert Ancell 2014-07-03 00:46:11 UTC
I do think header bars are cool, but only when they're used consistently across all applications (i.e. in GNOME). In particular they don't work well in Ubuntu because maximising a window blends the window decorations into Unity top bar and this doesn't happen with HeaderBars. 

Yes, agree on all a) b) c).

I suspect the preferences dialogs are a non-issue - aren't dialogs moving to be rendered inside the window so the WM will no longer be involved at all?

I'll update the patch to use the .ui file. Was also holding myself back from making a GtkTemplate patch - I just converted Simple Scan and Vala+GtkBuilder+GtkTemplate is super nice :)
Comment 10 Robert Ancell 2014-07-03 00:52:36 UTC
Created attachment 279810 [details] [review]
Don't show HeaderBar / app menu on shells that don't support it

Updated to only check gtk-shell-shows-menubar
Comment 11 Robert Ancell 2014-07-03 01:10:18 UTC
Created attachment 279812 [details] [review]
Don't show HeaderBar / app menu on shells that don't support it

Put menubar in .ui file
Comment 12 Michael Catanzaro 2014-07-03 02:11:16 UTC
OK, regarding the menu, after reading bug #722092 it looks like Ryan and Lars are favoring traditional menu bars when the shell does not show the menu bar (Xfce, Cinnamon). One thing I am positive about: we do not ever want to show a menu bar in the window with a header bar. My preference is still to use header bar and fallback app menu in these environments -- I think it looks a lot better since our menus are small -- but I'm open to the alternative.

Screenshot upcoming for anyone unfamiliar with 3.12 fallback app menus.  (The popover is configurable on GTK+ level and I think it defaults to false.) These only work if the app uses a header bar in the main window: if not, the 3.10-style menu bar fallback is used.

(In reply to comment #9)
> I do think header bars are cool, but only when they're used consistently across
> all applications (i.e. in GNOME). In particular they don't work well in Ubuntu
> because maximising a window blends the window decorations into Unity top bar
> and this doesn't happen with HeaderBars. 

This just seems like a very fixable thing.  And the rest is just theming and settings. I mean, if header bars looked horribly out of place, that'd be one thing, but you're already pretty darn close.  Just seems like it'd be easiest for both GNOME and Ubuntu to roll with them, even if that wasn't your original plan.

As I mentioned on IRC, GNOME is pushing really hard to use header bars all over the place, and maintaining a patch set will not be fun.  But maybe you have to: I doubt you're going to be keen on the action dialog pattern [1] that popped up in 3.12 and is used *pervasively* in 3.13.  (The games do not currently use any of these.)

> I suspect the preferences dialogs are a non-issue - aren't dialogs moving to be
> rendered inside the window so the WM will no longer be involved at all?

Er, I'm not sure. We're not changing anything about how dialogs are created, I don't think, we just make a GtkDialog and set it transient for the main window. And that there is the extent of my expertise on this topic, but I think the WM must be involved, because if the WM does not draw a title bar and there is no header bar, how would the user be able to close the preferences dialog (now that the dialog's action area is deprecated -- we no longer have close, apply, OK, cancel, etc. buttons on the bottom of dialogs)?

> I'll update the patch to use the .ui file. Was also holding myself back from
> making a GtkTemplate patch - I just converted Simple Scan and
> Vala+GtkBuilder+GtkTemplate is super nice :)

Yeah I'm looking at an example [2] and my only wonder is why we didn't start using this a year ago.

[1] https://wiki.gnome.org/Design/HIG/Dialogs
[2] http://blogs.gnome.org/tvb/2013/05/29/composite-templates-lands-in-vala/
Comment 13 Michael Catanzaro 2014-07-03 02:12:11 UTC
Created attachment 279813 [details]
fallback app menu screenshot (not used in Unity)
Comment 14 Michael Catanzaro 2014-07-03 02:45:40 UTC
Review of attachment 279812 [details] [review]:

Can you take a look at how the menu is created in the patch in Bug #712831; that's a much cleaner approach.

::: src/gnome-mines.vala
@@ +209,3 @@
+
+            var item = ui_builder.get_object ("new_game_menuitem") as Gtk.MenuItem;
+            item.activate.connect (() => { new_game_cb (); });

Hm, I think you don't need any of this code because of the action-name property of GtkMenuItem, inherited from GtkActionable.  (But don't do that, since that's still not as good as the approach taken in Bug #712831.)
Comment 15 Robert Ancell 2014-07-03 03:40:53 UTC
Created attachment 279815 [details] [review]
Don't show HeaderBar / app menu on shells that don't support it

Use Gtk.Application.set_menubar
Comment 16 Robert Roth 2014-07-03 05:05:32 UTC
I'm personally fine with having a fallback for DEs not wanting headerbars, as long as we keep the diff minimal, and Robert's patch does that. I still have to test it on Ubuntu (will do that later today), right now I'm on Fedora, but right now I'd give it a commit_now review based solely on the code review.
Comment 17 Robert Roth 2014-07-03 19:09:08 UTC
Review of attachment 279815 [details] [review]:

Currently this crashes on gnome-shell as the window object you are trying to set the headerbar for (gnome-mines.vala:line 145) is initialized only later (gnome-mines.vala:line 187). Could you please fix that?
Comment 18 Robert Ancell 2014-07-04 04:47:55 UTC
Created attachment 279877 [details] [review]
Don't show HeaderBar / app menu on shells that don't support it

Whoops, fixed
Comment 19 Michael Catanzaro 2014-07-04 13:10:12 UTC
Review of attachment 279877 [details] [review]:

Robert Roth, I think this is good to push?
Comment 20 Robert Roth 2014-07-04 14:13:57 UTC
(In reply to comment #19)
> Review of attachment 279877 [details] [review]:
> 
> Robert Roth, I think this is good to push?

I'm not sure, for me the menu is not shown with XFCE (which has gtk-shell-shows-menubar=1 in .config/gtk+3.0/settings.ini ). I will test this later today with Unity, and will commit if it works as I expect it to work.
Comment 21 Michael Catanzaro 2014-07-04 16:26:30 UTC
The menu should only be shown in the window if gtk-shell-shows-menubar=0, so our code is correct. With that misconfiguration it's a wonder you see menu bars in any of your apps, but I guess the apps that display menu bars simply aren't using GMenu to do so.

Warning: if you try to test this patch in Unity with jhbuild, you'll need to install unity-gtk-module from Launchpad for it to work as expected. I couldn't find instructions so I haven't done so.
Comment 22 Michael Catanzaro 2014-07-06 16:21:23 UTC
(In reply to comment #19) 
> Robert Roth, I think this is good to push?

Actually, let's wait until bug #732658 is resolved, since that one is more complicated (preferences dialog plus toolbar).
Comment 23 Robert Roth 2014-07-09 19:51:27 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.