SF.net SVN: geany: [2199] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Jan 29 16:34:16 UTC 2008


Revision: 2199
          http://geany.svn.sourceforge.net/geany/?rev=2199&view=rev
Author:   ntrel
Date:     2008-01-29 08:34:16 -0800 (Tue, 29 Jan 2008)

Log Message:
-----------
Factor out get_search_flags() from Find, Replace dialog response
code.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/search.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-01-29 16:11:18 UTC (rev 2198)
+++ trunk/ChangeLog	2008-01-29 16:34:16 UTC (rev 2199)
@@ -5,6 +5,9 @@
    in case.
  * src/keybindings.c, src/keybindings.h:
    Rename binding type KeyBinding.
+ * src/search.c:
+   Factor out get_search_flags() from Find, Replace dialog response
+   code.
 
 
 2008-01-28  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2008-01-29 16:11:18 UTC (rev 2198)
+++ trunk/src/search.c	2008-01-29 16:34:16 UTC (rev 2199)
@@ -788,6 +788,26 @@
 }
 
 
+static gint get_search_flags(GtkWidget *dialog)
+{
+	gboolean fl1, fl2, fl3, fl4;
+
+	fl1 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+				lookup_widget(dialog, "check_case")));
+	fl2 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+				lookup_widget(dialog, "check_word")));
+	fl3 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+				lookup_widget(dialog, "check_regexp")));
+	fl4 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+				lookup_widget(dialog, "check_wordstart")));
+
+	return (fl1 ? SCFIND_MATCHCASE : 0) |
+		(fl2 ? SCFIND_WHOLEWORD : 0) |
+		(fl3 ? SCFIND_REGEXP | SCFIND_POSIX : 0) |
+		(fl4 ? SCFIND_WORDSTART : 0);
+}
+
+
 static void
 on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
 {
@@ -797,17 +817,9 @@
 	{
 		gint idx = document_get_cur_idx();
 		gboolean search_replace_escape;
-		gboolean
-			fl1 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_case"))),
-			fl2 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_word"))),
-			fl3 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_regexp"))),
-			fl4 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_wordstart"))),
-			check_close = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+		gboolean check_close = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_close")));
+
 		search_replace_escape = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 						lookup_widget(GTK_WIDGET(widgets.find_dialog), "check_escape")));
 		search_data.backwards = FALSE;
@@ -826,11 +838,9 @@
 		}
 
 		ui_combo_box_add_to_history(GTK_COMBO_BOX(user_data), search_data.text);
-		search_data.flags = (fl1 ? SCFIND_MATCHCASE : 0) |
-				(fl2 ? SCFIND_WHOLEWORD : 0) |
-				(fl3 ? SCFIND_REGEXP | SCFIND_POSIX: 0) |
-				(fl4 ? SCFIND_WORDSTART : 0);
 
+		search_data.flags = get_search_flags(widgets.find_dialog);
+
 		switch (response)
 		{
 			case GEANY_RESPONSE_FIND:
@@ -884,7 +894,6 @@
 	GtkWidget *entry_replace = lookup_widget(GTK_WIDGET(widgets.replace_dialog), "entry_replace");
 	gint search_flags_re;
 	gboolean search_backwards_re, search_replace_escape_re;
-	gboolean fl1, fl2, fl3, fl4;
 	gboolean close_window;
 	gchar *find, *replace;
 
@@ -894,14 +903,6 @@
 		return;
 	}
 
-	fl1 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-				lookup_widget(GTK_WIDGET(widgets.replace_dialog), "check_case")));
-	fl2 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-				lookup_widget(GTK_WIDGET(widgets.replace_dialog), "check_word")));
-	fl3 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-				lookup_widget(GTK_WIDGET(widgets.replace_dialog), "check_regexp")));
-	fl4 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
-				lookup_widget(GTK_WIDGET(widgets.replace_dialog), "check_wordstart")));
 	close_window = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 				lookup_widget(GTK_WIDGET(widgets.replace_dialog), "check_close")));
 	search_backwards_re = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
@@ -911,7 +912,10 @@
 	find = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_find)))));
 	replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_replace)))));
 
-	if ((response != GEANY_RESPONSE_FIND) && fl1 && (strcmp(find, replace) == 0))
+	search_flags_re = get_search_flags(widgets.replace_dialog);
+
+	if ((response != GEANY_RESPONSE_FIND) && (search_flags_re & SCFIND_MATCHCASE)
+		&& (strcmp(find, replace) == 0))
 	{
 		utils_beep();
 		gtk_widget_grab_focus(GTK_WIDGET(GTK_BIN(lookup_widget(widgets.replace_dialog, "entry_find"))->child));
@@ -929,11 +933,6 @@
 		return;
 	}
 
-	search_flags_re = (fl1 ? SCFIND_MATCHCASE : 0) |
-					  (fl2 ? SCFIND_WHOLEWORD : 0) |
-					  (fl3 ? SCFIND_REGEXP | SCFIND_POSIX : 0) |
-					  (fl4 ? SCFIND_WORDSTART : 0);
-
 	switch (response)
 	{
 		case GEANY_RESPONSE_REPLACE_AND_FIND:


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list