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 722230 - Use a GtkHeaderBar
Use a GtkHeaderBar
Status: RESOLVED FIXED
Product: gnome-mahjongg
Classification: Applications
Component: general
3.10.x
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-mahjongg-maint
gnome-mahjongg-maint
Depends on:
Blocks:
 
 
Reported: 2014-01-15 01:41 UTC by Michael Catanzaro
Modified: 2014-02-17 09:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use a GtkHeaderBar (7.52 KB, patch)
2014-02-16 15:51 UTC, Alex Muñoz
reviewed Details | Review
Use a GtkHeaderBar (7.85 KB, patch)
2014-02-16 21:53 UTC, Alex Muñoz
reviewed Details | Review
Use a GtkHeaderBar (7.70 KB, patch)
2014-02-16 22:25 UTC, Alex Muñoz
none Details | Review
Use a GtkHeaderBar (7.70 KB, patch)
2014-02-16 22:33 UTC, Alex Muñoz
committed Details | Review

Description Michael Catanzaro 2014-01-15 01:41:27 UTC
After removing the toolbar, we should use a GtkHeaderBar for the title bar. This is part of the games modernization effort.

[1] https://wiki.gnome.org/Initiatives/GnomeGoals/HeaderBars
[2] https://wiki.gnome.org/Apps/Games/Modernisation
Comment 1 Alex Muñoz 2014-02-16 15:51:32 UTC
Created attachment 269311 [details] [review]
Use a GtkHeaderBar
Comment 2 Michael Catanzaro 2014-02-16 19:07:34 UTC
Review of attachment 269311 [details] [review]:

Er, surprise last-minute patch! This is done pretty well. Mario, think we can sneak this in before 3.11.90?

(Allan doesn't really want us packing buttons into the header bars for the games, but I think it's a good transition strategy -- and maybe even a final design -- for the games that have lots of buttons, like Mahjongg. I already adopted it for Chess, for example.  Looks much better than the toolbar.)

We can't forget to bump the GTK+ dep in configure.ac to 3.10.

I'd like to add tooltips to all the buttons using the tooltip_text property of Gtk.Widget. To be consistent with the other games:

Undo: "Undo your last move"
Redo: "Redo your last move" (or something like that -- I don't think any other game has Redo)
Pause: "Pause the game"
Unpause: "Unpause the game"
Hint: "Receive a hint for your next move"

::: src/gnome-mahjongg.vala
@@ +101,3 @@
+        undo_image.icon_size = Gtk.IconSize.BUTTON;
+        undo_image.icon_name = "edit-undo-symbolic";
+        var undo_button = new Gtk.Button ();

We can do all this one line:

var undo_button = new Gtk.Button.from_icon_name ("edit-undo-symbolic", Gtk.IconSize.BUTTON);

Same for the other buttons

But see below

@@ +110,3 @@
+        var redo_image = new Gtk.Image ();
+        redo_image.icon_size = Gtk.IconSize.BUTTON;
+        redo_image.icon_name = "edit-redo-symbolic";

With undo and redo we need to check the text direction so that we use a different icon in RTL languages (edit-undo-rtl-symbolic and edit-redo-rtl-symbolic). The test would look like:

if (undo_button.get_direction() == Gtk.TextDirection.RTL)

@@ +120,3 @@
+        var hint_image = new Gtk.Image ();
+        hint_image.icon_size = Gtk.IconSize.BUTTON;
+        hint_image.icon_name = "dialog-information-symbolic";

Can you please change this to dialog-question-symbolic; we recently started using that one for hints instead.

(I almost thought dialog-information-symbolic was a great idea, since if applied consistently it would resolve the ambiguity between Hint in most games and Resolve in Tetravex, and let us drop the text labels from Tetravex, which are inconsistent with the other games.  But I think the question mark is just a really good icon for hints, and we can probably find something else for Tetravex eventually.)

@@ +643,3 @@
         var display_name = dpgettext2 (null, "mahjongg map name", game_view.game.map.name);
         /* Translators: This is the window title for Mahjongg which contains the map name, e.g. 'Mahjongg - Red Dragon' */
+        title.set_label (_("Mahjongg - %s").printf (display_name));

Let's use the map name for the window title; we don't need to include the program name anymore, that just adds clutter. This change would require updating the translator comment, of course.
Comment 3 Michael Catanzaro 2014-02-16 19:16:01 UTC
Because Super Time Crunch, I'm just going to implement all the review comments myself instead of waiting!
Comment 4 Alex Muñoz 2014-02-16 21:53:19 UTC
Created attachment 269337 [details] [review]
Use a GtkHeaderBar
Comment 5 Michael Catanzaro 2014-02-16 22:06:28 UTC
Review of attachment 269337 [details] [review]:

Very minor comments follow:

::: src/gnome-mahjongg.vala
@@ +100,1 @@
+        var undo_image = "";

How about undo_image_name (and redo_image_name) instead?

@@ +104,3 @@
+                undo_image = "edit-undo-symbolic";
+
+        var undo_button = new Gtk.Button.from_icon_name (undo_image,  Gtk.IconSize.BUTTON);

Every time you use the Gtk.Button.from_icon_name constructor, there's an extra space between the two parameters.

@@ +574,2 @@
         }
+        pause_button.image = pause_image;

This does work, but it'd be cleaner to update the old image instead of creating a new one each time. You can get the original image like this:

var pause_image = (Gtk.Image) pause_button.image;

Then you don't need to create the new image, or set its icon size, or reassign it to the button.

@@ +641,3 @@
         var display_name = dpgettext2 (null, "mahjongg map name", game_view.game.map.name);
         /* Translators: This is the window title for Mahjongg which contains the map name, e.g. 'Mahjongg - Red Dragon' */
+        title.set_label (_("%s").printf (display_name));

We don't need the printf anymore, just:

title.set_label (_(display_name));

@@ +649,3 @@
+        pause_image.icon_size = Gtk.IconSize.BUTTON;
+        pause_image.icon_name = "media-playback-pause-symbolic";
+        pause_button.image = pause_image;

See above
Comment 6 Michael Catanzaro 2014-02-16 22:19:14 UTC
(In reply to comment #5)
> This does work, but it'd be cleaner to update the old image instead of creating
> a new one each time. You can get the original image like this:

Er actually, I'm not sure if this works after all. ^^  You can ignore these comments if you can't get it to work.
Comment 7 Alex Muñoz 2014-02-16 22:25:04 UTC
Created attachment 269340 [details] [review]
Use a GtkHeaderBar
Comment 8 Alex Muñoz 2014-02-16 22:33:02 UTC
Created attachment 269341 [details] [review]
Use a GtkHeaderBar
Comment 9 Michael Catanzaro 2014-02-16 22:52:39 UTC
Review of attachment 269341 [details] [review]:

LGTM.
Comment 10 Mario Wenzel 2014-02-17 09:21:57 UTC
Review of attachment 269341 [details] [review]:

That was unexpected and just in the nick of time. Thank you Alex, it looks nice and works well. Because it is so pressing, I fixed the remaining intendation and whitespace-issues myself.

Since I pushed the patch only moments ago, I am pretty confident, it will make it into the release tonight ;)

Thanks again and thank you Michael for reviewing.