diff --git a/src/dialogs/popups.c b/src/dialogs/popups.c
index c81b9e5..e79e74b 100644
--- a/src/dialogs/popups.c
+++ b/src/dialogs/popups.c
@@ -40,6 +40,24 @@
g_return_val_if_fail(GTK_IS_WIDGET(widget),GTK_RESPONSE_NONE);
+ // Check if the dialog is enabled
+ if(popup->name && GTK_IS_V3270(widget)) {
+
+ GtkResponseType response = GTK_RESPONSE_NONE;
+
+ v3270_signal_emit(
+ widget,
+ V3270_SIGNAL_LOAD_POPUP_RESPONSE,
+ popup->name,
+ response,
+ &response
+ );
+
+ if(response != GTK_RESPONSE_NONE)
+ return response;
+
+ }
+
// Popup settings.
static const struct _settings {
GtkMessageType type;
@@ -51,40 +69,30 @@
{
.type = GTK_MESSAGE_INFO,
.button = N_("_Ok"),
- .title = N_("Information")
-
},
// LIB3270_NOTIFY_WARNING - Warning message.
{
.type = GTK_MESSAGE_WARNING,
.button = N_("_Ok"),
- .title = N_("Warning")
-
},
// LIB3270_NOTIFY_ERROR - Error message.
{
.type = GTK_MESSAGE_ERROR,
.button = N_("_Ok"),
- .title = N_("Error")
-
},
// LIB3270_NOTIFY_CRITICAL - Critical error, user can abort application.
{
.type = GTK_MESSAGE_ERROR,
.button = N_("_Close"),
- .title = N_("Critical Error")
-
},
// LIB3270_NOTIFY_SECURE - Secure host dialog.
{
.type = GTK_MESSAGE_OTHER,
.button = N_("_Ok"),
- .title = N_("Security alert")
-
}
};
@@ -96,22 +104,46 @@
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
settings[popup->type].type,
GTK_BUTTONS_NONE,
- "%s",popup->summary
+ "%s",popup->summary
);
if(popup->body) {
- gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",popup->body);
+ gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",popup->body);
}
if(popup->title) {
gtk_window_set_title(GTK_WINDOW(dialog),popup->title);
- } else {
- gtk_window_set_title(GTK_WINDOW(dialog),g_dgettext(GETTEXT_PACKAGE,settings[popup->type].title));
}
-
if(wait) {
+ GtkWidget * dont_ask = NULL;
+
+#ifdef DEBUG
+ if(popup->name && GTK_IS_V3270(widget)) {
+ // Set check button
+ dont_ask = gtk_check_button_new_with_label(_("Don't ask again"));
+
+ gtk_widget_set_can_focus(dont_ask,FALSE);
+ gtk_widget_set_can_default(dont_ask,FALSE);
+
+#if GTK_CHECK_VERSION(3,20,0)
+ gtk_widget_set_focus_on_click(dont_ask,FALSE);
+#endif // GTK 3,20,0
+
+ //gtk_widget_set_valign(dont_ask, GTK_ALIGN_BASELINE);
+ //gtk_widget_set_halign(dont_ask, GTK_ALIGN_START);
+
+ gtk_box_pack_start(
+ GTK_BOX(gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog))),
+ dont_ask,
+ TRUE,
+ TRUE,
+ 0
+ );
+ }
+#endif // DEBUG
+
// Wait for response.
if(popup->label) {
@@ -129,7 +161,24 @@
}
gtk_widget_show_all(dialog);
- gint rc = gtk_dialog_run(GTK_DIALOG(dialog));
+ GtkResponseType rc = gtk_dialog_run(GTK_DIALOG(dialog));
+
+ if(dont_ask && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dont_ask))) {
+
+ gboolean saved = FALSE;
+
+ v3270_signal_emit(
+ widget,
+ V3270_SIGNAL_SAVE_POPUP_RESPONSE,
+ popup->name,
+ rc,
+ &saved
+ );
+
+ debug("response was %s",saved ? "saved" : "not saved");
+
+ }
+
gtk_widget_destroy(dialog);
return rc;
@@ -147,26 +196,6 @@
}
- /*
- void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) {
-
- LIB3270_POPUP popup = {
- .type = type,
- .body = text
- };
-
- if(message) {
- popup.summary = message;
- popup.title = title;
- } else {
- popup.summary = title;
- }
-
- v3270_show_popup(widget, &popup, FALSE);
-
- }
- */
-
void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body) {
LIB3270_POPUP popup = {
diff --git a/src/include/internals.h b/src/include/internals.h
index b69265e..9f63633 100644
--- a/src/include/internals.h
+++ b/src/include/internals.h
@@ -114,7 +114,9 @@
//
// Settings signals (Mostly fired by V3270Settings dialogs).
//
- V3270_SIGNAL_SAVE_SETTINGS, ///< @brief Notify main application to save all widget settings.
+ V3270_SIGNAL_SAVE_SETTINGS, ///< @brief Notify main application to save all widget settings.
+ V3270_SIGNAL_LOAD_POPUP_RESPONSE, ///< @brief Load popup response (GTK_RESPONSE_NONE to show popup).
+ V3270_SIGNAL_SAVE_POPUP_RESPONSE, ///< @brief Save popup response.
V3270_SIGNAL_LAST
};
diff --git a/src/include/terminal.h b/src/include/terminal.h
index 680ed26..9249b1a 100644
--- a/src/include/terminal.h
+++ b/src/include/terminal.h
@@ -105,6 +105,8 @@ G_BEGIN_DECLS
void (*activate)(GtkWidget *widget);
void (*toggle_changed)(v3270 *widget,LIB3270_TOGGLE_ID toggle_id,gboolean toggle_state,const gchar *toggle_name);
void (*message_changed)(v3270 *widget, LIB3270_MESSAGE id);
+ guint (*load_popup_response)(v3270 *widget, const gchar *popup_name, guint response);
+ gboolean (*save_popup_response)(v3270 *widget, const gchar *popup_name, guint response);
};
diff --git a/src/terminal/marshal b/src/terminal/marshal
index 7697035..775bfc7 100644
--- a/src/terminal/marshal
+++ b/src/terminal/marshal
@@ -6,6 +6,8 @@ VOID:POINTER
VOID:VOID,POINTER,POINTER
VOID:VOID,UINT,POINTER
BOOLEAN:UINT,ENUM
+UINT:POINTER,UINT
+BOOLEAN:POINTER,UINT
VOID:VOID,BOOLEAN
BOOLEAN:VOID,BOOLEAN,BOOLEAN,POINTER
VOID:VOID,UINT,UINT
diff --git a/src/terminal/widget.c b/src/terminal/widget.c
index 760a3b3..00ea4a6 100644
--- a/src/terminal/widget.c
+++ b/src/terminal/widget.c
@@ -201,6 +201,14 @@ static void finalize(GObject *object) {
G_OBJECT_CLASS(v3270_parent_class)->finalize(object);
}
+ static GtkResponseType load_popup_response(v3270 G_GNUC_UNUSED(*widget), const gchar G_GNUC_UNUSED(*popup_name), GtkResponseType response) {
+ return response;
+ }
+
+ static gboolean save_popup_response(v3270 G_GNUC_UNUSED(*widget), const gchar G_GNUC_UNUSED(*popup_name), GtkResponseType G_GNUC_UNUSED(response)) {
+ return FALSE;
+ }
+
static void v3270_class_init(v3270Class *klass)
{
GObjectClass * gobject_class = G_OBJECT_CLASS(klass);
@@ -242,10 +250,13 @@ static void v3270_class_init(v3270Class *klass)
klass->activate = v3270_activate;
klass->toggle_changed = v3270_toggle_changed;
klass->message_changed = v3270_update_message;
+ klass->load_popup_response = load_popup_response;
+ klass->save_popup_response = save_popup_response;
// Register I/O Handlers
v3270_register_io_handlers(klass);
+
// Cursors
{
#ifdef WIN32
@@ -464,6 +475,24 @@ static void v3270_class_init(v3270Class *klass)
v3270_VOID__VOID,
G_TYPE_NONE, 0);
+ v3270_widget_signal[V3270_SIGNAL_LOAD_POPUP_RESPONSE] =
+ g_signal_new( I_("load-popup-response"),
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (v3270Class, load_popup_response),
+ NULL, NULL,
+ v3270_UINT__POINTER_UINT,
+ G_TYPE_UINT, 2, G_TYPE_POINTER, G_TYPE_UINT);
+
+ v3270_widget_signal[V3270_SIGNAL_SAVE_POPUP_RESPONSE] =
+ g_signal_new( I_("save-popup-response"),
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (v3270Class, save_popup_response),
+ NULL, NULL,
+ v3270_BOOLEAN__POINTER_UINT,
+ G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_UINT);
+
v3270_init_properties(gobject_class);
}
diff --git a/src/testprogram/toolbar.c b/src/testprogram/toolbar.c
index 3e3e2f1..1c588c8 100644
--- a/src/testprogram/toolbar.c
+++ b/src/testprogram/toolbar.c
@@ -37,6 +37,7 @@
#include
#include
#include
+ #include
#include
#pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -163,6 +164,7 @@
*/
+ /*
{
//
// Test V3270 FT Dialog
@@ -180,7 +182,22 @@
gtk_widget_show_all(dialog);
}
+ */
+
+
+ }
+
+ static void popup_clicked(GtkButton *button, GtkWidget *terminal)
+ {
+
+ static const LIB3270_POPUP popup = {
+ .name = "sample_popup",
+ .type = LIB3270_NOTIFY_INFO,
+ .summary = "This is the summary of message",
+ .body = "This it the body of the message, can be used for a bigger explanation"
+ };
+ lib3270_popup_show(v3270_get_session(terminal), &popup, 1);
}
@@ -232,6 +249,7 @@
{ "gtk-paste", G_CALLBACK(paste_clicked), "Paste data" },
{ "document-save", G_CALLBACK(save_clicked), "Save screen or selection" },
{ "document-open", G_CALLBACK(load_clicked), "Paste file" },
+ { "dialog-information", G_CALLBACK(popup_clicked), "Show test popup" },
{ "applications-system", G_CALLBACK(preferences_clicked), "Session properties" },
--
libgit2 0.21.2