SF.net SVN: geany:[4491] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Dec 9 17:31:56 UTC 2009


Revision: 4491
          http://geany.svn.sourceforge.net/geany/?rev=4491&view=rev
Author:   ntrel
Date:     2009-12-09 17:31:56 +0000 (Wed, 09 Dec 2009)

Log Message:
-----------
Refactor/reformat on_replace_dialog_response().

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-12-09 17:16:54 UTC (rev 4490)
+++ trunk/ChangeLog	2009-12-09 17:31:56 UTC (rev 4491)
@@ -13,6 +13,8 @@
  * src/interface.c, src/keybindings.c, geany.glade:
    Capitalize, add mnemonics, sync with kb.c the Edit->Commands menu item
    labels.
+ * src/search.c:
+   Refactor/reformat on_replace_dialog_response().
 
 
 2009-12-08  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2009-12-09 17:16:54 UTC (rev 4490)
+++ trunk/src/search.c	2009-12-09 17:31:56 UTC (rev 4491)
@@ -1104,6 +1104,34 @@
 }
 
 
+static void replace_in_session(GeanyDocument *doc,
+		gint search_flags_re, gboolean search_replace_escape_re,
+		const gchar *find, const gchar *replace)
+{
+	guint n, page_count, count = 0;
+
+	/* replace in all documents following notebook tab order */
+	page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+	for (n = 0; n < page_count; n++)
+	{
+		GeanyDocument *tmp_doc = document_get_from_page(n);
+
+		if (document_replace_all(tmp_doc, find, replace, search_flags_re,
+			search_replace_escape_re)) count++;
+	}
+	if (count == 0)
+		utils_beep();
+
+	ui_set_statusbar(FALSE,
+		ngettext("Replaced text in %u file.",
+				 "Replaced text in %u files.", count), count);
+	/* show which docs had replacements: */
+	gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS);
+
+	ui_save_buttons_toggle(doc->changed);	/* update save all */
+}
+
+
 static void
 on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
 {
@@ -1163,11 +1191,10 @@
 			break;
 		}
 		case GEANY_RESPONSE_REPLACE:
-		{
 			document_replace_text(doc, find, replace, search_flags_re,
 				search_backwards_re);
 			break;
-		}
+
 		case GEANY_RESPONSE_FIND:
 		{
 			gint result = document_find_text(doc, find, search_flags_re,
@@ -1176,44 +1203,18 @@
 			break;
 		}
 		case GEANY_RESPONSE_REPLACE_IN_FILE:
-		{
 			if (! document_replace_all(doc, find, replace, search_flags_re,
 				search_replace_escape_re))
-			{
 				utils_beep();
-			}
 			break;
-		}
+
 		case GEANY_RESPONSE_REPLACE_IN_SESSION:
-		{
-			guint n, page_count, count = 0;
+			replace_in_session(doc, search_flags_re, search_replace_escape_re, find, replace);
+			break;
 
-			/* replace in all documents following notebook tab order */
-			page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
-			for (n = 0; n < page_count; n++)
-			{
-				GeanyDocument *tmp_doc = document_get_from_page(n);
-
-				if (document_replace_all(tmp_doc, find, replace, search_flags_re,
-					search_replace_escape_re)) count++;
-			}
-			if (count == 0)
-				utils_beep();
-
-			ui_set_statusbar(FALSE,
-				ngettext("Replaced text in %u file.",
-						 "Replaced text in %u files.", count), count);
-			/* show which docs had replacements: */
-			gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS);
-
-			ui_save_buttons_toggle(doc->changed);	/* update save all */
-			break;
-		}
 		case GEANY_RESPONSE_REPLACE_IN_SEL:
-		{
 			document_replace_sel(doc, find, replace, search_flags_re, search_replace_escape_re);
 			break;
-		}
 	}
 	switch (response)
 	{


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