2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * label_line.c: GLabels label line object
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "label-line.h"
29 /*========================================================*/
31 /*========================================================*/
33 struct _glLabelLinePrivate {
38 /*========================================================*/
39 /* Private globals. */
40 /*========================================================*/
42 static GObjectClass *parent_class = NULL;
44 static guint instance = 0;
46 /*========================================================*/
47 /* Private function prototypes. */
48 /*========================================================*/
50 static void gl_label_line_class_init (glLabelLineClass *klass);
51 static void gl_label_line_instance_init (glLabelLine *lline);
52 static void gl_label_line_finalize (GObject *object);
55 /*****************************************************************************/
56 /* Boilerplate object stuff. */
57 /*****************************************************************************/
59 gl_label_line_get_type (void)
61 static GType type = 0;
65 sizeof (glLabelLineClass),
68 (GClassInitFunc) gl_label_line_class_init,
73 (GInstanceInitFunc) gl_label_line_instance_init,
76 type = g_type_register_static (GL_TYPE_LABEL_OBJECT,
77 "glLabelLine", &info, 0);
84 gl_label_line_class_init (glLabelLineClass *klass)
86 GObjectClass *object_class = (GObjectClass *) klass;
88 parent_class = g_type_class_peek_parent (klass);
90 object_class->finalize = gl_label_line_finalize;
94 gl_label_line_instance_init (glLabelLine *lline)
96 lline->private = g_new0 (glLabelLinePrivate, 1);
100 gl_label_line_finalize (GObject *object)
104 g_return_if_fail (object && GL_IS_LABEL_LINE (object));
106 lline = GL_LABEL_LINE (object);
108 g_free (lline->private);
110 G_OBJECT_CLASS (parent_class)->finalize (object);
113 /*****************************************************************************/
114 /* NEW label "line" object. */
115 /*****************************************************************************/
117 gl_label_line_new (glLabel *label)
121 lline = g_object_new (gl_label_line_get_type(), NULL);
123 gl_label_object_set_parent (GL_LABEL_OBJECT(lline), label);
125 return G_OBJECT (lline);
128 /*****************************************************************************/
129 /* Duplicate object. */
130 /*****************************************************************************/
132 gl_label_line_dup (glLabelLine *lline,
135 glLabelLine *new_lline;
136 gdouble x, y, w, h, line_width;
139 gl_debug (DEBUG_LABEL, "START");
141 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
142 g_return_if_fail (label && GL_IS_LABEL (label));
144 new_lline = GL_LABEL_LINE(gl_label_line_new (label));
146 gl_label_object_get_position (GL_LABEL_OBJECT(lline), &x, &y);
147 gl_label_object_get_size (GL_LABEL_OBJECT(lline), &w, &h);
149 gl_label_object_set_position (GL_LABEL_OBJECT(new_lline), x, y);
150 gl_label_object_set_size (GL_LABEL_OBJECT(new_lline), w, h);
152 line_width = gl_label_line_get_line_width (lline);
153 line_color = gl_label_line_get_line_color (lline);
155 gl_label_line_set_line_width (new_lline, line_width);
156 gl_label_line_set_line_color (new_lline, line_color);
158 gl_debug (DEBUG_LABEL, "END");
164 /*****************************************************************************/
165 /* Set object params. */
166 /*****************************************************************************/
168 gl_label_line_set_line_width (glLabelLine *lline,
171 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
173 if ( lline->private->line_width != line_width ) {
174 lline->private->line_width = line_width;
175 gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
180 gl_label_line_set_line_color (glLabelLine *lline,
183 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
185 if ( lline->private->line_color != line_color ) {
186 lline->private->line_color = line_color;
187 gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
192 /*****************************************************************************/
193 /* Get object params. */
194 /*****************************************************************************/
196 gl_label_line_get_line_width (glLabelLine *lline)
198 g_return_val_if_fail (lline && GL_IS_LABEL_LINE (lline), 0.0);
200 return lline->private->line_width;
204 gl_label_line_get_line_color (glLabelLine *lline)
206 g_return_val_if_fail (lline && GL_IS_LABEL_LINE (lline), 0);
208 return lline->private->line_color;