Commit c1d9f910f727caaad5e0697e8ed294ea8f0b1f10

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

Fixing multiple "save-settings" signals on common dialog.

src/dialogs/settings/dialog.c
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 #include "../private.h" 30 #include "../private.h"
31 #include <internals.h> 31 #include <internals.h>
32 #include <v3270/settings.h> 32 #include <v3270/settings.h>
  33 + #include <terminal.h>
33 #include <lib3270/log.h> 34 #include <lib3270/log.h>
34 35
35 G_DEFINE_TYPE(V3270SettingsDialog, V3270SettingsDialog, GTK_TYPE_DIALOG); 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,6 +124,14 @@ static void revert_settings(GtkWidget *widget, GtkWidget G_GNUC_UNUSED(* termina
123 v3270_settings_revert(widget); 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 void v3270_settings_dialog_apply(GtkWidget *dialog) 135 void v3270_settings_dialog_apply(GtkWidget *dialog)
127 { 136 {
128 debug("%s",__FUNCTION__); 137 debug("%s",__FUNCTION__);
@@ -131,13 +140,17 @@ void v3270_settings_dialog_apply(GtkWidget *dialog) @@ -131,13 +140,17 @@ void v3270_settings_dialog_apply(GtkWidget *dialog)
131 if(!terminal) 140 if(!terminal)
132 return; 141 return;
133 142
  143 + // Freeze to avoid multiple "save settings" signals.
  144 + GTK_V3270(terminal)->freeze = 1;
  145 +
134 gtk_container_foreach( 146 gtk_container_foreach(
135 GTK_CONTAINER(GTK_V3270_SETTINGS_DIALOG(dialog)->tabs), 147 GTK_CONTAINER(GTK_V3270_SETTINGS_DIALOG(dialog)->tabs),
136 (GtkCallback) apply_settings, 148 (GtkCallback) apply_settings,
137 terminal 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,11 +133,12 @@ G_BEGIN_DECLS
133 GtkWidget parent; 133 GtkWidget parent;
134 134
135 // flags 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 /// @brief Action properties. 143 /// @brief Action properties.
143 GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; 144 GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM];
src/terminal/keyfile.c
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 { 57 {
58 const gchar * current = g_value_get_string(&value); 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 if(current && strcmp(current,G_PARAM_SPEC_STRING(pspec)->default_value ? G_PARAM_SPEC_STRING(pspec)->default_value : "")) 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,7 +84,7 @@
84 { 84 {
85 gboolean current = g_value_get_boolean(&value); 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 if(current != G_PARAM_SPEC_BOOLEAN(pspec)->default_value) 89 if(current != G_PARAM_SPEC_BOOLEAN(pspec)->default_value)
90 { 90 {
src/terminal/properties/get.c
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 v3270 * window = GTK_V3270(object); 37 v3270 * window = GTK_V3270(object);
38 v3270Class * klass = GTK_V3270_GET_CLASS(object); 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 if(prop_id >= klass->properties.type.responses) 42 if(prop_id >= klass->properties.type.responses)
43 { 43 {
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 else if(prop_id >= klass->properties.type.str) 46 else if(prop_id >= klass->properties.type.str)
47 { 47 {
48 const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); 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 if(prop->get) 51 if(prop->get)
52 g_value_set_string(value,prop->get(window->host)); 52 g_value_set_string(value,prop->get(window->host));
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 else if(prop_id >= klass->properties.type.uint) 55 else if(prop_id >= klass->properties.type.uint)
56 { 56 {
57 const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); 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 if(prop->get) 60 if(prop->get)
61 g_value_set_uint(value,prop->get(window->host)); 61 g_value_set_uint(value,prop->get(window->host));
@@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@
64 else if(prop_id >= klass->properties.type.integer) 64 else if(prop_id >= klass->properties.type.integer)
65 { 65 {
66 const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); 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 if(prop->get) 69 if(prop->get)
70 g_value_set_int(value,prop->get(window->host)); 70 g_value_set_int(value,prop->get(window->host));
@@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
73 else if(prop_id >= klass->properties.type.boolean) 73 else if(prop_id >= klass->properties.type.boolean)
74 { 74 {
75 const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); 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 if(prop->get) 78 if(prop->get)
79 g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE); 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,7 +771,8 @@ static gboolean bg_emit_save_settings(GObject *widget)
771 771
772 void v3270_emit_save_settings(GtkWidget *widget) 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 g_idle_add((GSourceFunc) bg_emit_save_settings, G_OBJECT(widget)); 776 g_idle_add((GSourceFunc) bg_emit_save_settings, G_OBJECT(widget));
776 } 777 }
777 778