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 723878 - GtkMenuButton: Support popovers
GtkMenuButton: Support popovers
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-02-08 00:26 UTC by Matthias Clasen
Modified: 2014-02-09 01:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkMenuButton: Support popovers (26.07 KB, patch)
2014-02-08 00:26 UTC, Matthias Clasen
reviewed Details | Review
how it looks in the wild (85.64 KB, image/png)
2014-02-08 00:41 UTC, Matthias Clasen
  Details
GtkMenuButton: Support popovers (27.16 KB, patch)
2014-02-08 01:24 UTC, Matthias Clasen
none Details | Review
GtkMenuButton: Support popovers (28.13 KB, patch)
2014-02-08 02:14 UTC, Matthias Clasen
committed Details | Review
Restrict menubutton styling (4.64 KB, patch)
2014-02-08 02:17 UTC, Matthias Clasen
committed Details | Review

Description Matthias Clasen 2014-02-08 00:26:42 UTC
Add api to allow explicitly setting a GtkPopover instead of
a GtkMenu as the popup of a GtkMenuButton. Also, add api to
instruct the menu button to construct a popover when given
a menu model.
Comment 1 Matthias Clasen 2014-02-08 00:26:44 UTC
Created attachment 268467 [details] [review]
GtkMenuButton: Support popovers
Comment 2 Matthias Clasen 2014-02-08 00:41:19 UTC
Created attachment 268468 [details]
how it looks in the wild
Comment 3 Matthias Clasen 2014-02-08 01:24:44 UTC
Created attachment 268469 [details] [review]
GtkMenuButton: Support popovers

Add api to allow explicitly setting a GtkPopover instead of
a GtkMenu as the popup of a GtkMenuButton. Also, add api to
instruct the menu button to construct a popover when given
a menu model.
Comment 4 Carlos Garnacho 2014-02-08 01:26:18 UTC
Review of attachment 268467 [details] [review]:

Looks great in general :), and looks like will make GtkPopover adoption quite faster where it's most expected. just a few minor comments

::: gtk/gtkmenubutton.c
@@ +224,3 @@
+      if (priv->menu)
+        gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
+      if (priv->popover)

If menu and popover are mutually exclusive, maybe this would be clearer as if ... else if ... for future reads, or check use_popover, dunno...

@@ +423,2 @@
     }
+  if (priv->popover)

same here

@@ +437,3 @@
+      if (priv->menu)
+        popup_menu (menu_button, event);
+      if (priv->popover)

and here

@@ +1085,3 @@
+
+  g_clear_object (&priv->model);
+  gtk_menu_button_set_popup (menu_button, NULL);

maybe gtk_menu_button_set_popup() should also unset the popover? both should protect for reentrancy in that case.

Also, I guess the popup must be unset only if popover != NULL.
Comment 5 Matthias Clasen 2014-02-08 01:48:01 UTC
Thanks for the review.

One thing to note in the screenshot is that we should make Adwaita not give the button this special treatment when it is not popping up a menu. Probably need to add a style class to differentiate the two cases.
Comment 6 Matthias Clasen 2014-02-08 02:14:49 UTC
Created attachment 268470 [details] [review]
GtkMenuButton: Support popovers

Add api to allow explicitly setting a GtkPopover instead of
a GtkMenu as the popup of a GtkMenuButton. Also, add api to
instruct the menu button to construct a popover when given
a menu model.

We set the style class "menu-button" on the button only when
it pops up a menu, to allow different treatment for the active
state of the button in the two cases.
Comment 7 Matthias Clasen 2014-02-08 02:17:27 UTC
Created attachment 268471 [details] [review]
Restrict menubutton styling

For menu buttons, we create an active state that makes the button
appear attached to the menu. That does not look so hot when the
button is actually popping up something else. GTK+ introduced
a style class, 'menu-button', to differentiate the case of a
button with a menu. Use it.
Comment 8 Matthias Clasen 2014-02-09 01:42:59 UTC
Attachment 268470 [details] pushed as 9822d51 - GtkMenuButton: Support popovers
Comment 9 Matthias Clasen 2014-02-09 01:44:14 UTC
Comment on attachment 268471 [details] [review]
Restrict menubutton styling

Attachment 268471 [details] pushed as 22882a4 - Restrict menubutton styling