From 0dc2f0a1cfcef51429248c80522723a1a5a0b71b Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 7 Dec 2010 14:36:25 -0500 Subject: [PATCH] Optimize loading of barcode styles. Only load barcode styles into object editor combo box if backend ID has changed. Otherwise, skip loading. This seems to be a very expensive operation and would manifest itself as sluggish resizes of barcodes. --- src/object-editor-bc-page.c | 21 ++++++++++++++------- src/object-editor-private.h | 1 + src/object-editor.c | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/object-editor-bc-page.c b/src/object-editor-bc-page.c index ca3aaff6..270b785f 100644 --- a/src/object-editor-bc-page.c +++ b/src/object-editor-bc-page.c @@ -280,15 +280,22 @@ gl_object_editor_load_bc_styles (glObjectEditor *editor, gl_debug (DEBUG_EDITOR, "START"); - g_signal_handlers_block_by_func (G_OBJECT (editor->priv->bc_style_combo), - style_changed_cb, editor); + if ( !editor->priv->current_backend_id || + strcmp(editor->priv->current_backend_id, backend_id) != 0 ) + { + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->bc_style_combo), + style_changed_cb, editor); - styles = gl_barcode_backends_get_styles_list (backend_id); - gl_combo_util_set_strings (GTK_COMBO_BOX_TEXT(editor->priv->bc_style_combo), styles); - gl_barcode_backends_free_styles_list (styles); + styles = gl_barcode_backends_get_styles_list (backend_id); + gl_combo_util_set_strings (GTK_COMBO_BOX_TEXT(editor->priv->bc_style_combo), styles); + gl_barcode_backends_free_styles_list (styles); - g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->bc_style_combo), - style_changed_cb, editor); + g_free (editor->priv->current_backend_id); + editor->priv->current_backend_id = g_strdup (backend_id); + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->bc_style_combo), + style_changed_cb, editor); + } gl_debug (DEBUG_EDITOR, "END"); } diff --git a/src/object-editor-private.h b/src/object-editor-private.h index 09175d07..053bcdea 100644 --- a/src/object-editor-private.h +++ b/src/object-editor-private.h @@ -135,6 +135,7 @@ struct _glObjectEditorPrivate { GtkWidget *bc_key_radio; GtkWidget *bc_key_hbox; GtkWidget *bc_key_combo; + gchar *current_backend_id; GtkWidget *data_page_vbox; GtkWidget *data_literal_radio; diff --git a/src/object-editor.c b/src/object-editor.c index 0901cdda..b258f4e8 100644 --- a/src/object-editor.c +++ b/src/object-editor.c @@ -208,6 +208,7 @@ gl_object_editor_finalize (GObject *object) g_object_unref (editor->priv->builder); + g_free (editor->priv->current_backend_id); g_free (editor->priv); G_OBJECT_CLASS (gl_object_editor_parent_class)->finalize (object); -- 2.39.5