Commit 08219022e594ac92ee6293966b4beb3efea5decd

Authored by Perry Werneck
1 parent dc7daf83
Exists in master and in 1 other branch develop

Implementing accelerator edit widget.

src/dialogs/font/chooser.c
... ... @@ -207,7 +207,7 @@
207 207  
208 208 if(chooser->font.face) {
209 209  
210   - debug("%s",__FUNCTION__);
  210 +// debug("%s",__FUNCTION__);
211 211  
212 212 cairo_set_font_face(cr,chooser->font.face);
213 213 cairo_set_font_size(cr,15);
... ... @@ -321,7 +321,7 @@ static void V3270FontChooserWidget_init(V3270FontChooserWidget *widget)
321 321  
322 322 }
323 323  
324   -GtkWidget * v3270_font_chooser_widget_new()
  324 +GtkWidget * v3270_font_settings_new()
325 325 {
326 326 V3270Settings * settings = GTK_V3270_SETTINGS(g_object_new(GTK_TYPE_V3270_FONT_CHOOSER, NULL));
327 327  
... ... @@ -331,3 +331,7 @@ GtkWidget * v3270_font_chooser_widget_new()
331 331 return GTK_WIDGET(settings);
332 332 }
333 333  
  334 +GtkWidget * v3270_font_chooser_widget_new()
  335 +{
  336 + return v3270_font_settings_new();
  337 +}
