Commit 0a69c938a51931da073dd5fafd93bcfa9be69c4c
1 parent
0dbf2175
Exists in
master
and in
1 other branch
Refactoring popup engine.
Showing
4 changed files
with
17 additions
and
12 deletions
Show diff stats
src/dialogs/popups.c
@@ -36,12 +36,14 @@ | @@ -36,12 +36,14 @@ | ||
36 | 36 | ||
37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
38 | 38 | ||
39 | - GtkResponseType v3270_show_popup(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait) { | 39 | + GtkResponseType v3270_popup_dialog_show(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait) { |
40 | 40 | ||
41 | g_return_val_if_fail(GTK_IS_WIDGET(widget),GTK_RESPONSE_NONE); | 41 | g_return_val_if_fail(GTK_IS_WIDGET(widget),GTK_RESPONSE_NONE); |
42 | 42 | ||
43 | // Check if the dialog is enabled | 43 | // Check if the dialog is enabled |
44 | - if(popup->name && GTK_IS_V3270(widget)) { | 44 | + gboolean allow_disabling = (popup->name && GTK_IS_V3270(widget)); |
45 | + | ||
46 | + if(allow_disabling) { | ||
45 | 47 | ||
46 | GtkResponseType response = GTK_RESPONSE_DELETE_EVENT; | 48 | GtkResponseType response = GTK_RESPONSE_DELETE_EVENT; |
47 | 49 | ||
@@ -55,6 +57,7 @@ | @@ -55,6 +57,7 @@ | ||
55 | if((response != GTK_RESPONSE_NONE) && (response != GTK_RESPONSE_DELETE_EVENT)) | 57 | if((response != GTK_RESPONSE_NONE) && (response != GTK_RESPONSE_DELETE_EVENT)) |
56 | return response; | 58 | return response; |
57 | 59 | ||
60 | + allow_disabling = (response == GTK_RESPONSE_NONE); | ||
58 | } | 61 | } |
59 | 62 | ||
60 | // Popup settings. | 63 | // Popup settings. |
@@ -119,7 +122,7 @@ | @@ -119,7 +122,7 @@ | ||
119 | GtkWidget * dont_ask = NULL; | 122 | GtkWidget * dont_ask = NULL; |
120 | 123 | ||
121 | #ifdef DEBUG | 124 | #ifdef DEBUG |
122 | - if(popup->name && GTK_IS_V3270(widget)) { | 125 | + if(allow_disabling) { |
123 | // Set check button | 126 | // Set check button |
124 | dont_ask = gtk_check_button_new_with_label(_("Don't ask again")); | 127 | dont_ask = gtk_check_button_new_with_label(_("Don't ask again")); |
125 | 128 | ||
@@ -204,7 +207,7 @@ | @@ -204,7 +207,7 @@ | ||
204 | .body = body | 207 | .body = body |
205 | }; | 208 | }; |
206 | 209 | ||
207 | - v3270_show_popup(widget, &popup, FALSE); | 210 | + v3270_popup_dialog_show(widget, &popup, FALSE); |
208 | 211 | ||
209 | } | 212 | } |
210 | 213 | ||
@@ -223,7 +226,7 @@ | @@ -223,7 +226,7 @@ | ||
223 | .body = error->message | 226 | .body = error->message |
224 | }; | 227 | }; |
225 | 228 | ||
226 | - v3270_show_popup(widget, &popup, FALSE); | 229 | + v3270_popup_dialog_show(widget, &popup, FALSE); |
227 | 230 | ||
228 | } | 231 | } |
229 | 232 |
src/include/internals.h
@@ -135,7 +135,7 @@ | @@ -135,7 +135,7 @@ | ||
135 | G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); | 135 | G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); |
136 | G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title); | 136 | G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title); |
137 | 137 | ||
138 | - G_GNUC_INTERNAL GtkResponseType v3270_show_popup(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait); | 138 | + G_GNUC_INTERNAL GtkResponseType v3270_popup_dialog_show(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait); |
139 | 139 | ||
140 | G_GNUC_INTERNAL void v3270_signal_emit(gpointer instance, enum V3270_SIGNAL signal_id, ...); | 140 | G_GNUC_INTERNAL void v3270_signal_emit(gpointer instance, enum V3270_SIGNAL signal_id, ...); |
141 | 141 |
src/selection/linux/paste.c
@@ -118,7 +118,7 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select | @@ -118,7 +118,7 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select | ||
118 | .label = _("_Paste as text") | 118 | .label = _("_Paste as text") |
119 | }; | 119 | }; |
120 | 120 | ||
121 | - if(v3270_show_popup(widget,&popup,1) == GTK_RESPONSE_APPLY) | 121 | + if(v3270_popup_dialog_show(widget,&popup,1) == GTK_RESPONSE_APPLY) |
122 | { | 122 | { |
123 | gtk_clipboard_request_text( | 123 | gtk_clipboard_request_text( |
124 | clipboard, | 124 | clipboard, |
src/terminal/callbacks.c
@@ -285,7 +285,7 @@ static void message(H3270 *session, LIB3270_NOTIFY type , const char *title, con | @@ -285,7 +285,7 @@ static void message(H3270 *session, LIB3270_NOTIFY type , const char *title, con | ||
285 | .body = text | 285 | .body = text |
286 | }; | 286 | }; |
287 | 287 | ||
288 | - v3270_show_popup(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); | 288 | + v3270_popup_dialog_show(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); |
289 | 289 | ||
290 | } | 290 | } |
291 | 291 | ||
@@ -334,10 +334,12 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | @@ -334,10 +334,12 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | ||
334 | 334 | ||
335 | g_autofree gchar * body = NULL; | 335 | g_autofree gchar * body = NULL; |
336 | 336 | ||
337 | - if(fmt) | 337 | + if(fmt) { |
338 | body = g_strdup_vprintf(fmt,args); | 338 | body = g_strdup_vprintf(fmt,args); |
339 | + popup.body = body; | ||
340 | + } | ||
339 | 341 | ||
340 | - v3270_show_popup(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); | 342 | + v3270_popup_dialog_show(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); |
341 | 343 | ||
342 | } | 344 | } |
343 | 345 | ||
@@ -432,10 +434,10 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | @@ -432,10 +434,10 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | ||
432 | 434 | ||
433 | static int popup_show(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char wait) { | 435 | static int popup_show(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char wait) { |
434 | 436 | ||
435 | - GtkResponseType response = v3270_show_popup( | 437 | + GtkResponseType response = v3270_popup_dialog_show( |
436 | GTK_WIDGET(lib3270_get_user_data(hSession)), | 438 | GTK_WIDGET(lib3270_get_user_data(hSession)), |
437 | popup, | 439 | popup, |
438 | - wait != 0 ? TRUE : FALSE ); | 440 | + wait != 0); |
439 | 441 | ||
440 | if(response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) | 442 | if(response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) |
441 | return 0; | 443 | return 0; |