Commit 8181c4e31c6b313b3755944aa1cecf3408e36fa2
1 parent
d60908ae
Exists in
master
and in
1 other branch
Adding "auto disconnect" option in the host settings dialog.
Showing
1 changed file
with
43 additions
and
5 deletions
Show diff stats
src/dialogs/hostselect.c
| @@ -53,17 +53,17 @@ | @@ -53,17 +53,17 @@ | ||
| 53 | { | 53 | { |
| 54 | { | 54 | { |
| 55 | .left = 2, | 55 | .left = 2, |
| 56 | - .top = 2, | 56 | + .top = 3, |
| 57 | .id = LIB3270_TOGGLE_CONNECT_ON_STARTUP, | 57 | .id = LIB3270_TOGGLE_CONNECT_ON_STARTUP, |
| 58 | }, | 58 | }, |
| 59 | { | 59 | { |
| 60 | .left = 3, | 60 | .left = 3, |
| 61 | - .top = 2, | 61 | + .top = 3, |
| 62 | .id = LIB3270_TOGGLE_RECONNECT, | 62 | .id = LIB3270_TOGGLE_RECONNECT, |
| 63 | }, | 63 | }, |
| 64 | { | 64 | { |
| 65 | .left = 4, | 65 | .left = 4, |
| 66 | - .top = 2, | 66 | + .top = 3, |
| 67 | .id = LIB3270_TOGGLE_KEEP_ALIVE, | 67 | .id = LIB3270_TOGGLE_KEEP_ALIVE, |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -249,7 +249,6 @@ | @@ -249,7 +249,6 @@ | ||
| 249 | .width_chars = 50, | 249 | .width_chars = 50, |
| 250 | }, | 250 | }, |
| 251 | 251 | ||
| 252 | - | ||
| 253 | }; | 252 | }; |
| 254 | 253 | ||
| 255 | struct _V3270HostSelectWidget | 254 | struct _V3270HostSelectWidget |
| @@ -263,6 +262,7 @@ | @@ -263,6 +262,7 @@ | ||
| 263 | GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes. | 262 | GtkComboBox * combos[G_N_ELEMENTS(combos)]; ///< @brief Combo-boxes. |
| 264 | GtkComboBox * charset; ///< @brief Charset combo box. | 263 | GtkComboBox * charset; ///< @brief Charset combo box. |
| 265 | GtkToggleButton * toggles[G_N_ELEMENTS(toggleList)]; ///< @brief Toggle checks. | 264 | GtkToggleButton * toggles[G_N_ELEMENTS(toggleList)]; ///< @brief Toggle checks. |
| 265 | + GtkSpinButton * auto_disconnect; ///< @brief Auto disconnect. | ||
| 266 | 266 | ||
| 267 | } input; | 267 | } input; |
| 268 | 268 | ||
| @@ -381,6 +381,21 @@ static void select_remap_file(GtkEditable *editable, G_GNUC_UNUSED GtkEntryIconP | @@ -381,6 +381,21 @@ static void select_remap_file(GtkEditable *editable, G_GNUC_UNUSED GtkEntryIconP | ||
| 381 | 381 | ||
| 382 | } | 382 | } |
| 383 | 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 | + | ||
| 384 | static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) | 399 | static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) |
| 385 | { | 400 | { |
| 386 | // Cell renderer | 401 | // Cell renderer |
| @@ -467,12 +482,29 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) | @@ -467,12 +482,29 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) | ||
| 467 | 482 | ||
| 468 | } | 483 | } |
| 469 | 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 | + | ||
| 470 | // SSL checkbox | 502 | // SSL checkbox |
| 471 | { | 503 | { |
| 472 | widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." ))); | 504 | widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." ))); |
| 473 | gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." )); | 505 | gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." )); |
| 474 | gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START); | 506 | gtk_widget_set_halign(GTK_WIDGET(widget->input.ssl),GTK_ALIGN_START); |
| 475 | - gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),1,2,1,1); | 507 | + gtk_grid_attach(GTK_GRID(connection),GTK_WIDGET(widget->input.ssl),1,3,1,1); |
| 476 | } | 508 | } |
| 477 | 509 | ||
| 478 | // Toggle checkboxes | 510 | // Toggle checkboxes |
| @@ -703,6 +735,9 @@ static void apply(GtkWidget *w, GtkWidget *terminal) | @@ -703,6 +735,9 @@ static void apply(GtkWidget *w, GtkWidget *terminal) | ||
| 703 | // Apply oversize | 735 | // Apply oversize |
| 704 | lib3270_set_oversize(hSession,gtk_entry_get_text(widget->input.entry[ENTRY_OVERSIZE])); | 736 | lib3270_set_oversize(hSession,gtk_entry_get_text(widget->input.entry[ENTRY_OVERSIZE])); |
| 705 | 737 | ||
| 738 | + // Apply auto-disconnect | ||
| 739 | + v3270_set_auto_disconnect(terminal,gtk_spin_button_get_value_as_int(widget->input.auto_disconnect)); | ||
| 740 | + | ||
| 706 | } | 741 | } |
| 707 | 742 | ||
| 708 | static void load(GtkWidget *w, GtkWidget *terminal) | 743 | static void load(GtkWidget *w, GtkWidget *terminal) |
| @@ -835,5 +870,8 @@ static void load(GtkWidget *w, GtkWidget *terminal) | @@ -835,5 +870,8 @@ static void load(GtkWidget *w, GtkWidget *terminal) | ||
| 835 | const char * oversize = lib3270_get_oversize(hSession); | 870 | const char * oversize = lib3270_get_oversize(hSession); |
| 836 | gtk_entry_set_text(widget->input.entry[ENTRY_OVERSIZE],oversize ? oversize : ""); | 871 | gtk_entry_set_text(widget->input.entry[ENTRY_OVERSIZE],oversize ? oversize : ""); |
| 837 | 872 | ||
| 873 | + // Load auto disconnect | ||
| 874 | + gtk_spin_button_set_value(widget->input.auto_disconnect, v3270_get_auto_disconnect(terminal)); | ||
| 875 | + | ||
| 838 | } | 876 | } |
| 839 | 877 |