Commit 8bf3ff8698d72468750ad9903c2fde6a7b0da7e0

Authored by Perry Werneck
1 parent f851f6c3

Changing action notifications to use pspec.

Showing 2 changed files with 27 additions and 16 deletions   Show diff stats
src/actions/abstract.c
... ... @@ -111,14 +111,6 @@
111 111 G_PARAM_CONSTRUCT_ONLY |
112 112 G_PARAM_STATIC_STRINGS));
113 113  
114   - g_object_class_install_property (object_class, PROP_ENABLED,
115   - g_param_spec_boolean ("enabled",
116   - N_("Enabled"),
117   - N_("If the action can be activated"),
118   - TRUE,
119   - G_PARAM_READWRITE |
120   - G_PARAM_STATIC_STRINGS));
121   -
122 114 g_object_class_install_property (object_class, PROP_STATE_TYPE,
123 115 g_param_spec_boxed ("state-type",
124 116 N_("State Type"),
... ... @@ -127,14 +119,31 @@
127 119 G_PARAM_READABLE |
128 120 G_PARAM_STATIC_STRINGS));
129 121  
130   - g_object_class_install_property (object_class, PROP_STATE,
131   - g_param_spec_variant ("state",
  122 + // Enabled property
  123 + klass->properties.enabled =
  124 + g_param_spec_boolean(
  125 + "enabled",
  126 + N_("Enabled"),
  127 + N_("If the action can be activated"),
  128 + TRUE,
  129 + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
  130 + );
  131 +
  132 + g_object_class_install_property(object_class, PROP_ENABLED, klass->properties.enabled);
  133 +
  134 + // State property
  135 + klass->properties.state =
  136 + g_param_spec_variant(
  137 + "state",
132 138 N_("State"),
133 139 N_("The state the action is in"),
134 140 G_VARIANT_TYPE_ANY,
135 141 NULL,
136 142 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
137   - G_PARAM_STATIC_STRINGS));
  143 + G_PARAM_STATIC_STRINGS
  144 + );
  145 +
  146 + g_object_class_install_property (object_class, PROP_STATE, klass->properties.state);
138 147  
139 148 // Install signals
140 149 action_signals[SIGNAL_CHANGE_STATE] =
... ... @@ -327,7 +336,7 @@
327 336 g_signal_emit(object, action_signals[SIGNAL_CHANGE_STATE], 0, value);
328 337 }
329 338  
330   - g_object_notify(G_OBJECT(object), "state");
  339 + g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.state);
331 340  
332 341 }
333 342  
... ... @@ -338,10 +347,7 @@
338 347 }
339 348  
340 349 void pw3270_action_set_enabled(GAction *object, gboolean state) {
341   -
342   -// pw3270Action * action = PW3270_ACTION(object);
343   -
344   - g_object_notify(G_OBJECT(object), "enabled");
  350 + g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.enabled);
345 351 }
346 352  
347 353  
... ...
src/actions/private.h
... ... @@ -64,6 +64,11 @@
64 64 struct _pw3270ActionClass {
65 65 GObjectClass parent_class;
66 66  
  67 + struct {
  68 + GParamSpec * state;
  69 + GParamSpec * enabled;
  70 + } properties;
  71 +
67 72 void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);
68 73 gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
69 74 void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
... ...