[glabels] Optimize loading of barcode styles.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Optimize loading of barcode styles.
- Date: Tue, 7 Dec 2010 19:39:17 +0000 (UTC)
commit 0dc2f0a1cfcef51429248c80522723a1a5a0b71b
Author: Jim Evins <evins snaught com>
Date: Tue Dec 7 14:36:25 2010 -0500
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 ca3aaff..270b785 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 09175d0..053bcde 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 0901cdd..b258f4e 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]