[patch] Search & Replace for Scintilla



Hi!

I finally found some time to finish the search and replace support for
Scintilla.  The patch for gdl is attached, along with two new files.
The patch also fixes two bugs in test.c.  I took "inspiration" from the
gtkhtml editor component.  I have a couple of questions though:

* In gIDE there is a verb SearchFind defined in the DocumentManager
plugin.  What is this supposed to do?  I used EditFind, EditFindAgain
and EditReplace as in GTKHTML.  Is this ok?

* The dialogs are small, but maybe they should be converted to Glade.
What is the general policy in this regard?

The one thing missing is regexp seaches.  This should be trivial to
implement once we switch to Scintilla 1.38.

Comments and suggestions are very welcome.

Cheers,

Gustavo

? scintilla-control/Bonobo_Control_Scintilla.oaf
? scintilla-control/scintilla-find.c
? scintilla-control/scintilla-find.h
Index: scintilla-control/Makefile.am
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/Makefile.am,v
retrieving revision 1.4
diff -u -r1.4 Makefile.am
--- scintilla-control/Makefile.am	2001/07/07 16:30:30	1.4
+++ scintilla-control/Makefile.am	2001/07/09 06:36:36
@@ -31,7 +31,9 @@
 	scintilla-editor-buffer.c \
 	scintilla-editor-buffer.h \
 	scintilla-editor-gutter.c \
-	scintilla-editor-gutter.h
+	scintilla-editor-gutter.h \
+	scintilla-find.c \
+	scintilla-find.h
 
 LEXER_OBJS = \
 	scintilla/LexCPP.o     \
Index: scintilla-control/scintilla-control.c
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/scintilla-control.c,v
retrieving revision 1.12
diff -u -r1.12 scintilla-control.c
--- scintilla-control/scintilla-control.c	2001/07/07 16:30:30	1.12
+++ scintilla-control/scintilla-control.c	2001/07/09 06:36:37
@@ -34,6 +34,7 @@
 #include "scintilla-persist-stream.h"
 #include "scintilla-editor-buffer.h"
 #include "scintilla-editor-gutter.h"
+#include "scintilla-find.h"
 
 #include <gdl/gdl-server-manager.h>
 
@@ -62,15 +63,22 @@
 
 static void notify_cb (ScintillaObject *sci, int wparam, void *lparam, 
                        gpointer user_data);
+static void destroy_cb (ScintillaObject *sci, gpointer data);
 
 static void cut_cb (GtkWidget *widget, ScintillaObject *sci);
 static void copy_cb (GtkWidget *widget, ScintillaObject *sci);
 static void paste_cb (GtkWidget *widget, ScintillaObject *sci);
+static void find_cb (GtkWidget *widget, ScintillaObject *sci);
+static void find_again_cb (GtkWidget *widget, ScintillaObject *sci);
+static void replace_cb (GtkWidget *widget, ScintillaObject *sci);
 
 BonoboUIVerb verbs[] = {
     BONOBO_UI_UNSAFE_VERB ("EditCut", cut_cb),
     BONOBO_UI_UNSAFE_VERB ("EditCopy", copy_cb),
     BONOBO_UI_UNSAFE_VERB ("EditPaste", paste_cb),
+    BONOBO_UI_UNSAFE_VERB ("EditFind", find_cb),
+    BONOBO_UI_UNSAFE_VERB ("EditFindAgain", find_again_cb),
+    BONOBO_UI_UNSAFE_VERB ("EditReplace", replace_cb),
     BONOBO_UI_VERB_END
 };
 
@@ -138,6 +146,9 @@
     gtk_signal_connect (GTK_OBJECT (sci), "notify",
                         GTK_SIGNAL_FUNC (notify_cb), NULL);
 
+    gtk_signal_connect (GTK_OBJECT (sci), "destroy",
+                        GTK_SIGNAL_FUNC (destroy_cb), NULL);
+
     scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINWIDTHN, 1, 30);
     scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINTYPEN, 1, SC_MARGIN_NUMBER);
     scintilla_send_message (SCINTILLA(sci), SCI_SETFOLDFLAGS, 16, 0);
