Commit c62a3222cb32b817bc7bfd916cef940a6e7ddfc4
1 parent
790b2f4e
Exists in
master
and in
4 other branches
Refactoring toggle action.
Showing
1 changed file
with
11 additions
and
10 deletions
Show diff stats
src/objects/actions/lib3270/toggle.c
| @@ -35,10 +35,11 @@ | @@ -35,10 +35,11 @@ | ||
| 35 | #include "../private.h" | 35 | #include "../private.h" |
| 36 | #include <pw3270/window.h> | 36 | #include <pw3270/window.h> |
| 37 | #include <v3270.h> | 37 | #include <v3270.h> |
| 38 | + #include <v3270/actions.h> | ||
| 38 | 39 | ||
| 39 | - #define PW3270_TYPE_LIB3270_TOGGLE_ACTION (Lib3270ToggleAction_get_type()) | ||
| 40 | - #define PW3270_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION, Lib3270ToggleAction)) | ||
| 41 | - #define PW3270_IS_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION)) | 40 | + #define LIB3270_TYPE_TOGGLE_ACTION (Lib3270ToggleAction_get_type()) |
| 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 | 43 | ||
| 43 | typedef struct _Lib3270ToggleActionClass { | 44 | typedef struct _Lib3270ToggleActionClass { |
| 44 | pw3270ActionClass parent_class; | 45 | pw3270ActionClass parent_class; |
| @@ -64,7 +65,7 @@ | @@ -64,7 +65,7 @@ | ||
| 64 | 65 | ||
| 65 | static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | 66 | static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { |
| 66 | 67 | ||
| 67 | - Lib3270ToggleAction * action = PW3270_LIB3270_TOGGLE_ACTION(object); | 68 | + Lib3270ToggleAction * action = LIB3270_TOGGLE_ACTION(object); |
| 68 | 69 | ||
| 69 | if(action->listener) | 70 | if(action->listener) |
| 70 | lib3270_unregister_toggle_listener(v3270_get_session(from),action->definition->id,object); | 71 | lib3270_unregister_toggle_listener(v3270_get_session(from),action->definition->id,object); |
| @@ -82,13 +83,13 @@ | @@ -82,13 +83,13 @@ | ||
| 82 | 83 | ||
| 83 | if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { | 84 | if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { |
| 84 | 85 | ||
| 85 | - lib3270_set_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id,g_variant_get_boolean(parameter)); | ||
| 86 | - debug("Toggle set to %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | 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"); | ||
| 87 | 88 | ||
| 88 | } else { | 89 | } else { |
| 89 | 90 | ||
| 90 | - lib3270_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id); | ||
| 91 | - debug("Toggle is %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | 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"); | ||
| 92 | 93 | ||
| 93 | } | 94 | } |
| 94 | 95 | ||
| @@ -105,7 +106,7 @@ | @@ -105,7 +106,7 @@ | ||
| 105 | return g_variant_new_boolean( | 106 | return g_variant_new_boolean( |
| 106 | lib3270_get_toggle( | 107 | lib3270_get_toggle( |
| 107 | v3270_get_session(terminal), | 108 | v3270_get_session(terminal), |
| 108 | - PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id | 109 | + LIB3270_TOGGLE_ACTION(action)->definition->id |
| 109 | ) | 110 | ) |
| 110 | ); | 111 | ); |
| 111 | 112 | ||
| @@ -127,7 +128,7 @@ | @@ -127,7 +128,7 @@ | ||
| 127 | 128 | ||
| 128 | GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { | 129 | GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { |
| 129 | 130 | ||
| 130 | - Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); | 131 | + Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(LIB3270_TYPE_TOGGLE_ACTION, NULL); |
| 131 | 132 | ||
| 132 | action->definition = definition; | 133 | action->definition = definition; |
| 133 | action->parent.name = definition->name; | 134 | action->parent.name = definition->name; |