Blame SOURCES/0040-report-gtk-confirm-the-ask-dialogs-on-Enter.patch

4b6aa8
From a10a6e9bbe8d53ffe661c180c6e75a4004d5f881 Mon Sep 17 00:00:00 2001
4b6aa8
From: Jakub Filak <jfilak@redhat.com>
4b6aa8
Date: Mon, 17 Mar 2014 10:37:58 +0100
4b6aa8
Subject: [LIBREPORT PATCH 40/93] report-gtk: confirm the ask dialogs on
4b6aa8
 'Enter'
4b6aa8
4b6aa8
This commit adds a convinient way of closing an ask dialog. If user
4b6aa8
enters some text, hitting 'Enter' key closes the dialog. Closing the
4b6aa8
dialog with empty input text is not allowed because it is simmilar to
4b6aa8
clicking 'Cancel' button.
4b6aa8
4b6aa8
Related to rhbz#1067123
4b6aa8
4b6aa8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
4b6aa8
---
4b6aa8
 src/gui-wizard-gtk/wizard.c | 8 ++++++++
4b6aa8
 1 file changed, 8 insertions(+)
4b6aa8
4b6aa8
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
4b6aa8
index 32e95c0..f8df31a 100644
4b6aa8
--- a/src/gui-wizard-gtk/wizard.c
4b6aa8
+++ b/src/gui-wizard-gtk/wizard.c
4b6aa8
@@ -1608,6 +1608,13 @@ static void run_event_gtk_alert(const char *msg, void *args)
4b6aa8
     log_request_response_communication(msg, NULL, (struct analyze_event_data *)args);
4b6aa8
 }
4b6aa8
 
4b6aa8
+static void gtk_entry_emit_dialog_response_ok(GtkEntry *entry, GtkDialog *dialog)
4b6aa8
+{
4b6aa8
+    /* Don't close the dialogue if the entry is empty */
4b6aa8
+    if (gtk_entry_get_text_length(entry) > 0)
4b6aa8
+        gtk_dialog_response(dialog, GTK_RESPONSE_OK);
4b6aa8
+}
4b6aa8
+
4b6aa8
 static char *ask_helper(const char *msg, void *args, bool password)
4b6aa8
 {
4b6aa8
     GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(g_wnd_assistant),
4b6aa8
@@ -1626,6 +1633,7 @@ static char *ask_helper(const char *msg, void *args, bool password)
4b6aa8
      * g_object_set
4b6aa8
      */
4b6aa8
     g_object_set(G_OBJECT(textbox), "editable", TRUE, NULL);
4b6aa8
+    g_signal_connect(textbox, "activate", G_CALLBACK(gtk_entry_emit_dialog_response_ok), dialog);
4b6aa8
 
4b6aa8
     if (password)
4b6aa8
         gtk_entry_set_visibility(GTK_ENTRY(textbox), FALSE);
4b6aa8
-- 
4b6aa8
1.8.3.1
4b6aa8