@@ -294,6 +305,39 @@
 paste_cb (GtkWidget *widget, ScintillaObject *sci)
 {
     scintilla_send_message (sci, SCI_PASTE, 0, 0);
+}
+
+void
+find_cb (GtkWidget *widget, ScintillaObject *sci)
+{
+    run_find_dialog (sci);
+}
+
+void
+find_again_cb (GtkWidget *widget, ScintillaObject *sci)
+{
+    find_again (sci);
+}
+
+void
+replace_cb (GtkWidget *widget, ScintillaObject *sci)
+{
+    run_replace_dialog (sci);
+}
+
+static void
+destroy_cb (ScintillaObject *sci, gpointer data)
+{
+    ScintillaFindDialog *fd;
+    ScintillaReplaceDialog *rd;
+
+    fd = gtk_object_get_data (GTK_OBJECT (sci), "find_dialog");
+    if (fd)
+        scintilla_find_dialog_destroy (fd);
+
+    rd = gtk_object_get_data (GTK_OBJECT (sci), "replace_dialog");
+    if (rd)
+        scintilla_replace_dialog_destroy (rd);
 }
 
 
Index: scintilla-control/scintilla-ui.xml
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/scintilla-ui.xml,v
retrieving revision 1.4
diff -u -r1.4 scintilla-ui.xml
--- scintilla-control/scintilla-ui.xml	2001/03/04 23:12:52	1.4
+++ scintilla-control/scintilla-ui.xml	2001/07/09 06:36:37
@@ -10,6 +10,18 @@
                 <cmd name="EditPaste" _label="Paste"
       		 _tip="Paste the clipboard" pixtype="stock" pixname="Paste"
                  accel="*Control*v"/>
+
+		<cmd name="EditFind" _label="_Find..." 
+		 _tip="Find text in the document"
+		 pixtype="stock" pixname="Search" accel="*Control*f"/>
+
+		<cmd name="EditFindAgain" _label="Find A_gain" 
+		 _tip="Repeats last search for text in the document"
+		 pixtype="none" accel="*Control*g"/>
+
+		<cmd name="EditReplace" _label="_Replace..." 
+		 _tip="Replace text in the document"
+		 pixtype="stock" pixname="Search/Replace" accel="*Control*r"/>
 	</commands>
 	<menu>
 		<submenu name="Edit" _label="_Edit">
@@ -18,6 +30,12 @@
                 	        <menuitem name="EditCopy" verb="" _label="_Copy"/>
 	                        <menuitem name="EditPaste" verb="" _label="_Paste"/>
 		 	</placeholder>
+
+			<placeholder name="EditFindReplace">
+		                <menuitem name="EditFind" verb="" _label="_Find"/>
+		                <menuitem name="EditFindAgain" verb="" _label="Find A_gain"/>
+		                <menuitem name="EditReplace" verb="" _label="_Replace"/>
+			</placeholder>
 		</submenu>
 	</menu>
 
@@ -26,6 +44,11 @@
 	                        <menuitem name="EditCut" verb="" _label="C_ut"/>
                 	        <menuitem name="EditCopy" verb="" _label="_Copy"/>
 	                        <menuitem name="EditPaste" verb="" _label="_Paste"/>
+		</placeholder>
+
+		<placeholder name="EditFindReplace">
+		                <menuitem name="EditFind" verb="" _label="_Find"/>
+		                <menuitem name="EditReplace" verb="" _label="_Replace"/>
 		</placeholder>
 	</dockitem>
 </Root>
Index: scintilla-control/test.c
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/test.c,v
retrieving revision 1.4
diff -u -r1.4 test.c
--- scintilla-control/test.c	2001/07/07 16:30:30	1.4
+++ scintilla-control/test.c	2001/07/09 06:36:38
@@ -70,6 +70,8 @@
     bonobo_activate ();
     
     win = bonobo_window_new ("scitest", "Scintilla Component Test");
