Commit a112b670bfca3a44f8c299659560a273ac6111dc

Authored by perry.werneck@gmail.com
1 parent cb78e38c

Iniciando inclusao de suporte para "plugin actions"

src/include/pw3270/plugin.h
... ... @@ -46,6 +46,11 @@
46 46 LIB3270_EXPORT void pw3270_plugin_start(GtkWidget *window);
47 47 LIB3270_EXPORT void pw3270_plugin_stop(GtkWidget *window);
48 48  
  49 + // plugins
  50 + LIB3270_EXPORT void pw3270_init_plugins(GtkWidget *widget);
  51 + LIB3270_EXPORT void pw3270_deinit_plugins(GtkWidget *widget);
  52 + LIB3270_EXPORT int pw3270_setup_plugin_action(GtkAction *action, GtkWidget *widget, const gchar *name);
  53 +
49 54 #ifdef __cplusplus
50 55 }
51 56 #endif
... ...
src/pw3270/Makefile.in
... ... @@ -56,10 +56,10 @@ include uiparser/sources.mak
56 56  
57 57 #---[ Targets ]----------------------------------------------------------------
58 58  
59   -APP_SOURCES= main.c plugin.c @APP_GUI_SRC@
  59 +APP_SOURCES= main.c @APP_GUI_SRC@
60 60  
61 61 LIB_SOURCES= window.c actions.c fonts.c dialog.c print.c colors.c \
62   - filetransfer.c tools.c \
  62 + filetransfer.c tools.c plugin.c \
63 63 $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \
64 64 $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
65 65 $(foreach SRC, $(COMMON_SRC), common/$(SRC))
... ...
src/pw3270/actions.c
... ... @@ -32,6 +32,7 @@
32 32 #include "globals.h"
33 33 #include "uiparser/parser.h"
34 34 #include <pw3270/v3270.h>
  35 + #include <pw3270/plugin.h>
35 36 #include "filetransfer.h"
36 37 #include <lib3270/actions.h>
37 38 #include <lib3270/selection.h>
... ... @@ -47,7 +48,7 @@
47 48 #define TOGGLE_GDKDEBUG LIB3270_TOGGLE_COUNT+1
48 49  
49 50 #ifdef X3270_TRACE
50   - #define trace_action(a,w) lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p\n",gtk_action_get_name(a),w);
  51 + #define trace_action(a,w) lib3270_trace_event(v3270_get_session(w),"Action %s activated on widget %p\n",gtk_action_get_name(a),w);
51 52 #else
52 53 #define trace_action(a,w) /* */
53 54 #endif // X3270_TRACE
... ... @@ -88,13 +89,6 @@ static void connect_action(GtkAction *action, GtkWidget *widget)
88 89 hostname_action(action,widget);
89 90 }
90 91  
91   -/*
92   -static void nop_action(GtkAction *action, GtkWidget *widget)
93   -{
94   - trace_action(action,widget);
95   -}
96   -*/
97   -
98 92 static void disconnect_action(GtkAction *action, GtkWidget *widget)
99 93 {
100 94 trace_action(action,widget);
... ... @@ -289,6 +283,10 @@ static void connect_standard_action(GtkAction *action, GtkWidget *widget, const
289 283 if(!g_ascii_strcasecmp(name,"screensizes"))
290 284 return;
291 285  
  286 + // Check for plugin actions
  287 + if(!pw3270_setup_plugin_action(action, widget, name))
  288 + return;
  289 +
292 290 // Not-found, disable action
293 291 gtk_action_set_sensitive(action,FALSE);
294 292 }
... ...
src/pw3270/globals.h
... ... @@ -77,9 +77,6 @@
77 77 G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget);
78 78 G_GNUC_INTERNAL void print_settings_action(GtkAction *action, GtkWidget *widget);
79 79  
80   - // plugins
81   - G_GNUC_INTERNAL void init_plugins(GtkWidget *widget);
82   - G_GNUC_INTERNAL void deinit_plugins(GtkWidget *widget);
83 80  
84 81  
85 82  
... ...
src/pw3270/main.c
... ... @@ -282,7 +282,7 @@ int main(int argc, char *argv[])
282 282 else
283 283 pw3270_restore_window(toplevel,"toplevel");
284 284  
285   - init_plugins(toplevel);
  285 + pw3270_init_plugins(toplevel);
286 286 gtk_window_present(GTK_WINDOW(toplevel));
287 287  
288 288 #ifdef HAVE_GTKMAC
... ... @@ -291,7 +291,7 @@ int main(int argc, char *argv[])
291 291  
292 292 gtk_main();
293 293  
294   - deinit_plugins(toplevel);
  294 + pw3270_deinit_plugins(toplevel);
295 295  
296 296 }
297 297  
... ...
src/pw3270/plugin.c
... ... @@ -125,7 +125,7 @@
125 125  
126 126 }
127 127  
128   - G_GNUC_INTERNAL void init_plugins(GtkWidget *widget)
  128 + LIB3270_EXPORT void pw3270_init_plugins(GtkWidget *widget)
129 129 {
130 130 #if defined(DEBUG)
131 131 load("." G_DIR_SEPARATOR_S "plugins", widget);
... ... @@ -137,7 +137,7 @@
137 137  
138 138 }
139 139  
140   - G_GNUC_INTERNAL void deinit_plugins(GtkWidget *widget)
  140 + LIB3270_EXPORT void pw3270_deinit_plugins(GtkWidget *widget)
141 141 {
142 142 int f;
143 143  
... ... @@ -168,3 +168,44 @@
168 168 hPlugin = NULL;
169 169 nPlugin = 0;
170 170 }
  171 +
  172 + LIB3270_EXPORT int pw3270_setup_plugin_action(GtkAction *action, GtkWidget *widget, const gchar *name)
  173 + {
  174 + int f;
  175 + gchar * fname;
  176 +
  177 + if(!hPlugin)
  178 + return ENOENT;
  179 +
  180 + // Search for plugin setup calls
  181 + fname = g_strdup_printf("pw3270_setup_action_%s",name);
  182 + for(f=0;f<nPlugin;f++)
  183 + {
  184 + int (*setup)(GtkAction *action, GtkWidget *widget);
  185 +
  186 + if(g_module_symbol(hPlugin[f], fname, (gpointer) &setup))
  187 + {
  188 + g_free(fname);
  189 + return setup(action,widget);
  190 + }
  191 + }
  192 + g_free(fname);
  193 +
  194 + // Search for activation callbacks
  195 + fname = g_strdup_printf("pw3270_action_%s_activated",name);
  196 + for(f=0;f<nPlugin;f++)
  197 + {
  198 + void (*call)(GtkAction *action, GtkWidget *widget);
  199 +
  200 + if(g_module_symbol(hPlugin[f], fname, (gpointer) &call))
  201 + {
  202 + g_signal_connect(action,"activate",G_CALLBACK(call),widget);
  203 + g_free(fname);
  204 + return 0;
  205 + }
  206 + }
  207 + g_free(fname);
  208 +
  209 + return ENOENT;
  210 +
  211 + }
... ...