Commit 6460e3d282a3aa2b4f19875273a62150a532cf04

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

Ajustando diálogo e opções de linha de comando para tratar corretamente o tipo d…

…e host e número de cores
src/include/lib3270/filetransfer.h
... ... @@ -56,7 +56,7 @@
56 56 LIB3270_FT_OPTION_ASCII = 0x0002,
57 57 LIB3270_FT_OPTION_CRLF = 0x0004,
58 58 LIB3270_FT_OPTION_APPEND = 0x0008,
59   - LIB3270_FT_OPTION_TSO = 0x0010,
  59 +// LIB3270_FT_OPTION_TSO = 0x0010,
60 60 LIB3270_FT_OPTION_REMAP_ASCII = 0x0020
61 61 } LIB3270_FT_OPTION;
62 62  
... ...
src/include/pw3270.h
... ... @@ -51,7 +51,7 @@
51 51 typedef struct _pw3270Class pw3270Class;
52 52  
53 53  
54   - LIB3270_EXPORT GtkWidget * pw3270_new(const gchar *host);
  54 + LIB3270_EXPORT GtkWidget * pw3270_new(const gchar *host, const gchar *systype, unsigned short colors);
55 55 LIB3270_EXPORT void pw3270_set_host(GtkWidget *widget, const gchar *uri);
56 56 LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix);
57 57 LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget);
... ...
src/lib3270/ft.c
... ... @@ -322,13 +322,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
322 322 (ft->flags & LIB3270_FT_OPTION_APPEND) ? " append" : ""
323 323 );
324 324  
  325 + trace("tso=%s",hSession->options & LIB3270_OPTION_TSO ? "yes" : "No");
  326 +