+    gtk_signal_connect (GTK_OBJECT (win), "destroy", gtk_main_quit, NULL);
+
     container = bonobo_ui_container_new ();
     bonobo_ui_container_set_win (container, BONOBO_WINDOW (win));
     corba_container = bonobo_object_corba_objref (BONOBO_OBJECT (container));
@@ -78,7 +80,7 @@
 
     bonobo_ui_util_set_ui (component, "/home/dave/cvs/scintilla-control", "test-ui.xml", "test");
 
-    sci = bonobo_widget_new_control ("OAFIID:control:scintilla:8e967999-d307-4a57-ae52-c1c2cb13b867", corba_container);
+    sci = bonobo_widget_new_control ("OAFIID:Bonobo_Control_Scintilla", corba_container);
     save_btn = gtk_button_new_with_label ("save");
     gtk_signal_connect (GTK_OBJECT (save_btn), "clicked",
 			GTK_SIGNAL_FUNC (save_clicked), &file);
#ifndef __SCINTILLA_FIND_H__
#define __SCINTILLA_FIND_H__

#include "scintilla/Scintilla.h"
#include "scintilla/ScintillaWidget.h"

typedef struct _ScintillaFindDialog ScintillaFindDialog;
typedef struct _ScintillaReplaceDialog ScintillaReplaceDialog;

void run_find_dialog (ScintillaObject *sci);
void find_again (ScintillaObject *sci);
void scintilla_find_dialog_destroy (ScintillaFindDialog *dialog);

void run_replace_dialog (ScintillaObject *sci);
void scintilla_replace_dialog_destroy (ScintillaReplaceDialog *dialog);

#endif
/*  -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 
 */

#include <gnome.h>
#include "scintilla-find.h"


/* ----------------------------------------------------------------------
 * Data Structures 
 * ---------------------------------------------------------------------- */

struct _ScintillaFindDialog {
    GnomeDialog *dialog;
    GtkWidget *entry;

    GtkWidget *case_sensitive, *whole_word, *word_start;
    GtkWidget *forward, *backward;

    ScintillaObject *sci;
};


struct _ScintillaReplaceDialog {
    GnomeDialog *dialog;
    GnomeDialog *ask_dialog;
    GtkWidget *entry_find, *entry_replace;

    GtkWidget *case_sensitive, *whole_word, *word_start;
    GtkWidget *selection_only;

    struct CharacterRange search_range;
    ScintillaObject *sci;
};


/* ----------------------------------------------------------------------
 * Search functions 
 * ---------------------------------------------------------------------- */

static void
do_search (GtkWidget *widget, ScintillaFindDialog *d)
{
    struct TextToFind ttf;
    long pos, flags = 0;

    ttf.lpstrText = gtk_entry_get_text (GTK_ENTRY (d->entry));
    if (strlen (ttf.lpstrText) == 0)
        return;

    /* search options */
    if (GTK_TOGGLE_BUTTON (d->case_sensitive)->active)
        flags |= SCFIND_MATCHCASE;
    if (GTK_TOGGLE_BUTTON (d->whole_word)->active)
        flags |= SCFIND_WHOLEWORD;
    if (GTK_TOGGLE_BUTTON (d->word_start)->active)
        flags |= SCFIND_WORDSTART;

    /* calculate search range */
    if (GTK_TOGGLE_BUTTON (d->backward)->active) {
        ttf.chrg.cpMin = MAX (0, scintilla_send_message 
                              (d->sci, SCI_GETCURRENTPOS, 0, 0) - 1);
        ttf.chrg.cpMax = 0;
    } else {
        ttf.chrg.cpMin = scintilla_send_message (d->sci, SCI_GETCURRENTPOS, 0, 0);
        ttf.chrg.cpMax = scintilla_send_message (d->sci, SCI_GETLENGTH, 0, 0);
    };

    pos = scintilla_send_message (d->sci, SCI_FINDTEXT, flags, (long) &ttf);
    if (pos >= 0) {
        /* mark search result */
        if (GTK_TOGGLE_BUTTON (d->backward)->active)
            scintilla_send_message (d->sci, SCI_SETSEL, 
                                    ttf.chrgText.cpMax, 
                                    ttf.chrgText.cpMin);
        else
            scintilla_send_message (d->sci, SCI_SETSEL, 
                                    ttf.chrgText.cpMin, 
                                    ttf.chrgText.cpMax);
    };
}


