[gtk/wip/matthiasc/popup5: 19/145] menubutton: Allocate the popover



commit d2103b0f5da67260044ccadab3e6bd842646c469
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 | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 80ad5affd5..1fff602eba 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"
 
@@ -485,12 +488,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
@@ -503,9 +524,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:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]