Commit 0dbf217553eb5800da5fde6d9c9a09e8c9811854

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

Refactoring popup engine.

src/dialogs/popups.c
@@ -61,7 +61,6 @@ @@ -61,7 +61,6 @@
61 static const struct _settings { 61 static const struct _settings {
62 GtkMessageType type; 62 GtkMessageType type;
63 const gchar *button; 63 const gchar *button;
64 - const gchar *title;  
65 } settings[LIB3270_NOTIFY_USER] = { 64 } settings[LIB3270_NOTIFY_USER] = {
66 65
67 // LIB3270_NOTIFY_INFO - Simple information dialog. 66 // LIB3270_NOTIFY_INFO - Simple information dialog.
@@ -163,7 +162,7 @@ @@ -163,7 +162,7 @@
163 gtk_widget_show_all(dialog); 162 gtk_widget_show_all(dialog);
164 GtkResponseType rc = gtk_dialog_run(GTK_DIALOG(dialog)); 163 GtkResponseType rc = gtk_dialog_run(GTK_DIALOG(dialog));
165 164
166 - if(dont_ask && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dont_ask))) { 165 + if(dont_ask && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dont_ask)) && rc != GTK_RESPONSE_DELETE_EVENT && rc != GTK_RESPONSE_NONE) {
167 166
168 gboolean saved = FALSE; 167 gboolean saved = FALSE;
169 168
@@ -228,6 +227,7 @@ @@ -228,6 +227,7 @@
228 227
229 } 228 }
230 229
  230 + /*
231 GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) { 231 GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) {
232 232
233 GtkResponseType response = GTK_V3270(widget)->responses[id]; 233 GtkResponseType response = GTK_V3270(widget)->responses[id];
@@ -315,3 +315,4 @@ @@ -315,3 +315,4 @@
315 return response; 315 return response;
316 316
317 } 317 }
  318 +*/
src/include/internals.h
@@ -185,6 +185,7 @@ @@ -185,6 +185,7 @@
185 unsigned short keycode; 185 unsigned short keycode;
186 } V3270PFKeyAccelerator; 186 } V3270PFKeyAccelerator;
187 187
  188 + /*
188 typedef enum v3270_toggleable_dialog 189 typedef enum v3270_toggleable_dialog
189 { 190 {
190 V3270_TOGGLEABLE_DIALOG_PASTE_FAILED, 191 V3270_TOGGLEABLE_DIALOG_PASTE_FAILED,
@@ -193,6 +194,7 @@ @@ -193,6 +194,7 @@
193 } V3270_TOGGLEABLE_DIALOG; 194 } V3270_TOGGLEABLE_DIALOG;
194 195
195 G_GNUC_INTERNAL GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED; 196 G_GNUC_INTERNAL GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED;
  197 + */
196 198
197 #if GTK_CHECK_VERSION(3,12,0) 199 #if GTK_CHECK_VERSION(3,12,0)
198 G_GNUC_INTERNAL GtkHeaderBar * v3270_dialog_get_header_bar(GtkWidget * widget); 200 G_GNUC_INTERNAL GtkHeaderBar * v3270_dialog_get_header_bar(GtkWidget * widget);
src/include/terminal.h
@@ -87,13 +87,13 @@ G_BEGIN_DECLS @@ -87,13 +87,13 @@ G_BEGIN_DECLS
87 guint integer; 87 guint integer;
88 guint uint; 88 guint uint;
89 guint str; 89 guint str;
90 - guint responses; 90 +// guint responses;
91 } type; 91 } type;
92 92
93 } properties; 93 } properties;
94 94
95 // Predefined responses. 95 // Predefined responses.
96 - GParamSpec * responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; 96 +// GParamSpec * responses[V3270_TOGGLEABLE_DIALOG_CUSTOM];
97 97
98 // Cursors 98 // Cursors
99 GdkCursor * cursors[LIB3270_POINTER_COUNT]; 99 GdkCursor * cursors[LIB3270_POINTER_COUNT];
@@ -163,7 +163,7 @@ G_BEGIN_DECLS @@ -163,7 +163,7 @@ G_BEGIN_DECLS
163 int copying : 1; /// @brief Copy with center mouse button 163 int copying : 1; /// @brief Copy with center mouse button
164 164
165 /// @brief Action properties. 165 /// @brief Action properties.
166 - GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; 166 +// GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM];
167 167
168 GSource * timer; 168 GSource * timer;
169 GtkIMContext * input_method; 169 GtkIMContext * input_method;
src/selection/linux/paste.c
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 #include <clipboard.h> 30 #include <clipboard.h>
31 #include <lib3270/toggle.h> 31 #include <lib3270/toggle.h>
32 #include <v3270/dialogs.h> 32 #include <v3270/dialogs.h>
  33 + #include <lib3270/popup.h>
