[AdgLineStyle] Removed order bug
[adg.git] / adg / adg-title-block.c
blobad6d973e4839bbd1564e43b00c67033fc814d2ea
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 /**
22 * SECTION:adg-title-block
23 * @short_description: A title block entity
25 * Title blocks are commonly used in technical drawings to include
26 * additional information not strictly related to physical dimensions,
27 * such as title, material of the represented part, special treatments,
28 * date and scale etc.
30 * Actually this entity is only a place-holder: it will be implemented
31 * properly in a 0.6.x release, after having AdgToyTable in place.
32 **/
34 /**
35 * AdgTitleBlock:
37 * All fields are privates and should not be used directly.
38 * Use its public methods instead.
39 **/
42 #include "adg-title-block.h"
43 #include "adg-title-block-private.h"
44 #include "adg-intl.h"
46 #define PARENT_OBJECT_CLASS ((GObjectClass *) adg_title_block_parent_class)
47 #define PARENT_ENTITY_CLASS ((AdgEntityClass *) adg_title_block_parent_class)
50 enum {
51 PROP_0,
52 PROP_TITLE,
53 PROP_DRAWING,
54 PROP_SIZE,
55 PROP_SCALE,
56 PROP_AUTHOR,
57 PROP_DATE,
58 PROP_LOGO,
59 PROP_PROJECTION
63 static void dispose (GObject *object);
64 static void finalize (GObject *object);
65 static void get_property (GObject *object,
66 guint prop_id,
67 GValue *value,
68 GParamSpec *pspec);
69 static void set_property (GObject *object,
70 guint prop_id,
71 const GValue *value,
72 GParamSpec *pspec);
73 static AdgTable * get_table (AdgTitleBlock *title_block);
74 static gboolean set_title (AdgTitleBlock *title_block,
75 const gchar *title);
76 static gboolean set_drawing (AdgTitleBlock *title_block,
77 const gchar *drawing);
78 static gboolean set_size (AdgTitleBlock *title_block,
79 const gchar *size);
80 static gboolean set_scale (AdgTitleBlock *title_block,
81 const gchar *scale);
82 static gboolean set_author (AdgTitleBlock *title_block,
83 const gchar *author);
84 static gboolean set_date (AdgTitleBlock *title_block,
85 const gchar *date);
86 static gboolean set_logo (AdgTitleBlock *title_block,
87 AdgEntity *logo);
88 static gboolean set_projection (AdgTitleBlock *title_block,
89 AdgEntity *projection);
92 G_DEFINE_TYPE(AdgTitleBlock, adg_title_block, ADG_TYPE_TABLE);
95 static void
96 adg_title_block_class_init(AdgTitleBlockClass *klass)
98 GObjectClass *gobject_class;
99 GParamSpec *param;
101 gobject_class = (GObjectClass *) klass;
103 g_type_class_add_private(klass, sizeof(AdgTitleBlockPrivate));
105 gobject_class->dispose = dispose;
106 gobject_class->finalize = finalize;
107 gobject_class->set_property = set_property;
108 gobject_class->get_property = get_property;
110 param = g_param_spec_string("title",
111 P_("Title"),
112 P_("A descriptive title of the drawing"),
113 NULL,
114 G_PARAM_READWRITE);
115 g_object_class_install_property(gobject_class, PROP_TITLE, param);
117 param = g_param_spec_string("drawing",
118 P_("Drawing Name"),
119 P_("The name of the drawing: the ADG canvas does not make any assumtpion on this text string"),
120 NULL,
121 G_PARAM_READWRITE);
122 g_object_class_install_property(gobject_class, PROP_DRAWING, param);
124 param = g_param_spec_string("size",
125 P_("Media Size"),
126 P_("The media size to be used to print the drawing, usually something like \"A3\" or \"Letter\""),
127 NULL,
128 G_PARAM_READWRITE);
129 g_object_class_install_property(gobject_class, PROP_SIZE, param);
131 param = g_param_spec_string("scale",
132 P_("Scale"),
133 P_("The scale of the drawing, if it makes sense"),
134 NULL,
135 G_PARAM_READWRITE);
136 g_object_class_install_property(gobject_class, PROP_SCALE, param);
138 param = g_param_spec_string("author",
139 P_("Author"),
140 P_("Name and last name of the author of the drawing"),
141 NULL,
142 G_PARAM_READWRITE);
143 g_object_class_install_property(gobject_class, PROP_AUTHOR, param);
145 param = g_param_spec_string("date",
146 P_("Date"),
147 P_("The date this drawing has been generated: setting it to an empty string will fallback to today in the preferred representation for the current locale"),
148 NULL,
149 G_PARAM_READWRITE);
150 g_object_class_install_property(gobject_class, PROP_DATE, param);
152 param = g_param_spec_object("logo",
153 P_("Logo"),
154 P_("An entity to be displayed in the title block as the logo of the owner: the containing cell has a 1:1 ratio"),
155 ADG_TYPE_ENTITY,
156 G_PARAM_READWRITE);
157 g_object_class_install_property(gobject_class, PROP_LOGO, param);
159 param = g_param_spec_object("projection",
160 P_("Projection Scheme"),
161 P_("The entity usually reserved to identify the projection scheme adopted by this drawing"),
162 ADG_TYPE_ENTITY,
163 G_PARAM_READWRITE);
164 g_object_class_install_property(gobject_class, PROP_PROJECTION, param);
167 static void
168 adg_title_block_init(AdgTitleBlock *title_block)
170 AdgTitleBlockPrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(title_block,
171 ADG_TYPE_TITLE_BLOCK,
172 AdgTitleBlockPrivate);
173 data->author = NULL;
174 data->title = NULL;
175 data->drawing = NULL;
176 data->size = NULL;
177 data->scale = NULL;
178 data->author = NULL;
179 data->date = NULL;
180 data->projection = NULL;
182 title_block->data = data;
185 static void
186 dispose(GObject *object)
188 AdgTitleBlockPrivate *data = ((AdgTitleBlock *) object)->data;
190 if (data->logo != NULL) {
191 g_object_unref(data->logo);
192 data->logo = NULL;
195 if (data->projection != NULL) {
196 g_object_unref(data->projection);
197 data->projection = NULL;
200 if (PARENT_OBJECT_CLASS->dispose != NULL)
201 PARENT_OBJECT_CLASS->dispose(object);
204 static void
205 finalize(GObject *object)
207 AdgTitleBlockPrivate *data = ((AdgTitleBlock *) object)->data;
209 g_free(data->title);
210 g_free(data->drawing);
211 g_free(data->size);
212 g_free(data->scale);
213 g_free(data->author);
214 g_free(data->date);
216 if (PARENT_OBJECT_CLASS->finalize != NULL)
217 PARENT_OBJECT_CLASS->finalize(object);
220 static void
221 get_property(GObject *object,
222 guint prop_id, GValue *value, GParamSpec *pspec)
224 AdgTitleBlockPrivate *data = ((AdgTitleBlock *) object)->data;
226 switch (prop_id) {
227 case PROP_TITLE:
228 g_value_set_string(value, data->title);
229 break;
230 case PROP_DRAWING:
231 g_value_set_string(value, data->drawing);
232 break;
233 case PROP_SIZE:
234 g_value_set_string(value, data->size);
235 break;
236 case PROP_SCALE:
237 g_value_set_string(value, data->scale);
238 break;
239 case PROP_AUTHOR:
240 g_value_set_string(value, data->author);
241 break;
242 case PROP_DATE:
243 g_value_set_string(value, data->date);
244 break;
245 case PROP_LOGO:
246 g_value_set_object(value, data->logo);
247 break;
248 case PROP_PROJECTION:
249 g_value_set_object(value, data->projection);
250 break;
251 default:
252 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
253 break;
257 static void
258 set_property(GObject *object,
259 guint prop_id, const GValue *value, GParamSpec *pspec)
261 AdgTitleBlock *title_block = (AdgTitleBlock *) object;
263 switch (prop_id) {
264 case PROP_TITLE:
265 set_title(title_block, g_value_get_string(value));
266 break;
267 case PROP_DRAWING:
268 set_drawing(title_block, g_value_get_string(value));
269 break;
270 case PROP_SIZE:
271 set_size(title_block, g_value_get_string(value));
272 break;
273 case PROP_SCALE:
274 set_scale(title_block, g_value_get_string(value));
275 break;
276 case PROP_AUTHOR:
277 set_author(title_block, g_value_get_string(value));
278 break;
279 case PROP_DATE:
280 set_date(title_block, g_value_get_string(value));
281 break;
282 case PROP_LOGO:
283 set_logo(title_block, g_value_get_object(value));
284 break;
285 case PROP_PROJECTION:
286 set_projection(title_block, g_value_get_object(value));
287 break;
288 default:
289 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
290 break;
296 * adg_title_block_new:
298 * Creates a new empty title block entity. The #AdgEntity:local-method
299 * property is set by default to #ADG_MIX_DISABLED, that is the
300 * title block is not subject to any local transformations.
302 * Returns: the newly created title block entity
304 AdgTitleBlock *
305 adg_title_block_new(void)
307 return g_object_new(ADG_TYPE_TITLE_BLOCK,
308 "local-method", ADG_MIX_DISABLED, NULL);
312 * adg_title_block_get_title:
313 * @title_block: an #AdgTitleBlock entity
315 * Gets the descriptive title associated to this title block.
316 * The returned string is owned by @title_block and should not
317 * be modifed or freed.
319 * Returns: the title or %NULL on no title or errors
321 const gchar *
322 adg_title_block_get_title(AdgTitleBlock *title_block)
324 AdgTitleBlockPrivate *data;
326 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
328 data = title_block->data;
330 return data->title;
334 * adg_title_block_set_title:
335 * @title_block: an #AdgTitleBlock entity
336 * @title: the new title
338 * Sets a new title on the title block.
340 void
341 adg_title_block_set_title(AdgTitleBlock *title_block, const gchar *title)
343 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
345 if (set_title(title_block, title))
346 g_object_notify((GObject *) title_block, "title");
350 * adg_title_block_get_drawing:
351 * @title_block: an #AdgTitleBlock entity
353 * Gets the drawing name, commonly used to specify the file name.
354 * The returned string is owned by @title_block and should not
355 * be modifed or freed.
357 * Returns: the drawing name or %NULL on no name or errors
359 const gchar *
360 adg_title_block_get_drawing(AdgTitleBlock *title_block)
362 AdgTitleBlockPrivate *data;
364 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
366 data = title_block->data;
368 return data->drawing;
372 * adg_title_block_set_drawing:
373 * @title_block: an #AdgTitleBlock entity
374 * @drawing: the new drawing name
376 * Sets a new drawing name on the title block.
378 void
379 adg_title_block_set_drawing(AdgTitleBlock *title_block, const gchar *drawing)
381 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
383 if (set_drawing(title_block, drawing))
384 g_object_notify((GObject *) title_block, "drawing");
388 * adg_title_block_get_size:
389 * @title_block: an #AdgTitleBlock entity
391 * Gets the media size (a descriptive name) where this drawing will
392 * be printed. Usually contains something like "A4" or "Letter".
393 * The returned string is owned by @title_block and should not
394 * be modifed or freed.
396 * Returns: the size or %NULL on no size or errors
398 const gchar *
399 adg_title_block_get_size(AdgTitleBlock *title_block)
401 AdgTitleBlockPrivate *data;
403 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
405 data = title_block->data;
407 return data->size;
411 * adg_title_block_set_size:
412 * @title_block: an #AdgTitleBlock entity
413 * @size: the new size
415 * Sets a new size on the title block.
417 void
418 adg_title_block_set_size(AdgTitleBlock *title_block, const gchar *size)
420 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
422 if (set_size(title_block, size))
423 g_object_notify((GObject *) title_block, "size");
427 * adg_title_block_get_scale:
428 * @title_block: an #AdgTitleBlock entity
430 * Gets the scale descriptive name of the drawing.
432 * Returns: the scale text or %NULL on no scale or errors
434 const gchar *
435 adg_title_block_get_scale(AdgTitleBlock *title_block)
437 AdgTitleBlockPrivate *data;
439 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
441 data = title_block->data;
443 return data->scale;
447 * adg_title_block_set_scale:
448 * @title_block: an #AdgTitleBlock entity
449 * @scale: the new scale
451 * Sets a new scale on the title block.
453 void
454 adg_title_block_set_scale(AdgTitleBlock *title_block, const gchar *scale)
456 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
458 if (set_scale(title_block, scale))
459 g_object_notify((GObject *) title_block, "scale");
463 * adg_title_block_get_author:
464 * @title_block: an #AdgTitleBlock entity
466 * Gets the author's name of the drawing.
468 * Returns: the author or %NULL on no author or errors
470 const gchar *
471 adg_title_block_get_author(AdgTitleBlock *title_block)
473 AdgTitleBlockPrivate *data;
475 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
477 data = title_block->data;
479 return data->author;
483 * adg_title_block_set_author:
484 * @title_block: an #AdgTitleBlock entity
485 * @author: the new author
487 * Sets a new author on the title block.
489 void
490 adg_title_block_set_author(AdgTitleBlock *title_block, const gchar *author)
492 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
494 if (set_author(title_block, author))
495 g_object_notify((GObject *) title_block, "author");
499 * adg_title_block_get_date:
500 * @title_block: an #AdgTitleBlock entity
502 * Gets the date of the rendering set on @title_block.
504 * Returns: the date or %NULL on no date or errors
506 const gchar *
507 adg_title_block_get_date(AdgTitleBlock *title_block)
509 AdgTitleBlockPrivate *data;
511 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
513 data = title_block->data;
515 return data->date;
519 * adg_title_block_set_date:
520 * @title_block: an #AdgTitleBlock entity
521 * @date: the new date
523 * Sets a new date on the title block. By default the date is set
524 * to %NULL (so no date will be rendered) but setting it to an
525 * empty string (that is, %"") will implicitely set the date to
526 * today, by using the preferred representation for the current
527 * local. This will give a result roughly equivalent to:
529 * |[
530 * strftime(buffer, sizeof(buffer), "%x", now);
531 * ]|
533 void
534 adg_title_block_set_date(AdgTitleBlock *title_block, const gchar *date)
536 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
538 if (set_date(title_block, date))
539 g_object_notify((GObject *) title_block, "date");
543 * adg_title_block_get_logo:
544 * @title_block: an #AdgTitleBlock entity
546 * Gets the logo bound to this title block.
547 * The returned object is owned by @title_block and should not
548 * be unreferenced although can be freely modified.
550 * Returns: the logo or %NULL on no logo or errors
552 AdgEntity *
553 adg_title_block_get_logo(AdgTitleBlock *title_block)
555 AdgTitleBlockPrivate *data;
557 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
559 data = title_block->data;
561 return data->logo;
565 * adg_title_block_set_logo:
566 * @title_block: an #AdgTitleBlock entity
567 * @logo: the new logo
569 * Sets a new logo on the title block. This function will add
570 * a reference to @logo, removing the eventual reference held
571 * to the old logo, hence possibly destroying the old endity.
573 * The space reserved for the logo is 56x56, so try to keep the
574 * new logo near this size or scale it accordingly.
576 void
577 adg_title_block_set_logo(AdgTitleBlock *title_block, AdgEntity *logo)
579 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
581 if (set_logo(title_block, logo))
582 g_object_notify((GObject *) title_block, "logo");
586 * adg_title_block_get_projection:
587 * @title_block: an #AdgTitleBlock entity
589 * Gets the projection bound to this title block.
590 * The returned object is owned by @title_block and should not
591 * be unreferenced although can be freely modified.
593 * Returns: the projection or %NULL on no projection or errors
595 AdgEntity *
596 adg_title_block_get_projection(AdgTitleBlock *title_block)
598 AdgTitleBlockPrivate *data;
600 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block), NULL);
602 data = title_block->data;
604 return data->projection;
608 * adg_title_block_set_projection:
609 * @title_block: an #AdgTitleBlock entity
610 * @projection: the new projection
612 * Sets a new projection symbol on the title block. This function
613 * will add a reference to @projection, removing the eventual
614 * reference held to the old symbol, hence possibly destroying
615 * the old endity.
617 * The space reserved for the projection is 56x56, so try to keep the
618 * new projection near this size or scale it accordingly.
620 void
621 adg_title_block_set_projection(AdgTitleBlock *title_block,
622 AdgEntity *projection)
624 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block));
626 if (set_projection(title_block, projection))
627 g_object_notify((GObject *) title_block, "projection");
631 static AdgTable *
632 get_table(AdgTitleBlock *title_block)
634 AdgTable *table = (AdgTable *) title_block;
636 if (adg_table_get_n_rows(table) == 0) {
637 AdgTableRow *row;
638 AdgTableCell *cell;
640 /* First row */
641 row = adg_table_row_new(table);
643 cell = adg_table_cell_new(row, 62);
645 cell = adg_table_cell_new(row, 200);
646 adg_table_cell_set_name(cell, "title");
647 adg_table_cell_set_text_title(cell, _("TITLE"));
648 adg_table_cell_switch_frame(cell, TRUE);
650 /* Second row */
651 row = adg_table_row_new(table);
653 cell = adg_table_cell_new(row, 62);
654 adg_table_cell_set_name(cell, "logo");
656 cell = adg_table_cell_new(row, 40);
657 adg_table_cell_set_name(cell, "size");
658 adg_table_cell_set_text_title(cell, _("SIZE"));
659 adg_table_cell_switch_frame(cell, TRUE);
661 cell = adg_table_cell_new(row, 60);
662 adg_table_cell_set_name(cell, "scale");
663 adg_table_cell_set_text_title(cell, _("SCALE"));
664 adg_table_cell_switch_frame(cell, TRUE);
666 cell = adg_table_cell_new(row, 100);
667 adg_table_cell_set_name(cell, "drawing");
668 adg_table_cell_set_text_title(cell, _("DRAWING"));
669 adg_table_cell_switch_frame(cell, TRUE);
671 /* Third row */
672 row = adg_table_row_new(table);
674 cell = adg_table_cell_new(row, 62);
675 adg_table_cell_set_name(cell, "projection");
676 adg_table_cell_switch_frame(cell, TRUE);
678 cell = adg_table_cell_new(row, 100);
679 adg_table_cell_set_name(cell, "author");
680 adg_table_cell_set_text_title(cell, _("AUTHOR"));
681 adg_table_cell_switch_frame(cell, TRUE);
683 cell = adg_table_cell_new(row, 100);
684 adg_table_cell_set_name(cell, "date");
685 adg_table_cell_set_text_title(cell, _("DATE"));
686 adg_table_cell_switch_frame(cell, TRUE);
689 return table;
692 static gboolean
693 set_title(AdgTitleBlock *title_block, const gchar *title)
695 AdgTitleBlockPrivate *data;
696 AdgTable *table;
697 AdgTableCell *cell;
699 data = title_block->data;
701 if (adg_strcmp(title, data->title) == 0)
702 return FALSE;
704 g_free(data->title);
705 data->title = g_strdup(title);
707 table = get_table(title_block);
708 cell = adg_table_get_cell(table, "title");
709 adg_table_cell_set_text_value(cell, data->title);
710 return TRUE;
713 static gboolean
714 set_drawing(AdgTitleBlock *title_block, const gchar *drawing)
716 AdgTitleBlockPrivate *data;
717 AdgTable *table;
718 AdgTableCell *cell;
720 data = title_block->data;
722 if (adg_strcmp(drawing, data->drawing) == 0)
723 return FALSE;
725 g_free(data->drawing);
726 data->drawing = g_strdup(drawing);
728 table = get_table(title_block);
729 cell = adg_table_get_cell(table, "drawing");
730 adg_table_cell_set_text_value(cell, data->drawing);
731 return TRUE;
734 static gboolean
735 set_size(AdgTitleBlock *title_block, const gchar *size)
737 AdgTitleBlockPrivate *data;
738 AdgTable *table;
739 AdgTableCell *cell;
741 data = title_block->data;
743 if (adg_strcmp(size, data->size) == 0)
744 return FALSE;
746 g_free(data->size);
747 data->size = g_strdup(size);
749 table = get_table(title_block);
750 cell = adg_table_get_cell(table, "size");
751 adg_table_cell_set_text_value(cell, data->size);
752 return TRUE;
755 static gboolean
756 set_scale(AdgTitleBlock *title_block, const gchar *scale)
758 AdgTitleBlockPrivate *data;
759 AdgTable *table;
760 AdgTableCell *cell;
762 data = title_block->data;
764 if (adg_strcmp(scale, data->scale) == 0)
765 return FALSE;
767 g_free(data->scale);
768 data->scale = g_strdup(scale);
770 table = get_table(title_block);
771 cell = adg_table_get_cell(table, "scale");
772 adg_table_cell_set_text_value(cell, data->scale);
773 return TRUE;
776 static gboolean
777 set_author(AdgTitleBlock *title_block, const gchar *author)
779 AdgTitleBlockPrivate *data;
780 AdgTable *table;
781 AdgTableCell *cell;
783 data = title_block->data;
785 if (adg_strcmp(author, data->author) == 0)
786 return FALSE;
788 g_free(data->author);
789 data->author = g_strdup(author);
791 table = get_table(title_block);
792 cell = adg_table_get_cell(table, "author");
793 adg_table_cell_set_text_value(cell, data->author);
794 return TRUE;
797 static gboolean
798 set_date(AdgTitleBlock *title_block, const gchar *date)
800 AdgTitleBlockPrivate *data;
801 AdgTable *table;
802 AdgTableCell *cell;
804 data = title_block->data;
806 if (adg_strcmp(date, data->date) == 0)
807 return FALSE;
809 g_free(data->date);
811 if (date != NULL && date[0] == '\0') {
812 /* The date must be automatically updated */
813 GDate *gdate;
814 char buffer[100] = { 0 };
816 gdate = g_date_new();
817 g_date_set_time_t(gdate, time (NULL));
818 g_date_strftime(buffer, sizeof(buffer), "%x", gdate);
819 g_date_free(gdate);
821 data->date = g_strdup(buffer);
822 } else {
823 data->date = g_strdup(date);
826 table = get_table(title_block);
827 cell = adg_table_get_cell(table, "date");
828 adg_table_cell_set_text_value(cell, data->date);
829 return TRUE;
832 static gboolean
833 set_logo(AdgTitleBlock *title_block, AdgEntity *logo)
835 AdgTitleBlockPrivate *data;
836 AdgTable *table;
837 AdgTableCell *cell;
839 data = title_block->data;
841 if (logo == data->logo)
842 return FALSE;
844 if (data->logo != NULL)
845 g_object_unref(data->logo);
847 data->logo = logo;
849 if (data->logo != NULL)
850 g_object_ref_sink(data->logo);
852 table = get_table(title_block);
853 cell = adg_table_get_cell(table, "logo");
854 adg_table_cell_set_value(cell, data->logo);
855 return TRUE;
858 static gboolean
859 set_projection(AdgTitleBlock *title_block, AdgEntity *projection)
861 AdgTitleBlockPrivate *data;
862 AdgTable *table;
863 AdgTableCell *cell;
865 data = title_block->data;
867 if (projection == data->projection)
868 return FALSE;
870 if (data->projection != NULL)
871 g_object_unref(data->projection);
873 data->projection = projection;
875 if (data->projection != NULL)
876 g_object_ref_sink(data->projection);
878 table = get_table(title_block);
879 cell = adg_table_get_cell(table, "projection");
880 adg_table_cell_set_value(cell, data->projection);
881 return TRUE;