Commit 5abb8018c3c526ea3b646308213b98c1ebec5868
1 parent
bf50c2f2
Exists in
master
and in
5 other branches
Corrigindo problemas na implementação de "actions" em plugins
Showing
7 changed files
with
113 additions
and
34 deletions
Show diff stats
pw3270.cbp
... | ... | @@ -432,6 +432,7 @@ |
432 | 432 | <Unit filename="ui/10functions.xml" /> |
433 | 433 | <Unit filename="ui/10keypad.xml" /> |
434 | 434 | <Unit filename="ui/99debug.xml" /> |
435 | + <Unit filename="ui/rexx.xml" /> | |
435 | 436 | <Unit filename="updateChangeLog.sh" /> |
436 | 437 | <Extensions> |
437 | 438 | <code_completion /> | ... | ... |
src/include/pw3270/plugin.h
... | ... | @@ -40,15 +40,19 @@ |
40 | 40 | extern "C" { |
41 | 41 | #endif |
42 | 42 | |
43 | - LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window); | |
44 | - LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window); | |
43 | + LIB3270_EXPORT int pw3270_plugin_init(void); | |
44 | + LIB3270_EXPORT int pw3270_plugin_deinit(void); | |
45 | 45 | |
46 | - LIB3270_EXPORT void pw3270_plugin_start(GtkWidget *window); | |
47 | - LIB3270_EXPORT void pw3270_plugin_stop(GtkWidget *window); | |
46 | + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window); | |
47 | + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window); | |
48 | 48 | |
49 | 49 | // plugins |
50 | - LIB3270_EXPORT void pw3270_init_plugins(GtkWidget *widget); | |
51 | - LIB3270_EXPORT void pw3270_deinit_plugins(GtkWidget *widget); | |
50 | + LIB3270_EXPORT void pw3270_init_plugins(void); | |
51 | + LIB3270_EXPORT void pw3270_deinit_plugins(void); | |
52 | + | |
53 | + LIB3270_EXPORT void pw3270_start_plugins(GtkWidget *widget); | |
54 | + LIB3270_EXPORT void pw3270_stop_plugins(GtkWidget *widget); | |
55 | + | |
52 | 56 | LIB3270_EXPORT int pw3270_setup_plugin_action(GtkAction *action, GtkWidget *widget, const gchar *name); |
53 | 57 | |
54 | 58 | #ifdef __cplusplus | ... | ... |
src/plugins/dbus3270/main.c
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | |
52 | 52 | /*---[ Implement ]-------------------------------------------------------------------------------*/ |
53 | 53 | |
54 | - LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) | |
54 | + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window) | |
55 | 55 | { |
56 | 56 | |
57 | 57 | GError * error = NULL; |
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | return 0; |
144 | 144 | } |
145 | 145 | |
146 | - LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window) | |
146 | + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window) | |
147 | 147 | { |
148 | 148 | if(service_name) |
149 | 149 | { | ... | ... |
src/plugins/rx3270/pluginmain.cc
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #include "rx3270.h" |
31 | 31 | #include <string.h> |
32 | 32 | #include <pw3270/plugin.h> |
33 | + #include <pw3270/v3270.h> | |
33 | 34 | #include <lib3270/actions.h> |
34 | 35 | #include <lib3270/log.h> |
35 | 36 | |
... | ... | @@ -198,3 +199,16 @@ |
198 | 199 | { |
199 | 200 | return lib3270_get_text(hSession,baddr,len); |
200 | 201 | } |
202 | + | |
203 | +extern "C" | |
204 | +{ | |
205 | + | |
206 | + LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) | |
207 | + { | |
208 | + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget); | |
209 | + | |
210 | + | |
211 | + | |
212 | + } | |
213 | + | |
214 | +} | ... | ... |
src/pw3270/main.c
... | ... | @@ -414,6 +414,7 @@ int main(int argc, char *argv[]) |
414 | 414 | gtk_settings_set_string_property(settings,"gtk-menu-bar-accel","Menu",""); |
415 | 415 | } |
416 | 416 | |
417 | + pw3270_init_plugins(); | |
417 | 418 | toplevel = pw3270_new(host,systype,syscolors); |
418 | 419 | pw3270_set_session_name(toplevel,session_name); |
419 | 420 | |
... | ... | @@ -441,7 +442,6 @@ int main(int argc, char *argv[]) |
441 | 442 | } |
442 | 443 | |
443 | 444 | |
444 | - | |
445 | 445 | toplevel_setup(GTK_WINDOW(toplevel)); |
446 | 446 | |
447 | 447 | if(pw3270_get_toggle(toplevel,LIB3270_TOGGLE_FULL_SCREEN)) |
... | ... | @@ -449,7 +449,7 @@ int main(int argc, char *argv[]) |
449 | 449 | else |
450 | 450 | pw3270_restore_window(toplevel,"toplevel"); |
451 | 451 | |
452 | - pw3270_init_plugins(toplevel); | |
452 | + pw3270_start_plugins(toplevel); | |
453 | 453 | gtk_window_present(GTK_WINDOW(toplevel)); |
454 | 454 | |
455 | 455 | #ifdef HAVE_GTKMAC |
... | ... | @@ -458,7 +458,8 @@ int main(int argc, char *argv[]) |
458 | 458 | |
459 | 459 | gtk_main(); |
460 | 460 | |
461 | - pw3270_deinit_plugins(toplevel); | |
461 | + pw3270_stop_plugins(toplevel); | |
462 | + pw3270_deinit_plugins(); | |
462 | 463 | |
463 | 464 | } |
464 | 465 | ... | ... |
src/pw3270/plugin.c
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | |
40 | 40 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
41 | 41 | |
42 | - static void load(const gchar *path, GtkWidget *widget) | |
42 | + static void load(const gchar *path) | |
43 | 43 | { |
44 | 44 | GDir * dir; |
45 | 45 | const gchar * name; |
... | ... | @@ -85,11 +85,11 @@ |
85 | 85 | } |
86 | 86 | else |
87 | 87 | { |
88 | - int (*init)(GtkWidget *); | |
88 | + int (*init)(); | |
89 | 89 | |
90 | 90 | if(g_module_symbol(handle, "pw3270_plugin_init", (gpointer) &init)) |
91 | 91 | { |
92 | - if(init(widget)) | |
92 | + if(init()) | |
93 | 93 | { |
94 | 94 | // Plugin init fails |
95 | 95 | g_module_close(handle); |
... | ... | @@ -104,7 +104,6 @@ |
104 | 104 | else |
105 | 105 | { |
106 | 106 | // No plugin init warn and save it anyway |
107 | - g_warning("No pw3270_plugin_init() method in %s",filename); | |
108 | 107 | lst = g_list_append(lst,handle); |
109 | 108 | } |
110 | 109 | } |
... | ... | @@ -121,7 +120,7 @@ |
121 | 120 | |
122 | 121 | if(lst) |
123 | 122 | { |
124 | - // At least one plugin was loaded, save handle, start it | |
123 | + // At least one plugin was loaded, save handle | |
125 | 124 | GList *l = g_list_first(lst); |
126 | 125 | int f; |
127 | 126 | |
... | ... | @@ -131,22 +130,15 @@ |
131 | 130 | |
132 | 131 | for(f=0;f<nPlugin && l;f++) |
133 | 132 | { |
134 | - void (*start)(GtkWidget *); | |
135 | - | |
136 | 133 | hPlugin[f] = (GModule *) l->data; |
137 | - | |
138 | 134 | l = g_list_next(l); |
139 | - | |
140 | - if(g_module_symbol(hPlugin[f], "pw3270_plugin_start", (gpointer) &start)) | |
141 | - start(widget); | |
142 | 135 | } |
143 | - | |
144 | 136 | g_list_free(lst); |
145 | 137 | } |
146 | 138 | |
147 | 139 | } |
148 | 140 | |
149 | - LIB3270_EXPORT void pw3270_init_plugins(GtkWidget *widget) | |
141 | + LIB3270_EXPORT void pw3270_init_plugins(void) | |
150 | 142 | { |
151 | 143 | #if defined( DEBUG ) |
152 | 144 | |
... | ... | @@ -165,12 +157,12 @@ |
165 | 157 | if(!g_file_test(path,G_FILE_TEST_IS_DIR)) |
166 | 158 | { |
167 | 159 | g_free(path); |
168 | - path = pw3270_build_filename(widget,"plugins",NULL); | |
160 | + path = pw3270_build_filename(NULL,"plugins",NULL); | |
169 | 161 | trace("%s using [%s]",__FUNCTION__,path); |
170 | 162 | } |
171 | 163 | } |
172 | 164 | |
173 | - load(path,widget); | |
165 | + load(path); | |
174 | 166 | |
175 | 167 | g_free(path); |
176 | 168 | g_free(dir); |
... | ... | @@ -203,29 +195,48 @@ |
203 | 195 | #endif |
204 | 196 | } |
205 | 197 | |
206 | - LIB3270_EXPORT void pw3270_deinit_plugins(GtkWidget *widget) | |
198 | + LIB3270_EXPORT void pw3270_start_plugins(GtkWidget *widget) | |
207 | 199 | { |
208 | - int f; | |
200 | + int f; | |
209 | 201 | |
210 | - if(!hPlugin) | |
211 | - return; | |
202 | + for(f=0;f<nPlugin;f++) | |
203 | + { | |
204 | + int (*start)(GtkWidget *); | |
212 | 205 | |
213 | - trace("Unloading %d plugin(s)",nPlugin); | |
206 | + if(g_module_symbol(hPlugin[f], "pw3270_plugin_start", (gpointer) &start)) | |
207 | + start(widget); | |
208 | + } | |
209 | + | |
210 | + } | |
211 | + | |
212 | + LIB3270_EXPORT void pw3270_stop_plugins(GtkWidget *widget) | |
213 | + { | |
214 | + int f; | |
214 | 215 | |
215 | 216 | for(f=0;f<nPlugin;f++) |
216 | 217 | { |
217 | - void (*stop)(GtkWidget *); | |
218 | + int (*stop)(GtkWidget *); | |
218 | 219 | |
219 | 220 | if(g_module_symbol(hPlugin[f], "pw3270_plugin_stop", (gpointer) &stop)) |
220 | 221 | stop(widget); |
221 | 222 | } |
222 | 223 | |
224 | + } | |
225 | + | |
226 | + LIB3270_EXPORT void pw3270_deinit_plugins(void) | |
227 | + { | |
228 | + int f; | |
229 | + | |
230 | + if(!hPlugin) | |
231 | + return; | |
232 | + | |
233 | + trace("Unloading %d plugin(s)",nPlugin); | |
223 | 234 | for(f=0;f<nPlugin;f++) |
224 | 235 | { |
225 | - void (*deinit)(GtkWidget *); | |
236 | + void (*deinit)(void); | |
226 | 237 | |
227 | 238 | if(g_module_symbol(hPlugin[f], "pw3270_plugin_deinit", (gpointer) &deinit)) |
228 | - deinit(widget); | |
239 | + deinit(); | |
229 | 240 | |
230 | 241 | g_module_close(hPlugin[f]); |
231 | 242 | } |
... | ... | @@ -240,17 +251,21 @@ |
240 | 251 | int f; |
241 | 252 | gchar * fname; |
242 | 253 | |
254 | + trace("%s hPlugin=%p",__FUNCTION__,hPlugin); | |
243 | 255 | if(!hPlugin) |
244 | 256 | return ENOENT; |
245 | 257 | |
246 | 258 | // Search for plugin setup calls |
247 | 259 | fname = g_strdup_printf("pw3270_setup_action_%s",name); |
260 | + trace("Searching for \"%s\"",fname); | |
261 | + | |
248 | 262 | for(f=0;f<nPlugin;f++) |
249 | 263 | { |
250 | 264 | int (*setup)(GtkAction *action, GtkWidget *widget); |
251 | 265 | |
252 | 266 | if(g_module_symbol(hPlugin[f], fname, (gpointer) &setup)) |
253 | 267 | { |
268 | + trace("%s=%p",fname,setup); | |
254 | 269 | g_free(fname); |
255 | 270 | return setup(action,widget); |
256 | 271 | } |
... | ... | @@ -259,12 +274,15 @@ |
259 | 274 | |
260 | 275 | // Search for activation callbacks |
261 | 276 | fname = g_strdup_printf("pw3270_action_%s_activated",name); |
277 | + trace("Searching for \"%s\"",fname); | |
278 | + | |
262 | 279 | for(f=0;f<nPlugin;f++) |
263 | 280 | { |
264 | 281 | void (*call)(GtkAction *action, GtkWidget *widget); |
265 | 282 | |
266 | 283 | if(g_module_symbol(hPlugin[f], fname, (gpointer) &call)) |
267 | 284 | { |
285 | + trace("%s=%p",fname,call); | |
268 | 286 | g_signal_connect(action,"activate",G_CALLBACK(call),widget); |
269 | 287 | g_free(fname); |
270 | 288 | return 0; | ... | ... |
... | ... | @@ -0,0 +1,41 @@ |
1 | +<!----------------------------------------------------------------------------- | |
2 | + | |
3 | + "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
4 | + (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
5 | + aplicativos mainframe. Registro no INPI sob o nome G3270. | |
6 | + | |
7 | + Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + | |
9 | + Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + Free Software Foundation. | |
12 | + | |
13 | + Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + obter mais detalhes. | |
17 | + | |
18 | + Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
20 | + Place, Suite 330, Boston, MA, 02111-1307, USA | |
21 | + | |
22 | + Contatos: | |
23 | + | |
24 | + perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
25 | + erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
26 | + licinio@bb.com.br (Licínio Luis Branco) | |
27 | + kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
28 | + | |
29 | +------------------------------------------------------------------------------> | |
30 | + | |
31 | +<ui> | |
32 | + <menubar name='topmenu' topmenu='yes'> | |
33 | + <menu name='FileMenu' label='_File' /> | |
34 | + <menu name='EditMenu' label='_Edit' /> | |
35 | + <menu name='View' label='_View' /> | |
36 | + <menu name='ScriptsMenu' label='Scripts' visible='yes' > | |
37 | + <menuitem action='rexx' label='External Rexx script'/> | |
38 | + </menu> | |
39 | + </menubar> | |
40 | +</ui> | |
41 | + | ... | ... |