... ...
src/dialogs/hostselect.c
... ... @@ -1,877 +0,0 @@
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 - 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   - /**
31   - * @brief Implements the host properties widget.
32   - *
33   - */
34   -
35   - #include "private.h"
36   - #include <hostselect.h>
37   - #include <v3270/dialogs.h>
38   - #include <v3270/settings.h>
39   - #include <lib3270/log.h>
40   - #include <lib3270/toggle.h>
41   - #include <lib3270/properties.h>
42   -
43   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
44   -
45   - static const struct ToggleList
46   - {
47   - gint left;
48   - gint top;
49   -
50   - LIB3270_TOGGLE_ID id;
51   - }
52   - toggleList[] =
53   - {
54   - {
55   - .left = 2,
56   - .top = 3,
57   - .id = LIB3270_TOGGLE_CONNECT_ON_STARTUP,
58   - },
59   - {
60   - .left = 3,
61   - .top = 3,
62   - .id = LIB3270_TOGGLE_RECONNECT,
63   - },
64   - {
65   - .left = 4,
66   - .top = 3,
67   - .id = LIB3270_TOGGLE_KEEP_ALIVE,
68   - }
69   -
70   - };
71   -
72   - enum _entry
73   - {
74   - ENTRY_HOSTNAME,
75   - ENTRY_SRVCNAME,
76   - ENTRY_OVERSIZE,
77   - ENTRY_REMAP_FILE,
78   - ENTRY_LU_NAMES,
79   -
80   - ENTRY_COUNT
81   - };
82   -
83   - /// @brief Combo box descriptors.
84   - static const struct Combos
85   - {
86   - ENTRY_FIELD_HEAD
87   -
88   - const unsigned int * values;
89   - const gchar **labels;
90   -
91   - unsigned int (*get)(const H3270 *);
92   - int (*set)(H3270 *, unsigned int);
93   -
94   - } combos[] =
95   - {
96   - {
97   - .top = 0,
98   - .left = 0,
99   - .width = 2,
100   - .height = 1,
101   -
102   - .label = N_("System _type"),
103   - .get = (unsigned int (*)(const H3270 *)) lib3270_get_host_type,
104   - .set = (int (*)(H3270 *, unsigned int)) lib3270_set_host_type,
105   -
106   - .values = (const unsigned int [])
107   - {
108   - LIB3270_HOST_S390,
109   - LIB3270_HOST_AS400,
110   - LIB3270_HOST_TSO,
111   - 0,
112   - },
113   -
114   - .labels = (const gchar *[])
115   - {
116   - N_( "IBM S/390" ),
117   - N_( "IBM AS/400" ),
118   - N_( "Other (TSO)" ),
119   - N_( "Other (VM/CMS)" ),
120   - NULL
121   - }
122   -
123   - },
124   - {
125   - .top = 0,
126   - .left = 3,
127   - .width = 2,
128   - .height = 1,
129   -
130   - .label = N_("_Color table"),
131   - .get = lib3270_get_color_type,
132   - .set = lib3270_set_color_type,
133   -
134   - .values = (const unsigned int [])
135   - {
136   - 0,
137   - 2,
138   - 8,
139   - 16,
140   - },
141   -
142   - .labels = (const gchar *[])
143   - {
144   - N_( "System default"),
145   - N_( "Monochrome" ),
146   - N_( "8 colors" ),
147   - N_( "16 colors" ),
148   - NULL
149   - }
150   -
151   - },
152   - {
153   - .top = 1,
154   - .left = 0,
155   - .width = 2,
156   - .height = 1,
157   -
158   - .label = N_("_Model"),
159   - .tooltip = N_("The model of 3270 display to be emulated"),
160   -
161   - .get = lib3270_get_model_number,
162   - .set = lib3270_set_model_number,
163   -
164   - .values = (const unsigned int [])
165   - {
166   - 2,
167   - 3,
168   - 4,
169   - 5
170   - },
171   -
172   - .labels = (const gchar *[])
173   - {
174   - N_( "Model 2 - 80x24" ),
175   - N_( "Model 3 - 80x32" ),
176   - N_( "Model 4 - 80x43" ),
177   - N_( "Model 5 - 132x27" ),
178   - NULL
179   - }
180   -
181   - }
182   - };
183   -
184   - static const struct Entry
185   - {
186   - ENTRY_FIELD_HEAD
187   -
188   - gint max_length;
189   - gint width_chars;
190   -
191   - } entryfields[] = {
192   - {
193   - .left = 0,
194   - .top = 0,
195   - .width = 4,
196   - .height = 1,
197   -
198   - .label = N_( "_Host" ),
199   - .tooltip = N_("Address or name of the host to connect."),
200   - .max_length = 0xFF,
201   - .width_chars = 50,
202   -
203   - },
204   - {
205   - .left = 0,
206   - .top = 1,
207   - .width = 1,
208   - .height = 1,
209   -
210   - .label = N_( "_Service" ),
211   - .tooltip = N_("Port or service name (empty for \"telnet\")."),
212   - .max_length = 6,
213   - .width_chars = 7,
214   - },
215   -
216   - {
217   - .top = 1,
218   - .left = 3,
219   - .width = 2,
220   - .height = 1,
221   -
222   - .label = N_( "Oversize" ),
223   - .tooltip = N_("Makes the screen larger than the default for the chosen model number."),
224   - .max_length = 7,
225   - .width_chars = 8,
226   - },
227   -
228   - {
229   - .top = 2,
230   - .left = 0,
231   - .width = 8,
232   - .height = 1,
233   -
234   - .label = N_( "Custom Remap" ),
235   - .tooltip = N_("Path to XML file with custom charset mapping."),
236   - .max_length = 0xFF,
237   - .width_chars = 50,
238   - },
239   -
240   - {
241   - .left = 2,
242   - .top = 1,
243   - .width = 2,
244   - .height = 1,
245   -
246   - .label = N_( "L_U Names" ),
247   - .tooltip = N_("Comma separated list of LU names."),
248   - .max_length = 0xFF,
249   - .width_chars = 50,
250   - },
251   -
252   - };
253   -
254   - struct _V3270HostSelectWidget
255   - {
256   - V3270Settings parent;
257   -
258   - struct
259   - {
260   - GtkEntry * entry[G_N_ELEMENTS(entryfields)]; ///< @brief Entry fields for host & service name.
261   - GtkToggleButton * ssl; ///< @brief SSL Connection?
262   - GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes.
263   - GtkComboBox * charset; ///< @brief Charset combo box.
264   - GtkToggleButton * toggles[G_N_ELEMENTS(toggleList)]; ///< @brief Toggle checks.
265   - GtkSpinButton * auto_disconnect; ///< @brief Auto disconnect.
266   -
267   - } input;
268   -
269   - };
270   -
271   - struct _V3270HostSelectWidgetClass
272   - {
273   - V3270SettingsClass parent_class;
274   - };
275   -
276   - static void load(GtkWidget *w, GtkWidget *terminal);
277   - static void apply(GtkWidget *w, GtkWidget *terminal);
278   -
279   - G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_V3270_SETTINGS);
280   -
281   -/*--[ Implement ]------------------------------------------------------------------------------------*/
282   -
283   -static void update_message(GtkWidget *widget, GtkWidget *terminal)
284   -{
285   - gtk_widget_set_sensitive(widget, lib3270_is_disconnected(v3270_get_session(terminal)));
286   -}
287   -
288   -static void V3270HostSelectWidget_class_init(G_GNUC_UNUSED V3270HostSelectWidgetClass *klass)
289   -{
290   - V3270SettingsClass * widget = GTK_V3270_SETTINGS_CLASS(klass);
291   -
292   - widget->apply = apply;
293   - widget->load = load;
294   - widget->update_message = update_message;
295   -
296   -}
297   -
298   -static void oversize_changed(GtkEditable *editable, GtkWidget *settings)
299   -{
300   - const gchar * chars = gtk_editable_get_chars(editable,0,-1);
301   - gboolean valid = TRUE;
302   - char junk;
303   - unsigned int ovc = 0, ovr = 0;
304   -
305   - if(*chars)
306   - {
307   - if(sscanf(chars, "%ux%u%c", &ovc, &ovr, &junk) != 2)
308   - {
309   - valid = FALSE;
310   - debug("Can't parse \"%s\"",chars);
311   - }
312   - else if( (ovc * ovr) > 0x4000)
313   - {
314   - valid = FALSE;
315   - debug("Invalid values on \"%s\"",chars);
316   - }
317   - }
318   -
319   - v3270_settings_set_valid(settings,valid);
320   -}
321   -
322   -static void remap_file_changed(GtkEditable *editable, V3270HostSelectWidget *settings)
323   -{
324   - const gchar * filename = gtk_editable_get_chars(editable,0,-1);
325   -
326   - debug("%s(%s)",__FUNCTION__,filename);
327   - if(*filename)
328   - {
329   - v3270_settings_set_valid(GTK_WIDGET(settings),g_file_test(filename,G_FILE_TEST_IS_REGULAR));
330   - gtk_widget_set_sensitive(GTK_WIDGET(settings->input.charset),FALSE);
331   - }
332   - else
333   - {
334   - v3270_settings_set_valid(GTK_WIDGET(settings),TRUE);
335   - gtk_widget_set_sensitive(GTK_WIDGET(settings->input.charset),TRUE);
336   - }
337   -
338   -}
339   -
340   -static void select_remap_file(GtkEditable *editable, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, G_GNUC_UNUSED GtkWidget *settings)
341   -{
342   - GtkWidget * dialog =
343   - gtk_file_chooser_dialog_new(
344   - _( "Select custom charset mapping"),
345   - GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(editable))),
346   - GTK_FILE_CHOOSER_ACTION_OPEN,
347   - _("Cancel"), GTK_RESPONSE_CANCEL,
348   - _("Select"), GTK_RESPONSE_ACCEPT,
349   - NULL );
350   -
351   -
352   - gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE);
353   - g_signal_connect(G_OBJECT(dialog),"close",G_CALLBACK(v3270_dialog_close),NULL);
354   -
355   - // Setup file filter
356   - GtkFileFilter * filter = gtk_file_filter_new();
357   - gtk_file_filter_set_name(filter,_("TN3270 Custom charset"));
358   - gtk_file_filter_add_pattern(filter,"*.xml");
359   - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
360   -
361   - // Get current file name.
362   - const gchar * filename = gtk_editable_get_chars(editable,0,-1);
363   -
364   - if(filename && *filename)
365   - {
366   - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename);
367   - }
368   - else
369   - {
370   - lib3270_autoptr(char) folder = lib3270_build_data_filename("remap",NULL);
371   -
372   - if(folder && *folder)
373   - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), folder);
374   -
375   - }
376   -
377   - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
378   - gtk_entry_set_text(GTK_ENTRY(editable),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
379   -
380   - gtk_widget_destroy(dialog);
381   -
382   -}
383   -
384   -static gboolean auto_disconnect_format(GtkSpinButton *spin, G_GNUC_UNUSED gpointer data) {
385   -
386   - GtkAdjustment * adjustment = gtk_spin_button_get_adjustment (spin);
387   - guint value = (guint) gtk_adjustment_get_value(adjustment);
388   -
389   - if(value < 1) {
390   - gtk_entry_set_text(GTK_ENTRY(spin), "");
391   - } else {
392   - g_autofree gchar * text = g_strdup_printf ("%d", value);
393   - gtk_entry_set_text(GTK_ENTRY(spin), text);
394   - }
395   -
396   - return TRUE;
397   -}
398   -
399   -static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
400   -{
401   - // Cell renderer
402   - GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new();
403   -
404   - // Connection properties
405   - GtkWidget * connection = gtk_grid_new();
406   - gtk_grid_set_row_spacing(GTK_GRID(connection),6);
407   - gtk_grid_set_column_spacing(GTK_GRID(connection),12);
408   -
409   - gtk_grid_attach(
410   - GTK_GRID(widget),
411   - v3270_dialog_create_frame(connection,_("Connection")),
412   - 0,0,10,5
413   - );
414   -
415   - // Emulation properties
416   - GtkWidget * emulation = gtk_grid_new();
417   - gtk_grid_set_row_spacing(GTK_GRID(emulation),6);
418   - gtk_grid_set_column_spacing(GTK_GRID(emulation),12);
419   -
420   - gtk_grid_attach(
421   - GTK_GRID(widget),
422   - v3270_dialog_create_frame(emulation,_("Emulation")),
423   - 0,6,10,5
424   - );
425   -
426   - // Entry fields
427   - {
428   - size_t entry;
429   -
430   - for(entry = 0; entry < G_N_ELEMENTS(entryfields); entry++)
431   - {
432   - widget->input.entry[entry] = GTK_ENTRY(gtk_entry_new());
433   - gtk_entry_set_max_length(widget->input.entry[entry],entryfields[entry].max_length);
434   - gtk_entry_set_width_chars(widget->input.entry[entry],entryfields[entry].width_chars);
435   - }
436   -
437   - // Custom settings
438   - gtk_entry_set_placeholder_text(widget->input.entry[ENTRY_SRVCNAME],"telnet");
439   -
440   - gtk_widget_set_hexpand(GTK_WIDGET(widget->input.entry[ENTRY_HOSTNAME]),TRUE);
441   - gtk_widget_set_hexpand(GTK_WIDGET(widget->input.entry[ENTRY_REMAP_FILE]),TRUE);
442   -
443   - gtk_entry_set_icon_from_icon_name(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,"document-open");
444   - gtk_entry_set_icon_activatable(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,TRUE);
445   - gtk_entry_set_icon_tooltip_text(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,_("Select charset remap file"));
446   -
447   - g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_REMAP_FILE]),"icon-press",G_CALLBACK(select_remap_file),widget);
448   - g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_REMAP_FILE]),"changed",G_CALLBACK(remap_file_changed),widget);
449   -
450   - g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_OVERSIZE]),"changed",G_CALLBACK(oversize_changed),widget);
451   -
452   - // Add to containers
453   - v3270_grid_attach(
454   - GTK_GRID(connection),
455   - (struct v3270_entry_field *) & entryfields[0],
456   - GTK_WIDGET(widget->input.entry[0])
457   - );
458   -
459   - v3270_grid_attach(
460   - GTK_GRID(connection),
461   - (struct v3270_entry_field *) & entryfields[1],
462   - GTK_WIDGET(widget->input.entry[1])
463   - );
464   -
465   - v3270_grid_attach(
466   - GTK_GRID(emulation),
467   - (struct v3270_entry_field *) & entryfields[2],
468   - GTK_WIDGET(widget->input.entry[2])
469   - );
470   -
471   - v3270_grid_attach(
472   - GTK_GRID(emulation),
473   - (struct v3270_entry_field *) & entryfields[3],
474   - GTK_WIDGET(widget->input.entry[3])
475   - );
476   -
477   - v3270_grid_attach(
478   - GTK_GRID(connection),
479   - (struct v3270_entry_field *) & entryfields[4],
480   - GTK_WIDGET(widget->input.entry[4])
481   - );
482   -
483   - }
484   -
485   - // Auto disconnect
486   - {
487   - GtkWidget *label = gtk_label_new_with_mnemonic(_("Auto _disconnect"));
488   -
489   - gtk_widget_set_halign(label,GTK_ALIGN_END);
490   -
491   - widget->input.auto_disconnect = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0,60,1));
492   - gtk_widget_set_tooltip_markup(GTK_WIDGET(widget->input.auto_disconnect),_("IDLE minutes for automatic disconnection"));
493   - gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(widget->input.auto_disconnect));
494   -
495   - gtk_spin_button_set_increments(widget->input.auto_disconnect,1,1);
496   -
497   - gtk_grid_attach(GTK_GRID(connection),label,0,2,1,1);
498   - gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.auto_disconnect),1,2,1,1);
499   - g_signal_connect(G_OBJECT(widget->input.auto_disconnect),"output",G_CALLBACK(auto_disconnect_format),widget);
500   - }
501   -
502   - // SSL checkbox
503   - {
504   - widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));
505   - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." ));
506   - gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START);
507   - gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),1,3,1,1);
508   - }
509   -
510   - // Toggle checkboxes
511   - {
512   - size_t toggle;
513   -
514   - for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
515   - {
516   - const LIB3270_TOGGLE * descriptor = lib3270_toggle_get_from_id(toggleList[toggle].id);
517   -
518   - if(descriptor)
519   - {
520   - widget->input.toggles[toggle] = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label(gettext(descriptor->label)));
521   -
522   - if(descriptor->description && *descriptor->description)
523   - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.toggles[toggle]),gettext(descriptor->description));
524   - else if(descriptor->summary && *descriptor->summary)
525   - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.toggles[toggle]),gettext(descriptor->summary));
526   -
527   - gtk_widget_set_halign(GTK_WIDGET(widget->input.toggles[toggle]),GTK_ALIGN_START);
528   - gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.toggles[toggle]),toggleList[toggle].left,toggleList[toggle].top,1,1);
529   -
530   - }
531   -
532   - }
533   -
534   - }
535   -
536   - // Create combo boxes
537   - {
538   - size_t combo, item;
539   -
540   - for(combo = 0; combo < G_N_ELEMENTS(combos); combo++) {
541   -
542   - GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_UINT);
543   -
544   - widget->input.combos[combo] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
545   -
546   - if(combos[combo].tooltip)
547   - gtk_widget_set_tooltip_markup(GTK_WIDGET(widget->input.combos[combo]),combos[combo].tooltip);
548   -
549   - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.combos[combo]), text_renderer, TRUE);
550   - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.combos[combo]), text_renderer, "text", 0, NULL);
551   -
552   - for(item = 0; combos[combo].labels[item]; item++)
553   - {
554   - GtkTreeIter iter;
555   - gtk_list_store_append((GtkListStore *) model, &iter);
556   - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(combos[combo].labels[item]), 1, combos[combo].values[item], -1);
557   - }
558   -
559   - v3270_grid_attach(GTK_GRID(emulation), (struct v3270_entry_field *) & combos[combo], GTK_WIDGET(widget->input.combos[combo]));
560   -
561   - }
562   -
563   - }
564   -
565   - // Create Charset Combo
566   - {
567   - GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(1,G_TYPE_STRING);
568   -
569   - widget->input.charset = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
570   -
571   - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.charset), text_renderer, TRUE);
572   - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.charset), text_renderer, "text", 0, NULL);
573   -
574   - static const gchar * charsets[] =
575   - {
576   - "us",
577   - "bracket",
578   - "cp500"
579   - };
580   -
581   - size_t charset;
582   - for(charset = 0; charset < G_N_ELEMENTS(charsets); charset++)
583   - {
584   - GtkTreeIter iter;
585   - gtk_list_store_append((GtkListStore *) model, &iter);
586   - gtk_list_store_set((GtkListStore *) model, &iter, 0, charsets[charset], -1);
587   - };
588   -
589   - static const struct v3270_entry_field descriptor =
590   - {
591   - .top = 0,
592   - .left = 6,
593   - .width = 2,
594   - .height = 1,
595   -
596   - .label = N_("_Charset"),
597   - .tooltip = N_("The EBCDIC host character set. "),
598   -
599   - };
600   -
601   - v3270_grid_attach(GTK_GRID(emulation), &descriptor, GTK_WIDGET(widget->input.charset));
602   -
603   - }
604   -
605   - gtk_widget_show_all(GTK_WIDGET(widget));
606   -
607   -}
608   -
609   -LIB3270_EXPORT GtkWidget * v3270_host_select_new()
610   -{
611   - V3270Settings * settings = GTK_V3270_SETTINGS(g_object_new(GTK_TYPE_V3270HostSelectWidget, NULL));
612   -
613   - settings->title = _("Host properties");
614   - settings->label = _("Host");
615   -
616   - return GTK_WIDGET(settings);
617   -}
618   -
619   -LIB3270_EXPORT void v3270_select_host(GtkWidget *widget)
620   -{
621   - g_return_if_fail(GTK_IS_V3270(widget));
622   -
623   - GtkWidget * dialog = v3270_settings_dialog_new();
624   - GtkWidget * settings = v3270_host_select_new();
625   -
626   - gtk_window_set_title(GTK_WINDOW(dialog), v3270_settings_get_title(settings));
627   - gtk_container_add(GTK_CONTAINER(dialog), settings);
628   -
629   - gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(widget)));
630   - gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
631   -
632   - v3270_settings_dialog_set_terminal_widget(dialog, widget);
633   -
634   - gtk_window_set_default_size(GTK_WINDOW(dialog), 700, 150);
635   - gtk_widget_show_all(dialog);
636   -
637   - gboolean again = TRUE;
638   - while(again)
639   - {
640   - gtk_widget_set_sensitive(dialog,TRUE);
641   - gtk_widget_set_visible(dialog,TRUE);
642   -
643   - switch(gtk_dialog_run(GTK_DIALOG(dialog)))
644   - {
645   - case GTK_RESPONSE_APPLY:
646   - debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_APPLY");
647   - v3270_settings_dialog_apply(dialog);
648   - again = lib3270_reconnect(v3270_get_session(widget),0);
649   - break;
650   -
651   - case GTK_RESPONSE_CANCEL:
652   - again = FALSE;
653   - debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_CANCEL");
654   - v3270_settings_dialog_revert(dialog);
655   - break;
656   - }
657   - }
658   -
659   - gtk_widget_destroy(dialog);
660   -
661   -}
662   -
663   -static void apply(GtkWidget *w, GtkWidget *terminal)
664   -{
665   - debug("V3270HostSelectWidget::%s",__FUNCTION__);
666   -
667   - V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
668   - H3270 *hSession = v3270_get_session(terminal);
669   -
670   - // Apply URL
671   - {
672   - g_autofree gchar * url =
673   - g_strconcat(
674   - (gtk_toggle_button_get_active(widget->input.ssl) ? "tn3270s://" : "tn3270://"),
675   - gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]),
676   - ":",
677   - gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]),
678   - NULL
679   - );
680   -
681   - debug("URL=[%s]",url);
682   - lib3270_set_url(hSession,url);
683   -
684   - }
685   -
686   - // Apply LU names
687   - v3270_set_lunames(terminal,gtk_entry_get_text(widget->input.entry[ENTRY_LU_NAMES]));
688   -
689   - // Apply combos.
690   - size_t combo;
691   - for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
692   - {
693   - GtkTreeIter iter;
694   -
695   - if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget->input.combos[combo]), &iter))
696   - {
697   - GValue value = { 0, };
698   - gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget->input.combos[combo])),&iter,1,&value);
699   -
700   - combos[combo].set(hSession,g_value_get_uint(&value));
701   -
702   - g_value_unset(&value);
703   -
704   - }
705   - }
706   -
707   - // Apply charset
708   - {
709   - GtkTreeIter iter;
710   -
711   - if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget->input.charset), &iter))
712   - {
713   - GValue value = { 0, };
714   - gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget->input.charset)),&iter,0,&value);
715   -
716   - lib3270_set_host_charset(hSession,g_value_get_string(&value));
717   -
718   - g_value_unset(&value);
719   -
720   - }
721   -
722   - v3270_set_remap_filename(terminal, gtk_entry_get_text(widget->input.entry[ENTRY_REMAP_FILE]));
723   -
724   - }
725   -
726   - // Apply toggles
727   - size_t toggle;
728   -
729   - for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
730   - {
731   - if(widget->input.toggles[toggle])
732   - v3270_set_toggle(terminal, toggleList[toggle].id, gtk_toggle_button_get_active(widget->input.toggles[toggle]));
733   - }
734   -
735   - // Apply oversize
736   - lib3270_set_oversize(hSession,gtk_entry_get_text(widget->input.entry[ENTRY_OVERSIZE]));
737   -
738   - // Apply auto-disconnect
739   - v3270_set_auto_disconnect(terminal,gtk_spin_button_get_value_as_int(widget->input.auto_disconnect));
740   -
741   -}
742   -
743   -static void load(GtkWidget *w, GtkWidget *terminal)
744   -{
745   - debug("V3270HostSelectWidget::%s",__FUNCTION__);
746   -
747   - H3270 *hSession = v3270_get_session(terminal);
748   - V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
749   -
750   - const gchar * u = lib3270_get_url(hSession);
751   -
752   - if(u)
753   - {
754   -
755   - g_autofree gchar * url = g_strdup(u);
756   - debug("URL=[%s]",url);
757   -
758   - gtk_toggle_button_set_active(widget->input.ssl,g_str_has_prefix(u,"tn3270s"));
759   -
760   - gchar *hostname = strstr(url,"://");
761   - if(!hostname)
762   - {
763   - g_message("Invalid URL: \"%s\" (no scheme)",url);
764   - }
765   - else
766   - {
767   - hostname += 3;
768   -
769   - gchar *srvcname = strchr(hostname,':');
770   -
771   - if(srvcname)
772   - {
773   - *(srvcname++) = 0;
774   - }
775   - else
776   - {
777   - srvcname = "telnet";
778   - }
779   -
780   - gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname);
781   - gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname);
782   -
783   - }
784   -
785   - }
786   -
787   - // Load LU names
788   - g_autofree gchar * lunames = v3270_get_lunames(terminal);
789   - gtk_entry_set_text(widget->input.entry[ENTRY_LU_NAMES],lunames ? lunames : "");
790   -
791   - // Load unsigned int combos
792   - size_t combo;
793   - for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
794   - {
795   -
796   - GtkTreeModel * model = gtk_combo_box_get_model(widget->input.combos[combo]);
797   - GtkTreeIter iter;
798   - unsigned int value = combos[combo].get(hSession);
799   -
800   - if(gtk_tree_model_get_iter_first(model,&iter))
801   - {
802   - do
803   - {
804   - GValue gVal = { 0, };
805   - gtk_tree_model_get_value(model,&iter,1,&gVal);
806   - guint iVal = g_value_get_uint(&gVal);
807   - g_value_unset(&gVal);
808   -
809   - if(iVal == value)
810   - {
811   - gtk_combo_box_set_active_iter(widget->input.combos[combo],&iter);
812   - break;
813   - }
814   -
815   - } while(gtk_tree_model_iter_next(model,&iter));
816   -
817   -
818   - }
819   -
820   - }
821   -
822   - // Load charset
823   - {
824   - const char * charset = lib3270_get_host_charset(hSession);
825   -
826   - if(charset)
827   - {
828   - GtkTreeModel * model = gtk_combo_box_get_model(widget->input.charset);
829   - GtkTreeIter iter;
830   -
831   - if(gtk_tree_model_get_iter_first(model,&iter))
832   - {
833   - do
834   - {
835   - GValue gVal = { 0, };
836   - gtk_tree_model_get_value(model,&iter,0,&gVal);
837   -
838   - if(!g_ascii_strcasecmp(charset,g_value_get_string(&gVal)))
839   - {
840   - gtk_combo_box_set_active_iter(widget->input.charset,&iter);
841   - g_value_unset(&gVal);
842   - break;
843   - }
844   -
845   - g_value_unset(&gVal);
846   -
847   - } while(gtk_tree_model_iter_next(model,&iter));
848   -
849   -
850   - }
851   -
852   - }
853   -
854   - const gchar * remap_file = v3270_get_remap_filename(terminal);
855   - gtk_entry_set_text(widget->input.entry[ENTRY_REMAP_FILE],remap_file ? remap_file : "");
856   -
857   -
858   - }
859   -
860   - // Load toggles
861   - size_t toggle;
862   -
863   - for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
864   - {
865   - if(widget->input.toggles[toggle])
866   - gtk_toggle_button_set_active(widget->input.toggles[toggle],v3270_get_toggle(terminal,toggleList[toggle].id));
867   - }
868   -
869   - // Load oversize
870   - const char * oversize = lib3270_get_oversize(hSession);
871   - gtk_entry_set_text(widget->input.entry[ENTRY_OVERSIZE],oversize ? oversize : "");
872   -
873   - // Load auto disconnect
874   - gtk_spin_button_set_value(widget->input.auto_disconnect, v3270_get_auto_disconnect(terminal));
875   -
876   -}
877   -
src/dialogs/settings/accelerator.c 0 → 100644
... ... @@ -0,0 +1,163 @@
  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 - 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 + /**
  31 + * @brief Implements the accelerator settings widget.
  32 + *
  33 + */
  34 +
  35 + #include <internals.h>
  36 + #include <v3270/dialogs.h>
  37 + #include <v3270/settings.h>
  38 + #include <lib3270/log.h>
  39 +
  40 +/*--[ Widget Definition ]----------------------------------------------------------------------------*/
  41 +
  42 + #define GTK_TYPE_V3270_ACCELERATOR_SETTINGS (V3270AcceleratorSettings_get_type ())
  43 + #define GTK_V3270_ACCELERATOR_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_ACCELERATOR_SETTINGS, V3270AcceleratorSettings))
  44 + #define GTK_V3270_ACCELERATOR_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_ACCELERATOR_SETTINGS, V3270AcceleratorSettingsClass))
  45 + #define GTK_IS_V3270_ACCELERATOR_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_ACCELERATOR_SETTINGS))
  46 + #define GTK_IS_V3270_ACCELERATOR_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_ACCELERATOR_SETTINGS))
  47 + #define GTK_V3270_ACCELERATOR_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_ACCELERATOR_SETTINGS, V3270AcceleratorSettingsClass))
  48 +
  49 + typedef struct _V3270AcceleratorSettings
  50 + {
  51 + V3270Settings parent;
  52 +
  53 + } V3270AcceleratorSettings;
  54 +
  55 + typedef struct _V3270AcceleratorSettingsClass
  56 + {
  57 + V3270SettingsClass parent;
  58 +
  59 + } V3270AcceleratorSettingsClass;
  60 +
  61 + G_DEFINE_TYPE(V3270AcceleratorSettings, V3270AcceleratorSettings, GTK_TYPE_V3270_SETTINGS);
  62 +
  63 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  64 +
  65 + static void load(GtkWidget *w, GtkWidget *terminal);
  66 + static void apply(GtkWidget *w, GtkWidget *terminal);
  67 +
  68 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  69 +
  70 + static void V3270AcceleratorSettings_class_init(V3270AcceleratorSettingsClass *klass)
  71 + {
  72 + klass->parent.apply = apply;
  73 + klass->parent.load = load;
  74 +
  75 + }
  76 +
  77 + enum
  78 + {
  79 + DESCRIPTION,
  80 + MAIN_MASK,
  81 + MAIN_VALUE,
  82 + ALTERNATIVE_MASK,
  83 + ALTERNATIVE_VALUE,
  84 +
  85 + COLUMNS
  86 + };
  87 +
  88 + static void V3270AcceleratorSettings_init(V3270AcceleratorSettings *widget)
  89 + {
  90 + // Create Accelerator list
  91 + GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new();
  92 +
  93 + GtkCellRenderer * accel_renderer = gtk_cell_renderer_accel_new();
  94 + g_object_set(accel_renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,"editable", TRUE, NULL);
  95 +
  96 + GtkTreeModel * model = (GtkTreeModel *) gtk_tree_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_UINT);
  97 + GtkWidget * view = gtk_tree_view_new_with_model(model);
  98 +
  99 + gtk_widget_set_tooltip_markup(view,_("Keyboard accelerators"));
  100 +
  101 + gtk_tree_view_insert_column_with_attributes(
  102 + GTK_TREE_VIEW(view),
  103 + -1,
  104 + _("Action"),
  105 + text_renderer,
  106 + "text",
  107 + DESCRIPTION,
  108 + NULL
  109 + );
  110 +
  111 + gtk_tree_view_insert_column_with_attributes(
  112 + GTK_TREE_VIEW(view),
  113 + -1,
  114 + _("Accelerator"),
  115 + accel_renderer,
  116 + "accel-mods", MAIN_MASK,
  117 + "accel-key", MAIN_VALUE,
  118 + NULL
  119 + );
  120 +
  121 + gtk_tree_view_insert_column_with_attributes(
  122 + GTK_TREE_VIEW(view),
  123 + -1,
  124 + _("Alternative"),
  125 + accel_renderer,
  126 + "accel-mods", ALTERNATIVE_MASK,
  127 + "accel-key", ALTERNATIVE_VALUE,
  128 + NULL
  129 + );
  130 +
  131 + // Create scroller view
  132 + {
  133 + GtkWidget * box = gtk_scrolled_window_new(NULL,NULL);
  134 + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(box),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  135 + gtk_container_add(GTK_CONTAINER(box),view);
  136 +
  137 + gtk_widget_set_vexpand(box,TRUE);
  138 + gtk_widget_set_hexpand(box,TRUE);
  139 +
  140 + gtk_grid_attach(GTK_GRID(widget),box,0,0,4,4);
  141 + }
  142 +
  143 + }
  144 +
  145 +LIB3270_EXPORT GtkWidget * v3270_accelerator_settings_new()
  146 +{
  147 + V3270Settings * settings = GTK_V3270_SETTINGS(g_object_new(GTK_TYPE_V3270_ACCELERATOR_SETTINGS, NULL));
  148 +
  149 + settings->title = _("Accelerator properties");
  150 + settings->label = _("Accelerators");
  151 +
  152 + return GTK_WIDGET(settings);
  153 +}
  154 +
  155 +void load(GtkWidget *widget, GtkWidget *terminal)
  156 +{
  157 +
  158 +}
  159 +
  160 +void apply(GtkWidget *widget, GtkWidget *terminal)
  161 +{
  162 +
  163 +}