/* called when the user presses ENTER in the find textbox */
static void
entry_activate (GtkWidget *entry, ScintillaFindDialog *d)
{
    gnome_dialog_close (d->dialog);
    do_search (NULL, d);
}


static ScintillaFindDialog *
scintilla_find_dialog_new (ScintillaObject *sci)
{
    GtkWidget *hbox, *label, *frame;
    GSList *radio_group = NULL;
    ScintillaFindDialog *dialog;
    
    dialog = g_new0 (ScintillaFindDialog, 1);

    dialog->sci = sci;

    /* create the dialog */
    dialog->dialog = GNOME_DIALOG 
        (gnome_dialog_new (_("Find"), 
                           _("Find"), 
                           GNOME_STOCK_BUTTON_CANCEL, 
                           NULL));

    /* find textbox hbox */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), hbox, FALSE, FALSE, 0);

    label = gtk_label_new (_("Find:"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

    /* create find entry textbox */
    dialog->entry = gtk_entry_new_with_max_length (20);
    gtk_signal_connect (GTK_OBJECT (dialog->entry), "activate",
                        entry_activate, dialog);
    gtk_box_pack_start (GTK_BOX (hbox), dialog->entry, TRUE, TRUE, 0);

    /* search options hbox */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), hbox, TRUE, TRUE, 0);

    dialog->case_sensitive = gtk_check_button_new_with_label (_("Case sensitive"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->case_sensitive, FALSE, FALSE, 0);

    dialog->whole_word = gtk_check_button_new_with_label (_("Whole word"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->whole_word, FALSE, FALSE, 0);

    dialog->word_start = gtk_check_button_new_with_label (_("Match word start"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->word_start, FALSE, FALSE, 0);

    /* search direction radio group */
    frame = gtk_frame_new (_("Direction"));
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), frame, FALSE, FALSE, 0);

    hbox = gtk_hbox_new (TRUE, 0);
    gtk_container_add (GTK_CONTAINER (frame), hbox);
    gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);

    dialog->forward = gtk_radio_button_new_with_label (radio_group, _("Forward"));
    radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (dialog->forward));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->forward, FALSE, TRUE, 0);

    dialog->backward = gtk_radio_button_new_with_label (radio_group, _("Backward"));
    radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (dialog->backward));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->backward, FALSE, TRUE, 0);

    gtk_widget_show_all (dialog->dialog->vbox);

    /* set dialog options */
    gnome_dialog_button_connect (dialog->dialog, 0, do_search, dialog);
    gnome_dialog_close_hides (dialog->dialog, TRUE);
    gnome_dialog_set_close (dialog->dialog, TRUE);
    gnome_dialog_set_default (dialog->dialog, 0);

    return dialog;
}


void
scintilla_find_dialog_destroy (ScintillaFindDialog *dialog)
{
    gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
    g_free (dialog);
}


void
run_find_dialog (ScintillaObject *sci)
{
    ScintillaFindDialog *dialog;

    dialog = gtk_object_get_data (GTK_OBJECT (sci), "find_dialog");
    if (!dialog) {
        dialog = scintilla_find_dialog_new (sci);
        gtk_object_set_data (GTK_OBJECT (sci), "find_dialog", dialog);
    };
    
    if (dialog) {
        gtk_widget_show (GTK_WIDGET (dialog->dialog));
        gdk_window_raise (GTK_WIDGET (dialog->dialog)->window);
        gtk_widget_grab_focus (dialog->entry);
    };
}


void 
find_again (ScintillaObject *sci)
{
    ScintillaFindDialog *dialog;

    dialog = gtk_object_get_data (GTK_OBJECT (sci), "find_dialog");
    if (dialog)
        do_search (NULL, dialog);
}


/* ----------------------------------------------------------------------
 * Replace functions 
 * ---------------------------------------------------------------------- */

