Commit 543b7e796f481d717a59ed245f153aa8b1e53b79
1 parent
2a2345a6
Exists in
master
and in
4 other branches
Fixing toggle action.
Showing
2 changed files
with
19 additions
and
32 deletions
Show diff stats
src/objects/actions/lib3270/toggle.c
| @@ -41,17 +41,15 @@ | @@ -41,17 +41,15 @@ | ||
| 41 | #define LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_TOGGLE_ACTION, Lib3270ToggleAction)) | 41 | #define LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_TOGGLE_ACTION, Lib3270ToggleAction)) |
| 42 | #define LIB3270_IS_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_TOGGLE_ACTION)) | 42 | #define LIB3270_IS_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_TOGGLE_ACTION)) |
| 43 | 43 | ||
| 44 | + #define GET_DESCRIPTOR(obj) ((const LIB3270_TOGGLE *) ((V3270Action *) obj)->info) | ||
| 45 | + | ||
| 44 | typedef struct _Lib3270ToggleActionClass { | 46 | typedef struct _Lib3270ToggleActionClass { |
| 45 | V3270ActionClass parent_class; | 47 | V3270ActionClass parent_class; |
| 46 | - | ||
| 47 | } Lib3270ToggleActionClass; | 48 | } Lib3270ToggleActionClass; |
| 48 | 49 | ||
| 49 | typedef struct _Lib3270ToggleAction { | 50 | typedef struct _Lib3270ToggleAction { |
| 50 | V3270Action parent; | 51 | V3270Action parent; |
| 51 | - | ||
| 52 | - const LIB3270_TOGGLE * definition; | ||
| 53 | const void * listener; | 52 | const void * listener; |
| 54 | - | ||
| 55 | } Lib3270ToggleAction; | 53 | } Lib3270ToggleAction; |
| 56 | 54 | ||
| 57 | static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass); | 55 | static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass); |
| @@ -68,10 +66,10 @@ | @@ -68,10 +66,10 @@ | ||
| 68 | Lib3270ToggleAction * action = LIB3270_TOGGLE_ACTION(object); | 66 | Lib3270ToggleAction * action = LIB3270_TOGGLE_ACTION(object); |
| 69 | 67 | ||
| 70 | if(action->listener) | 68 | if(action->listener) |
| 71 | - lib3270_unregister_toggle_listener(v3270_get_session(from),action->definition->id,object); | 69 | + lib3270_unregister_toggle_listener(v3270_get_session(from),GET_DESCRIPTOR(object)->id,object); |
| 72 | 70 | ||
| 73 | if(to) | 71 | if(to) |
| 74 | - action->listener = lib3270_register_toggle_listener(v3270_get_session(to),action->definition->id,change_state,object); | 72 | + action->listener = lib3270_register_toggle_listener(v3270_get_session(to),GET_DESCRIPTOR(object)->id,change_state,object); |
| 75 | 73 | ||
| 76 | V3270_ACTION_CLASS(Lib3270ToggleAction_parent_class)->change_widget(object,from,to); | 74 | V3270_ACTION_CLASS(Lib3270ToggleAction_parent_class)->change_widget(object,from,to); |
| 77 | 75 | ||
| @@ -79,53 +77,45 @@ | @@ -79,53 +77,45 @@ | ||
| 79 | 77 | ||
| 80 | static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | 78 | static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { |
| 81 | 79 | ||
| 82 | - debug("Activating \"%s\"",pw3270_action_get_name(action)); | 80 | + debug("Activating \"%s\"",g_action_get_name(action)); |
| 83 | 81 | ||
| 84 | if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { | 82 | if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { |
| 85 | 83 | ||
| 86 | - lib3270_set_toggle(v3270_get_session(terminal),LIB3270_TOGGLE_ACTION(action)->definition->id,g_variant_get_boolean(parameter)); | ||
| 87 | - debug("Toggle set to %s",lib3270_get_toggle(v3270_get_session(terminal),LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | 84 | + lib3270_set_toggle(v3270_get_session(terminal),GET_DESCRIPTOR(action)->id,g_variant_get_boolean(parameter)); |
| 85 | + debug("Toggle set to %s",lib3270_get_toggle(v3270_get_session(terminal),GET_DESCRIPTOR(action)->id) ? "ON" : "OFF"); | ||
| 88 | 86 | ||
| 89 | } else { | 87 | } else { |
| 90 | 88 | ||
| 91 | - lib3270_toggle(v3270_get_session(terminal),LIB3270_TOGGLE_ACTION(action)->definition->id); | ||
| 92 | - debug("Toggle is %s",lib3270_get_toggle(v3270_get_session(terminal),LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | 89 | + lib3270_toggle(v3270_get_session(terminal),GET_DESCRIPTOR(action)->id); |
| 90 | + debug("Toggle is %s",lib3270_get_toggle(v3270_get_session(terminal),GET_DESCRIPTOR(action)->id) ? "ON" : "OFF"); | ||
| 93 | 91 | ||
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | - void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { | ||
| 99 | - | ||
| 100 | - klass->parent_class.change_widget = change_widget; | ||
| 101 | - | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - static GVariant * get_state_property(GAction *action, GtkWidget *terminal) { | 96 | + static GVariant * get_state(GAction *action, GtkWidget *terminal) { |
| 105 | 97 | ||
| 106 | debug("%s(%s)",__FUNCTION__,g_action_get_name(action)); | 98 | debug("%s(%s)",__FUNCTION__,g_action_get_name(action)); |
| 107 | 99 | ||
| 108 | return g_variant_new_boolean( | 100 | return g_variant_new_boolean( |
| 109 | lib3270_get_toggle( | 101 | lib3270_get_toggle( |
| 110 | v3270_get_session(terminal), | 102 | v3270_get_session(terminal), |
| 111 | - LIB3270_TOGGLE_ACTION(action)->definition->id | 103 | + GET_DESCRIPTOR(action)->id |
| 112 | ) | 104 | ) |
| 113 | ); | 105 | ); |
| 114 | 106 | ||
| 115 | } | 107 | } |
| 116 | 108 | ||
| 117 | - void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { | ||
| 118 | - | ||
| 119 | - action->definition = NULL; | ||
| 120 | - action->listener = NULL; | ||
| 121 | - | ||
| 122 | -// action->parent.name = "toggle"; | 109 | + void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { |
| 123 | 110 | ||
| 124 | - action->parent.get_state_property = get_state_property; | ||
| 125 | - action->parent.activate = activate; | 111 | + klass->parent_class.change_widget = change_widget; |
| 112 | + klass->parent_class.state.type = G_VARIANT_TYPE_BOOLEAN; | ||
| 113 | + klass->parent_class.get_state = get_state; | ||
| 126 | 114 | ||
| 127 | - action->parent.types.state = G_VARIANT_TYPE_BOOLEAN; | 115 | + } |
| 128 | 116 | ||
| 117 | + void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { | ||
| 118 | + action->parent.activate = activate; | ||
| 129 | } | 119 | } |
| 130 | 120 | ||
| 131 | GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { | 121 | GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { |
| @@ -134,8 +124,6 @@ | @@ -134,8 +124,6 @@ | ||
| 134 | 124 | ||
| 135 | action->parent.info = (const LIB3270_PROPERTY *) definition; | 125 | action->parent.info = (const LIB3270_PROPERTY *) definition; |
| 136 | 126 | ||
| 137 | - action->definition = definition; | ||
| 138 | - | ||
| 139 | return G_ACTION(action); | 127 | return G_ACTION(action); |
| 140 | 128 | ||
| 141 | } | 129 | } |
src/objects/window/window.c
| @@ -185,7 +185,6 @@ | @@ -185,7 +185,6 @@ | ||
| 185 | 185 | ||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | -/* | ||
| 189 | #ifdef DEBUG | 188 | #ifdef DEBUG |
| 190 | 189 | ||
| 191 | { | 190 | { |
| @@ -202,6 +201,7 @@ | @@ -202,6 +201,7 @@ | ||
| 202 | 201 | ||
| 203 | debug("Action: %s",g_action_get_name(actions[ix])); | 202 | debug("Action: %s",g_action_get_name(actions[ix])); |
| 204 | debug("\tState-type:\t\t%s",g_action_get_state_type(actions[ix])); | 203 | debug("\tState-type:\t\t%s",g_action_get_state_type(actions[ix])); |
| 204 | + debug("\tState value:\t%p",g_action_get_state(actions[ix])); | ||
| 205 | debug("\tParameter-type:\t%s",g_action_get_parameter_type(actions[ix])); | 205 | debug("\tParameter-type:\t%s",g_action_get_parameter_type(actions[ix])); |
| 206 | 206 | ||
| 207 | } | 207 | } |
| @@ -209,7 +209,6 @@ | @@ -209,7 +209,6 @@ | ||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | #endif // DEBUG | 211 | #endif // DEBUG |
| 212 | -*/ | ||
| 213 | 212 | ||
| 214 | } | 213 | } |
| 215 | 214 |