... ...
src/dialogs/settings/host.c 0 → 100644
... ... @@ -0,0 +1,882 @@
  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 - 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 + /**
  31 + * @brief Implements the host settings widget.
  32 + *
  33 + */
  34 +
  35 + #include <internals.h>
  36 + #include <hostselect.h>
  37 + #include <v3270/dialogs.h>
  38 + #include <v3270/settings.h>
  39 + #include <lib3270/log.h>
  40 + #include <lib3270/toggle.h>
  41 + #include <lib3270/properties.h>
  42 +
  43 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  44 +
  45 + static const struct ToggleList
  46 + {
  47 + gint left;
  48 + gint top;
  49 +
  50 + LIB3270_TOGGLE_ID id;
  51 + }
  52 + toggleList[] =
  53 + {
  54 + {
  55 + .left = 2,
  56 + .top = 3,
  57 + .id = LIB3270_TOGGLE_CONNECT_ON_STARTUP,
  58 + },
  59 + {
  60 + .left = 3,
  61 + .top = 3,
  62 + .id = LIB3270_TOGGLE_RECONNECT,
  63 + },
  64 + {
  65 + .left = 4,
  66 + .top = 3,
  67 + .id = LIB3270_TOGGLE_KEEP_ALIVE,
  68 + }
  69 +
  70 + };
  71 +
  72 + enum _entry
  73 + {
  74 + ENTRY_HOSTNAME,
  75 + ENTRY_SRVCNAME,
  76 + ENTRY_OVERSIZE,
  77 + ENTRY_REMAP_FILE,
  78 + ENTRY_LU_NAMES,
  79 +
  80 + ENTRY_COUNT
  81 + };
  82 +
  83 + /// @brief Combo box descriptors.
  84 + static const struct Combos
  85 + {
  86 + ENTRY_FIELD_HEAD
  87 +
  88 + const unsigned int * values;
  89 + const gchar **labels;
  90 +
  91 + unsigned int (*get)(const H3270 *);
  92 + int (*set)(H3270 *, unsigned int);
  93 +
  94 + } combos[] =
  95 + {
  96 + {
  97 + .top = 0,
  98 + .left = 0,
  99 + .width = 2,
  100 + .height = 1,
  101 +
  102 + .label = N_("System _type"),
  103 + .get = (unsigned int (*)(const H3270 *)) lib3270_get_host_type,
  104 + .set = (int (*)(H3270 *, unsigned int)) lib3270_set_host_type,
  105 +
  106 + .values = (const unsigned int [])
  107 + {
  108 + LIB3270_HOST_S390,
  109 + LIB3270_HOST_AS400,
  110 + LIB3270_HOST_TSO,
  111 + 0,
  112 + },
  113 +
  114 + .labels = (const gchar *[])
  115 + {
  116 + N_( "IBM S/390" ),
  117 + N_( "IBM AS/400" ),
  118 + N_( "Other (TSO)" ),
  119 + N_( "Other (VM/CMS)" ),
  120 + NULL
  121 + }
  122 +
  123 + },
  124 + {
  125 + .top = 0,
  126 + .left = 3,
  127 + .width = 2,
  128 + .height = 1,
  129 +
  130 + .label = N_("_Color table"),
  131 + .get = lib3270_get_color_type,
  132 + .set = lib3270_set_color_type,
  133 +
  134 + .values = (const unsigned int [])
  135 + {
  136 + 0,
  137 + 2,
  138 + 8,
  139 + 16,
  140 + },
  141 +
  142 + .labels = (const gchar *[])
  143 + {
  144 + N_( "System default"),
  145 + N_( "Monochrome" ),
  146 + N_( "8 colors" ),
  147 + N_( "16 colors" ),
  148 + NULL
  149 + }
  150 +
  151 + },
  152 + {
  153 + .top = 1,
  154 + .left = 0,
  155 + .width = 2,
  156 + .height = 1,
  157 +
  158 + .label = N_("_Model"),
  159 + .tooltip = N_("The model of 3270 display to be emulated"),
  160 +
  161 + .get = lib3270_get_model_number,
  162 + .set = lib3270_set_model_number,
  163 +
  164 + .values = (const unsigned int [])
  165 + {
  166 + 2,
  167 + 3,
  168 + 4,
  169 + 5
  170 + },
  171 +
  172 + .labels = (const gchar *[])
  173 + {
  174 + N_( "Model 2 - 80x24" ),
  175 + N_( "Model 3 - 80x32" ),
  176 + N_( "Model 4 - 80x43" ),
  177 + N_( "Model 5 - 132x27" ),
  178 + NULL
  179 + }
  180 +
  181 + }
  182 + };
  183 +
  184 + static const struct Entry
  185 + {
  186 + ENTRY_FIELD_HEAD
  187 +
  188 + gint max_length;
  189 + gint width_chars;
  190 +
  191 + } entryfields[] = {
  192 + {
  193 + .left = 0,
  194 + .top = 0,
  195 + .width = 4,
  196 + .height = 1,
  197 +
  198 + .label = N_( "_Host" ),
  199 + .tooltip = N_("Address or name of the host to connect."),
  200 + .max_length = 0xFF,
  201 + .width_chars = 50,
  202 +
  203 + },
  204 + {
  205 + .left = 0,
  206 + .top = 1,
  207 + .width = 1,
  208 + .height = 1,
  209 +
  210 + .label = N_( "_Service" ),
  211 + .tooltip = N_("Port or service name (empty for \"telnet\")."),
  212 + .max_length = 6,
  213 + .width_chars = 7,
  214 + },
  215 +
  216 + {
  217 + .top = 1,
  218 + .left = 3,
  219 + .width = 2,
  220 + .height = 1,
  221 +
  222 + .label = N_( "Oversize" ),
  223 + .tooltip = N_("Makes the screen larger than the default for the chosen model number."),
  224 + .max_length = 7,
  225 + .width_chars = 8,
  226 + },
  227 +
  228 + {
  229 + .top = 2,
  230 + .left = 0,
  231 + .width = 8,
  232 + .height = 1,
  233 +
  234 + .label = N_( "Custom Remap" ),
  235 + .tooltip = N_("Path to XML file with custom charset mapping."),
  236 + .max_length = 0xFF,
  237 + .width_chars = 50,
  238 + },
  239 +
  240 + {
  241 + .left = 2,
  242 + .top = 1,
  243 + .width = 2,
  244 + .height = 1,
  245 +
  246 + .label = N_( "L_U Names" ),
  247 + .tooltip = N_("Comma separated list of LU names."),
  248 + .max_length = 0xFF,
  249 + .width_chars = 50,
  250 + },
  251 +
  252 + };
  253 +
  254 + struct _V3270HostSelectWidget
  255 + {
  256 + V3270Settings parent;
  257 +
  258 + struct
  259 + {
  260 + GtkEntry * entry[G_N_ELEMENTS(entryfields)]; ///< @brief Entry fields for host & service name.
  261 + GtkToggleButton * ssl; ///< @brief SSL Connection?
  262 + GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes.
  263 + GtkComboBox * charset; ///< @brief Charset combo box.
  264 + GtkToggleButton * toggles[G_N_ELEMENTS(toggleList)]; ///< @brief Toggle checks.
  265 + GtkSpinButton * auto_disconnect; ///< @brief Auto disconnect.
  266 +
  267 + } input;
  268 +
  269 + };
  270 +
  271 + struct _V3270HostSelectWidgetClass
  272 + {
  273 + V3270SettingsClass parent_class;
  274 + };
  275 +
  276 + static void load(GtkWidget *w, GtkWidget *terminal);
  277 + static void apply(GtkWidget *w, GtkWidget *terminal);
  278 +
  279 + G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_V3270_SETTINGS);
  280 +
  281 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  282 +
  283 +static void update_message(GtkWidget *widget, GtkWidget *terminal)
  284 +{
  285 + gtk_widget_set_sensitive(widget, lib3270_is_disconnected(v3270_get_session(terminal)));
  286 +}
  287 +
  288 +static void V3270HostSelectWidget_class_init(G_GNUC_UNUSED V3270HostSelectWidgetClass *klass)
  289 +{
  290 + V3270SettingsClass * widget = GTK_V3270_SETTINGS_CLASS(klass);
  291 +
  292 + widget->apply = apply;
  293 + widget->load = load;
  294 + widget->update_message = update_message;
  295 +
  296 +}
  297 +
  298 +static void oversize_changed(GtkEditable *editable, GtkWidget *settings)
  299 +{
  300 + const gchar * chars = gtk_editable_get_chars(editable,0,-1);
  301 + gboolean valid = TRUE;
  302 + char junk;
  303 + unsigned int ovc = 0, ovr = 0;
  304 +
  305 + if(*chars)
  306 + {
  307 + if(sscanf(chars, "%ux%u%c", &ovc, &ovr, &junk) != 2)
  308 + {
  309 + valid = FALSE;
  310 + debug("Can't parse \"%s\"",chars);
  311 + }
  312 + else if( (ovc * ovr) > 0x4000)
  313 + {
  314 + valid = FALSE;
  315 + debug("Invalid values on \"%s\"",chars);
  316 + }
  317 + }
  318 +
  319 + v3270_settings_set_valid(settings,valid);
  320 +}
  321 +
  322 +static void remap_file_changed(GtkEditable *editable, V3270HostSelectWidget *settings)
  323 +{
  324 + const gchar * filename = gtk_editable_get_chars(editable,0,-1);
  325 +
  326 + debug("%s(%s)",__FUNCTION__,filename);
  327 + if(*filename)
  328 + {
  329 + v3270_settings_set_valid(GTK_WIDGET(settings),g_file_test(filename,G_FILE_TEST_IS_REGULAR));
  330 + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.charset),FALSE);
  331 + }
  332 + else
  333 + {
  334 + v3270_settings_set_valid(GTK_WIDGET(settings),TRUE);
  335 + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.charset),TRUE);
  336 + }
  337 +
  338 +}
  339 +
  340 +static void select_remap_file(GtkEditable *editable, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, G_GNUC_UNUSED GtkWidget *settings)
  341 +{
  342 + GtkWidget * dialog =
  343 + gtk_file_chooser_dialog_new(
  344 + _( "Select custom charset mapping"),
  345 + GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(editable))),
  346 + GTK_FILE_CHOOSER_ACTION_OPEN,
  347 + _("Cancel"), GTK_RESPONSE_CANCEL,
  348 + _("Select"), GTK_RESPONSE_ACCEPT,
  349 + NULL );
  350 +
  351 +
  352 + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE);
  353 + g_signal_connect(G_OBJECT(dialog),"close",G_CALLBACK(v3270_dialog_close),NULL);
  354 +
  355 + // Setup file filter
  356 + GtkFileFilter * filter = gtk_file_filter_new();
  357 + gtk_file_filter_set_name(filter,_("TN3270 Custom charset"));
  358 + gtk_file_filter_add_pattern(filter,"*.xml");
  359 + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
  360 +
  361 + // Get current file name.
  362 + const gchar * filename = gtk_editable_get_chars(editable,0,-1);
  363 +
  364 + if(filename && *filename)
  365 + {
  366 + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename);
  367 + }
  368 + else
  369 + {
  370 + lib3270_autoptr(char) folder = lib3270_build_data_filename("remap",NULL);
  371 +
  372 + if(folder && *folder)
  373 + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), folder);
  374 +
  375 + }
  376 +
  377 + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
  378 + gtk_entry_set_text(GTK_ENTRY(editable),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
  379 +
  380 + gtk_widget_destroy(dialog);
  381 +
  382 +}
  383 +
  384 +static gboolean auto_disconnect_format(GtkSpinButton *spin, G_GNUC_UNUSED gpointer data) {
  385 +
  386 + GtkAdjustment * adjustment = gtk_spin_button_get_adjustment (spin);
  387 + guint value = (guint) gtk_adjustment_get_value(adjustment);
  388 +
  389 + if(value < 1) {
  390 + gtk_entry_set_text(GTK_ENTRY(spin), "");
  391 + } else {
  392 + g_autofree gchar * text = g_strdup_printf ("%d", value);
  393 + gtk_entry_set_text(GTK_ENTRY(spin), text);
  394 + }
  395 +
  396 + return TRUE;
  397 +}
  398 +
  399 +static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
  400 +{
  401 + // Cell renderer
  402 + GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new();
  403 +
  404 + // Connection properties
  405 + GtkWidget * connection = gtk_grid_new();
  406 + gtk_grid_set_row_spacing(GTK_GRID(connection),6);
  407 + gtk_grid_set_column_spacing(GTK_GRID(connection),12);
  408 +
  409 + gtk_grid_attach(
  410 + GTK_GRID(widget),
  411 + v3270_dialog_create_frame(connection,_("Connection")),
  412 + 0,0,10,5
  413 + );
  414 +
  415 + // Emulation properties
  416 + GtkWidget * emulation = gtk_grid_new();
  417 + gtk_grid_set_row_spacing(GTK_GRID(emulation),6);
  418 + gtk_grid_set_column_spacing(GTK_GRID(emulation),12);
  419 +
  420 + gtk_grid_attach(
  421 + GTK_GRID(widget),
  422 + v3270_dialog_create_frame(emulation,_("Emulation")),
  423 + 0,6,10,5
  424 + );
  425 +
  426 + // Entry fields
  427 + {
  428 + size_t entry;
  429 +
  430 + for(entry = 0; entry < G_N_ELEMENTS(entryfields); entry++)
  431 + {
  432 + widget->input.entry[entry] = GTK_ENTRY(gtk_entry_new());
  433 + gtk_entry_set_max_length(widget->input.entry[entry],entryfields[entry].max_length);
  434 + gtk_entry_set_width_chars(widget->input.entry[entry],entryfields[entry].width_chars);
  435 + }
  436 +
  437 + // Custom settings
  438 + gtk_entry_set_placeholder_text(widget->input.entry[ENTRY_SRVCNAME],"telnet");
  439 +
  440 + gtk_widget_set_hexpand(GTK_WIDGET(widget->input.entry[ENTRY_HOSTNAME]),TRUE);
  441 + gtk_widget_set_hexpand(GTK_WIDGET(widget->input.entry[ENTRY_REMAP_FILE]),TRUE);
  442 +
  443 + gtk_entry_set_icon_from_icon_name(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,"document-open");
  444 + gtk_entry_set_icon_activatable(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,TRUE);
  445 + gtk_entry_set_icon_tooltip_text(widget->input.entry[ENTRY_REMAP_FILE],GTK_ENTRY_ICON_SECONDARY,_("Select charset remap file"));
  446 +
  447 + g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_REMAP_FILE]),"icon-press",G_CALLBACK(select_remap_file),widget);
  448 + g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_REMAP_FILE]),"changed",G_CALLBACK(remap_file_changed),widget);
  449 +
  450 + g_signal_connect(G_OBJECT(widget->input.entry[ENTRY_OVERSIZE]),"changed",G_CALLBACK(oversize_changed),widget);
  451 +
  452 + // Add to containers
  453 + v3270_grid_attach(
  454 + GTK_GRID(connection),
  455 + (struct v3270_entry_field *) & entryfields[0],
  456 + GTK_WIDGET(widget->input.entry[0])
  457 + );
  458 +
  459 + v3270_grid_attach(
  460 + GTK_GRID(connection),
  461 + (struct v3270_entry_field *) & entryfields[1],
  462 + GTK_WIDGET(widget->input.entry[1])
  463 + );
  464 +
  465 + v3270_grid_attach(
  466 + GTK_GRID(emulation),
  467 + (struct v3270_entry_field *) & entryfields[2],
  468 + GTK_WIDGET(widget->input.entry[2])
  469 + );
  470 +
  471 + v3270_grid_attach(
  472 + GTK_GRID(emulation),
  473 + (struct v3270_entry_field *) & entryfields[3],
  474 + GTK_WIDGET(widget->input.entry[3])
  475 + );
  476 +
  477 + v3270_grid_attach(
  478 + GTK_GRID(connection),
  479 + (struct v3270_entry_field *) & entryfields[4],
  480 + GTK_WIDGET(widget->input.entry[4])
  481 + );
  482 +
  483 + }
  484 +
  485 + // Auto disconnect
  486 + {
  487 + GtkWidget *label = gtk_label_new_with_mnemonic(_("Auto _disconnect"));
  488 +
  489 + gtk_widget_set_halign(label,GTK_ALIGN_END);
  490 +
  491 + widget->input.auto_disconnect = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0,60,1));
  492 + gtk_widget_set_tooltip_markup(GTK_WIDGET(widget->input.auto_disconnect),_("IDLE minutes for automatic disconnection"));
  493 + gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(widget->input.auto_disconnect));
  494 +
  495 + gtk_spin_button_set_increments(widget->input.auto_disconnect,1,1);
  496 +
  497 + gtk_grid_attach(GTK_GRID(connection),label,0,2,1,1);
  498 + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.auto_disconnect),1,2,1,1);
  499 + g_signal_connect(G_OBJECT(widget->input.auto_disconnect),"output",G_CALLBACK(auto_disconnect_format),widget);
  500 + }
  501 +
  502 + // SSL checkbox
  503 + {
  504 + widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));
  505 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." ));
  506 + gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START);
  507 + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),1,3,1,1);
  508 + }
  509 +
  510 + // Toggle checkboxes
  511 + {
  512 + size_t toggle;
  513 +
  514 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  515 + {
  516 + const LIB3270_TOGGLE * descriptor = lib3270_toggle_get_from_id(toggleList[toggle].id);
  517 +
  518 + if(descriptor)
  519 + {
  520 + widget->input.toggles[toggle] = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label(gettext(descriptor->label)));
  521 +
  522 + if(descriptor->description && *descriptor->description)
  523 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.toggles[toggle]),gettext(descriptor->description));
  524 + else if(descriptor->summary && *descriptor->summary)
  525 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.toggles[toggle]),gettext(descriptor->summary));
  526 +
  527 + gtk_widget_set_halign(GTK_WIDGET(widget->input.toggles[toggle]),GTK_ALIGN_START);
  528 + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.toggles[toggle]),toggleList[toggle].left,toggleList[toggle].top,1,1);
  529 +
  530 + }
  531 +
  532 + }
  533 +
  534 + }
  535 +
  536 + // Create combo boxes
  537 + {
  538 + size_t combo, item;
  539 +
  540 + for(combo = 0; combo < G_N_ELEMENTS(combos); combo++) {
  541 +
  542 + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_UINT);
  543 +
  544 + widget->input.combos[combo] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
  545 +
  546 + if(combos[combo].tooltip)
  547 + gtk_widget_set_tooltip_markup(GTK_WIDGET(widget->input.combos[combo]),combos[combo].tooltip);
  548 +
  549 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.combos[combo]), text_renderer, TRUE);
  550 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.combos[combo]), text_renderer, "text", 0, NULL);
  551 +
  552 + for(item = 0; combos[combo].labels[item]; item++)
  553 + {
  554 + GtkTreeIter iter;
  555 + gtk_list_store_append((GtkListStore *) model, &iter);
  556 + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(combos[combo].labels[item]), 1, combos[combo].values[item], -1);
  557 + }
  558 +
  559 + v3270_grid_attach(GTK_GRID(emulation), (struct v3270_entry_field *) & combos[combo], GTK_WIDGET(widget->input.combos[combo]));
  560 +
  561 + }
  562 +
  563 + }
  564 +
  565 + // Create Charset Combo
  566 + {
  567 + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(1,G_TYPE_STRING);
  568 +
  569 + widget->input.charset = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
  570 +
  571 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.charset), text_renderer, TRUE);
  572 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.charset), text_renderer, "text", 0, NULL);
  573 +
  574 + static const gchar * charsets[] =
  575 + {
  576 + "us",
  577 + "bracket",
  578 + "cp500"
  579 + };
  580 +
  581 + size_t charset;
  582 + for(charset = 0; charset < G_N_ELEMENTS(charsets); charset++)
  583 + {
  584 + GtkTreeIter iter;
  585 + gtk_list_store_append((GtkListStore *) model, &iter);
  586 + gtk_list_store_set((GtkListStore *) model, &iter, 0, charsets[charset], -1);
  587 + };
  588 +
  589 + static const struct v3270_entry_field descriptor =
  590 + {
  591 + .top = 0,
  592 + .left = 6,
  593 + .width = 2,
  594 + .height = 1,
  595 +
  596 + .label = N_("_Charset"),
  597 + .tooltip = N_("The EBCDIC host character set. "),
  598 +
  599 + };
  600 +
  601 + v3270_grid_attach(GTK_GRID(emulation), &descriptor, GTK_WIDGET(widget->input.charset));
  602 +
  603 + }
  604 +
  605 + gtk_widget_show_all(GTK_WIDGET(widget));
  606 +
  607 +}
  608 +
  609 +LIB3270_EXPORT GtkWidget * v3270_host_settings_new()
  610 +{
  611 + V3270Settings * settings = GTK_V3270_SETTINGS(g_object_new(GTK_TYPE_V3270HostSelectWidget, NULL));
  612 +
  613 + settings->title = _("Host properties");
  614 + settings->label = _("Host");
  615 +
  616 + return GTK_WIDGET(settings);
  617 +}
  618 +
  619 +LIB3270_EXPORT GtkWidget * v3270_host_select_new()
  620 +{
  621 + return v3270_host_settings_new();
  622 +}
  623 +
  624 +LIB3270_EXPORT void v3270_select_host(GtkWidget *widget)
  625 +{
  626 + g_return_if_fail(GTK_IS_V3270(widget));
  627 +
  628 + GtkWidget * dialog = v3270_settings_dialog_new();
  629 + GtkWidget * settings = v3270_host_select_new();
  630 +
  631 + gtk_window_set_title(GTK_WINDOW(dialog), v3270_settings_get_title(settings));
  632 + gtk_container_add(GTK_CONTAINER(dialog), settings);
  633 +
  634 + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(widget)));
  635 + gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
  636 +
  637 + v3270_settings_dialog_set_terminal_widget(dialog, widget);
  638 +
  639 + gtk_window_set_default_size(GTK_WINDOW(dialog), 700, 150);
  640 + gtk_widget_show_all(dialog);
  641 +
  642 + gboolean again = TRUE;
  643 + while(again)
  644 + {
  645 + gtk_widget_set_sensitive(dialog,TRUE);
  646 + gtk_widget_set_visible(dialog,TRUE);
  647 +
  648 + switch(gtk_dialog_run(GTK_DIALOG(dialog)))
  649 + {
  650 + case GTK_RESPONSE_APPLY:
  651 + debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_APPLY");
  652 + v3270_settings_dialog_apply(dialog);
  653 + again = lib3270_reconnect(v3270_get_session(widget),0);
  654 + break;
  655 +
  656 + case GTK_RESPONSE_CANCEL:
  657 + again = FALSE;
  658 + debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_CANCEL");
  659 + v3270_settings_dialog_revert(dialog);
  660 + break;
  661 + }
  662 + }
  663 +
  664 + gtk_widget_destroy(dialog);
  665 +
  666 +}
  667 +
  668 +static void apply(GtkWidget *w, GtkWidget *terminal)
  669 +{
  670 + debug("V3270HostSelectWidget::%s",__FUNCTION__);
  671 +
  672 + V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
  673 + H3270 *hSession = v3270_get_session(terminal);
  674 +
  675 + // Apply URL
  676 + {
  677 + g_autofree gchar * url =
  678 + g_strconcat(
  679 + (gtk_toggle_button_get_active(widget->input.ssl) ? "tn3270s://" : "tn3270://"),
  680 + gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]),
  681 + ":",
  682 + gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]),
  683 + NULL
  684 + );
  685 +
  686 + debug("URL=[%s]",url);
  687 + lib3270_set_url(hSession,url);
  688 +
  689 + }
  690 +
  691 + // Apply LU names
  692 + v3270_set_lunames(terminal,gtk_entry_get_text(widget->input.entry[ENTRY_LU_NAMES]));
  693 +
  694 + // Apply combos.
  695 + size_t combo;
  696 + for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
  697 + {
  698 + GtkTreeIter iter;
  699 +
  700 + if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget->input.combos[combo]), &iter))
  701 + {
  702 + GValue value = { 0, };
  703 + gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget->input.combos[combo])),&iter,1,&value);
  704 +
  705 + combos[combo].set(hSession,g_value_get_uint(&value));
  706 +
  707 + g_value_unset(&value);
  708 +
  709 + }
  710 + }
  711 +
  712 + // Apply charset
  713 + {
  714 + GtkTreeIter iter;
  715 +
  716 + if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget->input.charset), &iter))
  717 + {
  718 + GValue value = { 0, };
  719 + gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget->input.charset)),&iter,0,&value);
  720 +
  721 + lib3270_set_host_charset(hSession,g_value_get_string(&value));
  722 +
  723 + g_value_unset(&value);
  724 +
  725 + }
  726 +
  727 + v3270_set_remap_filename(terminal, gtk_entry_get_text(widget->input.entry[ENTRY_REMAP_FILE]));
  728 +
  729 + }
  730 +
  731 + // Apply toggles
  732 + size_t toggle;
  733 +
  734 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  735 + {
  736 + if(widget->input.toggles[toggle])
  737 + v3270_set_toggle(terminal, toggleList[toggle].id, gtk_toggle_button_get_active(widget->input.toggles[toggle]));
  738 + }
  739 +
  740 + // Apply oversize
  741 + lib3270_set_oversize(hSession,gtk_entry_get_text(widget->input.entry[ENTRY_OVERSIZE]));
  742 +
  743 + // Apply auto-disconnect
  744 + v3270_set_auto_disconnect(terminal,gtk_spin_button_get_value_as_int(widget->input.auto_disconnect));
  745 +
  746 +}
  747 +
  748 +static void load(GtkWidget *w, GtkWidget *terminal)
  749 +{
  750 + debug("V3270HostSelectWidget::%s",__FUNCTION__);
  751 +
  752 + H3270 *hSession = v3270_get_session(terminal);
  753 + V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
  754 +
  755 + const gchar * u = lib3270_get_url(hSession);
  756 +
  757 + if(u)
  758 + {
  759 +
  760 + g_autofree gchar * url = g_strdup(u);
  761 + debug("URL=[%s]",url);
  762 +
  763 + gtk_toggle_button_set_active(widget->input.ssl,g_str_has_prefix(u,"tn3270s"));
  764 +
  765 + gchar *hostname = strstr(url,"://");
  766 + if(!hostname)
  767 + {
  768 + g_message("Invalid URL: \"%s\" (no scheme)",url);
  769 + }
  770 + else
  771 + {
  772 + hostname += 3;
  773 +
  774 + gchar *srvcname = strchr(hostname,':');
  775 +
  776 + if(srvcname)
  777 + {
  778 + *(srvcname++) = 0;
  779 + }
  780 + else
  781 + {
  782 + srvcname = "telnet";
  783 + }
  784 +
  785 + gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname);
  786 + gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname);
  787 +
  788 + }
  789 +
  790 + }
  791 +
  792 + // Load LU names
  793 + g_autofree gchar * lunames = v3270_get_lunames(terminal);
  794 + gtk_entry_set_text(widget->input.entry[ENTRY_LU_NAMES],lunames ? lunames : "");
  795 +
  796 + // Load unsigned int combos
  797 + size_t combo;
  798 + for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
  799 + {
  800 +
  801 + GtkTreeModel * model = gtk_combo_box_get_model(widget->input.combos[combo]);
  802 + GtkTreeIter iter;
  803 + unsigned int value = combos[combo].get(hSession);
  804 +
  805 + if(gtk_tree_model_get_iter_first(model,&iter))
  806 + {
  807 + do
  808 + {
  809 + GValue gVal = { 0, };
  810 + gtk_tree_model_get_value(model,&iter,1,&gVal);
  811 + guint iVal = g_value_get_uint(&gVal);
  812 + g_value_unset(&gVal);
  813 +
  814 + if(iVal == value)
  815 + {
  816 + gtk_combo_box_set_active_iter(widget->input.combos[combo],&iter);
  817 + break;
  818 + }
  819 +
  820 + } while(gtk_tree_model_iter_next(model,&iter));
  821 +
  822 +
  823 + }
  824 +
  825 + }
  826 +
  827 + // Load charset
  828 + {
  829 + const char * charset = lib3270_get_host_charset(hSession);
  830 +
  831 + if(charset)
  832 + {
  833 + GtkTreeModel * model = gtk_combo_box_get_model(widget->input.charset);
  834 + GtkTreeIter iter;
  835 +
  836 + if(gtk_tree_model_get_iter_first(model,&iter))
  837 + {
  838 + do
  839 + {
  840 + GValue gVal = { 0, };
  841 + gtk_tree_model_get_value(model,&iter,0,&gVal);
  842 +
  843 + if(!g_ascii_strcasecmp(charset,g_value_get_string(&gVal)))
  844 + {
  845 + gtk_combo_box_set_active_iter(widget->input.charset,&iter);
  846 + g_value_unset(&gVal);
  847 + break;
  848 + }
  849 +
  850 + g_value_unset(&gVal);
  851 +
  852 + } while(gtk_tree_model_iter_next(model,&iter));
  853 +
  854 +
  855 + }
  856 +
  857 + }
  858 +
  859 + const gchar * remap_file = v3270_get_remap_filename(terminal);
  860 + gtk_entry_set_text(widget->input.entry[ENTRY_REMAP_FILE],remap_file ? remap_file : "");
  861 +
  862 +
  863 + }
  864 +
  865 + // Load toggles
  866 + size_t toggle;
  867 +
  868 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  869 + {
  870 + if(widget->input.toggles[toggle])
  871 + gtk_toggle_button_set_active(widget->input.toggles[toggle],v3270_get_toggle(terminal,toggleList[toggle].id));
  872 + }
  873 +
  874 + // Load oversize
  875 + const char * oversize = lib3270_get_oversize(hSession);
  876 + gtk_entry_set_text(widget->input.entry[ENTRY_OVERSIZE],oversize ? oversize : "");
  877 +
  878 + // Load auto disconnect
  879 + gtk_spin_button_set_value(widget->input.auto_disconnect, v3270_get_auto_disconnect(terminal));
  880 +
  881 +}
  882 +