33 34
34 /*--[ Implement ]------------------------------------------------------------------------------------*/ 35 /*--[ Implement ]------------------------------------------------------------------------------------*/
35 36
@@ -109,18 +110,15 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select @@ -109,18 +110,15 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select
109 { 110 {
110 debug("%s: Can't paste data",__FUNCTION__); 111 debug("%s: Can't paste data",__FUNCTION__);
111 112
  113 + LIB3270_POPUP popup = {
  114 + .name = "cantpaste",
  115 + .title = _("Can't paste"),
  116 + .summary = _("Unable to paste formatted data."),
  117 + .body = _("None of the screens in the clipboard match with the current one."),
  118 + .label = _("_Paste as text")
  119 + };
112 120
113 - if(  
114 - v3270_popup_toggleable_dialog(  
115 - widget,  
116 - V3270_TOGGLEABLE_DIALOG_PASTE_FAILED,  
117 - _("Can't paste"),  
118 - _("Unable to paste formatted data."),  
119 - _("None of the screens in the clipboard match with the current one."),  
120 - _("_Cancel"), GTK_RESPONSE_CANCEL,  
121 - _("_Paste as text"), GTK_RESPONSE_APPLY,  
122 - NULL  
123 - ) == GTK_RESPONSE_APPLY) 121 + if(v3270_show_popup(widget,&popup,1) == GTK_RESPONSE_APPLY)
124 { 122 {
125 gtk_clipboard_request_text( 123 gtk_clipboard_request_text(
126 clipboard, 124 clipboard,
@@ -129,51 +127,8 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select @@ -129,51 +127,8 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select
129 ); 127 );
130 } 128 }
131 129
132 - /*  
133 - GtkResponseType response = GTK_V3270(terminal)->responses[V3270_TOGGLEABLE_DIALOG_PASTE_FAILED];  
134 -  
135 - if(response == GTK_RESPONSE_NONE)  
136 - {  
137 - // No predefined response, ask.  
138 - GtkWidget * dialog =  
139 - gtk_message_dialog_new(  
140 - GTK_WINDOW(gtk_widget_get_toplevel(widget)),  
141 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,  
142 - GTK_MESSAGE_INFO,  
143 - GTK_BUTTONS_NONE,  
144 - _("Unable to paste formatted data")  
145 - );  
146 -  
147 -  
148 - gtk_window_set_title(GTK_WINDOW(dialog),_("Can't paste"));  
149 -  
150 - gtk_dialog_add_buttons(  
151 - GTK_DIALOG (dialog),  
152 - _("_Cancel"), GTK_RESPONSE_CANCEL,  
153 - _("_Paste as text"), GTK_RESPONSE_APPLY,  
154 - NULL  
155 - );  
156 -  
157 - gtk_dialog_set_default_response(GTK_DIALOG (dialog),response);  
158 -  
159 - gint response = gtk_dialog_run(GTK_DIALOG(dialog));  
160 -  
161 - gtk_widget_destroy(dialog);  
162 - }  
163 -  
164 - if(response == GTK_RESPONSE_APPLY)  
165 - {  
166 - gtk_clipboard_request_text(  
167 - clipboard,  
168 - (GtkClipboardTextReceivedFunc) text_received,  
169 - (gpointer) widget  
170 - );  
171 - }  
172 -  
173 - */  
174 return; 130 return;
175 131
176 -  
177 } 132 }
178 133
179 } 134 }
src/terminal/actions/toggle.c
@@ -112,7 +112,7 @@ @@ -112,7 +112,7 @@
112 return G_VARIANT_TYPE_BOOLEAN; 112 return G_VARIANT_TYPE_BOOLEAN;
113 } 113 }
114 114
115 - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { 115 + static gboolean get_enabled(GAction G_GNUC_UNUSED(*action), GtkWidget G_GNUC_UNUSED(*terminal)) {
116 return TRUE; 116 return TRUE;
117 } 117 }
118 118
@@ -126,7 +126,7 @@ @@ -126,7 +126,7 @@
126 126
127 } 127 }
128 128
129 - void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { 129 + void Lib3270ToggleAction_init(Lib3270ToggleAction G_GNUC_UNUSED(*action)) {
130 } 130 }
131 131
132 GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) { 132 GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition) {
src/terminal/keyfile.c
@@ -309,8 +309,10 @@ @@ -309,8 +309,10 @@
309 save_by_pspec(widget,klass->properties.toggle[ix],key_file,group_name); 309 save_by_pspec(widget,klass->properties.toggle[ix],key_file,group_name);
310 310
311 // Save V3270 Responses 311 // Save V3270 Responses
  312 + /*
312 for(ix = 0; ix < G_N_ELEMENTS(terminal->responses); ix++) 313 for(ix = 0; ix < G_N_ELEMENTS(terminal->responses); ix++)
313 save_by_pspec(widget,klass->responses[ix],key_file,group_name); 314 save_by_pspec(widget,klass->responses[ix],key_file,group_name);
  315 + */
314 316
315 // Save V3270 properties 317 // Save V3270 properties
316 for(ix = 0; ix < V3270_SETTING_COUNT; ix++) 318 for(ix = 0; ix < V3270_SETTING_COUNT; ix++)
@@ -360,9 +362,11 @@ @@ -360,9 +362,11 @@
360 for(ix = 0; ix < G_N_ELEMENTS(klass->properties.toggle); ix++) 362 for(ix = 0; ix < G_N_ELEMENTS(klass->properties.toggle); ix++)
361 load_by_pspec(widget,klass->properties.toggle[ix],key_file,group_name); 363 load_by_pspec(widget,klass->properties.toggle[ix],key_file,group_name);
362 364
  365 + /*
363 // Load V3270 Responses 366 // Load V3270 Responses
364 for(ix = 0; ix < G_N_ELEMENTS(terminal->responses); ix++) 367 for(ix = 0; ix < G_N_ELEMENTS(terminal->responses); ix++)
365 load_by_pspec(widget,klass->responses[ix],key_file,group_name); 368 load_by_pspec(widget,klass->responses[ix],key_file,group_name);
  369 + */
366 370
367 // Load V3270 properties 371 // Load V3270 properties
368 for(ix = 0; ix < V3270_SETTING_COUNT; ix++) 372 for(ix = 0; ix < V3270_SETTING_COUNT; ix++)
src/terminal/properties/get.c
@@ -39,11 +39,13 @@ @@ -39,11 +39,13 @@
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 if(prop_id >= klass->properties.type.responses)
43 { 44 {
44 g_value_set_int(value,(int) window->responses[prop_id - klass->properties.type.responses]); 45 g_value_set_int(value,(int) window->responses[prop_id - klass->properties.type.responses]);
45 } 46 }
46 - else if(prop_id >= klass->properties.type.str) 47 + else */
  48 + if(prop_id >= klass->properties.type.str)
47 { 49 {
48 const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); 50 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); 51 // debug("%s.%s.%s",__FUNCTION__,"string",prop->name);
src/terminal/properties/init.c
@@ -398,6 +398,7 @@ @@ -398,6 +398,7 @@
398 // 398 //
399 // Create action properties. 399 // Create action properties.
400 // 400 //
  401 + /*
401 klass->properties.type.responses = klass->properties.count; 402 klass->properties.type.responses = klass->properties.count;
402 403
403 static const struct 404 static const struct
@@ -435,7 +436,7 @@ @@ -435,7 +436,7 @@
435 } 436 }
436 437
437 } 438 }
438 - 439 + */
439 440
440 } 441 }
441 442
src/terminal/widget.c
@@ -553,8 +553,10 @@ static void v3270_init(v3270 *widget) @@ -553,8 +553,10 @@ static void v3270_init(v3270 *widget)
553 v3270_font_info_init(&widget->font); 553 v3270_font_info_init(&widget->font);
554 v3270_set_color_table(widget->color,v3270_get_default_colors()); 554 v3270_set_color_table(widget->color,v3270_get_default_colors());
555 555
  556 + /*
556 for(ix = 0; ix < G_N_ELEMENTS(widget->responses); ix++) 557 for(ix = 0; ix < G_N_ELEMENTS(widget->responses); ix++)
557 widget->responses[ix] = GTK_RESPONSE_NONE; 558 widget->responses[ix] = GTK_RESPONSE_NONE;
  559 + */
558 560
559 // Init accelerators 561 // Init accelerators
560 v3270_init_accelerators(widget); 562 v3270_init_accelerators(widget);