@@ -36,37 +36,21 @@ void button_for_net_alpha() {
36
36
gtk_grid_insert_column ((GtkGrid*)grid, 0 );
37
37
38
38
// text entry for apha value
39
- GtkWidget* entry = gtk_entry_new ();
40
- std::string initialValue = std::to_string (get_net_alpha ());
41
- gtk_entry_set_text ((GtkEntry*)entry, initialValue.c_str ());
42
- gtk_entry_set_input_purpose ((GtkEntry*)entry, GTK_INPUT_PURPOSE_NUMBER);
43
- gtk_widget_set_name (entry, " alphaValue" );
44
- gtk_entry_set_activates_default ((GtkEntry*)entry, TRUE );
39
+ GtkWidget* alpha_widget = gtk_spin_button_new_with_range (0 , 100 , 1 );
40
+ GtkWidget* alpha_label = gtk_label_new (" Set Net Transparency:" );
41
+ gtk_widget_set_name (alpha_widget, " netAlpha" );
45
42
46
- // label
47
- GtkWidget* alpha_label = gtk_label_new (" Set net transparency [0., 1.]" );
48
-
49
- // button
50
- GtkWidget* button = gtk_button_new_with_label (" set" );
51
-
52
- // attach to the grid
53
- gtk_grid_attach ((GtkGrid*)grid, entry, 0 , 0 , box_width, box_height);
54
- gtk_grid_attach ((GtkGrid*)grid, button, 1 , 0 , box_width, box_height);
55
43
gtk_grid_attach ((GtkGrid*)main_window_grid, alpha_label, label_left_start_col, button_row++, box_width, box_height);
56
- gtk_grid_attach ((GtkGrid*)main_window_grid, grid , box_left_start_col, button_row++, box_width, box_height);
44
+ gtk_grid_attach ((GtkGrid*)main_window_grid, alpha_widget , box_left_start_col, button_row++, box_width, box_height);
57
45
58
46
// show newly added contents
59
47
gtk_widget_show_all ((GtkWidget*)main_window);
60
48
61
49
// connect signals
62
- g_signal_connect_swapped (GTK_BUTTON (button) ,
63
- " clicked " ,
50
+ g_signal_connect_swapped ((GtkSpinButton*)alpha_widget ,
51
+ " value_changed " ,
64
52
G_CALLBACK (set_net_alpha_value),
65
- entry);
66
- g_signal_connect_swapped (GTK_ENTRY (entry),
67
- " activate" ,
68
- G_CALLBACK (set_net_alpha_value_with_enter),
69
- entry);
53
+ alpha_widget);
70
54
}
71
55
72
56
void button_for_toggle_nets () {
0 commit comments