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);
54 static void copy (glLabelObject *dst_object,
55 glLabelObject *src_object);
57 static void set_line_color (glLabelObject *object,
60 static void set_line_width (glLabelObject *object,
63 static guint get_line_color (glLabelObject *object);
65 static gdouble get_line_width (glLabelObject *object);
69 /*****************************************************************************/
70 /* Boilerplate object stuff. */
71 /*****************************************************************************/
73 gl_label_line_get_type (void)
75 static GType type = 0;
78 static const GTypeInfo info = {
79 sizeof (glLabelLineClass),
82 (GClassInitFunc) gl_label_line_class_init,
87 (GInstanceInitFunc) gl_label_line_instance_init,
91 type = g_type_register_static (GL_TYPE_LABEL_OBJECT,
92 "glLabelLine", &info, 0);
99 gl_label_line_class_init (glLabelLineClass *klass)
101 GObjectClass *object_class = (GObjectClass *) klass;
102 glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
104 parent_class = g_type_class_peek_parent (klass);
106 label_object_class->copy = copy;
107 label_object_class->set_line_color = set_line_color;
108 label_object_class->set_line_width = set_line_width;
109 label_object_class->get_line_color = get_line_color;
110 label_object_class->get_line_width = get_line_width;
112 object_class->finalize = gl_label_line_finalize;
116 gl_label_line_instance_init (glLabelLine *lline)
118 lline->private = g_new0 (glLabelLinePrivate, 1);
122 gl_label_line_finalize (GObject *object)
126 g_return_if_fail (object && GL_IS_LABEL_LINE (object));
128 lline = GL_LABEL_LINE (object);
130 g_free (lline->private);
132 G_OBJECT_CLASS (parent_class)->finalize (object);
135 /*****************************************************************************/
136 /* NEW label "line" object. */
137 /*****************************************************************************/
139 gl_label_line_new (glLabel *label)
143 lline = g_object_new (gl_label_line_get_type(), NULL);
145 gl_label_object_set_parent (GL_LABEL_OBJECT(lline), label);
147 return G_OBJECT (lline);
150 /*****************************************************************************/
151 /* Copy object contents. */
152 /*****************************************************************************/
154 copy (glLabelObject *dst_object,
155 glLabelObject *src_object)
157 glLabelLine *lline = (glLabelLine *)src_object;
158 glLabelLine *new_lline = (glLabelLine *)dst_object;
162 gl_debug (DEBUG_LABEL, "START");
164 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
165 g_return_if_fail (new_lline && GL_IS_LABEL_LINE (new_lline));
167 line_width = get_line_width (src_object);
168 line_color = get_line_color (src_object);
170 set_line_width (dst_object, line_width);
171 set_line_color (dst_object, line_color);
173 gl_debug (DEBUG_LABEL, "END");
177 /*---------------------------------------------------------------------------*/
178 /* PRIVATE. Set line color method. */
179 /*---------------------------------------------------------------------------*/
181 set_line_color (glLabelObject *object,
184 glLabelLine *lline = (glLabelLine *)object;
186 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
188 if ( lline->private->line_color != line_color ) {
189 lline->private->line_color = line_color;
190 gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
194 /*---------------------------------------------------------------------------*/
195 /* PRIVATE. Set line width method. */
196 /*---------------------------------------------------------------------------*/
198 set_line_width (glLabelObject *object,
201 glLabelLine *lline = (glLabelLine *)object;
203 g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
205 if ( lline->private->line_width != line_width ) {
206 lline->private->line_width = line_width;
207 gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
212 /*---------------------------------------------------------------------------*/
213 /* PRIVATE. Get line color method. */
214 /*---------------------------------------------------------------------------*/
216 get_line_width (glLabelObject *object)
218 glLabelLine *lline = (glLabelLine *)object;
220 g_return_val_if_fail (lline && GL_IS_LABEL_LINE (lline), 0.0);
222 return lline->private->line_width;
225 /*---------------------------------------------------------------------------*/
226 /* PRIVATE. Get line width method. */
227 /*---------------------------------------------------------------------------*/
229 get_line_color (glLabelObject *object)
231 glLabelLine *lline = (glLabelLine *)object;
233 g_return_val_if_fail (lline && GL_IS_LABEL_LINE (lline), 0);
235 return lline->private->line_color;