Commit ee3269dbb8cc080dc2a6cd54138c4fd3df3447e7

Authored by Perry Werneck
1 parent a221488b
Exists in master and in 1 other branch develop

Refactoring actions to fix problem with the screen-size action behavior.

src/include/v3270/actions.h
... ... @@ -32,6 +32,7 @@
32 32 #define V3270_ACTIONS_H_INCLUDED 1
33 33  
34 34 #include <gtk/gtk.h>
  35 + #include <lib3270.h>
35 36 #include <lib3270/actions.h>
36 37 #include <lib3270/toggle.h>
37 38  
... ... @@ -119,14 +120,10 @@
119 120 GObject parent;
120 121  
121 122 GtkWidget * terminal; ///> @brief The active terminal widget.
122   - const LIB3270_PROPERTY * info; ///> @brief Action info.
123 123 const void * listener; ///> @brief Signal listener for the action group.
124 124  
125 125 const gchar * translation_domain; ///> @brief The translation domain for the action.
126 126  
127   - /// @brief Activation method.
128   - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
129   -
130 127 } V3270Action;
131 128  
132 129 typedef struct _V3270ActionClass {
... ... @@ -138,21 +135,24 @@
138 135 GParamSpec * enabled;
139 136 } properties;
140 137  
141   - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);
  138 + void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
142 139  
143   - const gchar * (*translate)(GAction *action, const gchar *text);
  140 + void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);
144 141  
145   - const GVariantType * (*get_state_type)(GAction *object);
146   - GVariant * (*get_state)(GAction *action, GtkWidget *terminal);
  142 + const gchar * (*translate)(GAction *action, const gchar *text);
147 143  
148   - const GVariantType * (*get_parameter_type)(GAction *object);
  144 + const GVariantType * (*get_state_type)(GAction *object);
  145 + GVariant * (*get_state)(GAction *action, GtkWidget *terminal);
149 146  
150   - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
  147 + const GVariantType * (*get_parameter_type)(GAction *object);
151 148  
152   - const gchar * (*get_name)(GAction *action);
153   - const gchar * (*get_icon_name)(GAction *action);
154   - const gchar * (*get_label)(GAction *action);
155   - const gchar * (*get_tooltip)(GAction *action);
  149 + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
  150 +
  151 + const gchar * (*get_name)(GAction *action);
  152 + const gchar * (*get_icon_name)(GAction *action);
  153 + const gchar * (*get_label)(GAction *action);
  154 + const gchar * (*get_tooltip)(GAction *action);
  155 + LIB3270_ACTION_GROUP (*get_action_group)(GAction *action);
156 156  
157 157 } V3270ActionClass;
158 158  
... ... @@ -162,6 +162,8 @@
162 162 LIB3270_EXPORT void v3270_action_set_terminal_widget(GAction *object, GtkWidget *widget);
163 163 LIB3270_EXPORT GtkWidget * v3270_action_get_terminal_widget(GAction *object);
164 164  
  165 + LIB3270_EXPORT LIB3270_ACTION_GROUP v3270_action_get_group(GAction *action);
  166 +
165 167 LIB3270_EXPORT void v3270_action_notify_state(GAction *action);
166 168 LIB3270_EXPORT void v3270_action_notify_enabled(GAction *action);
167 169  
... ... @@ -213,6 +215,7 @@
213 215 /// @brief Activation method.
214 216 void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
215 217  
  218 +
216 219 } V3270SimpleAction;
217 220  
218 221 typedef struct _V3270SimpleActionClass {
... ...
src/terminal/actions/action.c
... ... @@ -34,8 +34,6 @@
34 34 #include <lib3270.h>
35 35 #include <lib3270/log.h>
36 36  
37   - #define V3270_ACTION_GET_DESCRIPTOR(obj) ((V3270Action *) obj)->info
38   -
39 37 static void V3270_action_iface_init(GActionInterface *iface);
40 38 static void V3270Action_class_init(V3270ActionClass *klass);
41 39 static void V3270Action_init(V3270Action *action);
... ... @@ -43,12 +41,10 @@
43 41 static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
44 42 static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
45 43  
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);
  44 + static const gchar * get_null(GAction *action);
