+2007-09-14 Jim Evins <evins@snaught.com>
+
+ * src/marshal.list:
+ * src/label.c:
+ * src/label.h:
+ * src/label-object.c:
+ * src/label-object.h:
+ * src/label-barcode.c:
+ * src/label-ellipse.c:
+ * src/view.c:
+ * src/view-object.c:
+ * src/view-barcode.c:
+ * src/view-box.c:
+ * src/view-ellipse.c:
+ * src/view-image.c:
+ * src/view-line.c:
+ * src/view-text.c:
+ Better separation of model from view.
+
2007-08-21 Jim Evins <evins@snaught.com>
* src/print-op.c: (create_custom_widget_cb):
{
lbc->priv = g_new0 (glLabelBarcodePrivate, 1);
lbc->priv->color_node = gl_color_node_new_default ();
+ lbc->priv->text_node = gl_text_node_new_from_text ("");
}
static void
}
/*****************************************************************************/
-/* NEW label "text" object. */
+/* NEW label "barcode" object. */
/*****************************************************************************/
GObject *
gl_label_barcode_new (glLabel *label)
gl_label_ellipse_init (glLabelEllipse *lellipse)
{
lellipse->priv = g_new0 (glLabelEllipsePrivate, 1);
- lellipse->priv->fill_color_node = gl_color_node_new_default ();
+ lellipse->priv->line_color_node = gl_color_node_new_default ();
lellipse->priv->fill_color_node = gl_color_node_new_default ();
}
FLIP_ROTATE,
TOP,
BOTTOM,
+ REMOVED,
LAST_SIGNAL
};
gl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ signals[REMOVED] =
+ g_signal_new ("removed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glLabelObjectClass, removed),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
gl_debug (DEBUG_LABEL, "END");
}
g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
- parent = label_object->parent;
- gl_label_remove_object (parent, label_object);
-
g_free (label_object->priv->name);
g_free (label_object->priv);
return object->parent;
}
+/*****************************************************************************/
+/* Set remove object from parent. */
+/*****************************************************************************/
+void
+gl_label_object_remove (glLabelObject *object)
+{
+ glLabel *parent;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ parent = object->parent;
+ if ( parent != NULL ) {
+ g_signal_handlers_disconnect_by_func (parent,
+ G_CALLBACK(merge_changed_cb),
+ object);
+ gl_label_remove_object (parent, object);
+
+ g_signal_emit (G_OBJECT(object), signals[REMOVED], 0);
+
+ g_object_unref (G_OBJECT(object));
+ }
+
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
/*****************************************************************************/
/* Set name of object. */
/*****************************************************************************/
void (*bottom) (glLabelObject *object,
gpointer user_data);
+
+ void (*removed) (glLabelObject *object,
+ gpointer user_data);
+
};
GType gl_label_object_get_type (void) G_GNUC_CONST;
glLabel *gl_label_object_get_parent (glLabelObject *object);
+void gl_label_object_remove (glLabelObject *object);
+
void gl_label_object_set_name (glLabelObject *object,
gchar *name);
MODIFIED_CHANGED,
MERGE_CHANGED,
SIZE_CHANGED,
+ OBJECT_ADDED,
LAST_SIGNAL
};
gl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ signals[OBJECT_ADDED] =
+ g_signal_new ("object_added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glLabelClass, object_added),
+ NULL, NULL,
+ gl_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1, G_TYPE_OBJECT);
gl_debug (DEBUG_LABEL, "END");
}
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (label && GL_IS_LABEL (label));
- g_return_if_fail (GL_IS_LABEL_OBJECT (object));
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
object->parent = label;
- label->objects = g_list_append (label->objects, object);
+ label->objects = g_list_append (label->objects, g_object_ref (object));
label->priv->modified_flag = TRUE;
- g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[OBJECT_ADDED], 0, object);
g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
g_signal_connect (G_OBJECT(object), "changed",
G_CALLBACK(object_changed_cb), label);
label->priv->modified_flag = TRUE;
- g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
}
void (*size_changed) (glLabel *label, gpointer user_data);
+ void (*object_added) (glLabel *label,
+ glLabelObject *object,
+ gpointer user_data);
+
};
VOID:VOID
-VOID:BOOLEAN
VOID:INT
VOID:INT,INT
VOID:INT,UINT
-VOID:INT,DOUBLE
VOID:DOUBLE
VOID:DOUBLE,DOUBLE
-VOID:STRING
-BOOLEAN:OBJECT
+VOID:OBJECT
glColorNode *line_color_node;
glViewObject *view_barcode;
+ gl_view_unselect_all (view);
+
line_color_node = gl_color_node_new_default ();
object = gl_label_barcode_new (view->label);
gl_color_node_free (&line_color_node);
- gl_view_unselect_all (view);
- view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
-
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
view->create_y0 = y;
glColorNode *line_color_node;
glViewObject *view_box;
+ gl_view_unselect_all (view);
+
fill_color_node = gl_color_node_new_default ();
line_color_node = gl_color_node_new_default ();
gl_color_node_free (&fill_color_node);
gl_color_node_free (&line_color_node);
-
- gl_view_unselect_all (view);
- view_box = gl_view_box_new (GL_LABEL_BOX(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_box));
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
/*****************************************************************************/
glViewObject *
gl_view_ellipse_new (glLabelEllipse *object,
- glView *view)
+ glView *view)
{
glViewEllipse *view_ellipse;
glColorNode *line_color_node;
glViewObject *view_ellipse;
+ gl_view_unselect_all (view);
+
fill_color_node = gl_color_node_new_default ();
line_color_node = gl_color_node_new_default ();
gl_color_node_free (&fill_color_node);
gl_color_node_free (&line_color_node);
- gl_view_unselect_all (view);
- view_ellipse = gl_view_ellipse_new (GL_LABEL_ELLIPSE(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_ellipse));
-
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
view->create_y0 = y;
GObject *object;
glViewObject *view_image;
+ gl_view_unselect_all (view);
+
object = gl_label_image_new (view->label);
gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0);
- gl_view_unselect_all (view);
- view_image = gl_view_image_new (GL_LABEL_IMAGE(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_image));
-
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
view->create_y0 = y;
glColorNode *line_color_node;
glViewObject *view_line;
+ gl_view_unselect_all (view);
+
line_color_node = gl_color_node_new_default ();
object = gl_label_line_new (view->label);
gl_color_node_free (&line_color_node);
- gl_view_unselect_all (view);
- view_line = gl_view_line_new (GL_LABEL_LINE(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_line));
-
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
view->create_y0 = y;
static void gl_view_object_finalize (GObject *object);
+static void object_removed_cb (glViewObject *view_object,
+ glLabelObject *object);
+
+static void object_top_cb (glViewObject *view_object,
+ glLabelObject *object);
+
+static void object_bottom_cb (glViewObject *view_object,
+ glLabelObject *object);
+
g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
- view_object->priv->object = object;
+ view_object->priv->object = g_object_ref (G_OBJECT (object));
view_object->priv->handles_style = style;
+ g_signal_connect_swapped (G_OBJECT (object), "removed",
+ G_CALLBACK (object_removed_cb), view_object);
+ g_signal_connect_swapped (G_OBJECT (object), "top",
+ G_CALLBACK (object_top_cb), view_object);
+ g_signal_connect_swapped (G_OBJECT (object), "bottom",
+ G_CALLBACK (object_bottom_cb), view_object);
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Handle object "removed" signal. */
+/*---------------------------------------------------------------------------*/
+static void
+object_removed_cb (glViewObject *view_object,
+ glLabelObject *object)
+{
+ glView *view;
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ view = gl_view_object_get_view (view_object);
+ view->object_list = g_list_remove (view->object_list, view_object);
+ g_object_unref (G_OBJECT (view_object));
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Handle object "top" signal. */
+/*---------------------------------------------------------------------------*/
+static void
+object_top_cb (glViewObject *view_object,
+ glLabelObject *object)
+{
+ glView *view;
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ view = gl_view_object_get_view (view_object);
+
+ /* Move to end of list, representing front most object */
+ view->object_list = g_list_remove (view->object_list, view_object);
+ view->object_list = g_list_append (view->object_list, view_object);
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Handle object "removed" signal. */
+/*---------------------------------------------------------------------------*/
+static void
+object_bottom_cb (glViewObject *view_object,
+ glLabelObject *object)
+{
+ glView *view;
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ view = gl_view_object_get_view (view_object);
+
+ /* Move to front of list, representing rear most object */
+ view->object_list = g_list_remove (view->object_list, view_object);
+ view->object_list = g_list_prepend (view->object_list, view_object);
+
gl_debug (DEBUG_VIEW, "END");
}
gchar *family;
glColorNode *color_node;
+ gl_view_unselect_all (view);
+
object = gl_label_text_new (view->label);
color_node = gl_color_node_new_default ();
gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
view_text = gl_view_text_new (GL_LABEL_TEXT(object), view);
gl_color_node_free (&color_node);
- gl_view_unselect_all (view);
- view_text = gl_view_text_new (GL_LABEL_TEXT(object), view);
- gl_view_object_select (GL_VIEW_OBJECT(view_text));
-
view->create_object = GL_LABEL_OBJECT (object);
view->create_x0 = x;
view->create_y0 = y;
static void label_resized_cb (glView *view);
+static void label_object_added_cb (glView *view,
+ glLabelObject *object);
+
static void draw_layers (glView *view,
cairo_t *cr);
G_CALLBACK (label_changed_cb), view);
g_signal_connect_swapped (G_OBJECT (view->label), "size_changed",
G_CALLBACK (label_resized_cb), view);
+ g_signal_connect_swapped (G_OBJECT (view->label), "object_added",
+ G_CALLBACK (label_object_added_cb), view);
gl_debug (DEBUG_VIEW, "END");
}
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Handle new label object. */
+/*---------------------------------------------------------------------------*/
+static void
+label_object_added_cb (glView *view,
+ glLabelObject *object)
+{
+ glViewObject *view_object;
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if (GL_IS_LABEL_BOX (object)) {
+ view_object = gl_view_box_new (GL_LABEL_BOX(object), view);
+ } else if (GL_IS_LABEL_ELLIPSE (object)) {
+ view_object = gl_view_ellipse_new (GL_LABEL_ELLIPSE(object), view);
+ } else if (GL_IS_LABEL_LINE (object)) {
+ view_object = gl_view_line_new (GL_LABEL_LINE(object), view);
+ } else if (GL_IS_LABEL_IMAGE (object)) {
+ view_object = gl_view_image_new (GL_LABEL_IMAGE(object), view);
+ } else if (GL_IS_LABEL_TEXT (object)) {
+ view_object = gl_view_text_new (GL_LABEL_TEXT(object), view);
+ } else if (GL_IS_LABEL_BARCODE (object)) {
+ view_object = gl_view_barcode_new (GL_LABEL_BARCODE(object), view);
+ } else {
+ /* Should not happen! */
+ view_object = NULL;
+ g_message ("Invalid label object type.");
+ }
+
+ gl_view_select_object (view, view_object);
+}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Create, draw and order layers. */
/*---------------------------------------------------------------------------*/
void
gl_view_delete_selection (glView *view)
{
- GList *object_list;
- GList *p;
- GList *p_next;
+ GList *object_list;
+ GList *p;
+ GList *p_next;
+ glViewObject *view_object;
+ glLabelObject *object;
gl_debug (DEBUG_VIEW, "START");
for (p = object_list; p != NULL; p = p_next) {
p_next = p->next;
- g_object_unref (G_OBJECT (p->data));
- object_list = g_list_delete_link (object_list, p);
+ view_object = GL_VIEW_OBJECT (p->data);
+ object = gl_view_object_get_object (view_object);
+ gl_label_object_remove (object);
}
+ g_list_free (object_list);
+
gl_debug (DEBUG_VIEW, "END");
}