Commit 397032053791e9742fad4e105121099e681237d5
1 parent
126d58cf
Exists in
master
and in
1 other branch
Adjustments in the action object.
Showing
5 changed files
with
44 additions
and
24 deletions
Show diff stats
src/include/v3270/actions.h
... | ... | @@ -138,16 +138,16 @@ |
138 | 138 | GParamSpec * enabled; |
139 | 139 | } properties; |
140 | 140 | |
141 | - struct { | |
142 | - const GVariantType * state; ///> @brief State type. | |
143 | - const GVariantType * parameter; ///> @brief State type. | |
144 | - } type; | |
141 | + void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
145 | 142 | |
146 | - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
143 | + const gchar * (*translate)(GAction *action, const gchar *text); | |
147 | 144 | |
148 | - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
145 | + const GVariantType * (*get_state_type)(GAction *object); | |
149 | 146 | GVariant * (*get_state)(GAction *action, GtkWidget *terminal); |
150 | - const gchar * (*translate)(GAction *action, const gchar *text); | |
147 | + | |
148 | + const GVariantType * (*get_parameter_type)(GAction *object); | |
149 | + | |
150 | + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
151 | 151 | |
152 | 152 | const gchar * (*get_name)(GAction *action); |
153 | 153 | const gchar * (*get_icon_name)(GAction *action); | ... | ... |
src/terminal/actions/action.c
... | ... | @@ -43,10 +43,12 @@ |
43 | 43 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
44 | 44 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
45 | 45 | |
46 | - static const gchar * get_icon_name(GAction *action); | |
47 | - static const gchar * get_label(GAction *action); | |
48 | - static const gchar * get_tooltip(GAction *action); | |
49 | - static const gchar * get_name(GAction *action); | |
46 | + static const gchar * get_icon_name(GAction *action); | |
47 | + static const gchar * get_label(GAction *action); | |
48 | + static const gchar * get_tooltip(GAction *action); | |
49 | + static const gchar * get_name(GAction *action); | |
50 | + static const GVariantType * get_state_type(GAction *action); | |
51 | + static const GVariantType * get_parameter_type(GAction *object); | |
50 | 52 | |
51 | 53 | static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to); |
52 | 54 | static void finalize(GObject *object); |
... | ... | @@ -95,9 +97,8 @@ |
95 | 97 | klass->get_icon_name = get_icon_name; |
96 | 98 | klass->get_label = get_label; |
97 | 99 | klass->get_tooltip = get_tooltip; |
98 | - | |
99 | - klass->type.state = NULL; | |
100 | - klass->type.parameter = NULL; | |
100 | + klass->get_state_type = get_state_type; | |
101 | + klass->get_parameter_type = get_parameter_type; | |
101 | 102 | |
102 | 103 | object_class->finalize = finalize; |
103 | 104 | object_class->get_property = get_property; |
... | ... | @@ -267,7 +268,7 @@ |
267 | 268 | } |
268 | 269 | |
269 | 270 | void v3270_action_notify_state(GAction *action) { |
270 | - if(V3270_ACTION_GET_CLASS(action)->type.state) | |
271 | + if(g_action_get_state_type(action)) | |
271 | 272 | g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action)); |
272 | 273 | } |
273 | 274 | |
... | ... | @@ -294,8 +295,7 @@ |
294 | 295 | |
295 | 296 | g_idle_add((GSourceFunc) bg_notify_enabled, G_OBJECT(action)); |
296 | 297 | |
297 | - if(V3270_ACTION_GET_CLASS(action)->type.state) | |
298 | - g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action)); | |
298 | + v3270_action_notify_state(object); | |
299 | 299 | |
300 | 300 | } |
301 | 301 | |
... | ... | @@ -405,9 +405,9 @@ |
405 | 405 | |
406 | 406 | GVariant * state = NULL; |
407 | 407 | |
408 | - if(V3270_ACTION_GET_CLASS(object)->type.state) { | |
408 | + if(g_action_get_state_type(object)) { | |
409 | 409 | |
410 | - GtkWidget * terminal = V3270_ACTION(object)->terminal; | |
410 | + GtkWidget * terminal = V3270_ACTION(object)->terminal; | |
411 | 411 | |
412 | 412 | if(terminal) { |
413 | 413 | state = V3270_ACTION_GET_CLASS(object)->get_state(object,terminal); |
... | ... | @@ -424,12 +424,13 @@ |
424 | 424 | |
425 | 425 | } |
426 | 426 | |
427 | + | |
427 | 428 | const GVariantType * iface_get_parameter_type(GAction *object) { |
428 | - return V3270_ACTION_GET_CLASS(object)->type.parameter; | |
429 | + return V3270_ACTION_GET_CLASS(object)->get_parameter_type(object); | |
429 | 430 | } |
430 | 431 | |
431 | 432 | const GVariantType * iface_get_state_type(GAction *object) { |
432 | - return V3270_ACTION_GET_CLASS(object)->type.state; | |
433 | + return V3270_ACTION_GET_CLASS(object)->get_state_type(object); | |
433 | 434 | } |
434 | 435 | |
435 | 436 | GVariant * iface_get_state_hint(GAction G_GNUC_UNUSED(*object)) { |
... | ... | @@ -515,3 +516,10 @@ |
515 | 516 | return V3270_ACTION_GET_CLASS(action)->get_tooltip(action); |
516 | 517 | } |
517 | 518 | |
519 | + const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) { | |
520 | + return NULL; | |
521 | + } | |
522 | + | |
523 | + const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { | |
524 | + return NULL; | |
525 | + } | ... | ... |
src/terminal/actions/pakey.c
... | ... | @@ -82,8 +82,12 @@ |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { | |
86 | + return G_VARIANT_TYPE_UINT32; | |
87 | + } | |
88 | + | |
85 | 89 | void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) { |
86 | - klass->parent_class.type.parameter = G_VARIANT_TYPE_UINT32; | |
90 | + klass->parent_class.get_parameter_type = get_parameter_type; | |
87 | 91 | } |
88 | 92 | |
89 | 93 | void Lib3270PaAction_init(Lib3270PaAction *action) { | ... | ... |
src/terminal/actions/pfkey.c
... | ... | @@ -82,8 +82,12 @@ |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { | |
86 | + return G_VARIANT_TYPE_UINT32; | |
87 | + } | |
88 | + | |
85 | 89 | void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) { |
86 | - klass->parent_class.type.parameter = G_VARIANT_TYPE_UINT32; | |
90 | + klass->parent_class.get_parameter_type = get_parameter_type; | |
87 | 91 | } |
88 | 92 | |
89 | 93 | void Lib3270PfAction_init(Lib3270PfAction *action) { | ... | ... |
src/terminal/actions/toggle.c
... | ... | @@ -107,11 +107,15 @@ |
107 | 107 | |
108 | 108 | } |
109 | 109 | |
110 | + static const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) { | |
111 | + return G_VARIANT_TYPE_BOOLEAN; | |
112 | + } | |
113 | + | |
110 | 114 | void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { |
111 | 115 | |
112 | 116 | klass->parent_class.change_widget = change_widget; |
113 | - klass->parent_class.type.state = G_VARIANT_TYPE_BOOLEAN; | |
114 | 117 | klass->parent_class.get_state = get_state; |
118 | + klass->parent_class.get_state_type = get_state_type; | |
115 | 119 | |
116 | 120 | } |
117 | 121 | ... | ... |