50 45 static const GVariantType * get_state_type(GAction *action);
51 46 static const GVariantType * get_parameter_type(GAction *object);
  47 + static LIB3270_ACTION_GROUP get_action_group(GAction *action);
52 48  
53 49 static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to);
54 50 static void finalize(GObject *object);
... ... @@ -88,15 +84,18 @@
88 84  
89 85 debug("%s",__FUNCTION__);
90 86  
  87 + klass->get_name = get_null;
  88 + klass->get_icon_name = get_null;
  89 + klass->get_label = get_null;
  90 + klass->get_tooltip = get_null;
  91 + klass->get_action_group = get_action_group;
  92 +
91 93 klass->change_widget = change_widget;
92 94 klass->get_enabled = get_enabled;
93 95 klass->get_state = get_state;
94   - klass->get_name = get_name;
95 96 klass->translate = translate;
  97 + klass->activate = activate;
96 98  
97   - klass->get_icon_name = get_icon_name;
98   - klass->get_label = get_label;
99   - klass->get_tooltip = get_tooltip;
100 99 klass->get_state_type = get_state_type;
101 100 klass->get_parameter_type = get_parameter_type;
102 101  
... ... @@ -180,13 +179,7 @@
180 179  
181 180 void V3270Action_init(V3270Action *action) {
182 181  
183   - static const LIB3270_PROPERTY default_info = {
184   - .name = NULL
185   - };
186   -
187   - action->terminal = NULL;
188   - action->info = &default_info;
189   - action->activate = activate;
  182 + action->terminal = NULL;
190 183  
191 184 }
192 185  
... ... @@ -280,17 +273,18 @@
280 273  
281 274 if(from != to) {
282 275  
283   - V3270Action *action = V3270_ACTION(object);
  276 + V3270Action *action = V3270_ACTION(object);
  277 + LIB3270_ACTION_GROUP group = v3270_action_get_group(object);
284 278  
285 279 if(action->listener) {
286   - lib3270_unregister_action_group_listener(v3270_action_get_session(object),action->info->group,action->listener);
  280 + lib3270_unregister_action_group_listener(v3270_action_get_session(object),group,action->listener);
287 281 action->listener = NULL;
288 282 }
289 283  
290 284 action->terminal = to;
291 285  
292   - if(action->info->group != LIB3270_ACTION_GROUP_NONE && to) {
293   - action->listener = lib3270_register_action_group_listener(v3270_action_get_session(object),action->info->group,event_listener,object);
  286 + if(group != LIB3270_ACTION_GROUP_NONE && to) {
  287 + action->listener = lib3270_register_action_group_listener(v3270_action_get_session(object),group,event_listener,object);
294 288 }
295 289  
296 290 g_idle_add((GSourceFunc) bg_notify_enabled, G_OBJECT(action));
... ... @@ -323,18 +317,29 @@
323 317 return V3270_ACTION(object)->terminal;
324 318 }
325 319  
326   - gboolean get_enabled(GAction G_GNUC_UNUSED(*object), GtkWidget *terminal) {
327   - return terminal != NULL;
  320 + gboolean get_enabled(GAction *object, GtkWidget *terminal) {
  321 +
  322 + if(terminal == NULL)
  323 + return FALSE;
  324 +
  325 + LIB3270_ACTION_GROUP group = v3270_action_get_group(object);
  326 +
  327 + debug("**************** %s(%d %d)",g_action_get_name(object),(int) group, (int) LIB3270_ACTION_GROUP_NONE);
  328 +
  329 + if(group != LIB3270_ACTION_GROUP_NONE) {
  330 +
  331 + debug("**************** %s",g_action_get_name(object));
  332 +
  333 + return FALSE;
  334 + }
  335 +
  336 + return TRUE;
328 337 }
329 338  
330 339 void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) {
331 340 g_message("Action %s can't be activated",g_action_get_name(action));
332 341 }
333 342  
334   - const gchar * v3270_action_translate(GAction *action, const gchar *text) {
335   - return V3270_ACTION_GET_CLASS(action)->translate(action,text);
336   - }
337   -
338 343 //
339 344 // Action methods.
340 345 //
... ... @@ -447,9 +452,11 @@
447 452  
448 453 if(action && action->terminal) {
449 454  
450   - if(action->info->group != LIB3270_ACTION_GROUP_NONE) {
  455 + LIB3270_ACTION_GROUP group = v3270_action_get_group(object);
451 456  
452   - if(!lib3270_action_group_get_activatable(v3270_get_session(action->terminal),action->info->group))
  457 + if(group != LIB3270_ACTION_GROUP_NONE) {
  458 +
  459 + if(!lib3270_action_group_get_activatable(v3270_get_session(action->terminal),group))
453 460 return FALSE;
454 461  
455 462 }
... ... @@ -466,42 +473,33 @@
466 473 V3270Action * action = V3270_ACTION(object);
467 474  
468 475 if(action && action->terminal) {
469   - action->activate(object,parameter,action->terminal);
  476 + V3270_ACTION_GET_CLASS(object)->activate(object,parameter,action->terminal);
470 477 }
471 478  
472 479 }
473 480  
474   - const gchar * get_icon_name(GAction *action) {
475   - return V3270_ACTION_GET_DESCRIPTOR(action)->icon;
  481 + LIB3270_ACTION_GROUP get_action_group(GAction G_GNUC_UNUSED(*action)) {
  482 + return LIB3270_ACTION_GROUP_NONE;
476 483 }
477 484  
478   - const gchar * get_label(GAction *action) {
479   - const gchar * label = V3270_ACTION_GET_DESCRIPTOR(action)->label;
480   -
481   - debug("%s(%s): [%s] [%s]",__FUNCTION__,g_action_get_name(action),label,v3270_action_translate(action,label));
482   -
483   - if(label && *label)
484   - return v3270_action_translate(action,label);
485   -
  485 + const gchar * get_null(GAction G_GNUC_UNUSED(*action)) {
486 486 return NULL;
487 487 }
488 488  
489   - const gchar * get_tooltip(GAction *action) {
490   -
491   - const gchar * tooltip = V3270_ACTION_GET_DESCRIPTOR(action)->description;
492   -
493   - if(!tooltip)
494   - tooltip = V3270_ACTION_GET_DESCRIPTOR(action)->summary;
495   -
496   - if(tooltip)
497   - return v3270_action_translate(action,tooltip);
  489 + const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) {
  490 + return NULL;
  491 + }
498 492  
499   - return NULL;
  493 + const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) {
  494 + return NULL;
  495 + }
500 496  
  497 + const gchar * v3270_action_translate(GAction *action, const gchar *text) {
  498 + return V3270_ACTION_GET_CLASS(action)->translate(action,text);
501 499 }
502 500  
503   - const gchar * get_name(GAction *action) {
504   - return V3270_ACTION_GET_DESCRIPTOR(action)->name;
  501 + LIB3270_ACTION_GROUP v3270_action_get_group(GAction *action) {
  502 + return V3270_ACTION_GET_CLASS(action)->get_action_group(action);
505 503 }
506 504  
507 505 const gchar * v3270_action_get_icon_name(GAction *action) {
... ... @@ -509,17 +507,9 @@
509 507 }
510 508  
511 509 const gchar * v3270_action_get_label(GAction *action) {
512   - return V3270_ACTION_GET_CLASS(action)->get_label(action);
  510 + return v3270_action_translate(action,V3270_ACTION_GET_CLASS(action)->get_label(action));
513 511 }
514 512  
515 513 const gchar * v3270_action_get_tooltip(GAction *action) {
516   - return V3270_ACTION_GET_CLASS(action)->get_tooltip(action);
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;
  514 + return v3270_action_translate(action,v3270_action_translate(action,V3270_ACTION_GET_CLASS(action)->get_tooltip(action)));
525 515 }
... ...
src/terminal/actions/dialog.c
... ... @@ -77,13 +77,13 @@
77 77 }
78 78  
79 79 static void V3270DialogAction_class_init(V3270DialogActionClass *klass) {
80   - klass->parent_class.parent_class.get_enabled = get_enabled;
  80 + klass->parent_class.parent_class.get_enabled = get_enabled;
  81 + klass->parent_class.parent_class.activate = activate;
81 82 }
82 83  
83 84 static void V3270DialogAction_init(V3270DialogAction *action) {
84 85  
85 86 action->dialog = NULL;
86   - action->parent.parent.activate = activate;
87 87  
88 88 }
89 89  
... ...
src/terminal/actions/lib3270.c
... ... @@ -36,23 +36,12 @@
36 36 #include <lib3270/actions.h>
37 37 #include <v3270.h>
38 38 #include <v3270/actions.h>
39   -
40   - #define LIB3270_TYPE_ACTION (Lib3270Action_get_type())
41   - #define LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_ACTION, Lib3270Action))
42   - #define LIB3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_ACTION))
43   -
44   - typedef struct _Lib3270ActionClass {
45   - V3270ActionClass parent_class;
46   - } Lib3270ActionClass;
47   -
48   - typedef struct _Lib3270Action {
49   - V3270Action parent;
50   - } Lib3270Action;
  39 + #include "private.h"
51 40  
52 41 static void Lib3270Action_class_init(Lib3270ActionClass *klass);
53 42 static void Lib3270Action_init(Lib3270Action *action);
54 43  
55   - #define LIB3270_ACTION_GET_DESCRIPTOR(obj) ((LIB3270_ACTION *) ((V3270Action *) obj)->info)
  44 + #define LIB3270_ACTION_GET_DESCRIPTOR(obj) ((const LIB3270_ACTION *) LIB3270_ACTION(obj)->definition)
56 45  
57 46 G_DEFINE_TYPE(Lib3270Action, Lib3270Action, V3270_TYPE_ACTION);
58 47  
... ... @@ -85,21 +74,47 @@
85 74  
86 75 static void dispose(GObject *object) {
87 76  
88   - //Lib3270Action *action = LIB3270_ACTION(object);
  77 +// Lib3270Action *action = LIB3270_ACTION(object);
89 78  
90 79  
91 80 G_OBJECT_CLASS(Lib3270Action_parent_class)->dispose(object);
92 81 }
93 82  
  83 + static const gchar * get_name(GAction *action) {
  84 + return LIB3270_ACTION_GET_DESCRIPTOR(action)->name;
  85 + }
  86 +
  87 + static const gchar * get_icon_name(GAction *action) {
  88 + return LIB3270_ACTION_GET_DESCRIPTOR(action)->icon;
  89 + }
  90 +
  91 + static const gchar * get_label(GAction *action) {
  92 + return LIB3270_ACTION_GET_DESCRIPTOR(action)->label;
  93 + }
  94 +
  95 + static const gchar * get_tooltip(GAction *action) {
  96 + return LIB3270_ACTION_GET_DESCRIPTOR(action)->summary;
  97 + }
  98 +
  99 + static LIB3270_ACTION_GROUP get_action_group(GAction *action) {
  100 + return LIB3270_ACTION_GET_DESCRIPTOR(action)->group;
  101 + }
  102 +
94 103 void Lib3270Action_class_init(Lib3270ActionClass *klass) {
95 104  
96   - V3270_ACTION_CLASS(klass)->get_enabled = get_enabled;
  105 + klass->parent_class.get_name = get_name;
  106 + klass->parent_class.get_icon_name = get_icon_name;
  107 + klass->parent_class.get_label = get_label;
  108 + klass->parent_class.get_tooltip = get_tooltip;
  109 + klass->parent_class.get_action_group = get_action_group;
  110 + klass->parent_class.get_enabled = get_enabled;
  111 + klass->parent_class.activate = activate;
  112 +
97 113 G_OBJECT_CLASS(klass)->dispose = dispose;
98 114  
99 115 }
100 116  
101 117 void Lib3270Action_init(Lib3270Action *action) {
102   - action->parent.activate = activate;
103 118 action->parent.translation_domain = lib3270_get_translation_domain();
104 119 }
105 120  
... ... @@ -108,7 +123,7 @@
108 123 Lib3270Action * action = (Lib3270Action *) g_object_new(LIB3270_TYPE_ACTION, NULL);
109 124  
110 125 // Setup hooks.
111   - action->parent.info = (const LIB3270_PROPERTY *) definition;
  126 + action->definition = definition;
112 127  
113 128 return G_ACTION(action);
114 129 }
... ... @@ -123,7 +138,7 @@
123 138 GAction *action = g_action_new_from_lib3270(&actions[ix]);
124 139  
125 140 if(!g_action_get_name(action)) {
126   - g_warning("Action \"%s\" is invalid",actions[ix].name);
  141 + g_warning("Action \"%s\" is invalid (no name)",actions[ix].name);
127 142 } else {
128 143 g_action_map_add_action(action_map,action);
129 144 }
... ...
src/terminal/actions/pakey.c
... ... @@ -35,24 +35,25 @@
35 35 #include <internals.h>
36 36 #include <v3270.h>
37 37 #include <v3270/actions.h>
  38 + #include "private.h"
38 39  
39 40 #define LIB3270_TYPE_PA_ACTION (Lib3270PaAction_get_type())
40 41 #define LIB3270_PA_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_PA_ACTION, Lib3270PaAction))
41 42 #define LIB3270_IS_PA_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_PA_ACTION))
42 43  
43 44 typedef struct _Lib3270PaActionClass {
44   - V3270ActionClass parent_class;
  45 + Lib3270ActionClass parent_class;
45 46  
46 47 } Lib3270PaActionClass;
47 48  
48 49 typedef struct _Lib3270PaAction {
49   - V3270Action parent;
  50 + Lib3270Action parent;
50 51 } Lib3270PaAction;
51 52  
52 53 static void Lib3270PaAction_class_init(Lib3270PaActionClass *klass);
53 54 static void Lib3270PaAction_init(Lib3270PaAction *action);
54 55  
55   - G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, V3270_TYPE_ACTION);
  56 + G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, LIB3270_TYPE_ACTION);
