[glabels] Optimized the handling of moved objects.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Optimized the handling of moved objects.
- Date: Tue, 7 Dec 2010 15:34:27 +0000 (UTC)
commit c64827154b26e3cae7ba3f60e175ca38e242e2bd
Author: Jim Evins <evins snaught com>
Date: Tue Dec 7 10:29:16 2010 -0500
Optimized the handling of moved objects.
Created a separate "moved" signal for objects, so that we don't waste time
updating unrelated controls in the object editor. This currently is most
visible with barcode objects.
src/label-object.c | 20 ++++++++++++++++----
src/label-object.h | 3 +++
src/label.c | 18 ++++++++++++++++++
src/object-editor.c | 34 ++++++++++++++++++++++++++++++----
4 files changed, 67 insertions(+), 8 deletions(-)
---
diff --git a/src/label-object.c b/src/label-object.c
index d3ffe97..8eb2aa7 100644
--- a/src/label-object.c
+++ b/src/label-object.c
@@ -73,6 +73,7 @@ struct _glLabelObjectPrivate {
enum {
CHANGED,
+ MOVED,
LAST_SIGNAL
};
@@ -129,6 +130,16 @@ gl_label_object_class_init (glLabelObjectClass *class)
G_TYPE_NONE,
0);
+ signals[MOVED] =
+ g_signal_new ("moved",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glLabelObjectClass, moved),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
gl_debug (DEBUG_LABEL, "END");
}
@@ -388,9 +399,10 @@ gl_label_object_set_position (glLabelObject *object,
object->priv->x = x;
object->priv->y = y;
- }
- gl_label_object_emit_changed (object);
+ g_signal_emit (G_OBJECT(object), signals[MOVED], 0);
+
+ }
gl_debug (DEBUG_LABEL, "END");
}
@@ -422,9 +434,9 @@ gl_label_object_set_position_relative (glLabelObject *object,
gl_debug (DEBUG_LABEL, " x = %f, y= %f",
object->priv->x,
object->priv->y);
- }
- gl_label_object_emit_changed (object);
+ g_signal_emit (G_OBJECT(object), signals[MOVED], 0);
+ }
gl_debug (DEBUG_LABEL, "END");
}
diff --git a/src/label-object.h b/src/label-object.h
index 5875f8e..e2c43e0 100644
--- a/src/label-object.h
+++ b/src/label-object.h
@@ -194,6 +194,9 @@ struct _glLabelObjectClass {
void (*changed) (glLabelObject *object,
gpointer user_data);
+ void (*moved) (glLabelObject *object,
+ gpointer user_data);
+
};
diff --git a/src/label.c b/src/label.c
index 37e0c6c..2fb3c7f 100644
--- a/src/label.c
+++ b/src/label.c
@@ -141,6 +141,9 @@ static void gl_label_finalize (GObject *object);
static void object_changed_cb (glLabelObject *object,
glLabel *label);
+static void object_moved_cb (glLabelObject *object,
+ glLabel *label);
+
static void do_modify (glLabel *label);
static void begin_selection_op (glLabel *label);
@@ -519,6 +522,17 @@ object_changed_cb (glLabelObject *object,
/****************************************************************************/
+/* Object "moved" callback. */
+/****************************************************************************/
+static void
+object_moved_cb (glLabelObject *object,
+ glLabel *label)
+{
+ do_modify (label);
+}
+
+
+/****************************************************************************/
/* Do modify. */
/****************************************************************************/
static void
@@ -771,6 +785,8 @@ gl_label_add_object (glLabel *label,
g_signal_connect (G_OBJECT (object), "changed",
G_CALLBACK (object_changed_cb), label);
+ g_signal_connect (G_OBJECT (object), "moved",
+ G_CALLBACK (object_moved_cb), label);
do_modify (label);
@@ -794,6 +810,8 @@ gl_label_delete_object (glLabel *label,
g_signal_handlers_disconnect_by_func (G_OBJECT (object),
G_CALLBACK (object_changed_cb), label);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (object),
+ G_CALLBACK (object_moved_cb), label);
g_object_unref (object);
do_modify (label);
diff --git a/src/object-editor.c b/src/object-editor.c
index e302ac5..0901cdd 100644
--- a/src/object-editor.c
+++ b/src/object-editor.c
@@ -87,6 +87,9 @@ static void set_key_names (glObjectEditor *editor,
static void object_changed_cb (glLabelObject *object,
glObjectEditor *editor);
+static void object_moved_cb (glLabelObject *object,
+ glObjectEditor *editor);
+
/*****************************************************************************/
@@ -198,6 +201,8 @@ gl_object_editor_finalize (GObject *object)
{
g_signal_handlers_disconnect_by_func (G_OBJECT(editor->priv->object),
object_changed_cb, editor);
+ g_signal_handlers_disconnect_by_func (G_OBJECT(editor->priv->object),
+ object_moved_cb, editor);
g_object_unref (editor->priv->object);
}
@@ -291,6 +296,8 @@ set_object (glObjectEditor *editor,
{
g_signal_handlers_disconnect_by_func (G_OBJECT(editor->priv->object),
object_changed_cb, editor);
+ g_signal_handlers_disconnect_by_func (G_OBJECT(editor->priv->object),
+ object_moved_cb, editor);
g_object_unref (editor->priv->object);
}
@@ -442,10 +449,13 @@ set_object (glObjectEditor *editor,
gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 0);
}
+ object_moved_cb (object, editor);
object_changed_cb (object, editor);
g_signal_connect (G_OBJECT (object), "changed",
G_CALLBACK (object_changed_cb), editor);
+ g_signal_connect (G_OBJECT (object), "moved",
+ G_CALLBACK (object_moved_cb), editor);
}
else
{
@@ -728,7 +738,6 @@ static void
object_changed_cb (glLabelObject *object,
glObjectEditor *editor)
{
- gdouble x, y;
gdouble w, h;
glColorNode *line_color_node;
gdouble line_width;
@@ -755,9 +764,6 @@ object_changed_cb (glLabelObject *object,
gl_debug (DEBUG_EDITOR, "BEGIN");
- gl_label_object_get_position (object, &x, &y);
- gl_object_editor_set_position (editor, x, y);
-
label = gl_label_object_get_parent (object);
merge = gl_label_get_merge (label);
@@ -871,6 +877,24 @@ object_changed_cb (glLabelObject *object,
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. object "moved" callback. */
+/*---------------------------------------------------------------------------*/
+static void
+object_moved_cb (glLabelObject *object,
+ glObjectEditor *editor)
+{
+ gdouble x, y;
+
+ gl_debug (DEBUG_EDITOR, "BEGIN");
+
+ gl_label_object_get_position (object, &x, &y);
+ gl_object_editor_set_position (editor, x, y);
+
+ gl_debug (DEBUG_EDITOR, "END");
+}
+
+
/*****************************************************************************/
/* Object editor "changed" callback. */
/*****************************************************************************/
@@ -905,6 +929,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor)
g_signal_handlers_block_by_func (G_OBJECT (object), object_changed_cb, editor);
+ g_signal_handlers_block_by_func (G_OBJECT (object), object_moved_cb, editor);
gl_object_editor_get_position (editor, &x, &y);
@@ -1017,6 +1042,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor)
g_signal_handlers_unblock_by_func (G_OBJECT (object), object_changed_cb, editor);
+ g_signal_handlers_unblock_by_func (G_OBJECT (object), object_moved_cb, editor);
gl_debug (DEBUG_EDITOR, "END");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]