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 | 36 | |
37 | 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 | 41 | g_return_val_if_fail(GTK_IS_WIDGET(widget),GTK_RESPONSE_NONE); |
42 | 42 | |
43 | 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 | 48 | GtkResponseType response = GTK_RESPONSE_DELETE_EVENT; |
47 | 49 | |
... | ... | @@ -55,6 +57,7 @@ |
55 | 57 | if((response != GTK_RESPONSE_NONE) && (response != GTK_RESPONSE_DELETE_EVENT)) |
56 | 58 | return response; |
57 | 59 | |
60 | + allow_disabling = (response == GTK_RESPONSE_NONE); | |
58 | 61 | } |
59 | 62 | |
60 | 63 | // Popup settings. |
... | ... | @@ -119,7 +122,7 @@ |
119 | 122 | GtkWidget * dont_ask = NULL; |
120 | 123 | |
121 | 124 | #ifdef DEBUG |
122 | - if(popup->name && GTK_IS_V3270(widget)) { | |
125 | + if(allow_disabling) { | |
123 | 126 | // Set check button |
124 | 127 | dont_ask = gtk_check_button_new_with_label(_("Don't ask again")); |
125 | 128 | |
... | ... | @@ -204,7 +207,7 @@ |
204 | 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 | 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 | 135 | G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); |
136 | 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 | 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 | 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 | 123 | gtk_clipboard_request_text( |
124 | 124 | clipboard, | ... | ... |
src/terminal/callbacks.c
... | ... | @@ -285,7 +285,7 @@ static void message(H3270 *session, LIB3270_NOTIFY type , const char *title, con |
285 | 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 | 334 | |
335 | 335 | g_autofree gchar * body = NULL; |
336 | 336 | |
337 | - if(fmt) | |
337 | + if(fmt) { | |
338 | 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 | 434 | |
433 | 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 | 438 | GTK_WIDGET(lib3270_get_user_data(hSession)), |
437 | 439 | popup, |
438 | - wait != 0 ? TRUE : FALSE ); | |
440 | + wait != 0); | |
439 | 441 | |
440 | 442 | if(response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) |
441 | 443 | return 0; | ... | ... |