[gedit/wip/use-tagged-entry] ViewFrame: fix issue with the search entry tag
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/use-tagged-entry] ViewFrame: fix issue with the search entry tag
- Date: Sat, 13 Jul 2013 18:06:47 +0000 (UTC)
commit 81dc17ad657bea2ec4b65d8a7108a71fcea43eaa
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jul 13 19:47:59 2013 +0200
ViewFrame: fix issue with the search entry tag
Update the entry tag less often, so the tag doesn't resize all the time
the search entry.
gedit/gedit-view-frame.c | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 1775062..f57eff2 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -540,13 +540,14 @@ update_entry_tag (GeditViewFrame *frame)
GtkTextBuffer *buffer;
GtkTextIter select_start;
GtkTextIter select_end;
- guint count;
+ gint count;
gint pos;
-
- gd_tagged_entry_remove_tag (frame->priv->search_entry, "search-occurrences");
+ gchar *label;
+ gboolean ok;
if (frame->priv->search_mode == GOTO_LINE)
{
+ gd_tagged_entry_remove_tag (frame->priv->search_entry, "search-occurrences");
return;
}
@@ -560,21 +561,37 @@ update_entry_tag (GeditViewFrame *frame)
&select_start,
&select_end);
- if (pos > 0)
+ if (count == -1 || pos == -1)
{
- /* Translators: %d is the position of the current search occurrence,
- * and %u is the total number of search occurrences.
- */
- gchar *label = g_strdup_printf (_("%d of %u"), pos, count);
+ return;
+ }
+
+ if (count == 0 || pos == 0)
+ {
+ gd_tagged_entry_remove_tag (frame->priv->search_entry, "search-occurrences");
+ return;
+ }
+ /* Translators: the first %d is the position of the current search
+ * occurrence, and the second %d is the total number of search
+ * occurrences.
+ */
+ label = g_strdup_printf (_("%d of %d"), pos, count);
+
+ ok = gd_tagged_entry_set_tag_label (frame->priv->search_entry,
+ "search-occurrences",
+ label);
+
+ if (!ok)
+ {
gd_tagged_entry_append_tag_styled (frame->priv->search_entry,
"search-occurrences",
label,
"gedit-search-entry-occurrences-tag",
FALSE);
-
- g_free (label);
}
+
+ g_free (label);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]