[gedit/wip/previous-search-behavior: 1/2] Replace dialog: create the SearchContext before the actual search



commit f87ce394f9df149d14fa1edfca7d34d1718b37b1
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Sep 17 17:48:13 2013 +0200

    Replace dialog: create the SearchContext before the actual search
    
    The object method handler gedit_replace_dialog_response() creates the
    SearchContext if it is not already created.
    
    In commands-search.c, replace_dialog_response_cb() must be called after
    the SearchContext creation, to execute the actual find or replace.
    
    If replace_dialog_response_cb() is called before, the SearchContext may
    not be already created, and the find or replace doesn't work.

 gedit/gedit-replace-dialog.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gedit/gedit-replace-dialog.c b/gedit/gedit-replace-dialog.c
index 98905c6..6831715 100644
--- a/gedit/gedit-replace-dialog.c
+++ b/gedit/gedit-replace-dialog.c
@@ -385,8 +385,8 @@ connect_active_document (GeditReplaceDialog *dialog)
 }
 
 static void
-gedit_replace_dialog_response (GtkDialog *dialog,
-                               gint       response_id)
+response_cb (GtkDialog *dialog,
+            gint       response_id)
 {
        GeditReplaceDialog *dlg = GEDIT_REPLACE_DIALOG (dialog);
        const gchar *str;
@@ -444,11 +444,9 @@ gedit_replace_dialog_class_init (GeditReplaceDialogClass *klass)
 {
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-       GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
 
        gobject_class->dispose = gedit_replace_dialog_dispose;
        widget_class->delete_event = gedit_replace_dialog_delete_event;
-       dialog_class->response = gedit_replace_dialog_response;
 
        /* Bind class to template */
        gtk_widget_class_set_template_from_resource (widget_class,
@@ -668,6 +666,14 @@ gedit_replace_dialog_init (GeditReplaceDialog *dlg)
                          "hide",
                          G_CALLBACK (hide_cb),
                          NULL);
+
+       /* We connect here to make sure this handler runs before the others so
+        * that the search context is created.
+        */
+       g_signal_connect (dlg,
+                         "response",
+                         G_CALLBACK (response_cb),
+                         NULL);
 }
 
 GtkWidget *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]