--- mousepad-0.2.16/src/search.c.orig 2011-06-08 17:58:44.095184600 -0400
+++ mousepad-0.2.16/src/search.c 2011-06-09 00:26:05.511231000 -0400
@@ -78,7 +78,7 @@
static gint document_replace_real(StructData *sd)
{
GtkTextIter iter, match_start, match_end;
- GtkTextMark *mark_init = NULL;
+ GtkTextMark *mark_init = NULL, *mark_start, *mark_end;
gboolean res;
gint num = 0;
GtkWidget *q_dialog = NULL;
@@ -113,6 +113,11 @@
if (num == 0 && q_dialog == NULL)
q_dialog = create_dialog_message_question(
gtk_widget_get_toplevel(sd->mainwin->textview), _("Replace?"));
+
+ gtk_text_buffer_get_selection_bounds(textbuffer, &match_start, &match_end);
+ mark_start = gtk_text_buffer_create_mark(textbuffer, NULL, &match_start, FALSE);
+ mark_end = gtk_text_buffer_create_mark(textbuffer, NULL, &match_end, FALSE);
+
switch (gtk_dialog_run(GTK_DIALOG(q_dialog))) {
case GTK_RESPONSE_CANCEL:
res = 0;
@@ -122,6 +127,11 @@
case GTK_RESPONSE_NO:
continue;
}
+
+ gtk_text_buffer_get_iter_at_mark(textbuffer, &match_start, mark_start);
+ gtk_text_buffer_get_iter_at_mark(textbuffer, &match_end, mark_end);
+ gtk_text_buffer_move_mark_by_name(textbuffer, "selection_bound", &match_start);
+ gtk_text_buffer_move_mark_by_name(textbuffer, "insert", &match_end);
}
gtk_text_buffer_delete_selection(textbuffer, TRUE, TRUE);
undo_set_sequency(TRUE);
@@ -210,8 +220,11 @@
G_CALLBACK(toggle_sensitivity), NULL);
g_signal_connect(G_OBJECT(entry_find), "delete-text",
G_CALLBACK(toggle_sensitivity), NULL);
- if (sd->search.string_find)
+ if (sd->search.string_find) {
gtk_entry_set_text(GTK_ENTRY(entry_find), sd->search.string_find);
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
+ GTK_RESPONSE_OK, TRUE);
+ }
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE);
@@ -275,8 +288,11 @@
G_CALLBACK(toggle_sensitivity), NULL);
g_signal_connect(G_OBJECT(entry_find), "delete-text",
G_CALLBACK(toggle_sensitivity), NULL);
- if (sd->search.string_find)
+ if (sd->search.string_find) {
gtk_entry_set_text(GTK_ENTRY(entry_find), sd->search.string_find);
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
+ GTK_RESPONSE_OK, TRUE);
+ }
label_replace = gtk_label_new_with_mnemonic(_("Re_place with: "));
gtk_misc_set_alignment(GTK_MISC(label_replace), 0, 0.5);
gtk_table_attach_defaults(GTK_TABLE(table), label_replace, 0, 1, 1, 2);
@@ -371,3 +387,6 @@
gtk_widget_destroy (dialog);
}
+
+
+