325 327 if(!(ft->flags & LIB3270_FT_OPTION_RECEIVE))
326 328 {
327 329 // Sending file
328 330  
329   - trace("tso=%d",ft->flags & LIB3270_FT_OPTION_TSO);
330   -
331   - if(ft->flags & LIB3270_FT_OPTION_TSO)
  331 + if(hSession->options & LIB3270_OPTION_TSO)
332 332 {
333 333 // TSO Host
334 334 if(recfm > 0)
... ... @@ -375,7 +375,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
375 375  
376 376 if(*op)
377 377 {
378   - if(ft->flags & LIB3270_FT_OPTION_TSO)
  378 + if(hSession->options & LIB3270_OPTION_TSO)
379 379 snconcat(buffer,4095," %s",op+1);
380 380 else
381 381 snconcat(buffer,4095," (%s",op+1);
... ...
src/pw3270/actions.c
... ... @@ -67,27 +67,41 @@ static void lib3270_action(GtkAction *action, GtkWidget *widget)
67 67  
68 68 static void connect_action(GtkAction *action, GtkWidget *widget)
69 69 {
70   - gchar *host = (gchar *) g_object_get_data(G_OBJECT(action),"host");
  70 + const gchar * host = (const gchar *) g_object_get_data(G_OBJECT(action),"host");
  71 + const gchar * systype = (const gchar *) g_object_get_data(G_OBJECT(action),"type");
  72 + const gchar * colortype = (const gchar *) g_object_get_data(G_OBJECT(action),"colors");
  73 + unsigned short colors;
71 74  
72 75 trace_action(action,widget);
73 76  
  77 + if(!systype)
  78 + systype = get_string_from_config("host","systype","S390");
  79 +
  80 + if(colortype)
  81 + colors = atoi(colortype);
  82 + else
  83 + colors = (unsigned short) get_integer_from_config("host","colortype",16);
  84 +
  85 + trace("System type=%s System colors=%d",systype,(int) colors);
  86 +
  87 + v3270_set_session_color_type(widget,colors);
  88 + v3270_set_session_options(widget,pw3270_options_by_hosttype(systype));
  89 +
74 90 if(host)
75 91 {
76   - v3270_set_session_options(widget,0);
77   - v3270_set_session_color_type(widget,0);
78 92 v3270_connect(widget,host);
79   - return;
80 93 }
81   -
82   - host = get_string_from_config("host","uri","");
83   - if(*host)
  94 + else
84 95 {
85   - load_3270_options_from_config(widget);
86   - v3270_connect(widget,host);
87   - g_free(host);
88   - return;
  96 + gchar *ptr = get_string_from_config("host","uri","");
  97 + if(*ptr)
  98 + {
  99 + v3270_connect(widget,ptr);
  100 + g_free(ptr);
  101 + return;
  102 + }
  103 + g_free(ptr);
89 104 }
90   - g_free(host);
91 105  
92 106 hostname_action(action,widget);
93 107 }
... ...
src/pw3270/dialog.c
... ... @@ -51,20 +51,6 @@
51 51  
52 52 /*--[ Implement ]------------------------------------------------------------------------------------*/
53 53  
54   - void load_3270_options_from_config(GtkWidget *widget)
55   - {
56   - int f;
57   - LIB3270_OPTION opt = 0;
58   - const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list();
59   -
60   - for(f=0;f<LIB3270_OPTION_COUNT;f++)
61   - {
62   - if(get_boolean_from_config("host",options[f].key,FALSE))
63   - opt |= options[f].value;
64   - }
65   - v3270_set_session_options(widget,opt);
66   - }
67   -
68 54  
69 55 static void charset_changed(GtkComboBox *widget,gchar **encoding)
70 56 {
... ...
src/pw3270/filetransfer.c
... ... @@ -255,7 +255,7 @@ static void add_transfer_options(GObject *action, struct ftdialog *dlg)
255 255 {
256 256 static const struct ftoption option[] =
257 257 { { LIB3270_FT_OPTION_ASCII, "text", N_( "_Text file" ) },
258   - { LIB3270_FT_OPTION_TSO, "tso", N_( "Host is T_SO" ) },
  258 +// { LIB3270_FT_OPTION_TSO, "tso", N_( "Host is T_SO" ) },
259 259 { LIB3270_FT_OPTION_CRLF, "cr", N_( "Add/Remove _CR at end of line" ) },
260 260 { LIB3270_FT_OPTION_APPEND, "append", N_( "_Append" ) },
261 261 { LIB3270_FT_OPTION_REMAP_ASCII, "remap", N_( "_Remap ASCII Characters" ) }
... ...
src/pw3270/globals.h
... ... @@ -57,12 +57,11 @@
57 57  
58 58 #include "common/common.h"
59 59  
60   - G_GNUC_INTERNAL GtkWidget * create_main_window(const gchar *uri);
61   - G_GNUC_INTERNAL void setup_font_list(GtkWidget *widget, GtkWidget *obj);
62   - G_GNUC_INTERNAL void load_color_schemes(GtkWidget *widget, gchar *active);
63   - G_GNUC_INTERNAL GtkWidget * color_scheme_new(const GdkColor *current);
64   -
65   - G_GNUC_INTERNAL void load_3270_options_from_config(GtkWidget *widget);
  60 + G_GNUC_INTERNAL GtkWidget * create_main_window(const gchar *uri);
  61 + G_GNUC_INTERNAL void setup_font_list(GtkWidget *widget, GtkWidget *obj);
  62 + G_GNUC_INTERNAL void load_color_schemes(GtkWidget *widget, gchar *active);
  63 + G_GNUC_INTERNAL GtkWidget * color_scheme_new(const GdkColor *current);
  64 + G_GNUC_INTERNAL LIB3270_OPTION pw3270_options_by_hosttype(const gchar *systype);
66 65  
67 66  
68 67 // actions
... ...
src/pw3270/hostdialog.c
... ... @@ -58,6 +58,20 @@
58 58  
59 59 /*--[ Implement ]------------------------------------------------------------------------------------*/
60 60  
  61 + LIB3270_OPTION pw3270_options_by_hosttype(const gchar *systype)
  62 + {
  63 + int f;
  64 +
  65 + for(f=0;G_N_ELEMENTS(host_type);f++)
  66 + {
  67 + if(!g_ascii_strcasecmp(host_type[f].name,systype))
  68 + return host_type[f].option;
  69 + }
  70 +
  71 + g_message("Unexpected system type: \"%s\"",systype);
  72 + return 0;
  73 + }
  74 +
61 75 static void set_row(int row, GtkWidget *widget, GtkTable *container, const gchar *text)
62 76 {
63 77 GtkWidget *label = gtk_label_new_with_mnemonic(text);
... ...
src/pw3270/main.c
... ... @@ -42,17 +42,13 @@
42 42 #include "v3270/accessible.h"
43 43 #include <stdlib.h>
44 44  
45   - struct option
46   - {
47   - int colors;
48   - };
49   -
50   - #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME)
  45 +#define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME)
51 46  
52 47 /*--[ Statics ]--------------------------------------------------------------------------------------*/
53 48  
54   - static struct option cmdline_opt = { LIB3270_OPTION_DEFAULT };
55 49 static GtkWidget * toplevel = NULL;
  50 + static unsigned int syscolors = 16;
  51 + static const gchar * systype = NULL;
56 52  
57 53 #ifdef HAVE_GTKMAC
58 54 GtkOSXApplication * osxapp = NULL;
... ... @@ -169,15 +165,15 @@ static gboolean datadir(const gchar *option_name, const gchar *value, gpointer d
169 165  
170 166 static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer data, GError **error)
171 167 {
172   - static const unsigned char valid[] = { 2,8,16 };
  168 + static const unsigned short valid[] = { 2,8,16 };
173 169 int f;
174   - unsigned char optval = (unsigned char) atoi(value);
  170 + unsigned short optval = (unsigned short) atoi(value);
175 171  
176 172 for(f=0;f<G_N_ELEMENTS(valid);f++)
177 173 {
178 174 if(optval == valid[f])
179 175 {
180   - ((struct option *) data)->colors = optval;
  176 + syscolors = optval;
181 177 return TRUE;
182 178 }
183 179 }
... ... @@ -255,13 +251,14 @@ int main(int argc, char *argv[])
255 251 { "session", 's', 0, G_OPTION_ARG_STRING, &session_name, N_( "Session name" ), PACKAGE_NAME },
256 252 { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), NULL },
257 253 { "colors", 'c', 0, G_OPTION_ARG_CALLBACK, optcolors, N_( "Set reported colors (8/16)" ), "16" },
  254 + { "systype", 't', 0, G_OPTION_ARG_STRING, &system, N_( "Host system type" ), "S390" },
258 255  
259 256 { NULL }
260 257 };
261 258  
262 259 GOptionContext * context = g_option_context_new (_("- 3270 Emulator for Gtk"));
263 260 GError * error = NULL;
264   - GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, &cmdline_opt, NULL);
  261 + GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, NULL, NULL);
265 262  
266 263 g_option_context_set_main_group(context, group);
267 264  
... ... @@ -342,9 +339,8 @@ int main(int argc, char *argv[])
342 339 gtk_settings_set_string_property(settings,"gtk-menu-bar-accel","Menu","");
343 340 }
344 341  
345   - toplevel = pw3270_new(host);
  342 + toplevel = pw3270_new(host,systype,syscolors);
346 343 pw3270_set_session_name(toplevel,session_name);
347   - pw3270_set_session_color_type(toplevel,cmdline_opt.colors);
348 344 // pw3270_set_session_options(toplevel,cmdline_opt.host);
349 345  
350 346 toplevel_setup(GTK_WINDOW(toplevel));
... ...
src/pw3270/window.c
... ... @@ -176,9 +176,28 @@
176 176  
177 177 }
178 178  
179   - GtkWidget * pw3270_new(const gchar *host)
  179 + GtkWidget * pw3270_new(const gchar *host, const gchar *systype, unsigned short colors)
180 180 {
181   - GtkWidget *widget = g_object_new(GTK_TYPE_PW3270, NULL);
  181 + GtkWidget * widget = g_object_new(GTK_TYPE_PW3270, NULL);
  182 +
  183 + if(systype)
  184 + {
  185 + set_string_to_config("host","uri","%s",systype);
  186 + pw3270_set_session_options(widget,pw3270_options_by_hosttype(systype));
  187 + }
  188 + else
  189 + {
  190 + gchar *ptr = get_string_from_config("host","systype","S390");
  191 + pw3270_set_session_options(widget,pw3270_options_by_hosttype(ptr));
  192 + g_free(ptr);
  193 + }
  194 +
  195 + if(colors)
  196 + set_integer_to_config("host","colortype",colors);
  197 + else
  198 + colors = get_integer_from_config("host","colortype",16);
  199 +
  200 + pw3270_set_session_color_type(widget,colors);
182 201  
183 202 if(host)
184 203 {
... ...