56 57  
57 58 static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
58 59  
... ... @@ -86,8 +87,14 @@
86 87 return G_VARIANT_TYPE_UINT32;
87 88 }
88 89  
  90 + static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
  91 + return V3270_ACTION_GET_CLASS(action)->get_enabled(action,terminal);
  92 + }
  93 +
89 94 void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) {
90   - klass->parent_class.get_parameter_type = get_parameter_type;
  95 + klass->parent_class.parent_class.get_parameter_type = get_parameter_type;
  96 + klass->parent_class.parent_class.activate = activate;
  97 + klass->parent_class.parent_class.get_enabled = get_enabled;
91 98 }
92 99  
93 100 void Lib3270PaAction_init(Lib3270PaAction *action) {
... ... @@ -98,9 +105,8 @@
98 105 .summary = N_("Emit a PA Key action")
99 106 };
100 107  
101   - action->parent.activate = activate;
102   - action->parent.info = &info;
103   - action->parent.translation_domain = GETTEXT_PACKAGE;
  108 + action->parent.definition = &info;
  109 + action->parent.parent.translation_domain = GETTEXT_PACKAGE;
104 110  
105 111 }
106 112  
... ...
src/terminal/actions/pfkey.c
... ... @@ -35,24 +35,25 @@
35 35 #include <internals.h>
36 36 #include <v3270.h>
37 37 #include <v3270/actions.h>
  38 + #include "private.h"
