Commit 38d61d8a182ea133fe6750572947035a6f6e8e50

Authored by Perry Werneck
1 parent 5a9d0cda
Exists in master and in 1 other branch develop

Refactoring popup engine.

src/dialogs/popups.c
@@ -131,6 +131,7 @@ @@ -131,6 +131,7 @@
131 131
132 } 132 }
133 133
  134 + /*
134 void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) { 135 void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) {
135 136
136 LIB3270_POPUP popup = { 137 LIB3270_POPUP popup = {
@@ -148,6 +149,7 @@ @@ -148,6 +149,7 @@
148 v3270_show_popup(widget, &popup, FALSE); 149 v3270_show_popup(widget, &popup, FALSE);
149 150
150 } 151 }
  152 + */
151 153
152 void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body) { 154 void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body) {
153 155
src/include/internals.h
@@ -82,7 +82,6 @@ @@ -82,7 +82,6 @@
82 V3270_SIGNAL_KEYPRESS, 82 V3270_SIGNAL_KEYPRESS,
83 V3270_SIGNAL_MODEL_CHANGED, 83 V3270_SIGNAL_MODEL_CHANGED,
84 V3270_SIGNAL_CHANGED, 84 V3270_SIGNAL_CHANGED,
85 - V3270_SIGNAL_MESSAGE,  
86 V3270_SIGNAL_FIELD, 85 V3270_SIGNAL_FIELD,
87 V3270_SIGNAL_SESSION_CHANGED, 86 V3270_SIGNAL_SESSION_CHANGED,
88 87
@@ -133,6 +132,8 @@ @@ -133,6 +132,8 @@
133 G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); 132 G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align);
134 G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title); 133 G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title);
135 134
  135 + G_GNUC_INTERNAL GtkResponseType v3270_show_popup(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait);
  136 +
136 G_GNUC_INTERNAL void v3270_signal_emit(gpointer instance, enum V3270_SIGNAL signal_id, ...); 137 G_GNUC_INTERNAL void v3270_signal_emit(gpointer instance, enum V3270_SIGNAL signal_id, ...);
137 138
138 G_GNUC_INTERNAL void v3270_dialog_close(GtkDialog *dialog, gpointer user_data); 139 G_GNUC_INTERNAL void v3270_dialog_close(GtkDialog *dialog, gpointer user_data);
src/include/terminal.h
@@ -105,7 +105,6 @@ G_BEGIN_DECLS @@ -105,7 +105,6 @@ G_BEGIN_DECLS
105 void (*activate)(GtkWidget *widget); 105 void (*activate)(GtkWidget *widget);
106 void (*toggle_changed)(v3270 *widget,LIB3270_TOGGLE_ID toggle_id,gboolean toggle_state,const gchar *toggle_name); 106 void (*toggle_changed)(v3270 *widget,LIB3270_TOGGLE_ID toggle_id,gboolean toggle_state,const gchar *toggle_name);
107 void (*message_changed)(v3270 *widget, LIB3270_MESSAGE id); 107 void (*message_changed)(v3270 *widget, LIB3270_MESSAGE id);
108 - void (*popup_message)(GtkWidget *widget, LIB3270_NOTIFY id , const gchar *title, const gchar *message, const gchar *text);  
109 108
110 }; 109 };
111 110
src/include/v3270.h
@@ -215,13 +215,10 @@ @@ -215,13 +215,10 @@
215 LIB3270_EXPORT GtkIMContext * v3270_get_im_context(GtkWidget *widget); 215 LIB3270_EXPORT GtkIMContext * v3270_get_im_context(GtkWidget *widget);
216 LIB3270_EXPORT const gchar * v3270_get_default_font_name(); 216 LIB3270_EXPORT const gchar * v3270_get_default_font_name();
217 217
218 - LIB3270_EXPORT void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type, const gchar *title, const gchar *message, const gchar *text);  
219 -  
220 LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget); 218 LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget);
221 LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name); 219 LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name);
222 LIB3270_EXPORT gchar * v3270_get_session_title(GtkWidget *widget); 220 LIB3270_EXPORT gchar * v3270_get_session_title(GtkWidget *widget);
223 221
224 -// LIB3270_EXPORT gchar * v3270_get_title(GtkWidget *widget);  
225 LIB3270_EXPORT gchar * v3270_set_title(GtkWidget *widget, const gchar *title); 222 LIB3270_EXPORT gchar * v3270_set_title(GtkWidget *widget, const gchar *title);
226 223
227 LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id); 224 LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id);
src/terminal/callbacks.c
@@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
43 #include <lib3270.h> 43 #include <lib3270.h>
44 #include <lib3270/session.h> 44 #include <lib3270/session.h>
45 #include <lib3270/log.h> 45 #include <lib3270/log.h>
  46 + #include <lib3270/popup.h>
