Commit 319796e75c796b419f60e6f0a3101ed330c79399
1 parent
1b59e407
Exists in
master
and in
4 other branches
Moving lib3270 action to the v3270 library.
Showing
7 changed files
with
11 additions
and
164 deletions
Show diff stats
pw3270.cbp
@@ -49,7 +49,6 @@ | @@ -49,7 +49,6 @@ | ||
49 | <Unit filename="src/include/pw3270/settings.h" /> | 49 | <Unit filename="src/include/pw3270/settings.h" /> |
50 | <Unit filename="src/include/pw3270/toolbar.h" /> | 50 | <Unit filename="src/include/pw3270/toolbar.h" /> |
51 | <Unit filename="src/include/pw3270/window.h" /> | 51 | <Unit filename="src/include/pw3270/window.h" /> |
52 | - <Unit filename="src/include/v3270_actions.h" /> | ||
53 | <Unit filename="src/main/main.c"> | 52 | <Unit filename="src/main/main.c"> |
54 | <Option compilerVar="CC" /> | 53 | <Option compilerVar="CC" /> |
55 | </Unit> | 54 | </Unit> |
src/include/pw3270/actions.h
@@ -97,11 +97,11 @@ | @@ -97,11 +97,11 @@ | ||
97 | 97 | ||
98 | GType pw3270Action_get_type(void) G_GNUC_CONST; | 98 | GType pw3270Action_get_type(void) G_GNUC_CONST; |
99 | 99 | ||
100 | - /// @brief New generica acion. | 100 | + /// @brief New generic action. |
101 | GAction * pw3270_action_new(); | 101 | GAction * pw3270_action_new(); |
102 | 102 | ||
103 | /// @brief New action from LIB3270's control data. | 103 | /// @brief New action from LIB3270's control data. |
104 | - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); | 104 | + GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition); |
105 | 105 | ||
106 | /// @brief Get action name. | 106 | /// @brief Get action name. |
107 | const gchar * pw3270_action_get_name(GAction *action); | 107 | const gchar * pw3270_action_get_name(GAction *action); |
src/objects/actions/connect.c
@@ -34,13 +34,16 @@ | @@ -34,13 +34,16 @@ | ||
34 | 34 | ||
35 | #include "private.h" | 35 | #include "private.h" |
36 | 36 | ||
37 | + /* | ||
37 | static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | 38 | static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { |
38 | 39 | ||
39 | debug("%s",__FUNCTION__); | 40 | debug("%s",__FUNCTION__); |
40 | gtk_widget_activate(terminal); | 41 | gtk_widget_activate(terminal); |
41 | 42 | ||
42 | } | 43 | } |
44 | + */ | ||
43 | 45 | ||
46 | + /* | ||
44 | GAction * pw3270_action_connect_new(void) { | 47 | GAction * pw3270_action_connect_new(void) { |
45 | 48 | ||
46 | pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); | 49 | pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); |
@@ -51,3 +54,4 @@ | @@ -51,3 +54,4 @@ | ||
51 | return G_ACTION(action); | 54 | return G_ACTION(action); |
52 | 55 | ||
53 | } | 56 | } |
57 | + */ |
src/objects/actions/lib3270/action.c
@@ -1,159 +0,0 @@ | @@ -1,159 +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 actions. | ||
32 | - * | ||
33 | - */ | ||
34 | - | ||
35 | - #include "../private.h" | ||
36 | - #include <v3270.h> | ||
37 | - | ||
38 | - #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type()) | ||
39 | - #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action)) | ||
40 | - #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION)) | ||
41 | - | ||
42 | - typedef struct _Lib3270ActionClass { | ||
43 | - pw3270ActionClass parent_class; | ||
44 | - | ||
45 | - } Lib3270ActionClass; | ||
46 | - | ||
47 | - typedef struct _Lib3270Action { | ||
48 | - pw3270Action parent; | ||
49 | - | ||
50 | - const LIB3270_ACTION * definition; | ||
51 | - const void * listener; | ||
52 | - | ||
53 | - } Lib3270Action; | ||
54 | - | ||
55 | - static void Lib3270Action_class_init(Lib3270ActionClass *klass); | ||
56 | - static void Lib3270Action_init(Lib3270Action *action); | ||
57 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | ||
58 | - | ||
59 | - G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION); | ||
60 | - | ||
61 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | ||
62 | - | ||
63 | - if(terminal) { | ||
64 | - | ||
65 | - H3270 * hSession = v3270_get_session(terminal); | ||
66 | - if(hSession) | ||
67 | - return PW3270_LIB3270_ACTION(action)->definition->activatable(hSession) > 0 ? TRUE : FALSE; | ||
68 | - | ||
69 | - } | ||
70 | - | ||
71 | - return FALSE; | ||
72 | - | ||
73 | - } | ||
74 | - | ||
75 | - static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | ||
76 | - PW3270_LIB3270_ACTION(action)->definition->activate(v3270_get_session(terminal)); | ||
77 | - } | ||
78 | - | ||
79 | - static const gchar * get_icon_name(GAction *action) { | ||
80 | - debug("%s(%s)=\"%s\"",__FUNCTION__,g_action_get_name(action),PW3270_LIB3270_ACTION(action)->definition->icon); | ||
81 | - return PW3270_LIB3270_ACTION(action)->definition->icon; | ||
82 | - } | ||
83 | - | ||
84 | - static const gchar * get_label(GAction *action) { | ||
85 | - return PW3270_LIB3270_ACTION(action)->definition->label; | ||
86 | - } | ||
87 | - | ||
88 | - static const gchar * get_tooltip(GAction *action) { | ||
89 | - return PW3270_LIB3270_ACTION(action)->definition->summary; | ||
90 | - } | ||
91 | - | ||
92 | - static void dispose(GObject *object) { | ||
93 | - | ||
94 | - Lib3270Action *action = PW3270_LIB3270_ACTION(object); | ||
95 | - | ||
96 | - if(action->listener) { | ||
97 | - lib3270_unregister_action_group_listener(pw3270_action_get_session(G_ACTION(object)),action->definition->group,action->listener); | ||
98 | - action->listener = NULL; | ||
99 | - } | ||
100 | - | ||
101 | - G_OBJECT_CLASS(Lib3270Action_parent_class)->dispose(object); | ||
102 | - } | ||
103 | - | ||
104 | - void Lib3270Action_class_init(Lib3270ActionClass *klass) { | ||
105 | - | ||
106 | - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | ||
107 | - | ||
108 | - action->get_enabled = get_enabled; | ||
109 | - action->change_widget = change_widget; | ||
110 | - action->get_icon_name = get_icon_name; | ||
111 | - action->get_label = get_label; | ||
112 | - action->get_tooltip = get_tooltip; | ||
113 | - | ||
114 | - G_OBJECT_CLASS(klass)->dispose = dispose; | ||
115 | - | ||
116 | - } | ||
117 | - | ||
118 | - void Lib3270Action_init(Lib3270Action *action) { | ||
119 | - | ||
120 | - action->parent.activate = activate; | ||
121 | - action->parent.name = "tn3270"; | ||
122 | - | ||
123 | - } | ||
124 | - | ||
125 | - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition) { | ||
126 | - | ||
127 | - Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL); | ||
128 | - | ||
129 | - // Setup hooks. | ||
130 | - action->definition = definition; | ||
131 | - action->listener = NULL; | ||
132 | - action->parent.name = definition->name; | ||
133 | - | ||
134 | - return G_ACTION(action); | ||
135 | - } | ||
136 | - | ||
137 | - static void event_listener(H3270 G_GNUC_UNUSED(*hSession), void *object) { | ||
138 | - pw3270_action_notify_enabled(G_ACTION(object)); | ||
139 | - } | ||
140 | - | ||
141 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | ||
142 | - | ||
143 | - // Remove old listener | ||
144 | - Lib3270Action * action = PW3270_LIB3270_ACTION(object); | ||
145 | - if(action->listener) { | ||
146 | - lib3270_unregister_action_group_listener(pw3270_action_get_session(object),action->definition->group,action->listener); | ||
147 | - action->listener = NULL; | ||
148 | - } | ||
149 | - | ||
150 | - // Change widget | ||
151 | - PW3270_ACTION_CLASS(Lib3270Action_parent_class)->change_widget(object,from,to); | ||
152 | - | ||
153 | - // Setup new listener | ||
154 | - if(action->definition->group && to) { | ||
155 | - action->listener = lib3270_register_action_group_listener(pw3270_action_get_session(object),action->definition->group,event_listener,object); | ||
156 | - } | ||
157 | - | ||
158 | - } | ||
159 | - |
src/objects/actions/private.h
@@ -61,7 +61,7 @@ | @@ -61,7 +61,7 @@ | ||
61 | G_GNUC_INTERNAL void pw3270_action_notify_state(GAction *object); | 61 | G_GNUC_INTERNAL void pw3270_action_notify_state(GAction *object); |
62 | 62 | ||
63 | // Internal actions | 63 | // Internal actions |
64 | - G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); | 64 | +// G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); |
65 | G_GNUC_INTERNAL GAction * pw3270_action_copy_new(void); | 65 | G_GNUC_INTERNAL GAction * pw3270_action_copy_new(void); |
66 | G_GNUC_INTERNAL GAction * pw3270_action_cut_new(void); | 66 | G_GNUC_INTERNAL GAction * pw3270_action_cut_new(void); |
67 | G_GNUC_INTERNAL GAction * pw3270_action_paste_new(void); | 67 | G_GNUC_INTERNAL GAction * pw3270_action_paste_new(void); |
src/objects/actions/window.c
@@ -42,16 +42,18 @@ | @@ -42,16 +42,18 @@ | ||
42 | GActionMap * map = G_ACTION_MAP(appwindow); | 42 | GActionMap * map = G_ACTION_MAP(appwindow); |
43 | size_t ix; | 43 | size_t ix; |
44 | 44 | ||
45 | + /* | ||
45 | // Map lib3270 actions | 46 | // Map lib3270 actions |
46 | { | 47 | { |
47 | const LIB3270_ACTION * actions = lib3270_get_actions(); | 48 | const LIB3270_ACTION * actions = lib3270_get_actions(); |
48 | for(ix = 0; actions[ix].name; ix++) { | 49 | for(ix = 0; actions[ix].name; ix++) { |
49 | 50 | ||
50 | - GAction *action = pw3270_action_new_from_lib3270(&actions[ix]); | 51 | + GAction *action = g_action_new_from_lib3270(&actions[ix]); |
51 | g_action_map_add_action(map,action); | 52 | g_action_map_add_action(map,action); |
52 | 53 | ||
53 | } | 54 | } |
54 | } | 55 | } |
56 | + */ | ||
55 | 57 | ||
56 | // Map toggles | 58 | // Map toggles |
57 | { | 59 | { |
src/objects/window/window.c
@@ -143,6 +143,7 @@ | @@ -143,6 +143,7 @@ | ||
143 | pw3270_window_add_actions(GTK_WIDGET(widget)); | 143 | pw3270_window_add_actions(GTK_WIDGET(widget)); |
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 | 147 | ||
147 | // Map special actions | 148 | // Map special actions |
148 | { | 149 | { |