38 39  
39 40 #define LIB3270_TYPE_PF_ACTION (Lib3270PfAction_get_type())
40 41 #define LIB3270_PF_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_PF_ACTION, Lib3270PfAction))
41 42 #define LIB3270_IS_PF_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_PF_ACTION))
42 43  
43 44 typedef struct _Lib3270PfActionClass {
44   - V3270ActionClass parent_class;
  45 + Lib3270ActionClass parent_class;
45 46  
46 47 } Lib3270PfActionClass;
47 48  
48 49 typedef struct _Lib3270PfAction {
49   - V3270Action parent;
  50 + Lib3270Action parent;
50 51 } Lib3270PfAction;
51 52  
52 53 static void Lib3270PfAction_class_init(Lib3270PfActionClass *klass);
53 54 static void Lib3270PfAction_init(Lib3270PfAction *action);
54 55  
55   - G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, V3270_TYPE_ACTION);
  56 + G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, LIB3270_TYPE_ACTION);
56 57  
57 58 static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
58 59  
... ... @@ -86,8 +87,15 @@
86 87 return G_VARIANT_TYPE_UINT32;
87 88 }
88 89  
  90 + static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
  91 + return V3270_ACTION_GET_CLASS(action)->get_enabled(action,terminal);
  92 + }
  93 +
