[gtk/wip/matthiasc/popup5: 16/151] menubutton: Allocate the popover
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 16/151] menubutton: Allocate the popover
- Date: Tue, 28 May 2019 20:30:00 +0000 (UTC)
commit 1cbc26d9ee7841540620b2e685ef1fd1986f6d68
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 a92e9e48af..c35565e777 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"
@@ -498,12 +501,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
@@ -516,9 +537,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]