On Tue, 8 Mar 2011 20:22:19 +0100
Enrico Tröger <enrico.troe...@uvena.de> wrote:

> On Sun, 6 Mar 2011 18:12:25 +0200, Dimitar wrote:
> 
> >On Sun, 6 Mar 2011 15:53:48 +0100
> >Enrico Tröger <enrico.troe...@uvena.de> wrote:
> >
> >> Anyway, your patch is committed, thanks a bunch.
> >> 
> >> I added another small change afterwards which should remain the saved
> >> state for 'case sensitive' even if regex is checked. Hope that won't
> >> break anything.
> >
> >Well, it does; the initial stash group display is a bit tricky: [...]
> >
> >Your patch ignores this exact signal, so the first-regexp-uncheck-
> >after-restart clears the case instead of leaving it as-is [...]
> 
> Yeah. But why should it be left as-is?

Saa... OTOH, why should it be cleared? I realize now that it was my
mistake not to follow the Geany logic exactly, no matter how much sense
it makes to me.

> This leads again to the question why these two options are bound
> together so closely. I still don't have an answer, to be honest.

Well until then, and since there already is a VISIBLE(dialog) check, and
since it's just a few lines, here is a patch that implements the
previous case state to the letter, against the current svn.

-- 
E-gards: Jimmy
--- ./src/search.c.orig	2011-03-06 17:29:55.000000000 +0200
+++ ./src/search.c	2011-03-09 19:50:00.000000000 +0200
@@ -103,6 +103,7 @@
 	gboolean replace_match_word_start;
 	gboolean replace_search_backwards;
 	gboolean replace_close_dialog;
+	gboolean fire_saved_case_state[2];	/* FALSE = find state, TRUE = replace state */
 }
 settings;
 
@@ -218,11 +219,12 @@
 	group = stash_group_new("search");
 	find_prefs = group;
 	configuration_add_pref_group(group, FALSE);
-	/* if case is moved after regexp, the first regexp uncheck will clear it */
-	stash_group_add_toggle_button(group, &settings.find_case_sensitive,
-		"find_case_sensitive", FALSE, "check_case");
 	stash_group_add_toggle_button(group, &settings.find_regexp,
 		"find_regexp", FALSE, "check_regexp");
+	stash_group_add_toggle_button(group, &settings.find_case_sensitive,
+		"find_case_sensitive", FALSE, "check_case");
+	stash_group_add_boolean(group, &settings.fire_saved_case_state[FALSE],
+		"find_case_saved_state", FALSE);
 	stash_group_add_toggle_button(group, &settings.find_escape_sequences,
 		"find_escape_sequences", FALSE, "check_escape");
 	stash_group_add_toggle_button(group, &settings.find_match_whole_word,
@@ -235,10 +237,12 @@
 	group = stash_group_new("search");
 	replace_prefs = group;
 	configuration_add_pref_group(group, FALSE);
-	stash_group_add_toggle_button(group, &settings.replace_case_sensitive,
-		"replace_case_sensitive", FALSE, "check_case");
 	stash_group_add_toggle_button(group, &settings.replace_regexp,
 		"replace_regexp", FALSE, "check_regexp");
+	stash_group_add_toggle_button(group, &settings.replace_case_sensitive,
+		"replace_case_sensitive", FALSE, "check_case");
+	stash_group_add_boolean(group, &settings.fire_saved_case_state[TRUE],
+		"replace_case_saved_state", FALSE);
 	stash_group_add_toggle_button(group, &settings.replace_escape_sequences,
 		"replace_escape_sequences", FALSE, "check_escape");
 	stash_group_add_toggle_button(group, &settings.replace_match_whole_word,
@@ -1039,7 +1043,6 @@
 		GtkWidget *check_escape = ui_lookup_widget(dialog, "check_escape");
 		gboolean replace = (dialog != find_dlg.dialog);
 		const char *back_button[2] = { "btn_previous" , "check_back" };
-		static gboolean case_state[2] = { FALSE, FALSE }; /* state before regex enabled */
 
 		/* hide options that don't apply to regex searches */
 		gtk_widget_set_sensitive(check_escape, ! regex_set);
@@ -1052,7 +1055,7 @@
 			if (GTK_WIDGET_VISIBLE(dialog))
 			{
 				/* Enable case sensitive but remember original case toggle state */
-				case_state[replace] = gtk_toggle_button_get_active(check_case);
+				settings.fire_saved_case_state[replace] = gtk_toggle_button_get_active(check_case);
 				gtk_toggle_button_set_active(check_case, TRUE);
 			}
 		}
@@ -1060,7 +1063,7 @@
 		{
 			/* If case sensitive is still enabled, revert to what it was before we enabled it */
 			if (gtk_toggle_button_get_active(check_case) == TRUE)
-				gtk_toggle_button_set_active(check_case, case_state[replace]);
+				gtk_toggle_button_set_active(check_case, settings.fire_saved_case_state[replace]);
 		}
 	}
 }
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to