89 94 void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) {
90   - klass->parent_class.get_parameter_type = get_parameter_type;
  95 + klass->parent_class.parent_class.get_parameter_type = get_parameter_type;
  96 + klass->parent_class.parent_class.activate = activate;
  97 + klass->parent_class.parent_class.get_enabled = get_enabled;
  98 +
91 99 }
92 100  
93 101 void Lib3270PfAction_init(Lib3270PfAction *action) {
... ... @@ -99,9 +107,8 @@
99 107  
100 108 };
101 109  
102   - action->parent.activate = activate;
103   - action->parent.info = &info;
104   - action->parent.translation_domain = GETTEXT_PACKAGE;
  110 + action->parent.definition = &info;
  111 + action->parent.parent.translation_domain = GETTEXT_PACKAGE;
105 112  
106 113 }
107 114  
... ...
src/terminal/actions/private.h
... ... @@ -28,10 +28,33 @@
28 28 */
29 29  
30 30 #include <config.h>
  31 +
  32 + #include <glib.h>
  33 + #include <gtk/gtk.h>
  34 +
31 35 #include <v3270.h>
32 36 #include <v3270/actions.h>
33 37 #include <internals.h>
34 38  
  39 + // Lib3270 action
  40 +
  41 + G_GNUC_INTERNAL GType Lib3270Action_get_type(void) G_GNUC_CONST;
  42 +
  43 + #define LIB3270_TYPE_ACTION (Lib3270Action_get_type())
  44 + #define LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_ACTION, Lib3270Action))
  45 + #define LIB3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_ACTION))
  46 +
  47 + typedef struct _Lib3270ActionClass {
  48 + V3270ActionClass parent_class;
  49 + } Lib3270ActionClass;
  50 +
  51 + typedef struct _Lib3270Action {
  52 + V3270Action parent;
  53 + const LIB3270_PROPERTY * definition;
  54 + } Lib3270Action;
  55 +
  56 +
  57 + // Internal methods
