[gtk/wip/matthiasc/popup5: 24/124] menubutton: Allocate the popover
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 24/124] menubutton: Allocate the popover
- Date: Sun, 19 May 2019 03:44:56 +0000 (UTC)
commit bd9d8899a241940f9ee00cd435c3aabcd31a34b3
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Apr 26 23:17:37 2019 +0000
menubutton: Allocate the popover
This is temporary, until we've figured out
the proper way of hooking this up
gtk/gtkmenubutton.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 687a9c6850..003df8f892 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -123,6 +123,9 @@
#include "gtktypebuiltins.h"
#include "gtklabel.h"
#include "gtkbox.h"
+#include "gtkwidgetprivate.h"
+#include "gtkbuttonprivate.h"
+#include "gtknative.h"
#include "a11y/gtkmenubuttonaccessible.h"
@@ -478,12 +481,30 @@ gtk_menu_button_size_allocate (GtkWidget *widget,
int height,
int baseline)
{
- GtkMenuButton *menu_button = GTK_MENU_BUTTON (widget);
- GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
+ GtkMenuButton *button = GTK_MENU_BUTTON (widget);
+ GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
gtk_widget_size_allocate (priv->button,
&(GtkAllocation) { 0, 0, width, height },
baseline);
+
+ if (priv->popover)
+ gtk_native_check_resize (GTK_NATIVE (priv->popover));
+}
+
+static gboolean
+gtk_menu_button_focus (GtkWidget *widget,
+ GtkDirectionType direction)
+{
+ GtkMenuButton *button = GTK_MENU_BUTTON (widget);
+ GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
+
+ if (priv->menu && gtk_widget_get_visible (priv->menu))
+ return gtk_widget_focus_move (priv->menu, direction);
+ else if (priv->popover && gtk_widget_get_visible (priv->popover))
+ return gtk_widget_focus_move (priv->popover, direction);
+ else
+ return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->focus (widget, direction);
}
static void
@@ -496,9 +517,10 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
gobject_class->get_property = gtk_menu_button_get_property;
gobject_class->dispose = gtk_menu_button_dispose;
- widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
widget_class->measure = gtk_menu_button_measure;
widget_class->size_allocate = gtk_menu_button_size_allocate;
+ widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
+ widget_class->focus = gtk_menu_button_focus;
/**
* GtkMenuButton:popup:
@@ -644,8 +666,6 @@ gtk_menu_button_init (GtkMenuButton *menu_button)
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
GtkStyleContext *context;
- gtk_widget_set_has_surface (GTK_WIDGET (menu_button), FALSE);
-
priv->arrow_type = GTK_ARROW_DOWN;
priv->use_popover = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]