... ...
src/include/internals.h
... ... @@ -57,15 +57,14 @@
57 57 unsigned short attr; ///< @brief Character attribute.
58 58 };
59 59  
60   -
61   -/// @brief Head for settings widgets.
62   -#define ENTRY_FIELD_HEAD \
63   - gint left; \
64   - gint top; \
65   - gint width; \
66   - gint height; \
67   - const gchar * label; \
68   - const gchar * tooltip;
  60 + /// @brief Head for settings widgets.
  61 + #define ENTRY_FIELD_HEAD \
  62 + gint left; \
  63 + gint top; \
  64 + gint width; \
  65 + gint height; \
  66 + const gchar * label; \
  67 + const gchar * tooltip;
69 68  
70 69 struct v3270_entry_field
71 70 {
... ...
src/include/v3270.h
... ... @@ -284,7 +284,6 @@
284 284  
285 285 // Auxiliary widgets
286 286 LIB3270_EXPORT void v3270_select_host(GtkWidget *widget);
287   - LIB3270_EXPORT GtkWidget * v3270_font_chooser_widget_new();
288 287  
289 288 // Print
290 289 LIB3270_EXPORT int v3270_print(GtkWidget *widget, GError **error);
... ...
src/include/v3270/dialogs.h
... ... @@ -35,7 +35,6 @@
35 35  
36 36 G_BEGIN_DECLS
37 37  
38   - LIB3270_EXPORT GtkWidget * v3270_host_select_new();
39 38 LIB3270_EXPORT void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body);
40 39  
41 40 LIB3270_EXPORT GtkWidget * v3270_save_dialog_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename);
... ...
src/include/v3270/settings.h
... ... @@ -134,6 +134,15 @@
134 134 LIB3270_EXPORT void v3270_settings_dialog_apply(GtkWidget *widget);
135 135 LIB3270_EXPORT void v3270_settings_dialog_revert(GtkWidget *widget);
136 136  
  137 + LIB3270_EXPORT GtkWidget * v3270_host_settings_new();
  138 + LIB3270_EXPORT GtkWidget * v3270_accelerator_settings_new();
  139 + LIB3270_EXPORT GtkWidget * v3270_font_settings_new();
  140 +
  141 + LIB3270_EXPORT GtkWidget * v3270_font_chooser_widget_new() G_GNUC_DEPRECATED;
  142 + LIB3270_EXPORT GtkWidget * v3270_host_select_new() G_GNUC_DEPRECATED;
  143 +
  144 +
  145 +
