[gedit] Remove the use of "Phrase" when searching.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: svn-commits-list gnome org
- Subject: [gedit] Remove the use of "Phrase" when searching.
- Date: Sat, 6 Jun 2009 10:01:39 -0400 (EDT)
commit 8ef1dfdc39c152b6bdc106c533c8c2e4d297e775
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Jun 6 15:59:10 2009 +0200
Remove the use of "Phrase" when searching.
Remove the word "Phrase" and use "%s" instead to visualized what it was searched. (Fixes bug #572901).
---
gedit/gedit-commands-search.c | 23 +++++++++++++-------
gedit/gedit-utils.c | 45 +++++++++++++++++++++++++++++++---------
gedit/gedit-utils.h | 6 ++--
3 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/gedit/gedit-commands-search.c b/gedit/gedit-commands-search.c
index 20f4e73..d37fd8a 100644
--- a/gedit/gedit-commands-search.c
+++ b/gedit/gedit-commands-search.c
@@ -155,8 +155,8 @@ restore_last_searched_data (GeditSearchDialog *dialog,
/* Use occurences only for Replace All */
static void
-phrase_found (GeditWindow *window,
- gint occurrences)
+text_found (GeditWindow *window,
+ gint occurrences)
{
if (occurrences > 1)
{
@@ -180,12 +180,19 @@ phrase_found (GeditWindow *window,
}
}
+#define MAX_MSG_LENGTH 40
static void
-phrase_not_found (GeditWindow *window)
+text_not_found (GeditWindow *window,
+ const gchar *text)
{
+ gchar *searched;
+
+ searched = gedit_utils_str_end_truncate (text, MAX_MSG_LENGTH);
+
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
- _("Phrase not found"));
+ _("\"%s\" not found"), searched);
+ g_free (searched);
}
static gboolean
@@ -312,9 +319,9 @@ do_find (GeditSearchDialog *dialog,
search_backwards);
if (found)
- phrase_found (window, 0);
+ text_found (window, 0);
else
- phrase_not_found (window);
+ text_not_found (window, entry_text);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
@@ -464,11 +471,11 @@ do_replace_all (GeditSearchDialog *dialog,
if (count > 0)
{
- phrase_found (window, count);
+ text_found (window, count);
}
else
{
- phrase_not_found (window);
+ text_not_found (window, search_entry_text);
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index 2e54bd5..3708f93 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -567,9 +567,10 @@ gedit_utils_escape_underscores (const gchar* text,
/* the following functions are taken from eel */
-gchar *
-gedit_utils_str_middle_truncate (const gchar *string,
- guint truncate_length)
+static gchar *
+gedit_utils_str_truncate (const gchar *string,
+ guint truncate_length,
+ gboolean middle)
{
GString *truncated;
guint length;
@@ -602,18 +603,42 @@ gedit_utils_str_middle_truncate (const gchar *string,
}
/* Find the 'middle' where the truncation will occur. */
- num_left_chars = (truncate_length - delimiter_length) / 2;
- right_offset = n_chars - truncate_length + num_left_chars + delimiter_length;
+ if (middle)
+ {
+ num_left_chars = (truncate_length - delimiter_length) / 2;
+ right_offset = n_chars - truncate_length + num_left_chars + delimiter_length;
- truncated = g_string_new_len (string,
- g_utf8_offset_to_pointer (string, num_left_chars) - string);
- g_string_append (truncated, delimiter);
- g_string_append (truncated, g_utf8_offset_to_pointer (string, right_offset));
-
+ truncated = g_string_new_len (string,
+ g_utf8_offset_to_pointer (string, num_left_chars) - string);
+ g_string_append (truncated, delimiter);
+ g_string_append (truncated, g_utf8_offset_to_pointer (string, right_offset));
+ }
+ else
+ {
+ num_left_chars = truncate_length - delimiter_length;
+ truncated = g_string_new_len (string,
+ g_utf8_offset_to_pointer (string, num_left_chars) - string);
+ g_string_append (truncated, delimiter);
+ }
+
return g_string_free (truncated, FALSE);
}
gchar *
+gedit_utils_str_middle_truncate (const gchar *string,
+ guint truncate_length)
+{
+ return gedit_utils_str_truncate (string, truncate_length, TRUE);
+}
+
+gchar *
+gedit_utils_str_end_truncate (const gchar *string,
+ guint truncate_length)
+{
+ return gedit_utils_str_truncate (string, truncate_length, FALSE);
+}
+
+gchar *
gedit_utils_make_valid_utf8 (const char *name)
{
GString *string;
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index e16c49b..ddf1d9c 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -80,6 +80,9 @@ gchar *gedit_utils_escape_underscores (const gchar *text,
gchar *gedit_utils_str_middle_truncate (const gchar *string,
guint truncate_length);
+gchar *gedit_utils_str_end_truncate (const gchar *string,
+ guint truncate_length);
+
gboolean g_utf8_caselessnmatch (const char *s1,
const char *s2,
gssize n1,
@@ -103,9 +106,6 @@ void gedit_warning (GtkWindow *parent,
const gchar *format,
...) G_GNUC_PRINTF(2, 3);
-gchar *gedit_utils_str_middle_truncate (const char *string,
- guint truncate_length);
-
gchar *gedit_utils_make_valid_utf8 (const char *name);
/* Note that this function replace home dir with ~ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]