static long
search_next (ScintillaReplaceDialog *d)
{
    struct TextToFind ttf;
    long pos, flags = 0;

    /* search options */
    if (GTK_TOGGLE_BUTTON (d->case_sensitive)->active)
        flags |= SCFIND_MATCHCASE;
    if (GTK_TOGGLE_BUTTON (d->whole_word)->active)
        flags |= SCFIND_WHOLEWORD;
    if (GTK_TOGGLE_BUTTON (d->word_start)->active)
        flags |= SCFIND_WORDSTART;

    ttf.chrg.cpMin = d->search_range.cpMin;
    ttf.chrg.cpMax = d->search_range.cpMax;
    ttf.lpstrText = gtk_entry_get_text (GTK_ENTRY (d->entry_find));

    pos = scintilla_send_message (d->sci, SCI_FINDTEXT, flags, (long) &ttf);
    if (pos >= 0) {
        /* mark search result and move next range */
        scintilla_send_message (d->sci, SCI_SETSEL, 
                                ttf.chrgText.cpMin, 
                                ttf.chrgText.cpMax);
        d->search_range.cpMin = ttf.chrgText.cpMax;
    };
    return pos;
}

static void
skip_cb (GtkWidget *widget, ScintillaReplaceDialog *d)
{
    if (search_next (d) < 0)
        gnome_dialog_close (d->ask_dialog);
}

static void
replace_cb (GtkWidget *widget, ScintillaReplaceDialog *d)
{
    scintilla_send_message (d->sci, SCI_REPLACESEL, 0, 
                            (long) gtk_entry_get_text
                            (GTK_ENTRY (d->entry_replace)));
    skip_cb (widget, d);
}

static void
replace_all_cb (GtkWidget *widget, ScintillaReplaceDialog *d)
{
    do {
        scintilla_send_message (d->sci, SCI_REPLACESEL, 0, 
                                (long) gtk_entry_get_text
                                (GTK_ENTRY (d->entry_replace)));
    } while (search_next (d) >= 0);
    gnome_dialog_close (d->ask_dialog);
}

static void
cancel_cb (GtkWidget *widget, ScintillaReplaceDialog *d)
{
    gnome_dialog_close (d->ask_dialog);
}

static GnomeDialog *
ask_dialog_new (ScintillaReplaceDialog *d)
{
    GnomeDialog *dialog;
    GtkWidget *label;

    dialog = GNOME_DIALOG (gnome_dialog_new (_("Replace confirmation"),
                                             _("Replace"), 
                                             _("Replace All"),
                                             _("Skip"),
                                             GNOME_STOCK_BUTTON_CANCEL, 
                                             NULL));
    label = gtk_label_new (_("Found occurrence in document"));
    gtk_box_pack_start (GTK_BOX (dialog->vbox), label, TRUE, TRUE, 0);
    gtk_widget_show (label);

    gnome_dialog_button_connect (dialog, 0, replace_cb, d);
    gnome_dialog_button_connect (dialog, 1, replace_all_cb, d);
    gnome_dialog_button_connect (dialog, 2, skip_cb, d);
    gnome_dialog_button_connect (dialog, 3, cancel_cb, d);
    gnome_dialog_close_hides (dialog, TRUE);

    gnome_dialog_set_default (dialog, 0);

    return dialog;
}


static void
setup_replace (GtkWidget *widget, ScintillaReplaceDialog *d)
{
    if (strlen (gtk_entry_get_text (GTK_ENTRY (d->entry_find))) == 0)
        return;

    if (GTK_TOGGLE_BUTTON (d->selection_only)->active) {
        d->search_range.cpMin = scintilla_send_message 
            (d->sci, SCI_GETSELECTIONSTART, 0, 0);
        d->search_range.cpMax = scintilla_send_message
            (d->sci, SCI_GETSELECTIONEND, 0, 0);
    } else {
        d->search_range.cpMin = scintilla_send_message (d->sci, SCI_GETCURRENTPOS, 
                                                        0, 0);
        d->search_range.cpMax = scintilla_send_message (d->sci, SCI_GETLENGTH, 
                                                        0, 0);
    };

    if (!d->ask_dialog)
        d->ask_dialog = ask_dialog_new (d);

    if (search_next (d) >= 0) {
        gtk_widget_show (GTK_WIDGET (d->ask_dialog));
        gdk_window_raise (GTK_WIDGET (d->ask_dialog)->window);
    };
}


