From 4ac39648fcd945476099efbc8a5edab6f9e55e52 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 20 Dec 2012 19:21:31 +0000 Subject: [PATCH] Simplificando configuração do host para facilitar a transferência de arquivos "BB" --- src/include/lib3270.h | 7 ++++--- src/lib3270/kybd.c | 4 ++-- src/lib3270/options.c | 11 +++++++++-- src/pw3270/dialog.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- 4 files changed, 95 insertions(+), 40 deletions(-) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 7b8ac50..afb07eb 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -241,13 +241,14 @@ */ typedef enum lib3270_option { - LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */ - LIB3270_OPTION_AS400 = 0x0002, /**< Host is AS400? */ + LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */ + LIB3270_OPTION_KYBD_AS400 = 0x0002, /**< Prefix every PF with PA1 */ + LIB3270_OPTION_TSO = 0x0004, /**< Host is TSO? */ } LIB3270_OPTION; #define LIB3270_OPTION_DEFAULT 0 - #define LIB3270_OPTION_COUNT 2 + #define LIB3270_OPTION_COUNT 3 typedef struct _lib3270_option_entry { diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 6b65c56..13f8a80 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -566,14 +566,14 @@ LIB3270_FKEY_ACTION( pfkey ) if (hSession->kybdlock) { - if(hSession->options & LIB3270_OPTION_AS400) + if(hSession->options & LIB3270_OPTION_KYBD_AS400) enq_key(hSession,pa_xlate[0]); enq_key(hSession,pf_xlate[key-1]); } else { - if(hSession->options & LIB3270_OPTION_AS400) + if(hSession->options & LIB3270_OPTION_KYBD_AS400) key_AID(hSession,pa_xlate[0]); key_AID(hSession,pf_xlate[key-1]); diff --git a/src/lib3270/options.c b/src/lib3270/options.c index 34a9f89..9dd5389 100644 --- a/src/lib3270/options.c +++ b/src/lib3270/options.c @@ -46,9 +46,16 @@ }, { - LIB3270_OPTION_AS400, + LIB3270_OPTION_KYBD_AS400, "as400", - N_( "Host is AS_400" ), + N_( "Host is AS/400" ), + NULL + }, + + { + LIB3270_OPTION_TSO, + "tso", + N_( "Host is TSO" ), NULL }, diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c index 31e2293..dd67350 100644 --- a/src/pw3270/dialog.c +++ b/src/pw3270/dialog.c @@ -34,6 +34,36 @@ /*--[ Globals ]--------------------------------------------------------------------------------------*/ + static const struct _host_type + { + const gchar * name; + const gchar * description; + LIB3270_OPTION option; + } host_type[] = + { + { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO }, + { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_AS400 }, + { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, + { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } + }; + + static const struct _charset + { + const gchar *name; + const gchar *description; + } charset[] = + { + // http://en.wikipedia.org/wiki/Character_encoding + { "UTF-8", N_( "UTF-8" ) }, + { "ISO-8859-1", N_( "Western Europe (ISO 8859-1)" ) }, + { "CP1252", N_( "Windows Western languages (CP1252)" ) }, + + { NULL, NULL } + }; + + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + void load_3270_options_from_config(GtkWidget *widget) { int f; @@ -97,22 +127,8 @@ else { // Add charset options - static const struct _list - { - const gchar *charset; - const gchar *text; - } list[] = - { - // http://en.wikipedia.org/wiki/Character_encoding - { "UTF-8", N_( "UTF-8" ) }, - { "ISO-8859-1", N_( "Western Europe (ISO 8859-1)" ) }, - { "CP1252", N_( "Windows Western languages (CP1252)" ) }, - - { NULL, NULL } - }; - GtkWidget * label = gtk_label_new_with_mnemonic (_("C_haracter Coding:")); - const gchar * charset = NULL; + const gchar * scharset = NULL; #if GTK_CHECK_VERSION(3,0,0) GtkWidget * menu = gtk_combo_box_text_new(); #else @@ -125,14 +141,14 @@ int f; int p = 0; - g_get_charset(&charset); - *encoding = g_strdup(charset); + g_get_charset(&scharset); + *encoding = g_strdup(scharset); - text = g_strdup_printf(_("Current (%s)"),charset); + text = g_strdup_printf(_("Current (%s)"),scharset); #if GTK_CHECK_VERSION(3,0,0) - gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p,charset,text); + gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p,scharset,text); #else @@ -140,7 +156,7 @@ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(menu), renderer, "text", 0, NULL); gtk_list_store_append((GtkListStore *) model,&iter); - gtk_list_store_set((GtkListStore *) model, &iter, 0, text, 1, charset, -1); + gtk_list_store_set((GtkListStore *) model, &iter, 0, text, 1, scharset, -1); #endif // GTK(3,0,0) @@ -148,15 +164,15 @@ gtk_combo_box_set_active(GTK_COMBO_BOX(menu),p++); - for(f=0;list[f].charset;f++) + for(f=0;charset[f].name;f++) { - if(strcasecmp(charset,list[f].charset)) + if(strcasecmp(scharset,charset[f].name)) { #if GTK_CHECK_VERSION(3,0,0) - gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p++,list[f].charset,gettext(list[f].text)); + gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p++,charset[f].name,gettext(charset[f].description)); #else gtk_list_store_append((GtkListStore *) model,&iter); - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(list[f].text), 1, list[f].charset, -1); + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(charset[f].description), 1, charset[f].name, -1); #endif // GTK(3,0,0) } } @@ -304,9 +320,10 @@ void hostname_action(GtkAction *action, GtkWidget *widget) { - const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list(); +// const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list(); const gchar * title = g_object_get_data(G_OBJECT(action),"title"); + const gchar * systype = g_object_get_data(G_OBJECT(action),"type"); gchar * cfghost = get_string_from_config("host","uri",""); gchar * hostname; gchar * ptr; @@ -316,7 +333,7 @@ GtkEntry * host = GTK_ENTRY(gtk_entry_new()); GtkEntry * port = GTK_ENTRY(gtk_entry_new()); GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); - GtkToggleButton * optcheck[LIB3270_OPTION_COUNT]; +// GtkToggleButton * optcheck[LIB3270_OPTION_COUNT]; GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : N_( "Select hostname" )), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, @@ -344,12 +361,38 @@ gtk_table_attach(table,GTK_WIDGET(sslcheck), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); { + GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); + GtkBox * container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); + + // Host options + if(!systype) + { + // No system type defined, ask user + GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE)); + GtkWidget * widget = gtk_combo_box_text_new(); + gchar * str = get_string_from_config("host","systype",host_type[0].name); + int f; + + label = gtk_label_new_with_mnemonic( _("System _Type:") ); + gtk_table_attach(frame,label,0,1,0,1,0,0,5,0); + + for(f=0;f