[gtksourceview/wip/search] test-search-ui: update label in an idle
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/search] test-search-ui: update label in an idle
- Date: Sat, 6 Jul 2013 18:01:42 +0000 (UTC)
commit 10543342d6c7b5c3641ab9f9e2f4b1377940f5dc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jul 6 19:21:41 2013 +0200
test-search-ui: update label in an idle
tests/test-search-ui.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-search-ui.c b/tests/test-search-ui.c
index 6b0fb25..f5627be 100644
--- a/tests/test-search-ui.c
+++ b/tests/test-search-ui.c
@@ -50,6 +50,8 @@ struct _TestSearchUIPrivate
GtkSourceBuffer *source_buffer;
GtkEntry *replace_entry;
GtkLabel *label_occurrences;
+
+ guint idle_update_label_id;
};
GType test_search_ui_get_type (void);
@@ -242,6 +244,16 @@ button_replace_all_clicked_cb (TestSearchUI *search,
-1);
}
+static gboolean
+update_label_idle_cb (TestSearchUI *search)
+{
+ search->priv->idle_update_label_id = 0;
+
+ update_label (search);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
mark_set_cb (GtkTextBuffer *buffer,
GtkTextIter *location,
@@ -254,9 +266,11 @@ mark_set_cb (GtkTextBuffer *buffer,
insert = gtk_text_buffer_get_insert (buffer);
selection_bound = gtk_text_buffer_get_selection_bound (buffer);
- if (mark == insert || mark == selection_bound)
+ if ((mark == insert || mark == selection_bound) &&
+ search->priv->idle_update_label_id == 0)
{
- update_label (search);
+ search->priv->idle_update_label_id = g_idle_add ((GSourceFunc)update_label_idle_cb,
+ search);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]