[gimp] app: move updating the style editor to an idle function
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move updating the style editor to an idle function
- Date: Tue, 2 Mar 2010 17:43:43 +0000 (UTC)
commit f230019f7151cc5b317fc3b120c870c0b6246341
Author: Michael Natterer <mitch gimp org>
Date: Tue Mar 2 11:46:58 2010 +0100
app: move updating the style editor to an idle function
so subsequent signals trigger only one update.
app/widgets/gimptextstyleeditor.c | 26 ++++++++++++++++++++++++++
app/widgets/gimptextstyleeditor.h | 2 ++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index 5cd03bc..ed43cc0 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -80,6 +80,7 @@ static void gimp_text_style_editor_tag_toggled (GtkToggleButton *toggl
GimpTextStyleEditor *editor);
static void gimp_text_style_editor_update (GimpTextStyleEditor *editor);
+static gboolean gimp_text_style_editor_update_idle (GimpTextStyleEditor *editor);
G_DEFINE_TYPE (GimpTextStyleEditor, gimp_text_style_editor,
@@ -247,6 +248,12 @@ gimp_text_style_editor_dispose (GObject *object)
editor);
}
+ if (editor->update_idle_id)
+ {
+ g_source_remove (editor->update_idle_id);
+ editor->update_idle_id = 0;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -543,8 +550,25 @@ gimp_text_style_editor_set_font (GimpTextStyleEditor *editor,
static void
gimp_text_style_editor_update (GimpTextStyleEditor *editor)
{
+ if (editor->update_idle_id)
+ g_source_remove (editor->update_idle_id);
+
+ editor->update_idle_id =
+ gdk_threads_add_idle ((GSourceFunc) gimp_text_style_editor_update_idle,
+ editor);
+}
+
+static gboolean
+gimp_text_style_editor_update_idle (GimpTextStyleEditor *editor)
+{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (editor->buffer);
+ if (editor->update_idle_id)
+ {
+ g_source_remove (editor->update_idle_id);
+ editor->update_idle_id = 0;
+ }
+
if (gtk_text_buffer_get_has_selection (buffer))
{
GtkTextIter start, end;
@@ -667,4 +691,6 @@ gimp_text_style_editor_update (GimpTextStyleEditor *editor)
g_slist_free (tags_on);
g_slist_free (tags_off);
}
+
+ return FALSE;
}
diff --git a/app/widgets/gimptextstyleeditor.h b/app/widgets/gimptextstyleeditor.h
index 602007d..98953ff 100644
--- a/app/widgets/gimptextstyleeditor.h
+++ b/app/widgets/gimptextstyleeditor.h
@@ -55,6 +55,8 @@ struct _GimpTextStyleEditor
GtkWidget *size_label;
GList *toggles;
+
+ guint update_idle_id;
};
struct _GimpTextStyleEditorClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]