[gtk/wip/matthiasc/popup5: 38/118] menubutton: Allocate the popover



commit 3b599d7be6303e8aaf88d7b3de3e6076f28ad806
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 | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 60b5a2b034..1b4419eba1 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -121,6 +121,9 @@
 #include "gtkprivate.h"
 #include "gtkstylecontext.h"
 #include "gtktypebuiltins.h"
+#include "gtkwidgetprivate.h"
+#include "gtkbuttonprivate.h"
+#include "gtknative.h"
 
 #include "a11y/gtkmenubuttonaccessible.h"
 
@@ -465,6 +468,36 @@ gtk_menu_button_remove (GtkContainer *container,
   GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->remove (container, child);
 }
 
+static void
+gtk_menu_button_size_allocate (GtkWidget *widget,
+                               int        width,
+                               int        height,
+                               int        baseline)
+{
+  GtkMenuButton *button = GTK_MENU_BUTTON (widget);
+  GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
+
+  GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->size_allocate (widget, 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
 gtk_menu_button_class_init (GtkMenuButtonClass *klass)
 {
@@ -477,7 +510,9 @@ 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->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;
 
   container_class->add = gtk_menu_button_add;
   container_class->remove = gtk_menu_button_remove;


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