Commit 1c49b810deabb6422f80273e4243c28270da1396

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

Adding connection toggles in the host settings dialog.

Showing 1 changed file with 74 additions and 7 deletions   Show diff stats
src/dialogs/hostselect.c
@@ -37,8 +37,31 @@ @@ -37,8 +37,31 @@
37 #include <v3270/dialogs.h> 37 #include <v3270/dialogs.h>
38 #include <v3270/settings.h> 38 #include <v3270/settings.h>
39 #include <lib3270/log.h> 39 #include <lib3270/log.h>
  40 + #include <lib3270/toggle.h>
40 41
41 -/*--[ Widget definition ]----------------------------------------------------------------------------*/ 42 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  43 +
  44 + static const struct ToggleList
  45 + {
  46 + gint left;
  47 + gint top;
  48 +
  49 + LIB3270_TOGGLE_ID id;
  50 + }
  51 + toggleList[] =
  52 + {
  53 + {
  54 + .left = 3,
  55 + .top = 1,
  56 + .id = LIB3270_TOGGLE_CONNECT_ON_STARTUP,
  57 + },
  58 + {
  59 + .left = 4,
  60 + .top = 1,
  61 + .id = LIB3270_TOGGLE_RECONNECT,
  62 + }
  63 +
  64 + };
42 65
43 enum _entry 66 enum _entry
44 { 67 {
@@ -162,7 +185,7 @@ @@ -162,7 +185,7 @@
162 { 185 {
163 .left = 0, 186 .left = 0,
164 .top = 0, 187 .top = 0,
165 - .width = 5, 188 + .width = 4,
166 .height = 1, 189 .height = 1,
167 190
168 .label = N_( "_Host" ), 191 .label = N_( "_Host" ),
@@ -215,10 +238,11 @@ @@ -215,10 +238,11 @@
215 238
216 struct 239 struct
217 { 240 {
218 - GtkEntry * entry[G_N_ELEMENTS(entryfields)]; ///< @brief Entry fields for host & service name  
219 - GtkToggleButton * ssl; ///< @brief SSL Connection?  
220 - GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes  
221 - GtkComboBox * charset; ///< @brief Charset combo box 241 + GtkEntry * entry[G_N_ELEMENTS(entryfields)]; ///< @brief Entry fields for host & service name.
  242 + GtkToggleButton * ssl; ///< @brief SSL Connection?
  243 + GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes.
  244 + GtkComboBox * charset; ///< @brief Charset combo box.
  245 + GtkToggleButton * toggles[G_N_ELEMENTS(toggleList)]; ///< @brief Toggle checks.
222 246
223 } input; 247 } input;
224 248
@@ -423,7 +447,31 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -423,7 +447,31 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
423 widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." ))); 447 widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));
424 gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." )); 448 gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." ));
425 gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START); 449 gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START);
426 - gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),3,1,1,1); 450 + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),2,1,1,1);
  451 + }
  452 +
  453 + // Toggle checkboxes
  454 + {
  455 + size_t toggle;
  456 +
  457 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  458 + {
  459 + const LIB3270_TOGGLE * descriptor = lib3270_toggle_get_from_id(toggleList[toggle].id);
  460 +
  461 + if(descriptor)
  462 + {
  463 + widget->input.toggles[toggle] = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label(gettext(descriptor->label)));
  464 +
  465 + if(descriptor->summary)
  466 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.toggles[toggle]),gettext(descriptor->summary));
  467 +
  468 + gtk_widget_set_halign(GTK_WIDGET(widget->input.toggles[toggle]),GTK_ALIGN_START);
  469 + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.toggles[toggle]),toggleList[toggle].left,toggleList[toggle].top,1,1);
  470 +
  471 + }
  472 +
  473 + }
  474 +
427 } 475 }
428 476
429 // Create combo boxes 477 // Create combo boxes
@@ -613,6 +661,15 @@ static void apply(GtkWidget *w, GtkWidget *terminal) @@ -613,6 +661,15 @@ static void apply(GtkWidget *w, GtkWidget *terminal)
613 661
614 } 662 }
615 663
  664 + // Apply toggles
  665 + size_t toggle;
  666 +
  667 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  668 + {
  669 + if(widget->input.toggles[toggle])
  670 + v3270_set_toggle(terminal, toggleList[toggle].id, gtk_toggle_button_get_active(widget->input.toggles[toggle]));
  671 + }
  672 +
616 } 673 }
617 674
618 static void load(GtkWidget *w, GtkWidget *terminal) 675 static void load(GtkWidget *w, GtkWidget *terminal)
@@ -717,6 +774,7 @@ static void load(GtkWidget *w, GtkWidget *terminal) @@ -717,6 +774,7 @@ static void load(GtkWidget *w, GtkWidget *terminal)
717 774
718 } while(gtk_tree_model_iter_next(model,&iter)); 775 } while(gtk_tree_model_iter_next(model,&iter));
719 776
  777 +
720 } 778 }
721 779
722 } 780 }
@@ -727,5 +785,14 @@ static void load(GtkWidget *w, GtkWidget *terminal) @@ -727,5 +785,14 @@ static void load(GtkWidget *w, GtkWidget *terminal)
727 785
728 } 786 }
729 787
  788 + // Load toggles
  789 + size_t toggle;
  790 +
  791 + for(toggle = 0; toggle < G_N_ELEMENTS(toggleList); toggle++)
  792 + {
  793 + if(widget->input.toggles[toggle])
  794 + gtk_toggle_button_set_active(widget->input.toggles[toggle],v3270_get_toggle(terminal,toggleList[toggle].id));
  795 + }
  796 +
730 } 797 }
731 798