app: move updating the style editor to an idle function

so subsequent signals trigger only one update.
This commit is contained in:
Michael Natterer 2010-03-02 11:46:58 +01:00
parent 1ddef5d375
commit f230019f71
2 changed files with 28 additions and 0 deletions

View File

@ -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);
}
@ -542,9 +549,26 @@ 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;
}

View File

@ -55,6 +55,8 @@ struct _GimpTextStyleEditor
GtkWidget *size_label;
GList *toggles;
guint update_idle_id;
};
struct _GimpTextStyleEditorClass