[gedit] ViewFrame: remove entry tag after a timeout
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] ViewFrame: remove entry tag after a timeout
- Date: Sun, 6 Oct 2013 15:20:25 +0000 (UTC)
commit 3920479578c97878a64cd0b967e05e73f74601bc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Aug 31 23:28:55 2013 +0200
ViewFrame: remove entry tag after a timeout
It avoids outdated informution during a too long time, and avoids
flashing for small buffers (if the entry tag is removed directly).
gedit/gedit-view-frame.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 95261c5..8d52777 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -69,6 +69,7 @@ struct _GeditViewFramePrivate
guint flush_timeout_id;
guint idle_update_entry_tag_id;
+ guint remove_entry_tag_timeout_id;
gulong view_scroll_event_id;
gulong search_entry_focus_out_id;
gulong search_entry_changed_id;
@@ -115,6 +116,12 @@ gedit_view_frame_dispose (GObject *object)
frame->priv->idle_update_entry_tag_id = 0;
}
+ if (frame->priv->remove_entry_tag_timeout_id != 0)
+ {
+ g_source_remove (frame->priv->remove_entry_tag_timeout_id);
+ frame->priv->remove_entry_tag_timeout_id = 0;
+ }
+
g_clear_object (&frame->priv->entry_tag);
g_clear_object (&frame->priv->search_settings);
g_clear_object (&frame->priv->old_search_settings);
@@ -610,6 +617,17 @@ search_widget_key_press_event (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
+static gboolean
+remove_entry_tag_timeout_cb (GeditViewFrame *frame)
+{
+ frame->priv->remove_entry_tag_timeout_id = 0;
+
+ gd_tagged_entry_remove_tag (frame->priv->search_entry,
+ frame->priv->entry_tag);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
update_entry_tag (GeditViewFrame *frame)
{
@@ -646,7 +664,22 @@ update_entry_tag (GeditViewFrame *frame)
if (count == -1 || pos == -1)
{
- /* Wait that the buffer is fully scanned. */
+ /* The buffer is not fully scanned. Remove the tag after a short
+ * delay. If we don't remove the tag at all, the information can
+ * be outdated during a too long time (for big buffers). And if
+ * the tag is removed directly, there is some flashing for small
+ * buffers: the tag disappears and reappear after a really short
+ * time.
+ */
+
+ if (frame->priv->remove_entry_tag_timeout_id == 0)
+ {
+ frame->priv->remove_entry_tag_timeout_id =
+ g_timeout_add (500,
+ (GSourceFunc)remove_entry_tag_timeout_cb,
+ frame);
+ }
+
return;
}
@@ -657,6 +690,12 @@ update_entry_tag (GeditViewFrame *frame)
return;
}
+ if (frame->priv->remove_entry_tag_timeout_id != 0)
+ {
+ g_source_remove (frame->priv->remove_entry_tag_timeout_id);
+ frame->priv->remove_entry_tag_timeout_id = 0;
+ }
+
/* Translators: the first %d is the position of the current search
* occurrence, and the second %d is the total number of search
* occurrences.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]