|
Thank you all. Please check if this one is what we want. This time, I grayed out the button while nothing found. Not Zed wrote: grey out, yeah, something like that. *shrug* On Fri, 2003-10-24 at 22:11, Charles Zhang wrote: |
Index: components/html-editor/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/ChangeLog,v
retrieving revision 1.410.2.10
diff -u -p -r1.410.2.10 ChangeLog
--- components/html-editor/ChangeLog 14 Oct 2003 13:43:31 -0000 1.410.2.10
+++ components/html-editor/ChangeLog 28 Oct 2003 15:53:33 -0000
@@ -0,0 +0,12 @@
+2003-10-27 Charles Zhang <charles zhang sun com>
+
+ * search.c (search_dialog_response): if found nothing, disable
+ the find button, and leave the searchdialog visible, else destroy
+ the search dialog. Handle GTK_RESPONSE_CLOSE to make close button
+ looks fine.
+ (search): if the searchdialog isn't visible, then destroy it.
+ (condition_changed): enable the find button.
+ (entry_changed): when entry changed, enable the find button.
+ (gtk_html_search_dialog_new): connect toggled signal to checkbutton.
+ [49702]
+
2003-10-13 Frederic Crozat <fcrozat mandrakesoft com>
* popup.c: Add missing header include.
Index: components/html-editor/search.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/search.c,v
retrieving revision 1.22
diff -u -p -r1.22 search.c
--- components/html-editor/search.c 12 May 2003 20:46:48 -0000 1.22
+++ components/html-editor/search.c 28 Oct 2003 15:53:34 -0000
@@ -39,11 +39,18 @@ struct _GtkHTMLSearchDialog {
};
static void
+condition_changed (GtkWidget *widget, GtkHTMLSearchDialog *d)
+{
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (d->dialog), 0, TRUE);
+}
+
+static void
entry_changed (GtkWidget *entry, GtkHTMLSearchDialog *d)
{
if (d->cd->search_text)
g_free (d->cd->search_text);
d->cd->search_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (d->entry)));
+ condition_changed (entry, d);
}
static void
@@ -55,12 +62,21 @@ entry_activate (GtkWidget *entry, GtkHTM
static void
search_dialog_response (GtkDialog *dialog, gint response_id, GtkHTMLSearchDialog *d)
{
+ gboolean found = FALSE;
+
switch (response_id) {
case 0: /* Search */
+ found = html_engine_search (d->html->engine, gtk_entry_get_text (GTK_ENTRY (d->entry)),
+ GTK_TOGGLE_BUTTON (d->case_sensitive)->active,
+ GTK_TOGGLE_BUTTON (d->backward)->active == 0, d->cd->regular);
+ if (!found) {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (d->dialog), 0, FALSE);
+ break;
+ }
+
+ case GTK_RESPONSE_CLOSE:
gtk_widget_hide (GTK_WIDGET (d->dialog));
- html_engine_search (d->html->engine, gtk_entry_get_text (GTK_ENTRY (d->entry)),
- GTK_TOGGLE_BUTTON (d->case_sensitive)->active,
- GTK_TOGGLE_BUTTON (d->backward)->active == 0, d->cd->regular);
+ gtk_html_search_dialog_destroy (d);
break;
}
}
@@ -108,6 +124,8 @@ gtk_html_search_dialog_new (GtkHTML *htm
g_signal_connect (dialog->dialog, "response", G_CALLBACK (search_dialog_response), dialog);
g_signal_connect (dialog->entry, "changed", G_CALLBACK (entry_changed), dialog);
g_signal_connect (dialog->entry, "activate", G_CALLBACK (entry_activate), dialog);
+ g_signal_connect (dialog->backward, "toggled", G_CALLBACK (condition_changed), dialog);
+ g_signal_connect (dialog->case_sensitive, "toggled", G_CALLBACK (condition_changed), dialog);
return dialog;
}
@@ -124,7 +142,6 @@ search (GtkHTMLControlData *cd, gboolean
{
cd->regular = regular;
RUN_DIALOG (search, regular ? _("Find Regular Expression") : _("Find"));
- gtk_html_search_dialog_destroy (cd->search_dialog);
cd->search_dialog = NULL;
}