Commit 974728d23aae0fa0abc19d73fae8417fde8a6e92
1 parent
242a4a8c
Exists in
master
and in
4 other branches
Implementing "PF" & "PA" actions.
Showing
6 changed files
with
297 additions
and
2 deletions
Show diff stats
src/actions/abstract.c
... | ... | @@ -80,6 +80,11 @@ |
80 | 80 | iface->activate = pw3270_action_activate; |
81 | 81 | } |
82 | 82 | |
83 | + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action)) | |
84 | + { | |
85 | + return NULL; | |
86 | + } | |
87 | + | |
83 | 88 | void pw3270Action_class_init(pw3270ActionClass *klass) { |
84 | 89 | |
85 | 90 | GObjectClass *object_class = G_OBJECT_CLASS(klass); |
... | ... | @@ -87,6 +92,7 @@ |
87 | 92 | klass->change_widget = change_widget; |
88 | 93 | klass->get_enabled = get_enabled; |
89 | 94 | klass->activate = activate; |
95 | + klass->get_parameter_type = get_parameter_type; | |
90 | 96 | |
91 | 97 | object_class->finalize = finalize; |
92 | 98 | object_class->set_property = pw3270_action_set_property; |
... | ... | @@ -286,8 +292,7 @@ |
286 | 292 | } |
287 | 293 | |
288 | 294 | const GVariantType * pw3270_action_get_parameter_type(GAction *action) { |
289 | -// debug("%s",__FUNCTION__); | |
290 | - return NULL; | |
295 | + return PW3270_ACTION_GET_CLASS(action)->get_parameter_type(action); | |
291 | 296 | } |
292 | 297 | |
293 | 298 | const GVariantType * pw3270_action_get_state_type(GAction *object) { | ... | ... |
src/actions/actions.cbp
... | ... | @@ -46,6 +46,12 @@ |
46 | 46 | <Unit filename="lib3270/action.c"> |
47 | 47 | <Option compilerVar="CC" /> |
48 | 48 | </Unit> |
49 | + <Unit filename="lib3270/pakey.c"> | |
50 | + <Option compilerVar="CC" /> | |
51 | + </Unit> | |
52 | + <Unit filename="lib3270/pfkey.c"> | |
53 | + <Option compilerVar="CC" /> | |
54 | + </Unit> | |
49 | 55 | <Unit filename="lib3270/toggle.c"> |
50 | 56 | <Option compilerVar="CC" /> |
51 | 57 | </Unit> | ... | ... |
... | ... | @@ -0,0 +1,139 @@ |
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 PAs. | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | + #include "../private.h" | |
36 | + #include <v3270.h> | |
37 | + | |
38 | + #define PW3270_TYPE_PAKEY_ACTION (Lib3270PaAction_get_type()) | |
39 | + #define PW3270_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PAKEY_ACTION, Lib3270PaAction)) | |
40 | + #define PW3270_IS_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PAKEY_ACTION)) | |
41 | + | |
42 | + typedef struct _Lib3270PaActionClass { | |
43 | + pw3270ActionClass parent_class; | |
44 | + | |
45 | + } Lib3270PaActionClass; | |
46 | + | |
47 | + typedef struct _Lib3270PaAction { | |
48 | + pw3270Action parent; | |
49 | + | |
50 | + } Lib3270PaAction; | |
51 | + | |
52 | + static void Lib3270PaAction_class_init(Lib3270PaActionClass *klass); | |
53 | + static void Lib3270PaAction_init(Lib3270PaAction *action); | |
54 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
55 | + | |
56 | + G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, PW3270_TYPE_PAKEY_ACTION); | |
57 | + | |
58 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
59 | + | |
60 | + if(terminal) | |
61 | + return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
62 | + | |
63 | + return FALSE; | |
64 | + | |
65 | + } | |
66 | + | |
67 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
68 | + | |
69 | + if(action && terminal && parameter) { | |
70 | + | |
71 | + H3270 * hSession = v3270_get_session(terminal); | |
72 | + | |
73 | + if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
74 | + | |
75 | + lib3270_pakey(hSession,(int) g_variant_get_int32(parameter)); | |
76 | + | |
77 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
78 | + | |
79 | + lib3270_pakey(hSession,(int) g_variant_get_uint32(parameter)); | |
80 | + | |
81 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
82 | + | |
83 | + lib3270_pakey(hSession,(int) g_variant_get_int16(parameter)); | |
84 | + | |
85 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
86 | + | |
87 | + lib3270_pakey(hSession,(int) g_variant_get_uint16(parameter)); | |
88 | + | |
89 | + } | |
90 | + | |
91 | + } | |
92 | + | |
93 | + } | |
94 | + | |
95 | + static const GVariantType * get_parameter_type(GAction *action) | |
96 | + { | |
97 | + return G_VARIANT_TYPE_UINT16; | |
98 | + } | |
99 | + | |
100 | + void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) { | |
101 | + | |
102 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
103 | + | |
104 | + action->activate = activate; | |
105 | + action->get_enabled = get_enabled; | |
106 | + action->change_widget = change_widget; | |
107 | + action->get_parameter_type = get_parameter_type; | |
108 | + | |
109 | + } | |
110 | + | |
111 | + void Lib3270PaAction_init(Lib3270PaAction *action) { | |
112 | + } | |
113 | + | |
114 | + GAction * pw3270_action_new_pakey(void) { | |
115 | + | |
116 | + Lib3270PaAction * action = (Lib3270PaAction *) g_object_new(PW3270_TYPE_PAKEY_ACTION, NULL); | |
117 | + | |
118 | + // Setup the default name. | |
119 | + pw3270Action * abstract = PW3270_ACTION(action); | |
120 | + | |
121 | + if(abstract->name) | |
122 | + g_free(abstract->name); | |
123 | + | |
124 | + abstract->name = g_strdup("win.pakey"); | |
125 | + | |
126 | + return G_ACTION(action); | |
127 | + } | |
128 | + | |
129 | + void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
130 | + | |
131 | + PW3270_ACTION_CLASS(Lib3270PaAction_parent_class)->change_widget(object,from,to); | |
132 | + | |
133 | + // Does the "enabled" state has changed? If yes notify customers. | |
134 | + gboolean enabled = get_enabled(object,to); | |
135 | + if(get_enabled(object,from) != enabled) | |
136 | + pw3270_action_set_enabled(object,enabled); | |
137 | + | |
138 | + } | |
139 | + | ... | ... |
... | ... | @@ -0,0 +1,139 @@ |
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 PFs. | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | + #include "../private.h" | |
36 | + #include <v3270.h> | |
37 | + | |
38 | + #define PW3270_TYPE_PFKEY_ACTION (Lib3270PfAction_get_type()) | |
39 | + #define PW3270_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PFKEY_ACTION, Lib3270PfAction)) | |
40 | + #define PW3270_IS_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PFKEY_ACTION)) | |
41 | + | |
42 | + typedef struct _Lib3270PfActionClass { | |
43 | + pw3270ActionClass parent_class; | |
44 | + | |
45 | + } Lib3270PfActionClass; | |
46 | + | |
47 | + typedef struct _Lib3270PfAction { | |
48 | + pw3270Action parent; | |
49 | + | |
50 | + } Lib3270PfAction; | |
51 | + | |
52 | + static void Lib3270PfAction_class_init(Lib3270PfActionClass *klass); | |
53 | + static void Lib3270PfAction_init(Lib3270PfAction *action); | |
54 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
55 | + | |
56 | + G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, PW3270_TYPE_PFKEY_ACTION); | |
57 | + | |
58 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
59 | + | |
60 | + if(terminal) | |
61 | + return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
62 | + | |
63 | + return FALSE; | |
64 | + | |
65 | + } | |
66 | + | |
67 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
68 | + | |
69 | + if(action && terminal && parameter) { | |
70 | + | |
71 | + H3270 * hSession = v3270_get_session(terminal); | |
72 | + | |
73 | + if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
74 | + | |
75 | + lib3270_pfkey(hSession,(int) g_variant_get_int32(parameter)); | |
76 | + | |
77 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
78 | + | |
79 | + lib3270_pfkey(hSession,(int) g_variant_get_uint32(parameter)); | |
80 | + | |
81 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
82 | + | |
83 | + lib3270_pfkey(hSession,(int) g_variant_get_int16(parameter)); | |
84 | + | |
85 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
86 | + | |
87 | + lib3270_pfkey(hSession,(int) g_variant_get_uint16(parameter)); | |
88 | + | |
89 | + } | |
90 | + | |
91 | + } | |
92 | + | |
93 | + } | |
94 | + | |
95 | + static const GVariantType * get_parameter_type(GAction *action) | |
96 | + { | |
97 | + return G_VARIANT_TYPE_UINT16; | |
98 | + } | |
99 | + | |
100 | + void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) { | |
101 | + | |
102 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
103 | + | |
104 | + action->activate = activate; | |
105 | + action->get_enabled = get_enabled; | |
106 | + action->change_widget = change_widget; | |
107 | + action->get_parameter_type = get_parameter_type; | |
108 | + | |
109 | + } | |
110 | + | |
111 | + void Lib3270PfAction_init(Lib3270PfAction *action) { | |
112 | + } | |
113 | + | |
114 | + GAction * pw3270_action_new_pfkey(void) { | |
115 | + | |
116 | + Lib3270PfAction * action = (Lib3270PfAction *) g_object_new(PW3270_TYPE_PFKEY_ACTION, NULL); | |
117 | + | |
118 | + // Setup the default name. | |
119 | + pw3270Action * abstract = PW3270_ACTION(action); | |
120 | + | |
121 | + if(abstract->name) | |
122 | + g_free(abstract->name); | |
123 | + | |
124 | + abstract->name = g_strdup("win.pfkey"); | |
125 | + | |
126 | + return G_ACTION(action); | |
127 | + } | |
128 | + | |
129 | + void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
130 | + | |
131 | + PW3270_ACTION_CLASS(Lib3270PfAction_parent_class)->change_widget(object,from,to); | |
132 | + | |
133 | + // Does the "enabled" state has changed? If yes notify customers. | |
134 | + gboolean enabled = get_enabled(object,to); | |
135 | + if(get_enabled(object,from) != enabled) | |
136 | + pw3270_action_set_enabled(object,enabled); | |
137 | + | |
138 | + } | |
139 | + | ... | ... |
src/actions/private.h
... | ... | @@ -72,11 +72,14 @@ |
72 | 72 | void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); |
73 | 73 | gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); |
74 | 74 | void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); |
75 | + const GVariantType * (*get_parameter_type)(GAction *action); | |
75 | 76 | |
76 | 77 | }; |
77 | 78 | |
78 | 79 | G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); |
79 | 80 | G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition); |
81 | + G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); | |
82 | + G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); | |
80 | 83 | |
81 | 84 | G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state); |
82 | 85 | G_GNUC_INTERNAL void pw3270_action_set_enabled(GAction *action, gboolean state); | ... | ... |