SF.net SVN: geany: [783] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Sep 2 23:28:43 UTC 2006


Revision: 783
          http://svn.sourceforge.net/geany/?rev=783&view=rev
Author:   eht16
Date:     2006-09-02 16:28:34 -0700 (Sat, 02 Sep 2006)

Log Message:
-----------
Escape special characters when shown in the status window after "Replace All" or replacing a selection.
Set the focus to the replace entry widget when pressing the tabulator key in the find entry widget in the replace dialog.
Set the focus to the find entry widget when pressing the tabulator key in the directory entry widget in the FIF dialog.

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-09-02 21:04:47 UTC (rev 782)
+++ trunk/ChangeLog	2006-09-02 23:28:34 UTC (rev 783)
@@ -1,3 +1,14 @@
+2006-09-02  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/document.c, src/search.c:
+   Escape special characters when shown in the status window after
+   "Replace All" or replacing a selection.
+   Set the focus to the replace entry widget when pressing the
+   tabulator key in the find entry widget in the replace dialog.
+   Set the focus to the find entry widget when pressing the tabulator
+   key in the directory entry widget in the FIF dialog.
+
+
 2006-09-02  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/utils.c, src/sci_cb.c, src/main.c:

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-09-02 21:04:47 UTC (rev 782)
+++ trunk/src/document.c	2006-09-02 23:28:34 UTC (rev 783)
@@ -62,7 +62,7 @@
 /* Returns -1 if no text found or the new range endpoint after replacing. */
 static gint
 document_replace_range(gint idx, const gchar *find_text, const gchar *replace_text,
-	gint flags, gint start, gint end);
+	gint flags, gint start, gint end, gboolean escaped_chars);
 
 
 /* returns the index of the notebook page which has the given filename
@@ -943,12 +943,13 @@
 /* Returns -1 if no text found or the new range endpoint after replacing. */
 static gint
 document_replace_range(gint idx, const gchar *find_text, const gchar *replace_text,
-	gint flags, gint start, gint end)
+	gint flags, gint start, gint end, gboolean escaped_chars)
 {
 	gint search_pos;
 	gint count = 0;
 	gint find_len = 0, replace_len = 0;
 	gboolean match_found = FALSE;
+	gchar *escaped_find_text, *escaped_replace_text;
 	struct TextToFind ttf;
 
 	g_return_val_if_fail(find_text != NULL && replace_text != NULL, FALSE);
@@ -981,9 +982,23 @@
 		}
 	}
 	sci_end_undo_action(doc_list[idx].sci);
-	msgwin_status_add(_("Replaced %d occurrences of \"%s\" with \"%s\"."),
-						count, find_text, replace_text);
 
+	if (escaped_chars)
+	{	// escape special characters for showing
+		escaped_find_text = g_strescape(find_text, NULL);
+		escaped_replace_text = g_strescape(replace_text, NULL);
+		msgwin_status_add(_("Replaced %d occurrences of \"%s\" with \"%s\"."),
+							count, escaped_find_text, escaped_replace_text);
+		g_free(escaped_find_text);
+		g_free(escaped_replace_text);
+	}
+	else
+	{
+		msgwin_status_add(_("Replaced %d occurrences of \"%s\" with \"%s\"."),
+							count, find_text, replace_text);
+	}
+
+
 	if (match_found)
 	{
 		// scroll last match in view.
@@ -995,7 +1010,8 @@
 }
 
 
-void document_replace_sel(gint idx, const gchar *find_text, const gchar *replace_text, gint flags)
+void document_replace_sel(gint idx, const gchar *find_text, const gchar *replace_text, gint flags,
+						  gboolean escaped_chars)
 {
 	gint selection_end, selection_start;
 
@@ -1011,7 +1027,7 @@
 	}
 
 	selection_end = document_replace_range(idx, find_text, replace_text, flags,
-		selection_start, selection_end);
+		selection_start, selection_end, escaped_chars);
 	if (selection_end == -1)
 		utils_beep();
 	else
