From 1793cb9fc61fe010218dc43b590c00387bad7f25 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 16 Feb 2004 02:53:37 +0000 Subject: [PATCH] 2004-02-15 Jim Evins * src/label-barcode.c: (gl_label_barcode_set_data), (gl_label_barcode_set_props): Don't emit "changed" signal, if no change actually made for these methods. Reduces number of unnecessary redraws of barcodes. * src/label-object.h: * src/label-object.c: (gl_label_object_set_position), (gl_label_object_set_position_relative), (set_size), (gl_label_object_set_size), (gl_label_object_set_size_honor_aspect): Don't emit "changed" signal, if no change actually made for these methods. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@415 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 15 +++++++++++ glabels2/src/label-barcode.c | 25 ++++++++++++----- glabels2/src/label-object.c | 52 +++++++++++++++++++----------------- glabels2/src/label-object.h | 6 ++--- 4 files changed, 63 insertions(+), 35 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index f6ac66c0..a5eae24c 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,18 @@ +2004-02-15 Jim Evins + + * src/label-barcode.c: (gl_label_barcode_set_data), + (gl_label_barcode_set_props): + Don't emit "changed" signal, if no change actually made for these + methods. Reduces number of unnecessary redraws of barcodes. + + * src/label-object.h: + * src/label-object.c: (gl_label_object_set_position), + (gl_label_object_set_position_relative), (set_size), + (gl_label_object_set_size), + (gl_label_object_set_size_honor_aspect): + Don't emit "changed" signal, if no change actually made for these + methods. + 2004-02-15 Jim Evins * data/glabels-2.0.dtd: diff --git a/glabels2/src/label-barcode.c b/glabels2/src/label-barcode.c index c2cb91e7..b49d4d34 100644 --- a/glabels2/src/label-barcode.c +++ b/glabels2/src/label-barcode.c @@ -201,10 +201,14 @@ gl_label_barcode_set_data (glLabelBarcode *lbc, g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc)); - gl_text_node_free (&lbc->private->text_node); - lbc->private->text_node = gl_text_node_dup (text_node); + if (!gl_text_node_equal (lbc->private->text_node, text_node)) { + + gl_text_node_free (&lbc->private->text_node); + lbc->private->text_node = gl_text_node_dup (text_node); - gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc)); + gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc)); + + } gl_debug (DEBUG_LABEL, "END"); } @@ -219,11 +223,18 @@ gl_label_barcode_set_props (glLabelBarcode *lbc, g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc)); - lbc->private->id = g_strdup (id); - lbc->private->text_flag = text_flag; - lbc->private->checksum_flag = checksum_flag; + if ( ((lbc->private->id == NULL) && (id != NULL)) + || (g_strcasecmp (lbc->private->id, id) != 0) + || (lbc->private->text_flag != text_flag) + || (lbc->private->checksum_flag != checksum_flag) ) { - gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc)); + lbc->private->id = g_strdup (id); + lbc->private->text_flag = text_flag; + lbc->private->checksum_flag = checksum_flag; + + gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc)); + + } gl_debug (DEBUG_LABEL, "END"); } diff --git a/glabels2/src/label-object.c b/glabels2/src/label-object.c index 3274873f..1df223e0 100644 --- a/glabels2/src/label-object.c +++ b/glabels2/src/label-object.c @@ -376,13 +376,17 @@ gl_label_object_set_position (glLabelObject *object, g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); - dx = x - object->private->x; - dy = y - object->private->y; + if ( (x != object->private->x) || (y != object->private->y) ) { - object->private->x = x; - object->private->y = y; + dx = x - object->private->x; + dy = y - object->private->y; - g_signal_emit (G_OBJECT(object), signals[MOVED], 0, dx, dy); + object->private->x = x; + object->private->y = y; + + g_signal_emit (G_OBJECT(object), signals[MOVED], 0, dx, dy); + + } gl_debug (DEBUG_LABEL, "END"); } @@ -399,14 +403,18 @@ gl_label_object_set_position_relative (glLabelObject *object, g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); - object->private->x += dx; - object->private->y += dy; + if ( (dx != 0.0) || (dy != 0.0) ) { - gl_debug (DEBUG_LABEL, " x = %f, y= %f", - object->private->x, - object->private->y); + object->private->x += dx; + object->private->y += dy; - g_signal_emit (G_OBJECT(object), signals[MOVED], 0, dx, dy); + gl_debug (DEBUG_LABEL, " x = %f, y= %f", + object->private->x, + object->private->y); + + g_signal_emit (G_OBJECT(object), signals[MOVED], 0, dx, dy); + + } gl_debug (DEBUG_LABEL, "END"); } @@ -439,8 +447,13 @@ set_size (glLabelObject *object, { g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); - object->private->w = w; - object->private->h = h; + if ( (object->private->w != w) || (object->private->h != h) ) { + + object->private->w = w; + object->private->h = h; + + g_signal_emit (G_OBJECT(object), signals[CHANGED], 0); + } } /*****************************************************************************/ @@ -460,15 +473,10 @@ gl_label_object_set_size (glLabelObject *object, /* We have an object specific method, use it */ GL_LABEL_OBJECT_GET_CLASS(object)->set_size (object, w, h); - } else { - - set_size (object, w, h); + object->private->aspect_ratio = h / w; } - object->private->aspect_ratio = h / w; - - g_signal_emit (G_OBJECT(object), signals[CHANGED], 0); gl_debug (DEBUG_LABEL, "END"); } @@ -500,14 +508,8 @@ gl_label_object_set_size_honor_aspect (glLabelObject *object, /* We have an object specific method, use it */ GL_LABEL_OBJECT_GET_CLASS(object)->set_size (object, w, h); - } else { - - set_size (object, w, h); - } - g_signal_emit (G_OBJECT(object), signals[CHANGED], 0); - gl_debug (DEBUG_LABEL, "END"); } diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index afc17708..222f71d1 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -93,8 +93,8 @@ struct _glLabelObjectClass { void (*set_text_alignment) (glLabelObject *object, GtkJustification text_alignment); - void (*set_text_line_spacing) (glLabelObject *object, - gdouble text_line_spacing); + void (*set_text_line_spacing) (glLabelObject *object, + gdouble text_line_spacing); void (*set_text_color) (glLabelObject *object, guint text_color); @@ -118,7 +118,7 @@ struct _glLabelObjectClass { GtkJustification (*get_text_alignment) (glLabelObject *object); - gdouble (*get_text_line_spacing) (glLabelObject *object); + gdouble (*get_text_line_spacing) (glLabelObject *object); guint (*get_text_color) (glLabelObject *object); -- 2.39.5