Commit 8263506c27ffaae15fbfc62abf76a9cd0847673e
1 parent
a501773a
Exists in
master
and in
4 other branches
Working on actions.
Showing
8 changed files
with
29 additions
and
75 deletions
Show diff stats
src/objects/actions/abstract.c
@@ -251,7 +251,7 @@ | @@ -251,7 +251,7 @@ | ||
251 | switch (prop_id) | 251 | switch (prop_id) |
252 | { | 252 | { |
253 | case PROP_NAME: | 253 | case PROP_NAME: |
254 | -// pw3270_action_set_name(action, g_value_get_string(value)); | 254 | + pw3270_action_set_name(action, g_value_get_string(value)); |
255 | break; | 255 | break; |
256 | 256 | ||
257 | case PROP_PARAMETER_TYPE: | 257 | case PROP_PARAMETER_TYPE: |
@@ -273,24 +273,13 @@ | @@ -273,24 +273,13 @@ | ||
273 | } | 273 | } |
274 | 274 | ||
275 | const gchar * pw3270_action_get_name(GAction *action) { | 275 | const gchar * pw3270_action_get_name(GAction *action) { |
276 | - return PW3270_ACTION(action)->get_name(action); | 276 | + return PW3270_ACTION(action)->name; |
277 | } | 277 | } |
278 | 278 | ||
279 | void pw3270_action_set_name(GAction *object, const gchar *name) { | 279 | void pw3270_action_set_name(GAction *object, const gchar *name) { |
280 | 280 | ||
281 | -/* | ||
282 | - pw3270Action * action = PW3270_ACTION(object); | ||
283 | - | ||
284 | -// debug("%s %s -> %s", __FUNCTION__, action->name, name); | ||
285 | - | ||
286 | - if(action->name) | ||
287 | - g_free(action->name); | ||
288 | - | ||
289 | - if(name) | ||
290 | - action->name = g_strdup(name); | ||
291 | - else | ||
292 | - action->name = NULL; | ||
293 | -*/ | 281 | + if(name) |
282 | + g_warning("Invalid call to %s on action %s with value \"%s\"",__FUNCTION__,g_action_get_name(object),name); | ||
294 | 283 | ||
295 | } | 284 | } |
296 | 285 |
src/objects/actions/connect.c
@@ -41,18 +41,13 @@ | @@ -41,18 +41,13 @@ | ||
41 | 41 | ||
42 | } | 42 | } |
43 | 43 | ||
44 | - static const gchar * get_name(GAction G_GNUC_UNUSED(*action)) { | ||
45 | - return "connect"; | ||
46 | - } | ||
47 | - | ||
48 | GAction * pw3270_connect_action_new(void) { | 44 | GAction * pw3270_connect_action_new(void) { |
49 | 45 | ||
50 | - GAction * object = pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect")); | 46 | + pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); |
51 | 47 | ||
52 | - pw3270Action * action = PW3270_ACTION(object); | ||
53 | action->activate = activate; | 48 | action->activate = activate; |
54 | - action->get_name = get_name; | 49 | + action->name = "connect"; |
55 | 50 | ||
56 | - return object; | 51 | + return G_ACTION(action); |
57 | 52 | ||
58 | } | 53 | } |
src/objects/actions/lib3270/action.c
@@ -114,15 +114,10 @@ | @@ -114,15 +114,10 @@ | ||
114 | 114 | ||
115 | } | 115 | } |
116 | 116 | ||
117 | - static const gchar * get_name(GAction *action) { | ||
118 | - return PW3270_LIB3270_ACTION(action)->definition->name; | ||
119 | - } | ||
120 | - | ||
121 | - void Lib3270Action_init(Lib3270Action *object) { | ||
122 | - pw3270Action * action = PW3270_ACTION(object); | 117 | + void Lib3270Action_init(Lib3270Action *action) { |
123 | 118 | ||
124 | - action->activate = activate; | ||
125 | - action->get_name = get_name; | 119 | + action->parent.activate = activate; |
120 | + action->parent.name = "tn3270"; | ||
126 | 121 | ||
127 | } | 122 | } |
128 | 123 | ||
@@ -133,6 +128,7 @@ | @@ -133,6 +128,7 @@ | ||
133 | // Setup hooks. | 128 | // Setup hooks. |
134 | action->definition = definition; | 129 | action->definition = definition; |
135 | action->listener = NULL; | 130 | action->listener = NULL; |
131 | + action->parent.name = definition->name; | ||
136 | 132 | ||
137 | return G_ACTION(action); | 133 | return G_ACTION(action); |
138 | } | 134 | } |
src/objects/actions/lib3270/pakey.c
@@ -109,15 +109,11 @@ | @@ -109,15 +109,11 @@ | ||
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | - static const gchar * get_name(GAction G_GNUC_UNUSED(*action)) { | ||
113 | - return "pakey"; | ||
114 | - } | ||
115 | - | ||
116 | void Lib3270PaAction_init(Lib3270PaAction *object) { | 112 | void Lib3270PaAction_init(Lib3270PaAction *object) { |
117 | pw3270Action * action = PW3270_ACTION(object); | 113 | pw3270Action * action = PW3270_ACTION(object); |
118 | 114 | ||
119 | action->activate = activate; | 115 | action->activate = activate; |
120 | - action->get_name = get_name; | 116 | + action->name = "pakey"; |
121 | } | 117 | } |
122 | 118 | ||
123 | 119 |
src/objects/actions/lib3270/pfkey.c
@@ -108,15 +108,11 @@ | @@ -108,15 +108,11 @@ | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | - static const gchar * get_name(GAction *action) { | ||
112 | - return "pakey"; | ||
113 | - } | 111 | + void Lib3270PfAction_init(Lib3270PfAction *action) { |
114 | 112 | ||
115 | - void Lib3270PfAction_init(Lib3270PfAction *object) { | ||
116 | - pw3270Action * action = PW3270_ACTION(object); | 113 | + action->parent.activate = activate; |
114 | + action->parent.name = "pfkey"; | ||
117 | 115 | ||
118 | - action->activate = activate; | ||
119 | - action->get_name = get_name; | ||
120 | } | 116 | } |
121 | 117 | ||
122 | GAction * pw3270_action_new_pfkey(void) { | 118 | GAction * pw3270_action_new_pfkey(void) { |
src/objects/actions/lib3270/toggle.c
@@ -58,8 +58,12 @@ | @@ -58,8 +58,12 @@ | ||
58 | 58 | ||
59 | G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, PW3270_TYPE_ACTION); | 59 | G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, PW3270_TYPE_ACTION); |
60 | 60 | ||
61 | - static void change_state(H3270 G_GNUC_UNUSED(*hSession), LIB3270_TOGGLE_ID id, char state, void * action) { | ||
62 | - debug("%s: %s",__FUNCTION__,state ? "ON" : "OFF"); | 61 | + static void change_state(H3270 G_GNUC_UNUSED(*hSession), LIB3270_TOGGLE_ID G_GNUC_UNUSED(id), char state, void * action) { |
62 | + debug("%s: State on action %s is %s", | ||
63 | + __FUNCTION__, | ||
64 | + g_action_get_name(G_ACTION(action)), | ||
65 | + state ? "ON" : "OFF" | ||
66 | + ); | ||
63 | pw3270_action_change_state_boolean((GAction *) action, state == 0 ? FALSE : TRUE); | 67 | pw3270_action_change_state_boolean((GAction *) action, state == 0 ? FALSE : TRUE); |
64 | } | 68 | } |
65 | 69 | ||
@@ -105,35 +109,22 @@ | @@ -105,35 +109,22 @@ | ||
105 | 109 | ||
106 | } | 110 | } |
107 | 111 | ||
108 | - static const gchar * get_name(GAction *action) { | ||
109 | - return PW3270_LIB3270_TOGGLE_ACTION(action)->definition->name; | ||
110 | - } | ||
111 | - | ||
112 | - void Lib3270ToggleAction_init(Lib3270ToggleAction *toggle) { | 112 | + void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { |
113 | 113 | ||
114 | - toggle->definition = NULL; | ||
115 | - toggle->listener = NULL; | 114 | + action->definition = NULL; |
115 | + action->listener = NULL; | ||
116 | 116 | ||
117 | - pw3270Action * action = PW3270_ACTION(toggle); | ||
118 | - action->activate = activate; | ||
119 | - action->get_name = get_name; | 117 | + action->parent.activate = activate; |
118 | + action->parent.name = "toggle"; | ||
120 | 119 | ||
121 | } | 120 | } |
122 | 121 | ||
123 | GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition) { | 122 | GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition) { |
124 | 123 | ||
125 | Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); | 124 | Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); |
126 | - action->definition = definition; | ||
127 | 125 | ||
128 | - // Setup the default name. | ||
129 | - pw3270Action * abstract = PW3270_ACTION(action); | ||
130 | - | ||
131 | - /* | ||
132 | - if(abstract->name) | ||
133 | - g_free(abstract->name); | ||
134 | - | ||
135 | - abstract->name = g_strconcat("win.",definition->name,NULL); | ||
136 | - */ | 126 | + action->definition = definition; |
127 | + action->parent.name = definition->name; | ||
137 | 128 | ||
138 | return G_ACTION(action); | 129 | return G_ACTION(action); |
139 | 130 |
src/objects/actions/private.h
@@ -54,12 +54,12 @@ | @@ -54,12 +54,12 @@ | ||
54 | struct _pw3270Action { | 54 | struct _pw3270Action { |
55 | GObject parent; | 55 | GObject parent; |
56 | 56 | ||
57 | + const gchar * name; | ||
57 | GVariantType * parameter_type; | 58 | GVariantType * parameter_type; |
58 | GVariant * state; | 59 | GVariant * state; |
59 | GtkWidget * terminal; | 60 | GtkWidget * terminal; |
60 | 61 | ||
61 | void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); | 62 | void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); |
62 | - const gchar * (*get_name)(GAction *action); | ||
63 | 63 | ||
64 | }; | 64 | }; |
65 | 65 |
src/objects/actions/window.c
@@ -43,15 +43,6 @@ | @@ -43,15 +43,6 @@ | ||
43 | 43 | ||
44 | // Map lib3270 actions | 44 | // Map lib3270 actions |
45 | { | 45 | { |
46 | - GAction * action = pw3270_action_new_from_lib3270(lib3270_action_get_by_name("disconnect")); | ||
47 | - | ||
48 | - pw3270_action_set_name(G_ACTION(action),"disconnect"); | ||
49 | - | ||
50 | - g_action_map_add_action(map,action); | ||
51 | - | ||
52 | - } | ||
53 | - | ||
54 | - { | ||
55 | const LIB3270_ACTION * actions = lib3270_get_actions(); | 46 | const LIB3270_ACTION * actions = lib3270_get_actions(); |
56 | for(ix = 0; actions[ix].name; ix++) { | 47 | for(ix = 0; actions[ix].name; ix++) { |
57 | 48 |