Commit c1d9f910f727caaad5e0697e8ed294ea8f0b1f10
1 parent
43e31543
Exists in
master
and in
1 other branch
Fixing multiple "save-settings" signals on common dialog.
Showing
5 changed files
with
29 additions
and
14 deletions
Show diff stats
src/dialogs/settings/dialog.c
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #include "../private.h" |
31 | 31 | #include <internals.h> |
32 | 32 | #include <v3270/settings.h> |
33 | + #include <terminal.h> | |
33 | 34 | #include <lib3270/log.h> |
34 | 35 | |
35 | 36 | G_DEFINE_TYPE(V3270SettingsDialog, V3270SettingsDialog, GTK_TYPE_DIALOG); |
... | ... | @@ -123,6 +124,14 @@ static void revert_settings(GtkWidget *widget, GtkWidget G_GNUC_UNUSED(* termina |
123 | 124 | v3270_settings_revert(widget); |
124 | 125 | } |
125 | 126 | |
127 | +static gboolean bg_emit_save_settings(GObject *widget) | |
128 | +{ | |
129 | + debug("Unfreezing and emitting save settings for terminal %p",widget); | |
130 | + GTK_V3270(widget)->freeze = 0; | |
131 | + g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_SAVE_SETTINGS], 0, FALSE); | |
132 | + return FALSE; | |
133 | +} | |
134 | + | |
126 | 135 | void v3270_settings_dialog_apply(GtkWidget *dialog) |
127 | 136 | { |
128 | 137 | debug("%s",__FUNCTION__); |
... | ... | @@ -131,13 +140,17 @@ void v3270_settings_dialog_apply(GtkWidget *dialog) |
131 | 140 | if(!terminal) |
132 | 141 | return; |
133 | 142 | |
143 | + // Freeze to avoid multiple "save settings" signals. | |
144 | + GTK_V3270(terminal)->freeze = 1; | |
145 | + | |
134 | 146 | gtk_container_foreach( |
135 | 147 | GTK_CONTAINER(GTK_V3270_SETTINGS_DIALOG(dialog)->tabs), |
136 | 148 | (GtkCallback) apply_settings, |
137 | 149 | terminal |
138 | 150 | ); |
139 | 151 | |
140 | - v3270_emit_save_settings(terminal); | |
152 | + // Delay the "unfreeze" signal. | |
153 | + g_idle_add((GSourceFunc) bg_emit_save_settings, G_OBJECT(terminal)); | |
141 | 154 | |
142 | 155 | } |
143 | 156 | ... | ... |
src/include/terminal.h
... | ... | @@ -133,11 +133,12 @@ G_BEGIN_DECLS |
133 | 133 | GtkWidget parent; |
134 | 134 | |
135 | 135 | // flags |
136 | - int selecting : 1; /**< Selecting region */ | |
137 | - int moving : 1; /**< Moving selected region */ | |
138 | - int resizing : 1; /**< Resizing selected region */ | |
139 | - int scaled_fonts : 1; /**< Use scaled fonts */ | |
140 | - int drawing : 1; /**< Draw widget? */ | |
136 | + int selecting : 1; /// @brief Selecting region | |
137 | + int moving : 1; /// @brief Moving selected region | |
138 | + int resizing : 1; /// @brief Resizing selected region | |
139 | + int scaled_fonts : 1; /// @brief Use scaled fonts | |
140 | + int drawing : 1; /// @brief Draw widget? | |
141 | + int freeze : 1; /// @brief Truee when the "save settings" signal is disabled. | |
141 | 142 | |
142 | 143 | /// @brief Action properties. |
143 | 144 | GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; | ... | ... |
src/terminal/keyfile.c
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | { |
58 | 58 | const gchar * current = g_value_get_string(&value); |
59 | 59 | |
60 | - debug("%s=%s (default: %s)",name,current,G_PARAM_SPEC_STRING(pspec)->default_value); | |
60 | +// debug("%s=%s (default: %s)",name,current,G_PARAM_SPEC_STRING(pspec)->default_value); | |
61 | 61 | |
62 | 62 | if(current && strcmp(current,G_PARAM_SPEC_STRING(pspec)->default_value ? G_PARAM_SPEC_STRING(pspec)->default_value : "")) |
63 | 63 | { |
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 | { |
85 | 85 | gboolean current = g_value_get_boolean(&value); |
86 | 86 | |
87 | - debug("%s=%s (default: %s)",name,current ? "ON" : "OFF" ,G_PARAM_SPEC_BOOLEAN(pspec)->default_value ? "ON" : "OFF"); | |
87 | +// debug("%s=%s (default: %s)",name,current ? "ON" : "OFF" ,G_PARAM_SPEC_BOOLEAN(pspec)->default_value ? "ON" : "OFF"); | |
88 | 88 | |
89 | 89 | if(current != G_PARAM_SPEC_BOOLEAN(pspec)->default_value) |
90 | 90 | { | ... | ... |
src/terminal/properties/get.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | v3270 * window = GTK_V3270(object); |
38 | 38 | v3270Class * klass = GTK_V3270_GET_CLASS(object); |
39 | 39 | |
40 | - debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); | |
40 | +// debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); | |
41 | 41 | |
42 | 42 | if(prop_id >= klass->properties.type.responses) |
43 | 43 | { |
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | else if(prop_id >= klass->properties.type.str) |
47 | 47 | { |
48 | 48 | const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); |
49 | - debug("%s.%s.%s",__FUNCTION__,"string",prop->name); | |
49 | +// debug("%s.%s.%s",__FUNCTION__,"string",prop->name); | |
50 | 50 | |
51 | 51 | if(prop->get) |
52 | 52 | g_value_set_string(value,prop->get(window->host)); |
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | else if(prop_id >= klass->properties.type.uint) |
56 | 56 | { |
57 | 57 | const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); |
58 | - debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); | |
58 | +// debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); | |
59 | 59 | |
60 | 60 | if(prop->get) |
61 | 61 | g_value_set_uint(value,prop->get(window->host)); |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | else if(prop_id >= klass->properties.type.integer) |
65 | 65 | { |
66 | 66 | const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); |
67 | - debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); | |
67 | +// debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); | |
68 | 68 | |
69 | 69 | if(prop->get) |
70 | 70 | g_value_set_int(value,prop->get(window->host)); |
... | ... | @@ -73,7 +73,7 @@ |
73 | 73 | else if(prop_id >= klass->properties.type.boolean) |
74 | 74 | { |
75 | 75 | const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); |
76 | - debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); | |
76 | +// debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); | |
77 | 77 | |
78 | 78 | if(prop->get) |
79 | 79 | g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE); | ... | ... |
src/terminal/widget.c
... | ... | @@ -771,7 +771,8 @@ static gboolean bg_emit_save_settings(GObject *widget) |
771 | 771 | |
772 | 772 | void v3270_emit_save_settings(GtkWidget *widget) |
773 | 773 | { |
774 | - if(widget) | |
774 | + debug("%s(Freeze is %s)",__FUNCTION__,GTK_V3270(widget)->freeze ? "ON" : "OFF"); | |
775 | + if(widget && GTK_IS_V3270(widget) && !GTK_V3270(widget)->freeze) | |
775 | 776 | g_idle_add((GSourceFunc) bg_emit_save_settings, G_OBJECT(widget)); |
776 | 777 | } |
777 | 778 | ... | ... |