static ScintillaReplaceDialog *
scintilla_replace_dialog_new (ScintillaObject *sci)
{
    GtkWidget *hbox, *label, *table;
    ScintillaReplaceDialog *dialog;
    
    dialog = g_new0 (ScintillaReplaceDialog, 1);

    dialog->sci = sci;

    /* create the dialog */
    dialog->dialog = GNOME_DIALOG 
        (gnome_dialog_new (_("Find and Replace"), 
                           _("Replace"), 
                           GNOME_STOCK_BUTTON_CANCEL, 
                           NULL));

    /* find and replace entries table */
    table = gtk_table_new (2, 2, FALSE);
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), table, FALSE, FALSE, 0);

    label = gtk_label_new (_("Find:"));
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                      (GtkAttachOptions) GTK_FILL, 
                      (GtkAttachOptions) 0, 2, 2);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

    dialog->entry_find = gtk_entry_new_with_max_length (20);
    gtk_table_attach (GTK_TABLE (table), dialog->entry_find, 1, 2, 0, 1,
                      (GtkAttachOptions) GTK_FILL | GTK_EXPAND, 
                      (GtkAttachOptions) 0, 2, 2);

    label = gtk_label_new (_("Replace with:"));
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
                      (GtkAttachOptions) GTK_FILL, 
                      (GtkAttachOptions) 0, 2, 2);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

    dialog->entry_replace = gtk_entry_new_with_max_length (20);
    gtk_table_attach (GTK_TABLE (table), dialog->entry_replace, 1, 2, 1, 2,
                      (GtkAttachOptions) GTK_FILL | GTK_EXPAND, 
                      (GtkAttachOptions) 0, 2, 2);

    /* search options hbox */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), hbox, TRUE, TRUE, 0);

    dialog->case_sensitive = gtk_check_button_new_with_label (_("Case sensitive"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->case_sensitive, FALSE, FALSE, 0);

    dialog->whole_word = gtk_check_button_new_with_label (_("Whole word"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->whole_word, FALSE, FALSE, 0);

    dialog->word_start = gtk_check_button_new_with_label (_("Match word start"));
    gtk_box_pack_start (GTK_BOX (hbox), dialog->word_start, FALSE, FALSE, 0);

    /* selection only checkbox */
    dialog->selection_only = gtk_check_button_new_with_label (_("Selection only"));
    gtk_box_pack_start (GTK_BOX (dialog->dialog->vbox), 
                        dialog->selection_only, TRUE, TRUE, 0);

    gtk_widget_show_all (dialog->dialog->vbox);

    /* set dialog options */
    gnome_dialog_button_connect (dialog->dialog, 0, setup_replace, dialog);
    gnome_dialog_close_hides (dialog->dialog, TRUE);
    gnome_dialog_set_close (dialog->dialog, TRUE);
    gnome_dialog_set_default (dialog->dialog, 0);

    return dialog;
}


void
scintilla_replace_dialog_destroy (ScintillaReplaceDialog *dialog)
{
    if (dialog->ask_dialog)
        gtk_widget_destroy (GTK_WIDGET (dialog->ask_dialog));
    gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
    g_free (dialog);
}


void
run_replace_dialog (ScintillaObject *sci)
{
    ScintillaReplaceDialog *dialog;

    dialog = gtk_object_get_data (GTK_OBJECT (sci), "replace_dialog");
    if (!dialog) {
        dialog = scintilla_replace_dialog_new (sci);
        gtk_object_set_data (GTK_OBJECT (sci), "replace_dialog", dialog);
    };
    
    if (dialog) {
        gtk_widget_show (GTK_WIDGET (dialog->dialog));
        gdk_window_raise (GTK_WIDGET (dialog->dialog)->window);
        gtk_widget_grab_focus (dialog->entry_find);
    };
}



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