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

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