[gtk+/popover-menu: 7/18] Drop GtkModelButton:has-submenu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/popover-menu: 7/18] Drop GtkModelButton:has-submenu
- Date: Sun, 26 Oct 2014 23:53:43 +0000 (UTC)
commit 7dcda2a17a4d10e7ca1650037266565e1330e1dd
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 26 16:23:31 2014 -0400
Drop GtkModelButton:has-submenu
Replace the has-submenu property with checking menu-name != NULL.
gtk/gtkmenusectionbox.c | 51 ++++++++++++++++++++++++----------------------
gtk/gtkmodelbutton.c | 24 ++-------------------
2 files changed, 30 insertions(+), 45 deletions(-)
---
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index 58cf305..00e6562 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -50,13 +50,14 @@ struct _GtkMenuSectionBox
G_DEFINE_TYPE (GtkMenuSectionBox, gtk_menu_section_box, GTK_TYPE_BOX)
-void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
- gint *n_items);
-void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
- GtkMenuSectionBox *toplevel,
- GtkWidget *focus);
-GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
- GtkMenuSectionBox *parent);
+static void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
+ gint *n_items);
+static void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
+ GtkMenuSectionBox *toplevel,
+ GtkWidget *focus,
+ const gchar *name);
+static GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
+ GtkMenuSectionBox *parent);
static void
gtk_menu_section_box_sync_item (GtkWidget *widget,
@@ -79,7 +80,7 @@ gtk_menu_section_box_sync_item (GtkWidget *widget,
* no items before it
* (rule 5: these rules don't apply exactly the same way for subsections)
*/
-void
+static void
gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
gint *n_items)
{
@@ -209,16 +210,12 @@ close_submenu (GtkWidget *button,
gpointer data)
{
GtkMenuTrackerItem *item = data;
- GtkWidget *stack;
- GtkWidget *parent;
GtkWidget *focus;
if (gtk_menu_tracker_item_get_should_request_show (item))
gtk_menu_tracker_item_request_submenu_shown (item, FALSE);
focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus"));
- get_ancestors (focus, GTK_TYPE_STACK, &stack, &parent);
- gtk_stack_set_visible_child (GTK_STACK (stack), parent);
gtk_widget_grab_focus (focus);
}
@@ -227,16 +224,12 @@ open_submenu (GtkWidget *button,
gpointer data)
{
GtkMenuTrackerItem *item = data;
- GtkWidget *stack;
- GtkWidget *child;
GtkWidget *focus;
if (gtk_menu_tracker_item_get_should_request_show (item))
gtk_menu_tracker_item_request_submenu_shown (item, TRUE);
focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus"));
- get_ancestors (focus, GTK_TYPE_STACK, &stack, &child);
- gtk_stack_set_visible_child (GTK_STACK (stack), child);
gtk_widget_grab_focus (focus);
}
@@ -254,17 +247,25 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
}
else if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU))
{
- widget = g_object_new (GTK_TYPE_MODEL_BUTTON, "has-submenu", TRUE, NULL);
+ GtkWidget *stack = NULL;
+ GtkWidget *parent = NULL;
+ gchar *name;
+
+ widget = g_object_new (GTK_TYPE_MODEL_BUTTON,
+ "menu-name", gtk_menu_tracker_item_get_label (item),
+ NULL);
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
- gtk_menu_section_box_new_submenu (item, box->toplevel, widget);
- gtk_widget_show (widget);
+
+ get_ancestors (GTK_WIDGET (box->item_box), GTK_TYPE_STACK, &stack, &parent);
+ gtk_container_child_get (GTK_CONTAINER (stack), parent, "name", &name, NULL);
+ gtk_menu_section_box_new_submenu (item, box->toplevel, widget, name);
+ g_free (name);
}
else
{
widget = gtk_model_button_new ();
-
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
if (box->iconic)
@@ -367,10 +368,11 @@ gtk_menu_section_box_new_toplevel (GtkStack *stack,
gtk_widget_show (GTK_WIDGET (box));
}
-void
+static void
gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
GtkMenuSectionBox *toplevel,
- GtkWidget *focus)
+ GtkWidget *focus,
+ const gchar *name)
{
GtkMenuSectionBox *box;
GtkWidget *button;
@@ -378,10 +380,11 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, "margin", 10, NULL);
button = g_object_new (GTK_TYPE_MODEL_BUTTON,
- "has-submenu", TRUE,
+ "menu-name", name,
"inverted", TRUE,
"centered", TRUE,
NULL);
+
g_object_bind_property (item, "label", button, "text", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "icon", button, "icon", G_BINDING_SYNC_CREATE);
@@ -404,7 +407,7 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
box);
}
-GtkWidget *
+static GtkWidget *
gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
GtkMenuSectionBox *parent)
{
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 9569fd1..aa54e4d 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -41,7 +41,6 @@ struct _GtkModelButton
GtkWidget *image;
GtkWidget *label;
gboolean active;
- gboolean has_submenu;
gboolean centered;
gboolean inverted;
gboolean iconic;
@@ -61,7 +60,6 @@ enum
PROP_TEXT,
PROP_ACTIVE,
PROP_ACCEL,
- PROP_HAS_SUBMENU,
PROP_MENU_NAME,
PROP_INVERTED,
PROP_CENTERED,
@@ -151,7 +149,7 @@ gtk_model_button_update_state (GtkModelButton *button)
state &= ~GTK_STATE_FLAG_CHECKED;
- if (button->active && !button->has_submenu)
+ if (button->active && !button->menu_name)
state |= GTK_STATE_FLAG_CHECKED;
gtk_widget_set_state_flags (GTK_WIDGET (button), state, TRUE);
@@ -168,15 +166,6 @@ gtk_model_button_set_active (GtkModelButton *button,
}
static void
-gtk_model_button_set_has_submenu (GtkModelButton *button,
- gboolean has_submenu)
-{
- button->has_submenu = has_submenu;
- gtk_model_button_update_state (button);
- gtk_widget_queue_resize (GTK_WIDGET (button));
-}
-
-static void
gtk_model_button_set_menu_name (GtkModelButton *button,
const gchar *menu_name)
{
@@ -282,10 +271,6 @@ gtk_model_button_set_property (GObject *object,
gtk_model_button_set_accel (button, g_value_get_string (value));
break;
- case PROP_HAS_SUBMENU:
- gtk_model_button_set_has_submenu (button, g_value_get_boolean (value));
- break;
-
case PROP_MENU_NAME:
gtk_model_button_set_menu_name (button, g_value_get_string (value));
break;
@@ -355,7 +340,7 @@ has_sibling_with_indicator (GtkWidget *button)
continue;
if (!sibling->centered &&
- (sibling->has_submenu || sibling->role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL))
+ (sibling->menu_name || sibling->role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL))
{
has_indicator = TRUE;
break;
@@ -647,7 +632,7 @@ gtk_model_button_draw (GtkWidget *widget,
width - 2 * border_width,
height - 2 * border_width);
- if (model_button->has_submenu)
+ if (model_button->menu_name)
{
GtkStateFlags state;
@@ -758,9 +743,6 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
g_object_class_install_property (object_class, PROP_ACCEL,
g_param_spec_string ("accel", "", "", NULL,
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_HAS_SUBMENU,
- g_param_spec_boolean ("has-submenu", "", "", FALSE,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_MENU_NAME,
g_param_spec_string ("menu-name", "", "", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]