Commit 5089e43f7462bb35226e829b9e2c612f2ba43b44
1 parent
913e6102
Exists in
master
and in
5 other branches
Implementando novo widget para seleção de servidor
Showing
12 changed files
with
584 additions
and
55 deletions
Show diff stats
pw3270.cbp
... | ... | @@ -416,6 +416,9 @@ |
416 | 416 | <Option compilerVar="CC" /> |
417 | 417 | </Unit> |
418 | 418 | <Unit filename="src/pw3270/v3270/genmarshal" /> |
419 | + <Unit filename="src/pw3270/v3270/hostselect.c"> | |
420 | + <Option compilerVar="CC" /> | |
421 | + </Unit> | |
419 | 422 | <Unit filename="src/pw3270/v3270/iocallback.c"> |
420 | 423 | <Option compilerVar="CC" /> |
421 | 424 | </Unit> | ... | ... |
src/include/lib3270.h
... | ... | @@ -415,6 +415,9 @@ |
415 | 415 | */ |
416 | 416 | LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h); |
417 | 417 | |
418 | + LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname); | |
419 | + | |
420 | + | |
418 | 421 | /** |
419 | 422 | * Get servic or port for the connect/reconnect operations. |
420 | 423 | * |
... | ... | @@ -425,6 +428,7 @@ |
425 | 428 | */ |
426 | 429 | LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h); |
427 | 430 | |
431 | + LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc); | |
428 | 432 | |
429 | 433 | /** |
430 | 434 | * Get session options. |
... | ... | @@ -1055,6 +1059,8 @@ |
1055 | 1059 | LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype); |
1056 | 1060 | LIB3270_EXPORT unsigned short lib3270_get_color_type(H3270 *hSession); |
1057 | 1061 | |
1062 | + LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name); | |
1063 | + | |
1058 | 1064 | LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); |
1059 | 1065 | |
1060 | 1066 | /** | ... | ... |
src/include/pw3270/v3270.h
src/lib3270/host.c
... | ... | @@ -492,6 +492,20 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
492 | 492 | trace("%s ends",__FUNCTION__); |
493 | 493 | } |
494 | 494 | |
495 | +static void update_host(H3270 *h) | |
496 | +{ | |
497 | + Replace(h->host.full, | |
498 | + lib3270_strdup_printf( | |
499 | + "%s%s:%s", | |
500 | + h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
501 | + h->host.current, | |
502 | + h->host.srvc | |
503 | + )); | |
504 | + | |
505 | + trace("hosturl=[%s]",h->host.full); | |
506 | + | |
507 | +} | |
508 | + | |
495 | 509 | LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) |
496 | 510 | { |
497 | 511 | CHECK_SESSION_HANDLE(h); |
... | ... | @@ -558,17 +572,8 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) |
558 | 572 | |
559 | 573 | Replace(h->host.current,strdup(hostname)); |
560 | 574 | Replace(h->host.srvc,strdup(srvc)); |
561 | - Replace(h->host.full, | |
562 | - lib3270_strdup_printf( | |
563 | - "%s%s:%s%s%s", | |
564 | - h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
565 | - hostname, | |
566 | - srvc, | |
567 | - *query ? "?" : "", | |
568 | - query | |
569 | - )); | |
570 | - | |
571 | - trace("hosturl=[%s]",h->host.full); | |
575 | + | |
576 | + update_host(h); | |
572 | 577 | |
573 | 578 | free(str); |
574 | 579 | } |
... | ... | @@ -586,6 +591,13 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) |
586 | 591 | return ""; |
587 | 592 | } |
588 | 593 | |
594 | +LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) | |
595 | +{ | |
596 | + CHECK_SESSION_HANDLE(h); | |
597 | + Replace(h->host.current,strdup(hostname)); | |
598 | + update_host(h); | |
599 | +} | |
600 | + | |
589 | 601 | LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) |
590 | 602 | { |
591 | 603 | CHECK_SESSION_HANDLE(h); |
... | ... | @@ -594,6 +606,13 @@ LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) |
594 | 606 | return "telnet"; |
595 | 607 | } |
596 | 608 | |
609 | +LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) | |
610 | +{ | |
611 | + CHECK_SESSION_HANDLE(h); | |
612 | + Replace(h->host.srvc,strdup(srvc)); | |
613 | + update_host(h); | |
614 | +} | |
615 | + | |
597 | 616 | LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) |
598 | 617 | { |
599 | 618 | CHECK_SESSION_HANDLE(h); | ... | ... |
src/lib3270/options.c
... | ... | @@ -134,3 +134,33 @@ LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) |
134 | 134 | CHECK_SESSION_HANDLE(hSession); |
135 | 135 | return (hSession->options & LIB3270_OPTION_TSO) != 0; |
136 | 136 | } |
137 | + | |
138 | +LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) | |
139 | +{ | |
140 | + static const struct _host_type | |
141 | + { | |
142 | + const char * name; | |
143 | + LIB3270_OPTION option; | |
144 | + } host_type[] = | |
145 | + { | |
146 | + { "S390", LIB3270_OPTION_S390 }, | |
147 | + { "AS400", LIB3270_OPTION_AS400 }, | |
148 | + { "TSO", LIB3270_OPTION_TSO }, | |
149 | + { "VM/CMS", 0 } | |
150 | + }; | |
151 | + | |
152 | + int f; | |
153 | + | |
154 | + for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) | |
155 | + { | |
156 | + if(!strcasecmp(host_type[f].name,name)) | |
157 | + { | |
158 | + hSession->options &= ~LIB3270_OPTION_HOST_TYPE; | |
159 | + hSession->options |= host_type[f].option; | |
160 | + return 0; | |
161 | + } | |
162 | + } | |
163 | + | |
164 | + return EINVAL; | |
165 | +} | |
166 | + | ... | ... |
src/pw3270/actions.c
... | ... | @@ -75,6 +75,9 @@ static void connect_action(GtkAction *action, GtkWidget *widget) |
75 | 75 | |
76 | 76 | trace_action(action,widget); |
77 | 77 | |
78 | + #warning Reimplementar | |
79 | + | |
80 | + /* | |
78 | 81 | if(!systype) |
79 | 82 | systype = get_string_from_config("host","systype","S390"); |
80 | 83 | |
... | ... | @@ -87,6 +90,7 @@ static void connect_action(GtkAction *action, GtkWidget *widget) |
87 | 90 | |
88 | 91 | v3270_set_session_color_type(widget,colors); |
89 | 92 | v3270_set_session_options(widget,pw3270_options_by_hosttype(systype)); |
93 | + */ | |
90 | 94 | |
91 | 95 | if(host) |
92 | 96 | { | ... | ... |
src/pw3270/hostdialog.c
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | |
33 | 33 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
34 | 34 | |
35 | +/* | |
35 | 36 | static const struct _host_type |
36 | 37 | { |
37 | 38 | const gchar * name; |
... | ... | @@ -55,9 +56,11 @@ |
55 | 56 | { 8, N_( "8 colors" ) }, |
56 | 57 | { 2, N_( "Monochrome" ) }, |
57 | 58 | }; |
59 | +*/ | |
58 | 60 | |
59 | 61 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
60 | 62 | |
63 | +/* | |
61 | 64 | LIB3270_OPTION pw3270_options_by_hosttype(const gchar *systype) |
62 | 65 | { |
63 | 66 | int f; |
... | ... | @@ -129,12 +132,23 @@ |
129 | 132 | trace("Selected color type: %d",(int) colortable[*iColorTable].colors); |
130 | 133 | |
131 | 134 | } |
132 | - | |
135 | +*/ | |
133 | 136 | void hostname_action(GtkAction *action, GtkWidget *widget) |
134 | 137 | { |
138 | + H3270 * hSession = v3270_get_session(widget); | |
139 | + gchar * ptr; | |
140 | + | |
141 | + lib3270_set_color_type(hSession,(unsigned short) get_integer_from_config("host","colortype",16)); | |
142 | + | |
143 | + ptr = get_string_from_config("host","systype","s390"); | |
144 | + if(*ptr) | |
145 | + lib3270_set_host_type(hSession,ptr); | |
146 | + g_free(ptr); | |
147 | + | |
148 | + v3270_select_host(widget); | |
149 | + | |
150 | +/* | |
135 | 151 | const gchar * title = g_object_get_data(G_OBJECT(action),"title"); |
136 | -// gchar * cfghost = get_string_from_config("host","uri",""); | |
137 | -// gchar * hostname; | |
138 | 152 | gchar * ptr; |
139 | 153 | gboolean again = TRUE; |
140 | 154 | int iHostType = 0; |
... | ... | @@ -367,37 +381,6 @@ |
367 | 381 | gtk_toggle_button_set_active(sslcheck,(lib3270_get_options(hSession) & LIB3270_OPTION_SSL) ? TRUE : FALSE); |
368 | 382 | } |
369 | 383 | |
370 | -/* | |
371 | - hostname = cfghost; | |
372 | - | |
373 | - trace("hostname=[%s]",hostname); | |
374 | - | |
375 | -#ifdef HAVE_LIBSSL | |
376 | - if(!g_ascii_strncasecmp(hostname,"L:",2)) | |
377 | - { | |
378 | - gtk_toggle_button_set_active(sslcheck,TRUE); | |
379 | - hostname += 2; | |
380 | - } | |
381 | -#else | |
382 | - gtk_toggle_button_set_active(sslcheck,FALSE); | |
383 | - gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE); | |
384 | - if(!g_ascii_strncasecmp(hostname,"L:",2)) | |
385 | - hostname += 2; | |
386 | -#endif | |
387 | - | |
388 | - trace("hostname=[%s]",hostname); | |
389 | - | |
390 | - ptr = strchr(hostname,':'); | |
391 | - if(ptr) | |
392 | - { | |
393 | - *(ptr++) = 0; | |
394 | - gtk_entry_set_text(port,ptr); | |
395 | - } | |
396 | - else | |
397 | - { | |
398 | - gtk_entry_set_text(port,"23"); | |
399 | - } | |
400 | -*/ | |
401 | 384 | |
402 | 385 | while(again) |
403 | 386 | { |
... | ... | @@ -407,15 +390,6 @@ |
407 | 390 | case GTK_RESPONSE_ACCEPT: |
408 | 391 | gtk_widget_set_sensitive(dialog,FALSE); |
409 | 392 | |
410 | - /* | |
411 | - hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "", | |
412 | - gtk_entry_get_text(host), | |
413 | - ":", | |
414 | - gtk_entry_get_text(port), | |
415 | - NULL | |
416 | - ); | |
417 | - */ | |
418 | - | |
419 | 393 | #if GTK_CHECK_VERSION(2,18,0) |
420 | 394 | gtk_widget_set_visible(dialog,FALSE); |
421 | 395 | #else |
... | ... | @@ -455,5 +429,6 @@ |
455 | 429 | gtk_widget_destroy(dialog); |
456 | 430 | |
457 | 431 | // g_free(cfghost); |
432 | +*/ | |
458 | 433 | } |
459 | 434 | ... | ... |
... | ... | @@ -0,0 +1,417 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como hostdialog.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include "hostselect.h" | |
31 | + #include <pw3270/v3270.h> | |
32 | + | |
33 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
34 | + | |
35 | + static const struct _host_type | |
36 | + { | |
37 | + const gchar * name; | |
38 | + const gchar * description; | |
39 | + LIB3270_OPTION option; | |
40 | + } host_type[] = | |
41 | + { | |
42 | + { "S390", N_( "IBM S/390" ), LIB3270_OPTION_S390 }, | |
43 | + { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_AS400 }, | |
44 | + { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, | |
45 | + { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } | |
46 | + }; | |
47 | + | |
48 | + static const struct _colortable | |
49 | + { | |
50 | + unsigned short colors; | |
51 | + const gchar * description; | |
52 | + } colortable[] = | |
53 | + { | |
54 | + { 16, N_( "16 colors" ) }, | |
55 | + { 8, N_( "8 colors" ) }, | |
56 | + { 2, N_( "Monochrome" ) }, | |
57 | + }; | |
58 | + | |
59 | + enum _entry | |
60 | + { | |
61 | + ENTRY_HOSTNAME, | |
62 | + ENTRY_SRVCNAME, | |
63 | + | |
64 | + ENTRY_COUNT | |
65 | + }; | |
66 | + | |
67 | + static const gchar *comboLabel[] = { N_("System _type:"), N_("_Color table:") }; | |
68 | + | |
69 | + struct _V3270HostSelectWidget | |
70 | + { | |
71 | +#if GTK_CHECK_VERSION(3,0,0) | |
72 | + GtkBin parent; | |
73 | +#else | |
74 | + GtkVBox parent; | |
75 | +#endif // GTK_CHECK_VERSION | |
76 | + | |
77 | + LIB3270_OPTION options; /**< Connect option */ | |
78 | + | |
79 | + GtkEntry * entry[ENTRY_COUNT]; /**< Entry fields for host & service name */ | |
80 | + GtkToggleButton * ssl; /**< SSL Connection? */ | |
81 | + GtkComboBox * combo[G_N_ELEMENTS(comboLabel)]; /**< Model & Color combobox */ | |
82 | + unsigned short colors; /**< Number of colors */ | |
83 | + H3270 * hSession; /**< lib3270's session handle */ | |
84 | + | |
85 | + }; | |
86 | + | |
87 | + struct _V3270HostSelectWidgetClass | |
88 | + { | |
89 | +#if GTK_CHECK_VERSION(3,0,0) | |
90 | + GtkBinClass parent_class; | |
91 | +#else | |
92 | + GtkVBoxClass parent_class; | |
93 | +#endif // GTK_CHECK_VERSION | |
94 | + }; | |
95 | + | |
96 | + | |
97 | +#if GTK_CHECK_VERSION(3,0,0) | |
98 | + G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_BIN); | |
99 | +#else | |
100 | + G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_VBOX); | |
101 | +#endif // GTK_CHECK_VERSION | |
102 | + | |
103 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
104 | + | |
105 | +static void V3270HostSelectWidget_class_init(V3270HostSelectWidgetClass *klass) | |
106 | +{ | |
107 | +#if GTK_CHECK_VERSION(3,0,0) | |
108 | +#else | |
109 | +#endif // GTK_CHECK_VERSION | |
110 | +} | |
111 | + | |
112 | +static void toggle_ssl(GtkToggleButton *button, V3270HostSelectWidget *dialog) | |
113 | +{ | |
114 | + if(gtk_toggle_button_get_active(button)) | |
115 | + dialog->options |= LIB3270_OPTION_SSL; | |
116 | + else | |
117 | + dialog->options &= ~LIB3270_OPTION_SSL; | |
118 | +} | |
119 | + | |
120 | +static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) | |
121 | +{ | |
122 | + GValue value = { 0, }; | |
123 | + GtkTreeIter iter; | |
124 | + | |
125 | + if(!gtk_combo_box_get_active_iter(widget,&iter)) | |
126 | + return; | |
127 | + | |
128 | + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | |
129 | + | |
130 | + dialog->options &= ~(LIB3270_OPTION_HOST_TYPE); | |
131 | + dialog->options |= g_value_get_int(&value); | |
132 | + | |
133 | +} | |
134 | + | |
135 | +static void colortable_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) | |
136 | +{ | |
137 | + GValue value = { 0, }; | |
138 | + GtkTreeIter iter; | |
139 | + | |
140 | + if(!gtk_combo_box_get_active_iter(widget,&iter)) | |
141 | + return; | |
142 | + | |
143 | + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | |
144 | + | |
145 | + dialog->colors = g_value_get_int(&value); | |
146 | + | |
147 | +} | |
148 | + | |
149 | +static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) | |
150 | +{ | |
151 | +#if GTK_CHECK_VERSION(3,0,0) | |
152 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
153 | +#else | |
154 | + GtkTable * grid = gtk_table_new(?,?,FALSE); | |
155 | +#endif // GTK_CHECK_VERSION | |
156 | + | |
157 | + GtkWidget * label[ENTRY_COUNT] = | |
158 | + { | |
159 | + gtk_label_new_with_mnemonic( _( "_Host:" ) ), | |
160 | + gtk_label_new_with_mnemonic( _( "_Service:" ) ) | |
161 | + }; | |
162 | + | |
163 | + int f; | |
164 | + | |
165 | + gtk_container_set_border_width(GTK_CONTAINER(grid),3); | |
166 | + | |
167 | + for(f=0;f<ENTRY_COUNT;f++) | |
168 | + { | |
169 | + widget->entry[f] = GTK_ENTRY(gtk_entry_new()); | |
170 | + gtk_misc_set_alignment(GTK_MISC(label[f]),0,0.5); | |
171 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),GTK_WIDGET(widget->entry[f])); | |
172 | + } | |
173 | + | |
174 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),_("Address or name of the host to connect.") ); | |
175 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),_("Port or service name (empty for \"telnet\").") ); | |
176 | + | |
177 | + // SSL checkbox | |
178 | + widget->ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." ))); | |
179 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->ssl),_( "Check for SSL secure connection." )); | |
180 | + g_signal_connect(G_OBJECT(widget->ssl),"toggled",G_CALLBACK(toggle_ssl),widget); | |
181 | + | |
182 | + // Extended options | |
183 | + GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); | |
184 | + | |
185 | + // Host type | |
186 | + { | |
187 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
188 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
189 | + | |
190 | + widget->combo[0] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); | |
191 | + | |
192 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[0]), renderer, TRUE); | |
193 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[0]), renderer, "text", 0, NULL); | |
194 | + | |
195 | + for(f=0;f<G_N_ELEMENTS(host_type);f++) | |
196 | + { | |
197 | + GtkTreeIter iter; | |
198 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
199 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, host_type[f].option, -1); | |
200 | + } | |
201 | + | |
202 | + g_signal_connect(G_OBJECT(widget->combo[0]),"changed",G_CALLBACK(systype_changed),widget); | |
203 | + | |
204 | + } | |
205 | + | |
206 | + // Color table | |
207 | + { | |
208 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
209 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
210 | + | |
211 | + widget->combo[1] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); | |
212 | + | |
213 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[1]), renderer, TRUE); | |
214 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[1]), renderer, "text", 0, NULL); | |
215 | + | |
216 | + for(f=0;f<G_N_ELEMENTS(colortable);f++) | |
217 | + { | |
218 | + GtkTreeIter iter; | |
219 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
220 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, colortable[f].colors, -1); | |
221 | + } | |
222 | + | |
223 | + g_signal_connect(G_OBJECT(widget->combo[1]),"changed",G_CALLBACK(colortable_changed),widget); | |
224 | + | |
225 | + } | |
226 | + | |
227 | + gtk_entry_set_max_length(widget->entry[ENTRY_HOSTNAME],0xFF); | |
228 | + gtk_entry_set_width_chars(widget->entry[ENTRY_HOSTNAME],50); | |
229 | + | |
230 | + gtk_entry_set_max_length(widget->entry[ENTRY_SRVCNAME],6); | |
231 | + gtk_entry_set_width_chars(widget->entry[ENTRY_SRVCNAME],7); | |
232 | + | |
233 | + gtk_entry_set_placeholder_text(widget->entry[ENTRY_SRVCNAME],"telnet"); | |
234 | + | |
235 | +#if GTK_CHECK_VERSION(3,0,0) | |
236 | + | |
237 | + gtk_widget_set_hexpand(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),TRUE); | |
238 | + gtk_widget_set_hexpand(GTK_WIDGET(widget->ssl),TRUE); | |
239 | + gtk_widget_set_hexpand(GTK_WIDGET(expander),TRUE); | |
240 | + | |
241 | + gtk_grid_set_row_homogeneous(grid,FALSE); | |
242 | + gtk_grid_set_column_homogeneous(grid,FALSE); | |
243 | + gtk_grid_set_column_spacing(grid,5); | |
244 | + gtk_grid_set_row_spacing(grid,5); | |
245 | + | |
246 | + gtk_grid_attach(grid,label[ENTRY_HOSTNAME],0,0,1,1); | |
247 | + gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),1,0,3,1); | |
248 | + | |
249 | + gtk_grid_attach(grid,label[ENTRY_SRVCNAME],4,0,1,1); | |
250 | + gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),5,0,1,1); | |
251 | + | |
252 | + gtk_grid_attach(grid,GTK_WIDGET(widget->ssl),1,1,3,1); | |
253 | + | |
254 | + | |
255 | + // Host options | |
256 | + { | |
257 | + GtkGrid *opt = GTK_GRID(gtk_grid_new()); | |
258 | + gtk_grid_set_column_spacing(opt,5); | |
259 | + gtk_grid_set_row_spacing(opt,5); | |
260 | + | |
261 | + for(f=0;f<G_N_ELEMENTS(comboLabel);f++) | |
262 | + { | |
263 | + GtkWidget *label = gtk_label_new_with_mnemonic(gettext(comboLabel[f])); | |
264 | + gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | |
265 | + gtk_grid_attach(opt,label,0,f+1,1,1); | |
266 | + gtk_grid_attach(opt,GTK_WIDGET(widget->combo[f]),1,f+1,2,1); | |
267 | + } | |
268 | + | |
269 | + gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(opt)); | |
270 | + } | |
271 | + gtk_grid_attach(grid,GTK_WIDGET(expander),1,2,5,2); | |
272 | + | |
273 | + | |
274 | +#else | |
275 | + | |
276 | + gtk_table_set_row_spacings(grid,5); | |
277 | + gtk_table_set_col_spacings(grid,5); | |
278 | + | |
279 | + #error Implementar | |
280 | + | |
281 | +#endif // GTK_CHECK_VERSION | |
282 | + | |
283 | + | |
284 | + gtk_widget_show_all(GTK_WIDGET(grid)); | |
285 | + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(grid)); | |
286 | +} | |
287 | + | |
288 | +GtkWidget * v3270_host_select_new(GtkWidget *widget) | |
289 | +{ | |
290 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
291 | + | |
292 | + V3270HostSelectWidget * selector = GTK_V3270HostSelectWidget(g_object_new(GTK_TYPE_V3270HostSelectWidget, NULL)); | |
293 | + | |
294 | + v3270_host_select_set_session(selector,widget); | |
295 | + | |
296 | + return GTK_WIDGET(selector); | |
297 | +} | |
298 | + | |
299 | +void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session) | |
300 | +{ | |
301 | + g_return_if_fail(GTK_IS_V3270(session)); | |
302 | + g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget)); | |
303 | + | |
304 | + widget->hSession = v3270_get_session(session); | |
305 | + | |
306 | + gtk_entry_set_text(widget->entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession)); | |
307 | + gtk_entry_set_text(widget->entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession)); | |
308 | + | |
309 | + LIB3270_OPTION opt = lib3270_get_options(widget->hSession); | |
310 | + | |
311 | + gtk_toggle_button_set_active(widget->ssl,(opt & LIB3270_OPTION_SSL) != 0); | |
312 | + | |
313 | + // Set host type | |
314 | + { | |
315 | + GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[0]); | |
316 | + GtkTreeIter iter; | |
317 | + | |
318 | + if(gtk_tree_model_get_iter_first(model,&iter)) | |
319 | + { | |
320 | + do | |
321 | + { | |
322 | + GValue value = { 0, }; | |
323 | + | |
324 | + gtk_tree_model_get_value(model,&iter,1,&value); | |
325 | + | |
326 | + if(g_value_get_int(&value) == (opt&LIB3270_OPTION_HOST_TYPE)) | |
327 | + { | |
328 | + gtk_combo_box_set_active_iter(widget->combo[0],&iter); | |
329 | + break; | |
330 | + } | |
331 | + | |
332 | + } while(gtk_tree_model_iter_next(model,&iter)); | |
333 | + } | |
334 | + } | |
335 | + | |
336 | + // Set color type | |
337 | + { | |
338 | + GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[1]); | |
339 | + GtkTreeIter iter; | |
340 | + int colors = (int) lib3270_get_color_type(widget->hSession); | |
341 | + | |
342 | + if(gtk_tree_model_get_iter_first(model,&iter)) | |
343 | + { | |
344 | + do | |
345 | + { | |
346 | + GValue value = { 0, }; | |
347 | + | |
348 | + gtk_tree_model_get_value(model,&iter,1,&value); | |
349 | + | |
350 | + g_message("%d - %d",g_value_get_int(&value),colors); | |
351 | + | |
352 | + if(g_value_get_int(&value) == colors) | |
353 | + { | |
354 | + gtk_combo_box_set_active_iter(widget->combo[1],&iter); | |
355 | + break; | |
356 | + } | |
357 | + | |
358 | + } while(gtk_tree_model_iter_next(model,&iter)); | |
359 | + } | |
360 | + } | |
361 | + | |
362 | + // Just in case | |
363 | + widget->options = opt; | |
364 | +} | |
365 | + | |
366 | +LIB3270_EXPORT void v3270_select_host(GtkWidget *widget) | |
367 | +{ | |
368 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
369 | + | |
370 | + GtkWidget * dialog = v3270_host_select_new(widget); | |
371 | + GtkWidget * win = gtk_dialog_new_with_buttons( | |
372 | + _( "Select hostname" ), | |
373 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
374 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
375 | + _( "C_onnect" ), GTK_RESPONSE_ACCEPT, | |
376 | + _( "_Cancel" ), GTK_RESPONSE_REJECT, | |
377 | + NULL ); | |
378 | + | |
379 | + | |
380 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(win))),dialog,FALSE,FALSE,2); | |
381 | + gtk_widget_show_all(dialog); | |
382 | + | |
383 | + gboolean again = TRUE; | |
384 | + while(again) | |
385 | + { | |
386 | + gtk_widget_set_sensitive(win,TRUE); | |
387 | + gtk_widget_set_visible(win,TRUE); | |
388 | + | |
389 | + switch(gtk_dialog_run(GTK_DIALOG(win))) | |
390 | + { | |
391 | + case GTK_RESPONSE_ACCEPT: | |
392 | + gtk_widget_set_visible(win,FALSE); | |
393 | + gtk_widget_set_sensitive(win,FALSE); | |
394 | + again = v3270_host_select_apply(GTK_V3270HostSelectWidget(dialog)) != 0; | |
395 | + break; | |
396 | + | |
397 | + case GTK_RESPONSE_REJECT: | |
398 | + again = FALSE; | |
399 | + break; | |
400 | + } | |
401 | + } | |
402 | + | |
403 | + gtk_widget_destroy(win); | |
404 | + | |
405 | +} | |
406 | + | |
407 | +LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget) | |
408 | +{ | |
409 | + g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget)); | |
410 | + | |
411 | + lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_HOSTNAME])); | |
412 | + lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_SRVCNAME])); | |
413 | + lib3270_set_options(widget->hSession,widget->options); | |
414 | + | |
415 | + return lib3270_connect(widget->hSession,0); | |
416 | +} | |
417 | + | ... | ... |
... | ... | @@ -0,0 +1,67 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como hostdialog.h e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#ifndef V3270HOST_H_INCLUDED | |
31 | + | |
32 | + #include <lib3270/config.h> | |
33 | + #define ENABLE_NLS | |
34 | + | |
35 | + #ifndef GETTEXT_PACKAGE | |
36 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
37 | + #endif | |
38 | + | |
39 | + #include <libintl.h> | |
40 | + #include <glib/gi18n.h> | |
41 | + #include <gtk/gtk.h> | |
42 | + #include <lib3270.h> | |
43 | + | |
44 | + #define V3270FT_H_INCLUDED 1 | |
45 | + | |
46 | + G_BEGIN_DECLS | |
47 | + | |
48 | +/*--[ Progress widget ]------------------------------------------------------------------------------*/ | |
49 | + | |
50 | + #define GTK_TYPE_V3270HostSelectWidget (V3270HostSelectWidget_get_type ()) | |
51 | + #define GTK_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidget)) | |
52 | + #define GTK_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass)) | |
53 | + #define GTK_IS_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270HostSelectWidget)) | |
54 | + #define GTK_IS_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270HostSelectWidget)) | |
55 | + #define GTK_V3270HostSelectWidget_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass)) | |
56 | + | |
57 | + typedef struct _V3270HostSelectWidget V3270HostSelectWidget; | |
58 | + typedef struct _V3270HostSelectWidgetClass V3270HostSelectWidgetClass; | |
59 | + | |
60 | +/*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | |
61 | + | |
62 | + LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session); | |
63 | + LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget); | |
64 | + | |
65 | + G_END_DECLS | |
66 | + | |
67 | +#endif // V3270HOST_H_INCLUDED | ... | ... |
src/pw3270/v3270/mouse.c
src/pw3270/v3270/sources.mak
src/pw3270/window.c
... | ... | @@ -180,6 +180,9 @@ |
180 | 180 | { |
181 | 181 | GtkWidget * widget = g_object_new(GTK_TYPE_PW3270, NULL); |
182 | 182 | |
183 | + #warning Reimplementar | |
184 | + | |
185 | + /* | |
183 | 186 | if(systype) |
184 | 187 | { |
185 | 188 | set_string_to_config("host","uri","%s",systype); |
... | ... | @@ -197,6 +200,8 @@ |
197 | 200 | else |
198 | 201 | colors = get_integer_from_config("host","colortype",16); |
199 | 202 | |
203 | + */ | |
204 | + | |
200 | 205 | pw3270_set_session_color_type(widget,colors); |
201 | 206 | |
202 | 207 | if(host) | ... | ... |