46 #include <errno.h> 47 #include <errno.h>
47 48
48 /*--[ Implement ]------------------------------------------------------------------------------------*/ 49 /*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -275,16 +276,16 @@ static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNU @@ -275,16 +276,16 @@ static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNU
275 276
276 } 277 }
277 278
278 -static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text) 279 +static void message(H3270 *session, LIB3270_NOTIFY type , const char *title, const char *message, const char *text)
279 { 280 {
280 - v3270_signal_emit(  
281 - GTK_WIDGET(lib3270_get_user_data(session)),  
282 - V3270_SIGNAL_MESSAGE,  
283 - (int) id,  
284 - (gchar *) title,  
285 - (gchar *) message,  
286 - (gchar *) text  
287 - ); 281 + LIB3270_POPUP popup = {
  282 + .type = type,
  283 + .title = title,
  284 + .summary = message,
  285 + .body = text
  286 + };
  287 +
  288 + v3270_show_popup(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0);
288 289
289 } 290 }
290 291
@@ -325,23 +326,18 @@ static int load(H3270 *session, const char *filename) @@ -325,23 +326,18 @@ static int load(H3270 *session, const char *filename)
325 326
326 static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) 327 static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args)
327 { 328 {
328 - GtkWidget *terminal = (GtkWidget *) lib3270_get_user_data(session); 329 + LIB3270_POPUP popup = {
  330 + .type = type,
  331 + .title = title,
  332 + .summary = msg
  333 + };
329 334
330 - if(terminal && GTK_IS_V3270(terminal))  
331 - { 335 + g_autofree gchar * body = NULL;
332 336
333 - if(fmt)  
334 - {  
335 - gchar *text = g_strdup_vprintf(fmt,args);  
336 - v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,text);  
337 - g_free(text);  
338 - }  
339 - else  
340 - {  
341 - v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,NULL);  
342 - } 337 + if(fmt)
  338 + body = g_strdup_vprintf(fmt,args);
343 339
344 - } 340 + v3270_show_popup(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0);
345 341
346 } 342 }
347 343
src/terminal/widget.c
@@ -242,7 +242,6 @@ static void v3270_class_init(v3270Class *klass) @@ -242,7 +242,6 @@ static void v3270_class_init(v3270Class *klass)
242 klass->activate = v3270_activate; 242 klass->activate = v3270_activate;
243 klass->toggle_changed = v3270_toggle_changed; 243 klass->toggle_changed = v3270_toggle_changed;
244 klass->message_changed = v3270_update_message; 244 klass->message_changed = v3270_update_message;
245 - klass->popup_message = v3270_popup_message;  
246 245
247 // Register I/O Handlers 246 // Register I/O Handlers
248 v3270_register_io_handlers(klass); 247 v3270_register_io_handlers(klass);
@@ -428,15 +427,6 @@ static void v3270_class_init(v3270Class *klass) @@ -428,15 +427,6 @@ static void v3270_class_init(v3270Class *klass)
428 v3270_VOID__VOID_UINT_UINT, 427 v3270_VOID__VOID_UINT_UINT,
429 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); 428 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
430 429
431 - v3270_widget_signal[V3270_SIGNAL_MESSAGE] =  
432 - g_signal_new( I_("popup_message"),  
433 - G_OBJECT_CLASS_TYPE (gobject_class),  
434 - G_SIGNAL_RUN_FIRST,  
435 - G_STRUCT_OFFSET (v3270Class, popup_message),  
436 - NULL, NULL,  
437 - v3270_VOID__VOID_UINT_POINTER_POINTER_POINTER,  
438 - G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);  
439 -  
440 v3270_widget_signal[V3270_SIGNAL_FIELD] = 430 v3270_widget_signal[V3270_SIGNAL_FIELD] =
441 g_signal_new( I_("field_clicked"), 431 g_signal_new( I_("field_clicked"),
442 G_OBJECT_CLASS_TYPE (gobject_class), 432 G_OBJECT_CLASS_TYPE (gobject_class),