35 58 G_GNUC_INTERNAL int fire_copy_accelerator(GtkWidget *widget, const V3270_ACTION *action);
36 59 G_GNUC_INTERNAL int fire_paste_accelerator(GtkWidget *widget, const V3270_ACTION *action);
37 60 G_GNUC_INTERNAL int fire_zoom_action(GtkWidget *widget, const V3270_ACTION *action);
... ...
src/terminal/actions/property.c
... ... @@ -73,14 +73,17 @@
73 73 static const GVariantType * get_state_type(GAction *object);
74 74 static const GVariantType * get_parameter_type(GAction *object);
75 75 static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to);
  76 + static void activate(GAction *object, GVariant *parameter, GtkWidget *terminal);
  77 +
76 78  
77 79 G_DEFINE_TYPE(v3270PropertyAction, v3270PropertyAction, V3270_TYPE_SIMPLE_ACTION);
78 80  
79 81 void v3270PropertyAction_class_init(v3270PropertyActionClass *klass) {
80   - klass->parent_class.parent_class.change_widget = change_widget;
81   - klass->parent_class.parent_class.get_parameter_type = get_parameter_type;
82   - klass->parent_class.parent_class.get_state = get_state;
83   - klass->parent_class.parent_class.get_state_type = get_state_type;
  82 + klass->parent_class.parent_class.change_widget = change_widget;
  83 + klass->parent_class.parent_class.get_parameter_type = get_parameter_type;
  84 + klass->parent_class.parent_class.get_state = get_state;
  85 + klass->parent_class.parent_class.get_state_type = get_state_type;
  86 + klass->parent_class.parent_class.activate = activate;
84 87 }
85 88  
86 89 static void v3270PropertyAction_init(v3270PropertyAction G_GNUC_UNUSED(*action)) {
... ... @@ -134,7 +137,7 @@
134 137  
135 138 }
136 139  
137   - static void activate(GAction *object, GVariant *parameter, GtkWidget *terminal) {
  140 + void activate(GAction *object, GVariant *parameter, GtkWidget *terminal) {
138 141  
139 142 v3270PropertyAction * action = V3270_PROPERTY_ACTION(object);
140 143  
... ... @@ -246,7 +249,6 @@
246 249 if(!action->parent.tooltip)
247 250 action->parent.tooltip = g_param_spec_get_blurb(pspec);
248 251  
249   - action->parent.parent.activate = activate;
250 252 action->pspec = pspec;
251 253 action->parent.group.id = action_group;
252 254  
... ...
src/terminal/actions/simple.c
... ... @@ -41,10 +41,6 @@
41 41  
42 42 G_DEFINE_TYPE(V3270SimpleAction, V3270SimpleAction, V3270_TYPE_ACTION);
43 43  
44   - static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) {
45   - g_warning("Action %s activation method is invalid",g_action_get_name(action));
46   - }
47   -
48 44 static const gchar * get_icon_name(GAction *action) {
49 45 return V3270_SIMPLE_ACTION(action)->icon_name;
50 46 }
... ... @@ -73,25 +69,34 @@
73 69 G_OBJECT_CLASS(V3270SimpleAction_parent_class)->dispose(object);
74 70 }
75 71  
  72 + static void klass_activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
  73 + V3270_SIMPLE_ACTION(action)->activate(action,parameter,terminal);
  74 + }
  75 +