@@ -1024,14 +1040,14 @@
 
 
 void document_replace_all(gint idx, const gchar *find_text, const gchar *replace_text,
-	gint flags)
+						  gint flags, gboolean escaped_chars)
 {
 	gint len;
 	g_return_if_fail(find_text != NULL && replace_text != NULL);
 	if (idx == -1 || ! *find_text) return;
 
 	len = sci_get_length(doc_list[idx].sci);
-	if (document_replace_range(idx, find_text, replace_text, flags, 0, len) == -1)
+	if (document_replace_range(idx, find_text, replace_text, flags, 0, len, escaped_chars) == -1)
 		utils_beep();
 }
 

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2006-09-02 21:04:47 UTC (rev 782)
+++ trunk/src/document.h	2006-09-02 23:28:34 UTC (rev 783)
@@ -150,9 +150,9 @@
 
 void document_replace_text(gint, const gchar*, const gchar*, gint, gboolean);
 
-void document_replace_all(gint, const gchar*, const gchar*, gint);
+void document_replace_all(gint, const gchar*, const gchar*, gint, gboolean);
 
-void document_replace_sel(gint, const gchar*, const gchar*, gint);
+void document_replace_sel(gint, const gchar*, const gchar*, gint, gboolean);
 
 void document_set_font(gint, const gchar*, gint);
 

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2006-09-02 21:04:47 UTC (rev 782)
+++ trunk/src/search.c	2006-09-02 23:28:34 UTC (rev 783)
@@ -21,6 +21,8 @@
  * $Id$
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include "geany.h"
 #include "search.h"
 #include "support.h"
@@ -84,6 +86,9 @@
 static void
 on_replace_entry_activate(GtkEntry *entry, gpointer user_data);
 
+static gboolean
+on_combo_entry_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+
 static void
 on_find_in_files_dialog_response(GtkDialog *dialog, gint response, gpointer user_data);
 
@@ -299,6 +304,8 @@
 		g_object_set_data_full(G_OBJECT(widgets.replace_dialog), "entry_replace",
 						gtk_widget_ref(entry_replace), (GDestroyNotify)gtk_widget_unref);
 
+		g_signal_connect((gpointer) gtk_bin_get_child(GTK_BIN(entry_find)), "key-press-event",
+				G_CALLBACK(on_combo_entry_key_pressed), gtk_bin_get_child(GTK_BIN(entry_replace)));
 		g_signal_connect((gpointer) gtk_bin_get_child(GTK_BIN(entry_replace)), "activate",
 				G_CALLBACK(on_replace_entry_activate), NULL);
 		g_signal_connect((gpointer) widgets.replace_dialog, "response",
@@ -453,6 +460,8 @@
 		gtk_container_add(GTK_CONTAINER(cbox), checkbox2);
 		gtk_container_add(GTK_CONTAINER(cbox), checkbox3);
 
+		g_signal_connect((gpointer) entry1, "key-press-event",
+				G_CALLBACK(on_combo_entry_key_pressed), gtk_bin_get_child(GTK_BIN(combo)));
 		g_signal_connect((gpointer) widgets.find_in_files_dialog, "response",
 				G_CALLBACK(on_find_in_files_dialog_response), combo);
 		g_signal_connect((gpointer) widgets.find_in_files_dialog, "delete_event",
@@ -677,7 +686,7 @@
 		{
 			if (! doc_list[i].is_valid) continue;
 
-			document_replace_all(i, find, replace, search_flags_re);
+			document_replace_all(i, find, replace, search_flags_re, search_replace_escape_re);
 		}
 		if (close_window) gtk_widget_hide(widgets.replace_dialog);
 	}
@@ -698,13 +707,13 @@
 			}
 			case GEANY_RESPONSE_REPLACE_ALL:
 			{
-				document_replace_all(idx, find, replace, search_flags_re);
+				document_replace_all(idx, find, replace, search_flags_re, search_replace_escape_re);
 				if (close_window) gtk_widget_hide(widgets.replace_dialog);
 				break;
 			}
 			case GEANY_RESPONSE_REPLACE_SEL:
 			{
-				document_replace_sel(idx, find, replace, search_flags_re);
+				document_replace_sel(idx, find, replace, search_flags_re, search_replace_escape_re);
 				if (close_window) gtk_widget_hide(widgets.replace_dialog);
 				break;
 			}
@@ -722,6 +731,20 @@
 }
 
 
+static gboolean
+on_combo_entry_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+	// catch tabulator key to set the focus in the replace entry instead of
+	// setting it to the combo box
+	if (event->keyval == GDK_Tab)
+	{
+		gtk_widget_grab_focus(GTK_WIDGET(user_data));
+		return TRUE;
+	}
+	return FALSE;
+}
+
+
 static void
 on_find_in_files_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
 {


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