[gtk+/popover-menu: 2/17] Make GtkModelButton a better GtkActionable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/popover-menu: 2/17] Make GtkModelButton a better GtkActionable
- Date: Sun, 26 Oct 2014 15:31:27 +0000 (UTC)
commit 49e074f4064a4d7cc70fc74c543b45e44b25e249
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 23 21:43:28 2014 -0400
Make GtkModelButton a better GtkActionable
Rename the "toggled" property to "active", since that is what
GtkActionHelper expects to update for check and radio actions.
Also make the property readable, since GtkActionHelper wants
to read it.
gtk/gtkmenusectionbox.c | 2 +-
gtk/gtkmodelbutton.c | 45 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index 648e933..34097ff 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -278,7 +278,7 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "role", widget, "action-role", G_BINDING_SYNC_CREATE);
- g_object_bind_property (item, "toggled", widget, "toggled", G_BINDING_SYNC_CREATE);
+ g_object_bind_property (item, "toggled", widget, "active", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "accel", widget, "accel", G_BINDING_SYNC_CREATE);
g_signal_connect (widget, "clicked", G_CALLBACK (gtk_popover_item_activate), item);
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 6cc201c..a45169c 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -38,7 +38,7 @@ struct _GtkModelButton
GtkWidget *box;
GtkWidget *image;
GtkWidget *label;
- gboolean toggled;
+ gboolean active;
gboolean has_submenu;
gboolean centered;
gboolean inverted;
@@ -56,7 +56,7 @@ enum
PROP_ACTION_ROLE,
PROP_ICON,
PROP_TEXT,
- PROP_TOGGLED,
+ PROP_ACTIVE,
PROP_ACCEL,
PROP_HAS_SUBMENU,
PROP_INVERTED,
@@ -140,11 +140,14 @@ gtk_model_button_update_state (GtkModelButton *button)
{
GtkStateFlags state;
+ if (button->role == GTK_MENU_TRACKER_ITEM_ROLE_NORMAL)
+ return;
+
state = gtk_widget_get_state_flags (GTK_WIDGET (button));
state &= ~GTK_STATE_FLAG_CHECKED;
- if (button->toggled && !button->has_submenu)
+ if (button->active && !button->has_submenu)
state |= GTK_STATE_FLAG_CHECKED;
gtk_widget_set_state_flags (GTK_WIDGET (button), state, TRUE);
@@ -152,10 +155,10 @@ gtk_model_button_update_state (GtkModelButton *button)
static void
-gtk_model_button_set_toggled (GtkModelButton *button,
- gboolean toggled)
+gtk_model_button_set_active (GtkModelButton *button,
+ gboolean active)
{
- button->toggled = toggled;
+ button->active = active;
gtk_model_button_update_state (button);
gtk_widget_queue_draw (GTK_WIDGET (button));
}
@@ -213,6 +216,25 @@ gtk_model_button_set_iconic (GtkModelButton *button,
}
static void
+gtk_model_button_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkModelButton *button = GTK_MODEL_BUTTON (object);
+
+ switch (prop_id)
+ {
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, button->active);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
gtk_model_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -234,8 +256,8 @@ gtk_model_button_set_property (GObject *object,
gtk_model_button_set_text (button, g_value_get_string (value));
break;
- case PROP_TOGGLED:
- gtk_model_button_set_toggled (button, g_value_get_boolean (value));
+ case PROP_ACTIVE:
+ gtk_model_button_set_active (button, g_value_get_boolean (value));
break;
case PROP_ACCEL:
@@ -661,6 +683,7 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ object_class->get_property = gtk_model_button_get_property;
object_class->set_property = gtk_model_button_set_property;
widget_class->get_preferred_width = gtk_model_button_get_preferred_width;
@@ -682,9 +705,9 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
g_object_class_install_property (object_class, PROP_TEXT,
g_param_spec_string ("text", "", "", NULL,
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_TOGGLED,
- g_param_spec_boolean ("toggled", "", "", FALSE,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_ACTIVE,
+ g_param_spec_boolean ("active", "", "", FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ACCEL,
g_param_spec_string ("accel", "", "", NULL,
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]