]> git.sur5r.net Git - glabels/commitdiff
Optimize loading of barcode styles.
authorJim Evins <evins@snaught.com>
Tue, 7 Dec 2010 19:36:25 +0000 (14:36 -0500)
committerJim Evins <evins@snaught.com>
Tue, 7 Dec 2010 19:36:25 +0000 (14:36 -0500)
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
src/object-editor-private.h
src/object-editor.c

index ca3aaff6a9846a29caed399ec8922874a5c835bf..270b785f5b625f251059804e759acba7141d4ba4 100644 (file)
@@ -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");
 }
index 09175d07b1e3cc1e0fc504802ca89e9ba602183e..053bcdea1bee59ca95430b7c68c650904ab02090 100644 (file)
@@ -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;
index 0901cdda7c2a77db942df1af0b24fb99feb386db..b258f4e8b47605f7735d3d65ba04e536d15982f9 100644 (file)
@@ -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);