3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of libglabels.
7 * libglabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * libglabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
25 #include <glib/gi18n.h>
29 #include <sys/types.h>
31 #include "libglabels-private.h"
36 /*===========================================*/
38 /*===========================================*/
41 /*===========================================*/
43 /*===========================================*/
46 /*===========================================*/
47 /* Local function prototypes */
48 /*===========================================*/
50 static gint compare_origins (gconstpointer a,
54 /*===========================================*/
56 /*===========================================*/
60 * @brand: Template brand
61 * @part: Template part name/number
62 * @description: Template descriptions
63 * @paper_id: Page size id
64 * @page_width: Page width in points, set to zero unless paper_id="Other"
65 * @page_height: Page height in points, set to zero unless paper_id="Other"
67 * Create a new template structure, with the given top-level attributes. The
68 * created template will have no initial aliases, categories, or frames
69 * associated with it. See lgl_template_add_alias(), lgl_template_add_category(),
70 * and lgl_template_add_frame() to add these.
72 * Returns: pointer to a newly allocated #lglTemplate structure.
76 lgl_template_new (const gchar *brand,
78 const gchar *description,
79 const gchar *paper_id,
83 lglTemplate *template;
84 lglTemplateAlias *alias;
86 template = g_new0 (lglTemplate,1);
88 template->brand = g_strdup (brand);
89 template->part = g_strdup (part);
90 template->description = g_strdup (description);
91 template->paper_id = g_strdup (paper_id);
92 template->page_width = page_width;
93 template->page_height = page_height;
95 /* Always include primary name in alias list. */
96 template->aliases = NULL;
97 alias = lgl_template_alias_new (brand, part);
98 lgl_template_add_alias (template, alias);
105 * lgl_template_new_from_equiv:
106 * @brand: Template brand
107 * @part: Template part name/number
108 * @equiv_part: Name of equivalent part to base template on
110 * Create a new template structure based on an existing template. The
111 * created template will be a duplicate of the original template, except with
112 * the new part name/number.
114 * Returns: pointer to a newly allocated #lglTemplate structure.
118 lgl_template_new_from_equiv (const gchar *brand,
120 const gchar *equiv_part)
122 lglTemplate *template;
124 lglTemplateAlias *alias;
126 template = lgl_db_lookup_template_from_brand_part (brand, equiv_part);
129 g_free (template->part);
130 g_free (template->equiv_part);
132 template->part = g_strdup (part);
133 template->equiv_part = g_strdup (equiv_part);
135 for ( p_alias = template->aliases; p_alias != NULL; p_alias = p_alias->next )
137 alias = (lglTemplateAlias *)p_alias->data;
138 lgl_template_alias_free (alias);
140 g_list_free (template->aliases);
141 template->aliases = NULL;
143 alias = lgl_template_alias_new (brand, part);
144 lgl_template_add_alias (template, alias);
148 g_message (_("Equivalent part (\"%s\") for \"%s\", not previously defined."),
157 * lgl_template_get_name:
158 * @template: Pointer to template structure to test
160 * This function returns the name of the given template. The name is the concetenation
161 * of the brand and part name/number.
163 * Returns: A pointer to a newly allocated name string. Should be freed with g_free().
167 lgl_template_get_name (const lglTemplate *template)
169 g_return_val_if_fail (template, NULL);
171 return g_strdup_printf ("%s %s", template->brand, template->part);
176 * lgl_template_do_templates_match:
177 * @template1: Pointer to 1st template structure to test
178 * @template2: Pointer to 2nd template structure to test
180 * This function tests if the given templates match. This is a simple test that only tests
181 * the brand and part name/number. It does not test if they are actually identical.
183 * Returns: TRUE if the two template matche.
187 lgl_template_do_templates_match (const lglTemplate *template1,
188 const lglTemplate *template2)
190 g_return_val_if_fail (template1, FALSE);
191 g_return_val_if_fail (template2, FALSE);
193 return (UTF8_EQUAL (template1->brand, template2->brand) &&
194 UTF8_EQUAL (template1->part, template2->part));
199 * lgl_template_does_brand_match:
200 * @template: Pointer to template structure to test
201 * @brand: Brand string
203 * This function tests if the brand of the template matches the given brand.
205 * Returns: TRUE if the template matches the given brand.
209 lgl_template_does_brand_match (const lglTemplate *template,
212 g_return_val_if_fail (template, FALSE);
214 /* NULL matches everything. */
220 return UTF8_EQUAL (template->brand, brand);
225 * lgl_template_does_page_size_match:
226 * @template: Pointer to template structure to test
227 * @paper_id: Page size ID string
229 * This function tests if the page size of the template matches the given ID.
231 * Returns: TRUE if the template matches the given page size ID.
235 lgl_template_does_page_size_match (const lglTemplate *template,
236 const gchar *paper_id)
238 g_return_val_if_fail (template, FALSE);
240 /* NULL matches everything. */
241 if (paper_id == NULL)
246 return ASCII_EQUAL(paper_id, template->paper_id);
251 * lgl_template_does_category_match:
252 * @template: Pointer to template structure to test
253 * @category_id: Category ID string
255 * This function tests if the given template belongs to the given category ID.
257 * Returns: TRUE if the template matches the given category ID.
261 lgl_template_does_category_match (const lglTemplate *template,
262 const gchar *category_id)
266 g_return_val_if_fail (template, FALSE);
268 /* NULL matches everything. */
269 if (category_id == NULL)
274 for ( p=template->category_ids; p != NULL; p=p->next )
276 if (ASCII_EQUAL(category_id, p->data))
287 * lgl_template_alias_new:
288 * @brand: Alias brand
289 * @part: Alias part name/number
291 * Create a new template alias structure, with the given brand and part number.
293 * Returns: pointer to a newly allocated #lglTemplateAlias structure.
297 lgl_template_alias_new (const gchar *brand,
300 lglTemplateAlias *alias;
302 alias = g_new0 (lglTemplateAlias,1);
304 alias->brand = g_strdup (brand);
305 alias->part = g_strdup (part);
312 * lgl_template_add_alias:
313 * @template: Pointer to template structure
314 * @alias: Alias string
316 * This function adds the given alias to a templates list of aliases.
320 lgl_template_add_alias (lglTemplate *template,
321 lglTemplateAlias *alias)
323 g_return_if_fail (template);
324 g_return_if_fail (alias);
326 template->aliases = g_list_append (template->aliases, alias);
331 * lgl_template_add_frame:
332 * @template: Pointer to template structure
333 * @frame: Pointer to frame structure
335 * This function adds the given frame structure to the template. Once added,
336 * the frame structure belongs to the given template; do not attempt to free
339 * Note: Currently glabels only supports a single frame per template.
343 lgl_template_add_frame (lglTemplate *template,
344 lglTemplateFrame *frame)
346 g_return_if_fail (template);
347 g_return_if_fail (frame);
349 template->frames = g_list_append (template->frames, frame);
354 * lgl_template_add_category:
355 * @template: Pointer to template structure
356 * @category_id: Category ID string
358 * This function adds the given category ID to a templates category list.
362 lgl_template_add_category (lglTemplate *template,
363 const gchar *category_id)
365 g_return_if_fail (template);
366 g_return_if_fail (category_id);
368 template->category_ids = g_list_append (template->category_ids,
369 g_strdup (category_id));
374 * lgl_template_frame_rect_new:
375 * @id: ID of frame. (This should currently always be "0").
376 * @w: width of frame in points.
377 * @h: height of frame in points.
378 * @r: radius of rounded corners in points. (Should be 0 for square corners.)
379 * @x_waste: Amount of overprint to allow in the horizontal direction.
380 * @y_waste: Amount of overprint to allow in the vertical direction.
382 * This function creates a new template frame for a rectangular label or card.
384 * Returns: Pointer to newly allocated #lglTemplateFrame structure.
388 lgl_template_frame_rect_new (const gchar *id,
395 lglTemplateFrame *frame;
397 frame = g_new0 (lglTemplateFrame, 1);
399 frame->shape = LGL_TEMPLATE_FRAME_SHAPE_RECT;
400 frame->rect.id = g_strdup (id);
405 frame->rect.x_waste = x_waste;
406 frame->rect.y_waste = y_waste;
413 * lgl_template_frame_ellipse_new:
414 * @id: ID of frame. (This should currently always be "0").
415 * @w: width of frame in points.
416 * @h: height of frame in points.
417 * @r: radius of rounded corners in points. (Should be 0 for square corners.)
418 * @x_waste: Amount of overprint to allow in the horizontal direction.
419 * @y_waste: Amount of overprint to allow in the vertical direction.
421 * This function creates a new template frame for an elliptical label or card.
423 * Returns: Pointer to newly allocated #lglTemplateFrame structure.
427 lgl_template_frame_ellipse_new (const gchar *id,
432 lglTemplateFrame *frame;
434 frame = g_new0 (lglTemplateFrame, 1);
436 frame->shape = LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE;
437 frame->ellipse.id = g_strdup (id);
439 frame->ellipse.w = w;
440 frame->ellipse.h = h;
441 frame->ellipse.waste = waste;
448 * lgl_template_frame_round_new:
449 * @id: ID of frame. (This should currently always be "0").
450 * @r: radius of label in points.
451 * @waste: Amount of overprint to allow.
453 * This function creates a new template frame for a round label.
455 * Returns: Pointer to newly allocated #lglTemplateFrame structure.
459 lgl_template_frame_round_new (const gchar *id,
463 lglTemplateFrame *frame;
465 frame = g_new0 (lglTemplateFrame, 1);
467 frame->shape = LGL_TEMPLATE_FRAME_SHAPE_ROUND;
468 frame->round.id = g_strdup (id);
471 frame->round.waste = waste;
478 * lgl_template_frame_cd_new:
479 * @id: ID of frame. (This should currently always be "0").
480 * @r1: outer radius of label in points.
481 * @r2: radius of center hole in points.
482 * @w: clip width of frame in points for business card CDs. Should be 0 for no clipping.
483 * @h: clip height of frame in points for business card CDs. Should be 0 for no clipping.
484 * @waste: Amount of overprint to allow.
486 * This function creates a new template frame for a CD/DVD label.
488 * Returns: Pointer to newly allocated #lglTemplateFrame structure.
492 lgl_template_frame_cd_new (const gchar *id,
499 lglTemplateFrame *frame;
501 frame = g_new0 (lglTemplateFrame, 1);
503 frame->shape = LGL_TEMPLATE_FRAME_SHAPE_CD;
504 frame->cd.id = g_strdup (id);
510 frame->cd.waste = waste;
517 * lgl_template_frame_get_size:
518 * @frame: #lglTemplateFrame structure to query
519 * @w: pointer to location to receive width of frame
520 * @h: pointer to location to receive height of frame
522 * Get size (width and height) of given #lglTemplateFrame in points.
526 lgl_template_frame_get_size (const lglTemplateFrame *frame,
530 g_return_if_fail (frame);
532 switch (frame->shape) {
533 case LGL_TEMPLATE_FRAME_SHAPE_RECT:
537 case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
538 *w = frame->ellipse.w;
539 *h = frame->ellipse.h;
541 case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
542 *w = 2.0 * frame->round.r;
543 *h = 2.0 * frame->round.r;
545 case LGL_TEMPLATE_FRAME_SHAPE_CD:
546 if (frame->cd.w == 0.0) {
547 *w = 2.0 * frame->cd.r1;
551 if (frame->cd.h == 0.0) {
552 *h = 2.0 * frame->cd.r1;
566 * lgl_template_frame_get_n_labels:
567 * @frame: #lglTemplateFrame structure to query
569 * Get total number of labels per sheet corresponding to the given frame.
571 * Returns: number of labels per sheet.
575 lgl_template_frame_get_n_labels (const lglTemplateFrame *frame)
579 lglTemplateLayout *layout;
581 g_return_val_if_fail (frame, 0);
583 for ( p=frame->all.layouts; p != NULL; p=p->next ) {
584 layout = (lglTemplateLayout *)p->data;
586 n_labels += layout->nx * layout->ny;
594 * lgl_template_frame_get_origins:
595 * @frame: #lglTemplateFrame structure to query
597 * Get an array of label origins for the given frame. These origins represent the
598 * upper left hand corner of each label on a page corresponding to the given frame.
599 * The origins will be ordered geometrically left to right and then top to bottom.
600 * The array should be freed using g_free().
602 * Returns: A newly allocated array of #lglTemplateOrigin structures.
606 lgl_template_frame_get_origins (const lglTemplateFrame *frame)
608 gint i_label, n_labels, ix, iy;
609 lglTemplateOrigin *origins;
611 lglTemplateLayout *layout;
613 g_return_val_if_fail (frame, NULL);
615 n_labels = lgl_template_frame_get_n_labels (frame);
616 origins = g_new0 (lglTemplateOrigin, n_labels);
619 for ( p=frame->all.layouts; p != NULL; p=p->next ) {
620 layout = (lglTemplateLayout *)p->data;
622 for (iy = 0; iy < layout->ny; iy++) {
623 for (ix = 0; ix < layout->nx; ix++, i_label++) {
624 origins[i_label].x = ix*layout->dx + layout->x0;
625 origins[i_label].y = iy*layout->dy + layout->y0;
630 g_qsort_with_data (origins, n_labels, sizeof(lglTemplateOrigin),
631 compare_origins, NULL);
638 * lgl_template_frame_add_layout:
639 * @frame: Pointer to template frame to add layout to.
640 * @layout: Pointer to layout structure to add to frame.
642 * This function adds a layout structure to the given template frame.
646 lgl_template_frame_add_layout (lglTemplateFrame *frame,
647 lglTemplateLayout *layout)
649 g_return_if_fail (frame);
650 g_return_if_fail (layout);
652 frame->all.layouts = g_list_append (frame->all.layouts, layout);
657 * lgl_template_frame_add_markup:
658 * @frame: Pointer to template frame to add markup to.
659 * @markup: Pointer to markup structure to add to frame.
661 * This function adds a markup structure to the given template frame.
665 lgl_template_frame_add_markup (lglTemplateFrame *frame,
666 lglTemplateMarkup *markup)
668 g_return_if_fail (frame);
669 g_return_if_fail (markup);
671 frame->all.markups = g_list_append (frame->all.markups, markup);
676 * lgl_template_layout_new:
677 * @nx: Number of labels across.
678 * @ny: Number of labels down.
679 * @x0: X coordinate of the top-left corner of the top-left label in the layout in points.
680 * @y0: Y coordinate of the top-left corner of the top-left label in the layout in points.
681 * @dx: Horizontal pitch in points. This is the distance from left-edge to left-edge.
682 * @dy: Vertical pitch in points. This is the distance from top-edge to top-edge.
684 * This function creates a new layout structure with the given parameters.
686 * Returns: a newly allocated #lglTemplateLayout structure.
690 lgl_template_layout_new (gint nx,
697 lglTemplateLayout *layout;
699 layout = g_new0 (lglTemplateLayout, 1);
713 * lgl_template_markup_margin_new:
714 * @size: margin size in points.
716 * This function creates a new margin markup structure.
718 * Returns: a newly allocated #lglTemplateMarkup structure.
722 lgl_template_markup_margin_new (gdouble size)
724 lglTemplateMarkup *markup;
726 markup = g_new0 (lglTemplateMarkup, 1);
728 markup->type = LGL_TEMPLATE_MARKUP_MARGIN;
729 markup->margin.size = size;
736 * lgl_template_markup_line_new:
737 * @x1: x coordinate of first endpoint.
738 * @y1: y coordinate of first endpoint.
739 * @x2: x coordinate of second endpoint.
740 * @y2: y coordinate of second endpoint.
742 * This function creates a new line markup structure.
744 * Returns: a newly allocated #lglTemplateMarkup structure.
748 lgl_template_markup_line_new (gdouble x1,
753 lglTemplateMarkup *markup;
755 markup = g_new0 (lglTemplateMarkup, 1);
757 markup->type = LGL_TEMPLATE_MARKUP_LINE;
758 markup->line.x1 = x1;
759 markup->line.y1 = y1;
760 markup->line.x2 = x2;
761 markup->line.y2 = y2;
768 * lgl_template_markup_circle_new:
769 * @x0: x coordinate of center of circle.
770 * @y0: y coordinate of center of circle.
771 * @r: radius of circle.
773 * This function creates a new circle markup structure.
775 * Returns: a newly allocated #lglTemplateMarkup structure.
779 lgl_template_markup_circle_new (gdouble x0,
783 lglTemplateMarkup *markup;
785 markup = g_new0 (lglTemplateMarkup, 1);
787 markup->type = LGL_TEMPLATE_MARKUP_CIRCLE;
788 markup->circle.x0 = x0;
789 markup->circle.y0 = y0;
790 markup->circle.r = r;
797 * lgl_template_markup_rect_new:
798 * @x1: x coordinate of top-left corner of rectangle.
799 * @y1: y coordinate of top-left corner of rectangle.
800 * @w: width of rectangle.
801 * @h: height of rectangle.
802 * @r: radius of rounded corner.
804 * This function creates a new rectangle markup structure.
806 * Returns: a newly allocated #lglTemplateMarkup structure.
810 lgl_template_markup_rect_new (gdouble x1,
816 lglTemplateMarkup *markup;
818 markup = g_new0 (lglTemplateMarkup, 1);
820 markup->type = LGL_TEMPLATE_MARKUP_RECT;
821 markup->rect.x1 = x1;
822 markup->rect.y1 = y1;
832 * lgl_template_markup_ellipse_new:
833 * @x1: x coordinate of top-left corner of ellipse.
834 * @y1: y coordinate of top-left corner of ellipse.
835 * @w: width of ellipse.
836 * @h: height of ellipse.
838 * This function creates a new ellipse markup structure.
840 * Returns: a newly allocated #lglTemplateMarkup structure.
844 lgl_template_markup_ellipse_new (gdouble x1,
849 lglTemplateMarkup *markup;
851 markup = g_new0 (lglTemplateMarkup, 1);
853 markup->type = LGL_TEMPLATE_MARKUP_ELLIPSE;
854 markup->ellipse.x1 = x1;
855 markup->ellipse.y1 = y1;
856 markup->ellipse.w = w;
857 markup->ellipse.h = h;
865 * @orig_template: Template to duplicate.
867 * This function duplicates a template structure.
869 * Returns: a newly allocated #lglTemplate structure.
873 lgl_template_dup (const lglTemplate *orig_template)
875 lglTemplate *template;
876 lglTemplateAlias *alias;
878 lglTemplateFrame *frame;
880 g_return_val_if_fail (orig_template, NULL);
882 template = lgl_template_new (orig_template->brand,
884 orig_template->description,
885 orig_template->paper_id,
886 orig_template->page_width,
887 orig_template->page_height);
889 template->equiv_part = g_strdup (orig_template->equiv_part);
890 template->product_url = g_strdup (orig_template->product_url);
892 for ( p=orig_template->aliases; p != NULL; p=p->next )
894 alias = (lglTemplateAlias *)p->data;
896 if ( !(UTF8_EQUAL (template->brand, alias->brand) &&
897 UTF8_EQUAL (template->part, alias->part)) )
899 lgl_template_add_alias (template, lgl_template_alias_dup (alias));
904 for ( p=orig_template->category_ids; p != NULL; p=p->next )
906 lgl_template_add_category (template, p->data);
909 for ( p=orig_template->frames; p != NULL; p=p->next )
911 frame = (lglTemplateFrame *)p->data;
913 lgl_template_add_frame (template, lgl_template_frame_dup (frame));
922 * @template: Template to free.
924 * This function frees all memory associated with given template structure.
928 lgl_template_free (lglTemplate *template)
931 lglTemplateFrame *frame;
933 if ( template != NULL ) {
935 g_free (template->brand);
936 template->brand = NULL;
938 g_free (template->part);
939 template->part = NULL;
941 g_free (template->description);
942 template->description = NULL;
944 g_free (template->paper_id);
945 template->paper_id = NULL;
947 for ( p=template->aliases; p != NULL; p=p->next ) {
949 lgl_template_alias_free (p->data);
953 g_list_free (template->aliases);
954 template->aliases = NULL;
956 for ( p=template->category_ids; p != NULL; p=p->next ) {
962 g_list_free (template->category_ids);
963 template->category_ids = NULL;
965 for ( p=template->frames; p != NULL; p=p->next ) {
967 frame = (lglTemplateFrame *)p->data;
969 lgl_template_frame_free (frame);
972 g_list_free (template->frames);
973 template->frames = NULL;
983 * lgl_template_alias_dup:
984 * @orig_alias: Alias to duplicate.
986 * This function duplicates a template alias structure.
988 * Returns: a newly allocated #lglTemplateAlias structure.
992 lgl_template_alias_dup (const lglTemplateAlias *orig_alias)
994 g_return_val_if_fail (orig_alias, NULL);
996 return lgl_template_alias_new (orig_alias->brand, orig_alias->part);
1001 * lgl_template_alias_free:
1002 * @alias: Alias to free.
1004 * This function frees all memory associated with given template alias structure.
1008 lgl_template_alias_free (lglTemplateAlias *alias)
1011 if ( alias != NULL )
1013 g_free (alias->brand);
1014 alias->brand = NULL;
1016 g_free (alias->part);
1025 * lgl_template_frame_dup:
1026 * @orig_frame: Frame to duplicate.
1028 * This function duplicates a template frame structure.
1030 * Returns: a newly allocated #lglTemplateFrame structure.
1034 lgl_template_frame_dup (const lglTemplateFrame *orig_frame)
1036 lglTemplateFrame *frame;
1038 lglTemplateLayout *layout;
1039 lglTemplateMarkup *markup;
1041 g_return_val_if_fail (orig_frame, NULL);
1043 switch (orig_frame->shape) {
1045 case LGL_TEMPLATE_FRAME_SHAPE_RECT:
1047 lgl_template_frame_rect_new (orig_frame->all.id,
1051 orig_frame->rect.x_waste,
1052 orig_frame->rect.y_waste);
1055 case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
1057 lgl_template_frame_ellipse_new (orig_frame->all.id,
1058 orig_frame->ellipse.w,
1059 orig_frame->ellipse.h,
1060 orig_frame->ellipse.waste);
1063 case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
1065 lgl_template_frame_round_new (orig_frame->all.id,
1066 orig_frame->round.r,
1067 orig_frame->round.waste);
1070 case LGL_TEMPLATE_FRAME_SHAPE_CD:
1072 lgl_template_frame_cd_new (orig_frame->all.id,
1077 orig_frame->cd.waste);
1085 for ( p=orig_frame->all.layouts; p != NULL; p=p->next ) {
1087 layout = (lglTemplateLayout *)p->data;
1089 lgl_template_frame_add_layout (frame, lgl_template_layout_dup (layout));
1092 for ( p=orig_frame->all.markups; p != NULL; p=p->next ) {
1094 markup = (lglTemplateMarkup *)p->data;
1096 lgl_template_frame_add_markup (frame, lgl_template_markup_dup (markup));
1104 * lgl_template_frame_free:
1105 * @frame: Frame to free.
1107 * This function frees all memory associated with given template frame structure.
1111 lgl_template_frame_free (lglTemplateFrame *frame)
1114 lglTemplateLayout *layout;
1115 lglTemplateMarkup *markup;
1117 if ( frame != NULL ) {
1119 g_free (frame->all.id);
1120 frame->all.id = NULL;
1122 for ( p=frame->all.layouts; p != NULL; p=p->next ) {
1124 layout = (lglTemplateLayout *)p->data;
1126 lgl_template_layout_free (layout);
1129 g_list_free (frame->all.layouts);
1130 frame->all.layouts = NULL;
1132 for ( p=frame->all.markups; p != NULL; p=p->next ) {
1134 markup = (lglTemplateMarkup *)p->data;
1136 lgl_template_markup_free (markup);
1139 g_list_free (frame->all.markups);
1140 frame->all.markups = NULL;
1150 * lgl_template_layout_dup:
1151 * @orig_layout: Layout to duplicate.
1153 * This function duplicates a template layout structure.
1155 * Returns: a newly allocated #lglTemplateLayout structure.
1159 lgl_template_layout_dup (const lglTemplateLayout *orig_layout)
1161 lglTemplateLayout *layout;
1163 g_return_val_if_fail (orig_layout, NULL);
1165 layout = g_new0 (lglTemplateLayout, 1);
1168 *layout = *orig_layout;
1175 * lgl_template_layout_free:
1176 * @layout: Layout to free.
1178 * This function frees all memory associated with given template layout structure.
1182 lgl_template_layout_free (lglTemplateLayout *layout)
1189 * lgl_template_markup_dup:
1190 * @orig_markup: Markup to duplicate.
1192 * This function duplicates a template markup structure.
1194 * Returns: a newly allocated #lglTemplateMarkup structure.
1198 lgl_template_markup_dup (const lglTemplateMarkup *orig_markup)
1200 lglTemplateMarkup *markup;
1202 g_return_val_if_fail (orig_markup, NULL);
1204 markup = g_new0 (lglTemplateMarkup, 1);
1206 *markup = *orig_markup;
1213 * lgl_template_markup_free:
1214 * @markup: Markup to free.
1216 * This function frees all memory associated with given template markup structure.
1220 lgl_template_markup_free (lglTemplateMarkup *markup)
1227 compare_origins (gconstpointer a,
1231 const lglTemplateOrigin *a_origin = a, *b_origin = b;
1233 if ( a_origin->y < b_origin->y ) {
1235 } else if ( a_origin->y > b_origin->y ) {
1238 if ( a_origin->x < b_origin->x ) {
1240 } else if ( a_origin->x > b_origin->x ) {
1243 return 0; /* hopefully 2 labels won't have the same origin */
1251 * Local Variables: -- emacs
1253 * c-basic-offset: 8 -- emacs
1254 * tab-width: 8 -- emacs
1255 * indent-tabs-mode: nil -- emacs