[gtk+] event controller: Convert to g_object_notify_by_pspec
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] event controller: Convert to g_object_notify_by_pspec
- Date: Sun, 6 Sep 2015 21:16:21 +0000 (UTC)
commit 89ca0db7c5c17017b1b6e32c0682dd43ecd738a0
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 6 10:46:15 2015 -0400
event controller: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
gtk/gtkeventcontroller.c | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkeventcontroller.c b/gtk/gtkeventcontroller.c
index 5449846..28a3689 100644
--- a/gtk/gtkeventcontroller.c
+++ b/gtk/gtkeventcontroller.c
@@ -42,9 +42,12 @@ typedef struct _GtkEventControllerPrivate GtkEventControllerPrivate;
enum {
PROP_WIDGET = 1,
- PROP_PROPAGATION_PHASE
+ PROP_PROPAGATION_PHASE,
+ LAST_PROP
};
+static GParamSpec *properties[LAST_PROP] = { NULL, };
+
struct _GtkEventControllerPrivate
{
GtkWidget *widget;
@@ -160,14 +163,12 @@ gtk_event_controller_class_init (GtkEventControllerClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_WIDGET,
- g_param_spec_object ("widget",
- P_("Widget"),
- P_("Widget the gesture relates to"),
- GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ properties[PROP_WIDGET] =
+ g_param_spec_object ("widget",
+ P_("Widget"),
+ P_("Widget the gesture relates to"),
+ GTK_TYPE_WIDGET,
+ GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
/**
* GtkEventController:propagation-phase:
*
@@ -175,14 +176,15 @@ gtk_event_controller_class_init (GtkEventControllerClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_PROPAGATION_PHASE,
- g_param_spec_enum ("propagation-phase",
- P_("Propagation phase"),
- P_("Propagation phase at which this controller is
run"),
- GTK_TYPE_PROPAGATION_PHASE,
- GTK_PHASE_BUBBLE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+ properties[PROP_PROPAGATION_PHASE] =
+ g_param_spec_enum ("propagation-phase",
+ P_("Propagation phase"),
+ P_("Propagation phase at which this controller is run"),
+ GTK_TYPE_PROPAGATION_PHASE,
+ GTK_PHASE_BUBBLE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
}
static void
@@ -359,5 +361,5 @@ gtk_event_controller_set_propagation_phase (GtkEventController *controller,
if (phase == GTK_PHASE_NONE)
gtk_event_controller_reset (controller);
- g_object_notify (G_OBJECT (controller), "propagation-phase");
+ g_object_notify_by_pspec (G_OBJECT (controller), properties[PROP_PROPAGATION_PHASE]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]