From e812d17c2a22568a0c6f96b39542a13d9deb84e6 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 8 Apr 2013 14:38:01 +0000 Subject: [PATCH] Iniciando implementação da action que seleciona e executa um plugin rexx --- src/include/pw3270.h | 5 +++++ src/plugins/rx3270/pluginmain.cc | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/pw3270/tools.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) diff --git a/src/include/pw3270.h b/src/include/pw3270.h index bdd21d8..bfe9f95 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -71,6 +71,11 @@ LIB3270_EXPORT void pw3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options); LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type); + LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title); + + LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def); + LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val); + LIB3270_EXPORT gint pw3270_get_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint def); LIB3270_EXPORT void pw3270_set_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint val); diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index b03861a..f5602b9 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -27,8 +27,17 @@ * */ + #define ENABLE_NLS + #define GETTEXT_PACKAGE PACKAGE_NAME + #include "rx3270.h" + + #include + #include + #include + #include + #include #include #include #include @@ -72,12 +81,16 @@ }; - static plugin * session = NULL; +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + + static plugin * session = NULL; + static GMutex mutex; /*--[ Implement ]------------------------------------------------------------------------------------*/ LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) { + g_mutex_init(&mutex); session = new plugin(lib3270_get_default_session_handle()); session->set_plugin(); trace("%s: Rexx object is %p",__FUNCTION__,session); @@ -91,6 +104,7 @@ delete session; session = NULL; } + g_mutex_clear(&mutex); return 0; } @@ -203,12 +217,79 @@ extern "C" { + static void call_rexx_script(const gchar *filename) + { + + } + LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) { + gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src"); + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget); + if(!g_mutex_trylock(&mutex)) + { + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + "%s", _( "Can't start script" )); + + gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" )); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Please, try again in a few moments" )); + + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + return; + } + + gtk_action_set_sensitive(action,FALSE); + if(filename) + { + // Has filename, call it directly + call_rexx_script(filename); + } + else + { + // No filename, ask user + static const struct _list + { + const gchar *name; + const gchar *pattern; + } list[] = + { + { N_( "Rexx script file" ), "*.rex" }, + { N_( "Rexx class file" ), "*.cls" } + }; + + GtkFileFilter * filter[G_N_ELEMENTS(list)+1]; + unsigned int f; + + memset(filter,0,sizeof(filter)); + + for(f=0;f