static void gl_label_barcode_instance_init (glLabelBarcode *lbc);
static void gl_label_barcode_finalize (GObject *object);
-static void update_size (glLabelBarcode *lbc);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
+static void get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h);
\f
/*****************************************************************************/
static void
gl_label_barcode_class_init (glLabelBarcodeClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+ label_object_class->get_size = get_size;
+
object_class->finalize = gl_label_barcode_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelBarcode *
-gl_label_barcode_dup (glLabelBarcode *lbc,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelBarcode *new_lbc;
+ glLabelBarcode *lbc = (glLabelBarcode *)src_object;
+ glLabelBarcode *new_lbc = (glLabelBarcode *)dst_object;
glTextNode *text_node;
glBarcodeStyle style;
gboolean text_flag;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_lbc = GL_LABEL_BARCODE(gl_label_barcode_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_lbc), GL_LABEL_OBJECT(lbc));
+ g_return_if_fail (new_lbc && GL_IS_LABEL_BARCODE (new_lbc));
text_node = gl_label_barcode_get_data (lbc);
gl_label_barcode_get_props (lbc, &style, &text_flag, &color, &scale);
gl_text_node_free (&text_node);
gl_debug (DEBUG_LABEL, "END");
-
- return new_lbc;
}
gl_text_node_free (&lbc->private->text_node);
lbc->private->text_node = gl_text_node_dup (text_node);
- update_size (lbc);
-
gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc));
gl_debug (DEBUG_LABEL, "END");
lbc->private->color = color;
lbc->private->scale = scale;
- update_size (lbc);
-
gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc));
gl_debug (DEBUG_LABEL, "END");
}
/*---------------------------------------------------------------------------*/
-/* PRIVATE. Update object size. */
+/* PRIVATE. Get object size method. */
/*---------------------------------------------------------------------------*/
static void
-update_size (glLabelBarcode *lbc)
+get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h)
{
+ glLabelBarcode *lbc = (glLabelBarcode *)object;
gchar *data;
glBarcode *gbc;
gl_debug (DEBUG_LABEL, "START");
+ g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
+
data = gl_barcode_default_digits (lbc->private->style);
gbc = gl_barcode_new (lbc->private->style,
lbc->private->text_flag,
lbc->private->scale,
data);
- gl_label_object_set_size (GL_LABEL_OBJECT(lbc),
- gbc->width, gbc->height);
+ *w = gbc->width;
+ *h = gbc->height;
gl_barcode_free (&gbc);
GObject *gl_label_barcode_new (glLabel *label);
-glLabelBarcode *gl_label_barcode_dup (glLabelBarcode *lbc,
- glLabel *label);
-
void gl_label_barcode_set_data (glLabelBarcode *lbc,
glTextNode *text_node);
void gl_label_barcode_set_props (glLabelBarcode *lbc,
static void gl_label_box_instance_init (glLabelBox *lbox);
static void gl_label_box_finalize (GObject *object);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
gl_label_box_class_init (glLabelBoxClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+
object_class->finalize = gl_label_box_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelBox *
-gl_label_box_dup (glLabelBox *lbox,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelBox *new_lbox;
+ glLabelBox *lbox = (glLabelBox *)src_object;
+ glLabelBox *new_lbox = (glLabelBox *)dst_object;
gdouble line_width;
guint line_color, fill_color;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_lbox = GL_LABEL_BOX(gl_label_box_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_lbox), GL_LABEL_OBJECT(lbox));
+ g_return_if_fail (new_lbox && GL_IS_LABEL_BOX (new_lbox));
line_width = gl_label_box_get_line_width (lbox);
line_color = gl_label_box_get_line_color (lbox);
gl_label_box_set_line_color (new_lbox, line_color);
gl_label_box_set_fill_color (new_lbox, fill_color);
-
gl_debug (DEBUG_LABEL, "END");
-
- return new_lbox;
}
GType gl_label_box_get_type (void);
-GObject *gl_label_box_new (glLabel *label);
-
-glLabelBox *gl_label_box_dup (glLabelBox *lbox,
- glLabel *label);
+GObject *gl_label_box_new (glLabel *label);
void gl_label_box_set_line_width (glLabelBox *lbox,
gdouble line_width);
static void gl_label_ellipse_instance_init (glLabelEllipse *lellipse);
static void gl_label_ellipse_finalize (GObject *object);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
gl_label_ellipse_class_init (glLabelEllipseClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+
object_class->finalize = gl_label_ellipse_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelEllipse *
-gl_label_ellipse_dup (glLabelEllipse *lellipse,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelEllipse *new_lellipse;
+ glLabelEllipse *lellipse = (glLabelEllipse *)src_object;
+ glLabelEllipse *new_lellipse = (glLabelEllipse *)dst_object;
gdouble line_width;
guint line_color, fill_color;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_lellipse = GL_LABEL_ELLIPSE(gl_label_ellipse_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_lellipse),
- GL_LABEL_OBJECT(lellipse));
+ g_return_if_fail (new_lellipse && GL_IS_LABEL_ELLIPSE (new_lellipse));
line_width = gl_label_ellipse_get_line_width (lellipse);
line_color = gl_label_ellipse_get_line_color (lellipse);
gl_label_ellipse_set_fill_color (new_lellipse, fill_color);
gl_debug (DEBUG_LABEL, "END");
-
- return new_lellipse;
}
GType gl_label_ellipse_get_type (void);
-GObject *gl_label_ellipse_new (glLabel *label);
-
-glLabelEllipse *gl_label_ellipse_dup (glLabelEllipse *lellipse,
- glLabel *label);
+GObject *gl_label_ellipse_new (glLabel *label);
void gl_label_ellipse_set_line_width (glLabelEllipse *lellipse,
gdouble line_width);
static void gl_label_image_instance_init (glLabelImage *limage);
static void gl_label_image_finalize (GObject *object);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
gl_label_image_class_init (glLabelImageClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+
object_class->finalize = gl_label_image_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelImage *
-gl_label_image_dup (glLabelImage *limage,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelImage *new_limage;
+ glLabelImage *limage = (glLabelImage *)src_object;
+ glLabelImage *new_limage = (glLabelImage *)dst_object;
gchar *filename;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (limage && GL_IS_LABEL_IMAGE (limage));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_limage = GL_LABEL_IMAGE(gl_label_image_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_limage), GL_LABEL_OBJECT(limage));
+ g_return_if_fail (new_limage && GL_IS_LABEL_IMAGE (new_limage));
filename = gl_label_image_get_filename (limage);
gl_label_image_set_filename (new_limage, filename);
g_free (filename);
gl_debug (DEBUG_LABEL, "END");
-
- return new_limage;
}
GType gl_label_image_get_type (void);
-GObject *gl_label_image_new (glLabel *label);
-
-glLabelImage *gl_label_image_dup (glLabelImage *limage,
- glLabel *label);
+GObject *gl_label_image_new (glLabel *label);
void gl_label_image_set_filename (glLabelImage *limage,
const gchar *filename);
static void gl_label_line_instance_init (glLabelLine *lline);
static void gl_label_line_finalize (GObject *object);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
gl_label_line_class_init (glLabelLineClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+
object_class->finalize = gl_label_line_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelLine *
-gl_label_line_dup (glLabelLine *lline,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelLine *new_lline;
+ glLabelLine *lline = (glLabelLine *)src_object;
+ glLabelLine *new_lline = (glLabelLine *)dst_object;
gdouble line_width;
guint line_color;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_lline = GL_LABEL_LINE(gl_label_line_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_lline), GL_LABEL_OBJECT(lline));
+ g_return_if_fail (new_lline && GL_IS_LABEL_LINE (new_lline));
line_width = gl_label_line_get_line_width (lline);
line_color = gl_label_line_get_line_color (lline);
gl_label_line_set_line_color (new_lline, line_color);
gl_debug (DEBUG_LABEL, "END");
-
- return new_lline;
}
GObject *gl_label_line_new (glLabel *label);
-glLabelLine *gl_label_line_dup (glLabelLine *lline,
- glLabel *label);
-
void gl_label_line_set_line_width (glLabelLine *lline,
gdouble line_width);
}
/*****************************************************************************/
-/* Copy properties of one label object to another. */
+/* Duplicate object. */
/*****************************************************************************/
-void
-gl_label_object_copy_props (glLabelObject *dst_object,
- glLabelObject *src_object)
+glLabelObject *
+gl_label_object_dup (glLabelObject *src_object,
+ glLabel *label)
{
+ glLabelObject *dst_object;
gdouble x, y, w, h;
gdouble affine[6];
+ gl_debug (DEBUG_LABEL, "START");
+
g_return_if_fail (src_object && GL_IS_LABEL_OBJECT (src_object));
- g_return_if_fail (dst_object && GL_IS_LABEL_OBJECT (dst_object));
+
+ dst_object = g_object_new (G_OBJECT_TYPE(src_object), NULL);
+
+ gl_label_object_set_parent (dst_object, label);
gl_label_object_get_position (src_object, &x, &y);
gl_label_object_get_size (src_object, &w, &h);
gl_label_object_set_position (dst_object, x, y);
gl_label_object_set_size (dst_object, w, h);
gl_label_object_set_affine (dst_object, affine);
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(src_object)->copy != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(src_object)->copy (dst_object, src_object);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+
+ return dst_object;
}
/*****************************************************************************/
gdouble *w,
gdouble *h);
+ void (*copy) (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
/*
* Signals
*/
gpointer user_data);
};
-GType gl_label_object_get_type (void);
+GType gl_label_object_get_type (void);
-GObject *gl_label_object_new (glLabel *label);
+GObject *gl_label_object_new (glLabel *label);
-void gl_label_object_copy_props (glLabelObject *dst_object,
- glLabelObject *src_object);
+glLabelObject *gl_label_object_dup (glLabelObject *src_object,
+ glLabel *label);
-void gl_label_object_emit_changed (glLabelObject *object);
+void gl_label_object_emit_changed (glLabelObject *object);
-void gl_label_object_set_parent (glLabelObject *object,
- glLabel *label);
+void gl_label_object_set_parent (glLabelObject *object,
+ glLabel *label);
-glLabel *gl_label_object_get_parent (glLabelObject *object);
+glLabel *gl_label_object_get_parent (glLabelObject *object);
-void gl_label_object_set_name (glLabelObject *object,
- gchar *name);
+void gl_label_object_set_name (glLabelObject *object,
+ gchar *name);
-gchar *gl_label_object_get_name (glLabelObject *object);
+gchar *gl_label_object_get_name (glLabelObject *object);
-void gl_label_object_set_position (glLabelObject *object,
- gdouble x,
- gdouble y);
+void gl_label_object_set_position (glLabelObject *object,
+ gdouble x,
+ gdouble y);
-void gl_label_object_set_position_relative (glLabelObject *object,
- gdouble dx,
- gdouble dy);
+void gl_label_object_set_position_relative (glLabelObject *object,
+ gdouble dx,
+ gdouble dy);
-void gl_label_object_get_position (glLabelObject *object,
- gdouble *x,
- gdouble *y);
+void gl_label_object_get_position (glLabelObject *object,
+ gdouble *x,
+ gdouble *y);
-void gl_label_object_set_size (glLabelObject *object,
- gdouble w,
- gdouble h);
+void gl_label_object_set_size (glLabelObject *object,
+ gdouble w,
+ gdouble h);
-void gl_label_object_get_size (glLabelObject *object,
- gdouble *w,
- gdouble *h);
+void gl_label_object_get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h);
-void gl_label_object_get_extent (glLabelObject *object,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2);
+void gl_label_object_get_extent (glLabelObject *object,
+ gdouble *x1,
+ gdouble *y1,
+ gdouble *x2,
+ gdouble *y2);
-void gl_label_object_raise_to_top (glLabelObject *object);
+void gl_label_object_raise_to_top (glLabelObject *object);
-void gl_label_object_lower_to_bottom (glLabelObject *object);
+void gl_label_object_lower_to_bottom (glLabelObject *object);
-void gl_label_object_flip_horiz (glLabelObject *object);
+void gl_label_object_flip_horiz (glLabelObject *object);
-void gl_label_object_flip_vert (glLabelObject *object);
+void gl_label_object_flip_vert (glLabelObject *object);
-void gl_label_object_rotate (glLabelObject *object,
- gdouble theta_degs);
+void gl_label_object_rotate (glLabelObject *object,
+ gdouble theta_degs);
-void gl_label_object_set_affine (glLabelObject *object,
- gdouble affine[6]);
+void gl_label_object_set_affine (glLabelObject *object,
+ gdouble affine[6]);
-void gl_label_object_get_affine (glLabelObject *object,
- gdouble affine[6]);
+void gl_label_object_get_affine (glLabelObject *object,
+ gdouble affine[6]);
-void gl_label_object_get_applied_affine (glLabelObject *object,
- gdouble affine[6]);
+void gl_label_object_get_applied_affine (glLabelObject *object,
+ gdouble affine[6]);
G_END_DECLS
static void gl_label_text_instance_init (glLabelText *ltext);
static void gl_label_text_finalize (GObject *object);
-static void update_size (glLabelText *ltext);
+static void copy (glLabelObject *dst_object,
+ glLabelObject *src_object);
+
+static void get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h);
\f
/*****************************************************************************/
static void
gl_label_text_class_init (glLabelTextClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ label_object_class->copy = copy;
+ label_object_class->get_size = get_size;
+
object_class->finalize = gl_label_text_finalize;
}
}
/*****************************************************************************/
-/* Duplicate object. */
+/* Copy object contents. */
/*****************************************************************************/
-glLabelText *
-gl_label_text_dup (glLabelText *ltext,
- glLabel *label)
+static void
+copy (glLabelObject *dst_object,
+ glLabelObject *src_object)
{
- glLabelText *new_ltext;
+ glLabelText *ltext = (glLabelText *)src_object;
+ glLabelText *new_ltext = (glLabelText *)dst_object;
GList *lines;
gchar *font_family;
gdouble font_size;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
- g_return_if_fail (label && GL_IS_LABEL (label));
-
- new_ltext = GL_LABEL_TEXT(gl_label_text_new (label));
-
- gl_label_object_copy_props (GL_LABEL_OBJECT(new_ltext), GL_LABEL_OBJECT(ltext));
+ g_return_if_fail (new_ltext && GL_IS_LABEL_TEXT (new_ltext));
lines = gl_label_text_get_lines (ltext);
gl_label_text_get_props (ltext,
g_free (font_family);
gl_debug (DEBUG_LABEL, "END");
-
- return new_ltext;
}
gl_text_node_lines_free (<ext->private->lines);
ltext->private->lines = gl_text_node_lines_dup (lines);
- update_size (ltext);
-
gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
gl_debug (DEBUG_LABEL, "END");
gl_debug (DEBUG_LABEL, "just = %d", ltext->private->just);
- update_size (ltext);
-
gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
gl_debug (DEBUG_LABEL, "END");
}
/*---------------------------------------------------------------------------*/
-/* PRIVATE. Update object size. */
+/* PRIVATE. get object size method. */
/*---------------------------------------------------------------------------*/
static void
-update_size (glLabelText *ltext)
+get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h)
{
- gdouble w, h;
+ glLabelText *ltext = (glLabelText *)object;
GnomeFont *font;
gchar *text;
gchar **line;
gl_debug (DEBUG_LABEL, "START");
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
font = gnome_font_find_closest_from_weight_slant (
ltext->private->font_family,
ltext->private->font_weight,
art_affine_identity (affine);
- w = 0.0;
- h = 0.0;
+ *w = 0.0;
+ *h = 0.0;
for (i = 0; line[i] != NULL; i++) {
glyphlist = gnome_glyphlist_from_text_dumb (font, 0,
gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox);
- if ( bbox.x1 > w ) w = bbox.x1;
+ if ( bbox.x1 > *w ) *w = bbox.x1;
- h += ltext->private->font_size;
+ *h += ltext->private->font_size;
}
g_strfreev (line);
- gl_label_object_set_size (GL_LABEL_OBJECT(ltext), w, h);
-
gl_debug (DEBUG_LABEL, "END");
}
GObject *gl_label_text_new (glLabel *label);
-glLabelText *gl_label_text_dup (glLabelText *ltext,
- glLabel *label);
-
void gl_label_text_set_lines (glLabelText *ltext,
GList *lines);
void gl_label_text_set_props (glLabelText *ltext,
view_object = GL_VIEW_OBJECT (p->data);
object = gl_view_object_get_object (view_object);
- gl_debug (DEBUG_VIEW, "Object copied");
-
- if (GL_IS_LABEL_BOX (object)) {
- gl_label_box_dup (GL_LABEL_BOX(object),
- view->selection_data);
- } else if (GL_IS_LABEL_ELLIPSE (object)) {
- gl_label_ellipse_dup (GL_LABEL_ELLIPSE(object),
- view->selection_data);
- } else if (GL_IS_LABEL_LINE (object)) {
- gl_label_line_dup (GL_LABEL_LINE(object),
- view->selection_data);
- } else if (GL_IS_LABEL_IMAGE (object)) {
- gl_label_image_dup (GL_LABEL_IMAGE(object),
- view->selection_data);
- } else if (GL_IS_LABEL_TEXT (object)) {
- gl_label_text_dup (GL_LABEL_TEXT(object),
- view->selection_data);
- } else if (GL_IS_LABEL_BARCODE (object)) {
- gl_label_barcode_dup (GL_LABEL_BARCODE(object),
- view->selection_data);
- } else {
- /* Should not happen! */
- g_warning ("Invalid label object type.");
- }
-
+ gl_label_object_dup (object, view->selection_data);
}