76 76 static void V3270SimpleAction_class_init(V3270SimpleActionClass *klass) {
77 77  
78 78 klass->parent_class.get_name = get_name;
79 79 klass->parent_class.get_icon_name = get_icon_name;
80 80 klass->parent_class.get_label = get_label;
81 81 klass->parent_class.get_tooltip = get_tooltip;
  82 + klass->parent_class.activate = klass_activate;
82 83  
83 84 G_OBJECT_CLASS(klass)->dispose = dispose;
84 85  
85 86 }
86 87  
  88 + static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) {
  89 + g_warning("Action %s activation method is invalid",g_action_get_name(action));
  90 + }
  91 +
87 92 static void V3270SimpleAction_init(V3270SimpleAction *action) {
88 93  
89   - action->icon_name = NULL;
90   - action->label = _( "No label" );
91   - action->tooltip = NULL;
92   - action->activate = activate;
93   - action->group.id = LIB3270_ACTION_GROUP_NONE;
94   - action->group.listener = NULL;
  94 + action->icon_name = NULL;
  95 + action->label = _( "No label" );
  96 + action->tooltip = NULL;
  97 + action->activate = activate;
  98 + action->group.id = LIB3270_ACTION_GROUP_NONE;
  99 + action->group.listener = NULL;
95 100  
96 101 }
97 102  
... ...
src/terminal/actions/table.c
... ... @@ -348,8 +348,10 @@
348 348 {
349 349 debug("Activating action \"%s\"",g_action_get_name(action));
350 350  
  351 + /*
351 352 V3270_ACTION * descriptor = (V3270_ACTION *) ((V3270Action *) action)->info;
352 353 descriptor->activate(terminal,descriptor);
  354 + */
353 355  
354 356 }
355 357  
... ... @@ -359,6 +361,7 @@
359 361 const V3270_ACTION * actions = v3270_get_actions();
360 362 size_t ix;
361 363  
  364 + /*
362 365 for(ix = 0; actions[ix].name; ix++) {
363 366  
364 367 V3270Action * action = V3270_ACTION(g_object_new(V3270_TYPE_ACTION, NULL));
... ... @@ -374,6 +377,7 @@
374 377 }
375 378  
376 379 }
  380 + */