137 146 G_END_DECLS
138 147  
139 148 #endif // V3270SETTINGS_H_INCLUDED
... ...
src/testprogram/toolbar.c
... ... @@ -55,7 +55,7 @@
55 55 static void font_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal)
56 56 {
57 57 v3270_settings_popup_dialog(
58   - v3270_font_chooser_widget_new(),
  58 + v3270_font_settings_new(),
59 59 terminal,
60 60 FALSE
61 61 );
... ... @@ -67,9 +67,10 @@
67 67 GtkWidget * dialog = v3270_settings_dialog_new();
68 68  
69 69 gtk_window_set_title(GTK_WINDOW(dialog),"Session properties");
70   - gtk_container_add(GTK_CONTAINER(dialog), v3270_host_select_new());
  70 + gtk_container_add(GTK_CONTAINER(dialog), v3270_host_settings_new());
71 71 gtk_container_add(GTK_CONTAINER(dialog), v3270_color_selection_new());
72   - gtk_container_add(GTK_CONTAINER(dialog), v3270_font_chooser_widget_new());
  72 + gtk_container_add(GTK_CONTAINER(dialog), v3270_font_settings_new());
  73 + gtk_container_add(GTK_CONTAINER(dialog), v3270_accelerator_settings_new());
73 74  
74 75 gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(terminal)));
75 76  
... ...
v3270.cbp
... ... @@ -60,9 +60,6 @@
60 60 <Unit filename="src/dialogs/font/select.c">
61 61 <Option compilerVar="CC" />
62 62 </Unit>
63   - <Unit filename="src/dialogs/hostselect.c">
64   - <Option compilerVar="CC" />
65   - </Unit>
66 63 <Unit filename="src/dialogs/linux/select.c">
67 64 <Option compilerVar="CC" />
68 65 </Unit>
... ... @@ -102,9 +99,15 @@
102 99 <Unit filename="src/dialogs/security.c">
103 100 <Option compilerVar="CC" />
104 101 </Unit>
  102 + <Unit filename="src/dialogs/settings/accelerator.c">
  103 + <Option compilerVar="CC" />
  104 + </Unit>
105 105 <Unit filename="src/dialogs/settings/dialog.c">
106 106 <Option compilerVar="CC" />
107 107 </Unit>
  108 + <Unit filename="src/dialogs/settings/host.c">
  109 + <Option compilerVar="CC" />
  110 + </Unit>
108 111 <Unit filename="src/dialogs/settings/widget.c">
109 112 <Option compilerVar="CC" />
110 113 </Unit>
... ...