Commit 81583857459350d8dae215dc5133e01a07850f8c

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

Convertendo toggles em propriedades gtk

src/include/lib3270.h
@@ -119,12 +119,6 @@ @@ -119,12 +119,6 @@
119 LIB3270_TOGGLE_KEEP_ALIVE, /**< Enable network keep-alive with SO_KEEPALIVE */ 119 LIB3270_TOGGLE_KEEP_ALIVE, /**< Enable network keep-alive with SO_KEEPALIVE */
120 LIB3270_TOGGLE_NETWORK_TRACE, /**< Enable network in/out trace */ 120 LIB3270_TOGGLE_NETWORK_TRACE, /**< Enable network in/out trace */
121 121
122 -  
123 -// LIB3270_TOGGLE_ALT_CURSOR,  
124 -// LIB3270_TOGGLE_AID_WAIT,  
125 -// LIB3270_TOGGLE_SCROLL_BAR,  
126 -// LIB3270_TOGGLE_KEYPAD,  
127 -  
128 LIB3270_TOGGLE_COUNT 122 LIB3270_TOGGLE_COUNT
129 123
130 } LIB3270_TOGGLE; 124 } LIB3270_TOGGLE;
src/lib3270/toggles.c
@@ -55,39 +55,40 @@ @@ -55,39 +55,40 @@
55 #include "togglesc.h" 55 #include "togglesc.h"
56 #include "api.h" 56 #include "api.h"
57 57
58 -static const struct _toggle 58 +static const struct _toggle_info
59 { 59 {
60 - const char *name;  
61 - const char *description; 60 + const char * name;
  61 + const char def;
  62 + const char * description;
62 } 63 }
63 toggle_info[LIB3270_TOGGLE_COUNT] = 64 toggle_info[LIB3270_TOGGLE_COUNT] =
64 { 65 {
65 - { "monocase", N_( "" ) },  
66 - { "cursorblink", N_( "" ) },  
67 - { "showtiming", N_( "" ) },  
68 - { "cursorpos", N_( "" ) },  
69 - { "dstrace", N_( "" ) },  
70 - { "linewrap", N_( "" ) },  
71 - { "blankfill", N_( "" ) },  
72 - { "screentrace", N_( "" ) },  
73 - { "eventtrace", N_( "" ) },  
74 - { "marginedpaste", N_( "" ) },  
75 - { "rectselect", N_( "" ) },  
76 - { "crosshair", N_( "" ) },  
77 - { "fullscreen", N_( "" ) },  
78 - { "reconnect", N_( "" ) },  
79 - { "insert", N_( "" ) },  
80 - { "smartpaste", N_( "" ) },  
81 - { "bold", N_( "" ) },  
82 - { "keepselected", N_( "" ) },  
83 - { "underline", N_( "" ) },  
84 - { "autoconnect", N_( "" ) },  
85 - { "kpalternative", N_( "Keypad +/- move to next/previous field" ) },  
86 - { "beep", N_( "Beep on errors" ) },  
87 - { "fieldattr", N_( "Show Field attribute" ) },  
88 - { "altscreen", N_( "Auto resize on altscreen" ) },  
89 - { "keepalive", N_( "Enable network keep-alive with SO_KEEPALIVE" ) },  
90 - { "nettrace", N_( "Enable network in/out trace" ) }, 66 + { "monocase", False, N_( "Uppercase mode." ) },
  67 + { "cursorblink", True, N_( "" ) },
  68 + { "showtiming", False, N_( "" ) },
  69 + { "cursorpos", True, N_( "Display the cursor location in the OIA (the status line)." ) },
  70 + { "dstrace", False, N_( "" ) },
  71 + { "linewrap", False, N_( "" ) },
  72 + { "blankfill", False, N_( "Automatically convert trailing blanks in a field to NULLs in order to insert a character, and will automatically convert leading NULLs to blanks so that input data is not squeezed to the left" ) },
  73 + { "screentrace", False, N_( "" ) },
  74 + { "eventtrace", False, N_( "" ) },
  75 + { "marginedpaste", False, N_( "" ) },
  76 + { "rectselect", False, N_( "" ) },
  77 + { "crosshair", False, N_( "" ) },
  78 + { "fullscreen", False, N_( "" ) },
  79 + { "reconnect", False, N_( "" ) },
  80 + { "insert", False, N_( "" ) },
  81 + { "smartpaste", False, N_( "" ) },
  82 + { "bold", False, N_( "" ) },
  83 + { "keepselected", False, N_( "" ) },
  84 + { "underline", False, N_( "" ) },
  85 + { "autoconnect", False, N_( "" ) },
  86 + { "kpalternative", False, N_( "Keypad +/- move to next/previous field" ) },
  87 + { "beep", True, N_( "Beep on errors" ) },
  88 + { "fieldattr", False, N_( "Show Field attribute" ) },
  89 + { "altscreen", True, N_( "Auto resize on altscreen" ) },
  90 + { "keepalive", True, N_( "Enable network keep-alive with SO_KEEPALIVE" ) },
  91 + { "nettrace", False, N_( "Enable network in/out trace" ) },
91 }; 92 };
92 93
93 LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix) 94 LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix)
@@ -202,23 +203,11 @@ void initialize_toggles(H3270 *session) @@ -202,23 +203,11 @@ void initialize_toggles(H3270 *session)
202 session->toggle[LIB3270_TOGGLE_MONOCASE].upcall = toggle_redraw; 203 session->toggle[LIB3270_TOGGLE_MONOCASE].upcall = toggle_redraw;
203 session->toggle[LIB3270_TOGGLE_UNDERLINE].upcall = toggle_redraw; 204 session->toggle[LIB3270_TOGGLE_UNDERLINE].upcall = toggle_redraw;
204 session->toggle[LIB3270_TOGGLE_ALTSCREEN].upcall = toggle_altscreen; 205 session->toggle[LIB3270_TOGGLE_ALTSCREEN].upcall = toggle_altscreen;
205 - session->toggle[LIB3270_TOGGLE_ALTSCREEN].upcall = toggle_altscreen;  
206 session->toggle[LIB3270_TOGGLE_KEEP_ALIVE].upcall = toggle_keepalive; 206 session->toggle[LIB3270_TOGGLE_KEEP_ALIVE].upcall = toggle_keepalive;
207 207
208 - static const LIB3270_TOGGLE active_by_default[] =  
209 - {  
210 - LIB3270_TOGGLE_CURSOR_BLINK,  
211 - LIB3270_TOGGLE_CURSOR_POS,  
212 - LIB3270_TOGGLE_BEEP,  
213 - LIB3270_TOGGLE_ALTSCREEN,  
214 - LIB3270_TOGGLE_KEEP_ALIVE  
215 - };  
216 -  
217 - for(f=0;f< (sizeof(active_by_default)/sizeof(active_by_default[0])); f++)  
218 - session->toggle[active_by_default[f]].value = True;  
219 -  
220 for(f=0;f<LIB3270_TOGGLE_COUNT;f++) 208 for(f=0;f<LIB3270_TOGGLE_COUNT;f++)
221 { 209 {
  210 + session->toggle[f].value = toggle_info[f].def;
222 if(session->toggle[f].value) 211 if(session->toggle[f].value)
223 session->toggle[f].upcall(session,&session->toggle[f],TT_INITIAL); 212 session->toggle[f].upcall(session,&session->toggle[f],TT_INITIAL);
224 } 213 }
src/pw3270/v3270/widget.c
@@ -75,10 +75,6 @@ @@ -75,10 +75,6 @@
75 /* Construct */ 75 /* Construct */
76 PROP_TYPE, 76 PROP_TYPE,
77 77
78 - /* Normal Props */  
79 - PROP_FULLSCREEN,  
80 -  
81 -  
82 /* Toggle - always the last one, the real values are PROP_TOGGLE+LIB3270_TOGGLE */ 78 /* Toggle - always the last one, the real values are PROP_TOGGLE+LIB3270_TOGGLE */
83 PROP_TOGGLE 79 PROP_TOGGLE
84 }; 80 };
@@ -321,12 +317,6 @@ static void v3270_set_property(GObject *object, guint prop_id, const GValue *val @@ -321,12 +317,6 @@ static void v3270_set_property(GObject *object, guint prop_id, const GValue *val
321 317
322 switch (prop_id) 318 switch (prop_id)
323 { 319 {
324 - case PROP_FULLSCREEN:  
325 - if(g_value_get_boolean (value))  
326 - gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object))));  
327 - else  
328 - gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object))));  
329 - break;  
330 320
331 default: 321 default:
332 if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT)) 322 if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT))
@@ -345,10 +335,6 @@ static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GPa @@ -345,10 +335,6 @@ static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GPa
345 335
346 switch (prop_id) 336 switch (prop_id)
347 { 337 {
348 - case PROP_FULLSCREEN:  
349 - #warning Get the correct value  
350 - g_value_set_boolean(value,FALSE);  
351 - break;  
352 338
353 default: 339 default:
354 if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT)) 340 if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT))
@@ -630,10 +616,6 @@ static void v3270_class_init(v3270Class *klass) @@ -630,10 +616,6 @@ static void v3270_class_init(v3270Class *klass)
630 gobject_class->set_property = v3270_set_property; 616 gobject_class->set_property = v3270_set_property;
631 gobject_class->get_property = v3270_get_property; 617 gobject_class->get_property = v3270_get_property;
632 618
633 - v3270_properties[PROP_FULLSCREEN] = g_param_spec_boolean("fullscreen","Fullscreen","If TRUE, the toplevel window was set to fullscreen",FALSE,G_PARAM_WRITABLE|G_PARAM_READABLE);  
634 - g_object_class_install_property(gobject_class,PROP_FULLSCREEN,v3270_properties[PROP_FULLSCREEN]);  
635 -  
636 -  
637 // Toggle properties 619 // Toggle properties
638 int f; 620 int f;
639 621
@@ -760,6 +742,13 @@ static void set_timer(H3270 *session, unsigned char on) @@ -760,6 +742,13 @@ static void set_timer(H3270 *session, unsigned char on)
760 742
761 static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name) 743 static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name)
762 { 744 {
  745 + if(ix == LIB3270_TOGGLE_FULL_SCREEN)
  746 + {
  747 + if(value)
  748 + gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(session->widget))));
  749 + else
  750 + gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(session->widget))));
  751 + }
763 g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_TOGGLE+ix]); 752 g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_TOGGLE+ix]);
764 g_signal_emit(GTK_WIDGET(session->widget), v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); 753 g_signal_emit(GTK_WIDGET(session->widget), v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name);
765 } 754 }
src/pw3270/window.c
@@ -511,14 +511,6 @@ @@ -511,14 +511,6 @@
511 set_boolean_to_config("toggle",nm,toggled); 511 set_boolean_to_config("toggle",nm,toggled);
512 g_free(nm); 512 g_free(nm);
513 513
514 - if(id == LIB3270_TOGGLE_FULL_SCREEN)  
515 - {  
516 - if(toggled)  
517 - gtk_window_fullscreen(GTK_WINDOW(toplevel));  
518 - else  
519 - gtk_window_unfullscreen(GTK_WINDOW(toplevel));  
520 - }  
521 -  
522 if(list[id]) 514 if(list[id])
523 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(list[id]),toggled); 515 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(list[id]),toggled);
524 516