summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-09-06 10:45:33 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-09-06 17:11:36 -0400
commit0e4589d902ee30c77c14dd2e226a568c71e3183a (patch)
treeb34bd1a0687c3e012377b4ec97137d59ad4357ed
parent4c376d1a9ce4ee956c72165e0cc98b66e7e1f595 (diff)
downloadgtk+-0e4589d902ee30c77c14dd2e226a568c71e3183a.tar.gz
toggle button: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
-rw-r--r--gtk/gtktogglebutton.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index a808d184c6..bbe764bf92 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -119,9 +119,11 @@ enum {
PROP_0,
PROP_ACTIVE,
PROP_INCONSISTENT,
- PROP_DRAW_INDICATOR
+ PROP_DRAW_INDICATOR,
+ NUM_PROPERTIES
};
+static GParamSpec *toggle_button_props[NUM_PROPERTIES] = { NULL, };
static gboolean gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
@@ -173,29 +175,28 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
class->toggled = NULL;
- g_object_class_install_property (gobject_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- P_("Active"),
- P_("If the toggle button should be pressed in"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (gobject_class,
- PROP_INCONSISTENT,
- g_param_spec_boolean ("inconsistent",
- P_("Inconsistent"),
- P_("If the toggle button is in an \"in between\" state"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (gobject_class,
- PROP_DRAW_INDICATOR,
- g_param_spec_boolean ("draw-indicator",
- P_("Draw Indicator"),
- P_("If the toggle part of the button is displayed"),
- FALSE,
- GTK_PARAM_READWRITE));
+ toggle_button_props[PROP_ACTIVE] =
+ g_param_spec_boolean ("active",
+ P_("Active"),
+ P_("If the toggle button should be pressed in"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ toggle_button_props[PROP_INCONSISTENT] =
+ g_param_spec_boolean ("inconsistent",
+ P_("Inconsistent"),
+ P_("If the toggle button is in an \"in between\" state"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ toggle_button_props[PROP_DRAW_INDICATOR] =
+ g_param_spec_boolean ("draw-indicator",
+ P_("Draw Indicator"),
+ P_("If the toggle part of the button is displayed"),
+ FALSE,
+ GTK_PARAM_READWRITE);
+
+ g_object_class_install_properties (gobject_class, NUM_PROPERTIES, toggle_button_props);
/**
* GtkToggleButton::toggled:
@@ -414,7 +415,7 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
if (gtk_widget_get_visible (GTK_WIDGET (toggle_button)))
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
- g_object_notify (G_OBJECT (toggle_button), "draw-indicator");
+ g_object_notify_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_DRAW_INDICATOR]);
/* Make toggle buttons conditionally have the "button"
* class depending on draw_indicator.
@@ -471,7 +472,7 @@ gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
if (priv->active != is_active)
{
gtk_button_clicked (GTK_BUTTON (toggle_button));
- g_object_notify (G_OBJECT (toggle_button), "active");
+ g_object_notify_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_ACTIVE]);
}
}
@@ -557,7 +558,7 @@ gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
else
gtk_widget_unset_state_flags (GTK_WIDGET (toggle_button), GTK_STATE_FLAG_INCONSISTENT);
- g_object_notify (G_OBJECT (toggle_button), "inconsistent");
+ g_object_notify_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_INCONSISTENT]);
}
}
@@ -605,7 +606,7 @@ gtk_toggle_button_clicked (GtkButton *button)
gtk_toggle_button_toggled (toggle_button);
- g_object_notify (G_OBJECT (toggle_button), "active");
+ g_object_notify_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_ACTIVE]);
if (GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked)
GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked (button);