Commit a785862631eb3c01f612ea310422b23a7835a036
1 parent
543b7e79
Exists in
master
and in
4 other branches
Toggle action now lives in libv3270.
Showing
5 changed files
with
4 additions
and
158 deletions
Show diff stats
src/objects/actions/lib3270/pakey.c
src/objects/actions/lib3270/toggle.c
@@ -1,131 +0,0 @@ | @@ -1,131 +0,0 @@ | ||
1 | -/* | ||
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | - * | ||
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | - * | ||
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | - * Free Software Foundation. | ||
11 | - * | ||
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | - * obter mais detalhes. | ||
16 | - * | ||
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | - * | ||
21 | - * Este programa está nomeado como - e possui - linhas de código. | ||
22 | - * | ||
23 | - * Contatos: | ||
24 | - * | ||
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | - * | ||
28 | - */ | ||
29 | - | ||
30 | - /** | ||
31 | - * @brief Implement GAction "wrapper" for lib3270's toggles. | ||
32 | - * | ||
33 | - */ | ||
34 | - | ||
35 | - #include "../private.h" | ||
36 | - #include <pw3270/window.h> | ||
37 | - #include <v3270.h> | ||
38 | - #include <v3270/actions.h> | ||
39 | - | ||
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)) | ||
43 | - | ||
44 | - #define GET_DESCRIPTOR(obj) ((const LIB3270_TOGGLE *) ((V3270Action *) obj)->info) | ||
45 | - | ||
46 | - typedef struct _Lib3270ToggleActionClass { | ||
47 | - V3270ActionClass parent_class; | ||
48 | - } Lib3270ToggleActionClass; | ||
49 | - | ||
50 | - typedef struct _Lib3270ToggleAction { | ||
51 | - V3270Action parent; | ||
52 | - const void * listener; | ||
53 | - } Lib3270ToggleAction; | ||
54 | - | ||
55 | - static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass); | ||
56 | - static void Lib3270ToggleAction_init(Lib3270ToggleAction *action); | ||
57 | - | ||
58 | - G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, V3270_TYPE_ACTION); | ||
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)) { | ||
61 | - v3270_action_notify_state(G_ACTION(action)); | ||
62 | - } | ||
63 | - | ||
64 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | ||
65 | - | ||
66 | - Lib3270ToggleAction * action = LIB3270_TOGGLE_ACTION(object); | ||
67 | - | ||
68 | - if(action->listener) | ||
69 | - lib3270_unregister_toggle_listener(v3270_get_session(from),GET_DESCRIPTOR(object)->id,object); | ||
70 | - | ||
71 | - if(to) | ||
72 | - action->listener = lib3270_register_toggle_listener(v3270_get_session(to),GET_DESCRIPTOR(object)->id,change_state,object); | ||
73 | - | ||
74 | - V3270_ACTION_CLASS(Lib3270ToggleAction_parent_class)->change_widget(object,from,to); | ||
75 | - | ||
76 | - } | ||
77 | - | ||
78 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | ||
79 | - | ||
80 | - debug("Activating \"%s\"",g_action_get_name(action)); | ||
81 | - | ||
82 | - if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { | ||
83 | - | ||
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"); | ||
86 | - | ||
87 | - } else { | ||
88 | - | ||
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"); | ||
91 | - | ||
92 | - } | ||
93 | - | ||
94 | - } | ||
95 | - | ||
96 | - static GVariant * get_state(GAction *action, GtkWidget *terminal) { | ||
97 | - | ||
98 | - debug("%s(%s)",__FUNCTION__,g_action_get_name(action)); | ||
99 | - | ||
100 | - return g_variant_new_boolean( | ||
101 | - lib3270_get_toggle( | ||
102 | - v3270_get_session(terminal), | ||
103 | - GET_DESCRIPTOR(action)->id | ||
104 | - ) | ||
105 | - ); | ||
106 | - | ||
107 | - } | ||
108 | - | ||
109 | - void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { | ||
110 | - | ||
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; | ||
114 | - | ||
115 | - } | ||
116 | - | ||
117 | - void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { | ||
118 | - action->parent.activate = activate; | ||
119 | - } | ||
120 | - | ||
121 | - GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { | ||
122 | - | ||
123 | - Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(LIB3270_TYPE_TOGGLE_ACTION, NULL); | ||
124 | - | ||
125 | - action->parent.info = (const LIB3270_PROPERTY *) definition; | ||
126 | - | ||
127 | - return G_ACTION(action); | ||
128 | - | ||
129 | - } | ||
130 | - | ||
131 | - |
src/objects/actions/private.h
@@ -51,7 +51,6 @@ | @@ -51,7 +51,6 @@ | ||
51 | /* not really I18N-related, but also a string marker macro */ | 51 | /* not really I18N-related, but also a string marker macro */ |
52 | #define I_(string) g_intern_static_string (string) | 52 | #define I_(string) g_intern_static_string (string) |
53 | 53 | ||
54 | - G_GNUC_INTERNAL GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition); | ||
55 | G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); | 54 | G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); |
56 | G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); | 55 | G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); |
57 | 56 |
src/objects/actions/window.c
@@ -55,6 +55,7 @@ | @@ -55,6 +55,7 @@ | ||
55 | } | 55 | } |
56 | */ | 56 | */ |
57 | 57 | ||
58 | + /* | ||
58 | // Map toggles | 59 | // Map toggles |
59 | { | 60 | { |
60 | const LIB3270_TOGGLE * toggles = lib3270_get_toggles(); | 61 | const LIB3270_TOGGLE * toggles = lib3270_get_toggles(); |
@@ -65,6 +66,7 @@ | @@ -65,6 +66,7 @@ | ||
65 | 66 | ||
66 | } | 67 | } |
67 | } | 68 | } |
69 | + */ | ||
68 | 70 | ||
69 | /* | 71 | /* |
70 | // Map V3270 actions | 72 | // Map V3270 actions |
src/objects/window/window.c
@@ -144,6 +144,7 @@ | @@ -144,6 +144,7 @@ | ||
144 | 144 | ||
145 | g_action_map_add_v3270_actions(G_ACTION_MAP(widget)); | 145 | g_action_map_add_v3270_actions(G_ACTION_MAP(widget)); |
146 | g_action_map_add_lib3270_actions(G_ACTION_MAP(widget)); | 146 | g_action_map_add_lib3270_actions(G_ACTION_MAP(widget)); |
147 | + g_action_map_add_lib3270_toggles(G_ACTION_MAP(widget)); | ||
147 | 148 | ||
148 | // Map special actions | 149 | // Map special actions |
149 | { | 150 | { |
@@ -185,31 +186,6 @@ | @@ -185,31 +186,6 @@ | ||
185 | 186 | ||
186 | } | 187 | } |
187 | 188 | ||
188 | -#ifdef DEBUG | ||
189 | - | ||
190 | - { | ||
191 | - GAction *actions[] = { | ||
192 | - g_action_map_lookup_action(G_ACTION_MAP(widget),"crosshair"), | ||
193 | - g_action_map_lookup_action(G_ACTION_MAP(widget),"toolbar") | ||
194 | - }; | ||
195 | - | ||
196 | - size_t ix; | ||
197 | - | ||
198 | - for(ix = 0; ix < G_N_ELEMENTS(actions);ix++) { | ||
199 | - | ||
200 | - debug("\n\nAction %u = %p",(unsigned int) ix, actions[ix]); | ||
201 | - | ||
202 | - debug("Action: %s",g_action_get_name(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])); | ||
206 | - | ||
207 | - } | ||
208 | - | ||
209 | - } | ||
210 | - | ||
211 | -#endif // DEBUG | ||
212 | - | ||
213 | } | 189 | } |
214 | 190 | ||
215 | GtkWidget * pw3270_application_window_new(GtkApplication * application) { | 191 | GtkWidget * pw3270_application_window_new(GtkApplication * application) { |