377 381  
378 382 }
379 383  
... ...
src/terminal/actions/toggle.c
... ... @@ -35,26 +35,27 @@
35 35 #include <internals.h>
36 36 #include <v3270.h>
37 37 #include <v3270/actions.h>
  38 + #include "private.h"
38 39  
39 40 #define LIB3270_TYPE_TOGGLE_ACTION (Lib3270ToggleAction_get_type())
40 41 #define LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_TOGGLE_ACTION, Lib3270ToggleAction))
41 42 #define LIB3270_IS_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_TOGGLE_ACTION))
42 43  
43   - #define GET_DESCRIPTOR(obj) ((const LIB3270_TOGGLE *) ((V3270Action *) obj)->info)
  44 + #define GET_DESCRIPTOR(obj) ((const LIB3270_TOGGLE *) LIB3270_ACTION(obj)->definition)
44 45  
45 46 typedef struct _Lib3270ToggleActionClass {
46   - V3270ActionClass parent_class;
  47 + Lib3270ActionClass parent_class;
47 48 } Lib3270ToggleActionClass;
48 49  
49 50 typedef struct _Lib3270ToggleAction {
50   - V3270Action parent;
51   - const void * listener;
  51 + Lib3270Action parent;
  52 + const void * listener; ///> @brief Signal listener for the toggle.
52 53 } Lib3270ToggleAction;
53 54  
54 55 static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass);
55 56 static void Lib3270ToggleAction_init(Lib3270ToggleAction *action);
56 57  
57   - G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, V3270_TYPE_ACTION);
  58 + G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, LIB3270_TYPE_ACTION);
58 59  
59 60 static void change_state(H3270 G_GNUC_UNUSED(*hSession), LIB3270_TOGGLE_ID G_GNUC_UNUSED(id), char G_GNUC_UNUSED(state), void G_GNUC_UNUSED(*action)) {
60 61 v3270_action_notify_state(G_ACTION(action));
... ... @@ -111,24 +112,27 @@
111 112 return G_VARIANT_TYPE_BOOLEAN;
112 113 }
113 114  
  115 + static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
  116 + return V3270_ACTION_GET_CLASS(action)->get_enabled(action,terminal);
  117 + }
  118 +
114 119 void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) {
115 120  
116   - klass->parent_class.change_widget = change_widget;
117   - klass->parent_class.get_state = get_state;
118   - klass->parent_class.get_state_type = get_state_type;
  121 + klass->parent_class.parent_class.change_widget = change_widget;
  122 + klass->parent_class.parent_class.get_state = get_state;
  123 + klass->parent_class.parent_class.get_state_type = get_state_type;
  124 + klass->parent_class.parent_class.activate = activate;
  125 + klass->parent_class.parent_class.get_enabled = get_enabled;
119 126  
120 127 }
121 128  
122 129 void Lib3270ToggleAction_init(Lib3270ToggleAction *action) {
123   - action->parent.activate = activate;
124   - action->parent.translation_domain = lib3270_get_translation_domain();
125 130 }
126 131  
127 132 GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) {
128 133  
129 134 Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(LIB3270_TYPE_TOGGLE_ACTION, NULL);
130   - action->parent.info = (const LIB3270_PROPERTY *) definition;
131   -
  135 + action->parent.definition = (const LIB3270_PROPERTY *) definition;
132 136 return G_ACTION(action);
133 137  
134 138 }
... ...