template = gl_label_get_template (label);
rotate_flag = gl_label_get_rotate_flag (label);
- gl_debug (DEBUG_FILE, "%s, %s", template->page_size, template->name->data);
+ gl_debug (DEBUG_FILE, "%s, %s", template->page_size, template->name);
if (template->page_size != NULL) {
gl_wdgt_media_select_set_page_size (GL_WDGT_MEDIA_SELECT (template_entry),
template->page_size);
}
- if (template->name->data != NULL) {
+ if (template->name != NULL) {
+ gchar *template_name = gl_template_get_name_with_desc (template);
gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (template_entry),
- template->name->data);
+ template_name);
gl_wdgt_rotate_label_set_template_name (GL_WDGT_ROTATE_LABEL
- (rotate_sel), template->name->data);
+ (rotate_sel), template_name);
+ g_free (template_name);
} else {
sheet_name =
gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (template_entry));
gl_wdgt_rotate_label_set_template_name (GL_WDGT_ROTATE_LABEL
- (rotate_sel), sheet_name);
+ (rotate_sel), sheet_name);
}
gl_wdgt_rotate_label_set_state (GL_WDGT_ROTATE_LABEL (rotate_sel), rotate_flag);
NAME_CHANGED,
MODIFIED_CHANGED,
MERGE_CHANGED,
+ SIZE_CHANGED,
LAST_SIGNAL
};
gl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ signals[SIZE_CHANGED] =
+ g_signal_new ("size_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glLabelClass, size_changed),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
gl_debug (DEBUG_LABEL, "END");
}
g_return_if_fail (label && GL_IS_LABEL (label));
- gl_template_free (&label->private->template);
- label->private->template = gl_template_dup (template);
+ if ((label->private->template == NULL) ||
+ (g_strcasecmp (template->name, label->private->template->name) != 0)) {
- label->private->modified_flag = TRUE;
+ gl_template_free (&label->private->template);
+ label->private->template = gl_template_dup (template);
- g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
- g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+ label->private->modified_flag = TRUE;
+
+ g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[SIZE_CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+
+ }
gl_debug (DEBUG_LABEL, "END");
}
g_return_if_fail (label && GL_IS_LABEL (label));
- label->private->rotate_flag = rotate_flag;
+ if (rotate_flag != label->private->rotate_flag) {
- label->private->modified_flag = TRUE;
+ label->private->rotate_flag = rotate_flag;
- g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
- g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+ label->private->modified_flag = TRUE;
+
+ g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[SIZE_CHANGED], 0);
+ g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
+
+ }
gl_debug (DEBUG_LABEL, "END");
}
void (*merge_changed) (glLabel *label, gpointer user_data);
+ void (*size_changed) (glLabel *label, gpointer user_data);
+
};
GList *
gl_template_get_name_list (const gchar *page_size)
{
- GList *p_tmplt, *p_name;
+ GList *p_tmplt, *p_alias;
glTemplate *template;
gchar *str;
GList *names = NULL;
for (p_tmplt = templates; p_tmplt != NULL; p_tmplt = p_tmplt->next) {
template = (glTemplate *) p_tmplt->data;
if (g_strcasecmp (page_size, template->page_size) == 0) {
- for (p_name = template->name; p_name != NULL;
- p_name = p_name->next) {
+ for (p_alias = template->alias; p_alias != NULL;
+ p_alias = p_alias->next) {
str = g_strdup_printf("%s: %s",
- (gchar *) p_name->data,
+ (gchar *) p_alias->data,
template->description);
names = g_list_insert_sorted (names, str,
(GCompareFunc)g_strcasecmp);
glTemplate *
gl_template_from_name (const gchar *name)
{
- GList *p_tmplt, *p_name;
- glTemplate *template;
+ GList *p_tmplt, *p_alias;
+ glTemplate *template, *new_template;
gchar **split_name;
gl_debug (DEBUG_TEMPLATE, "START");
for (p_tmplt = templates; p_tmplt != NULL; p_tmplt = p_tmplt->next) {
template = (glTemplate *) p_tmplt->data;
- for (p_name = template->name; p_name != NULL;
- p_name = p_name->next) {
- if (g_strcasecmp (p_name->data, split_name[0]) == 0) {
+ for (p_alias = template->alias; p_alias != NULL;
+ p_alias = p_alias->next) {
+ if (g_strcasecmp (p_alias->data, split_name[0]) == 0) {
+
+ new_template = gl_template_dup (template);
+
+ /* Use the real name */
+ g_free (new_template->name);
+ new_template->name = g_strdup (split_name[0]);
+
g_strfreev (split_name);
gl_debug (DEBUG_TEMPLATE, "END");
- return gl_template_dup (template);
+
+ return new_template;
}
}
}
return NULL;
}
+/*****************************************************************************/
+/* Get name and format with description. */
+/*****************************************************************************/
+gchar *
+gl_template_get_name_with_desc (const glTemplate *template)
+{
+ return g_strdup_printf("%s: %s", template->name, template->description);
+}
+
+
/*****************************************************************************/
/* Copy a template. */
/*****************************************************************************/
template = g_new0 (glTemplate,1);
- template->name = NULL;
- for ( p=orig_template->name; p != NULL; p=p->next ) {
- template->name = g_list_append (template->name,
+ template->name = g_strdup (orig_template->name);
+
+ template->alias = NULL;
+ for ( p=orig_template->alias; p != NULL; p=p->next ) {
+ template->alias = g_list_append (template->alias,
g_strdup (p->data));
}
template->description = g_strdup (orig_template->description);
if ( *template != NULL ) {
- for ( p=(*template)->name; p != NULL; p=p->next ) {
+ g_free ((*template)->name);
+ (*template)->name = NULL;
+
+ for ( p=(*template)->alias; p != NULL; p=p->next ) {
g_free (p->data);
p->data = NULL;
}
- g_list_free ((*template)->name);
- (*template)->name = NULL;
+ g_list_free ((*template)->alias);
+ (*template)->alias = NULL;
g_free ((*template)->description);
(*template)->description = NULL;
template = g_new0 (glTemplate, 1);
- template->name = g_list_append (template->name,
- g_strdup_printf(_("Generic %s full page"),
- page_size));
+ template->name = g_strdup_printf (_("Generic %s full page"), page_size);
+
+ template->alias = g_list_append (template->alias, template->name);
+
template->page_size = g_strdup(page_size);
template->page_width = paper->width;
template->page_height = paper->height;
* Template
*/
typedef struct {
- GList *name;
+ gchar *name;
gchar *description;
gchar *page_size;
gdouble page_width;
glTemplateLabel label;
+ GList *alias;
} glTemplate;
glTemplate *gl_template_from_name (const gchar *name);
+gchar *gl_template_get_name_with_desc (const glTemplate *template);
+
glTemplate *gl_template_dup (const glTemplate *orig);
void gl_template_free (glTemplate **template);
static void draw_layers (glView *view);
+static void label_resized_cb (glLabel *label,
+ glView *view);
+
static void draw_label_layer (glView *view);
static void draw_highlight_layer (glView *view);
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->fg_group));
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->highlight_group));
+
+ g_signal_connect (G_OBJECT (view->label), "size_changed",
+ G_CALLBACK (label_resized_cb), view);
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Handle label resize event. . */
+/*---------------------------------------------------------------------------*/
+static void
+label_resized_cb (glLabel *label,
+ glView *view)
+{
+ g_return_if_fail (label && GL_IS_LABEL (label));
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ gtk_object_destroy (GTK_OBJECT (view->bg_group));
+ gtk_object_destroy (GTK_OBJECT (view->grid_group));
+ gtk_object_destroy (GTK_OBJECT (view->markup_group));
+ gtk_object_destroy (GTK_OBJECT (view->fg_group));
+
+ draw_bg_fg_layers (view);
+ draw_grid_layer (view);
+ draw_markup_layer (view);
+
+ gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->label_group));
+ gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->fg_group));
+ gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->highlight_group));
}
/*---------------------------------------------------------------------------*/
copies->mini_preview = gl_wdgt_mini_preview_new (WDGT_MINI_PREVIEW_HEIGHT,
WDGT_MINI_PREVIEW_WIDTH);
gl_wdgt_mini_preview_set_label (GL_WDGT_MINI_PREVIEW(copies->mini_preview),
- template->name->data);
+ template->name);
gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), copies->mini_preview);
wvbox = gl_hig_vbox_new (GL_HIG_VBOX_INNER);
merge->mini_preview = gl_wdgt_mini_preview_new (WDGT_MINI_PREVIEW_HEIGHT,
WDGT_MINI_PREVIEW_WIDTH);
gl_wdgt_mini_preview_set_label( GL_WDGT_MINI_PREVIEW (merge->mini_preview),
- template->name->data );
+ template->name );
gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), merge->mini_preview);
gl_wdgt_mini_preview_highlight_range (GL_WDGT_MINI_PREVIEW(merge->mini_preview),
1, 1);
template = g_new0 (glTemplate, 1);
- template->name = g_list_append (template->name,
- xmlGetProp (sheet_node, "name"));
- gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name->data);
+ template->name = xmlGetProp (sheet_node, "name");
+ template->alias = g_list_append (template->alias, g_strdup (template->name));
+ gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name);
template->page_size = xmlGetProp (sheet_node, "size");
if (xmlStrEqual (template->page_size, "Other")) {
{
gl_debug (DEBUG_TEMPLATE, "START");
- template->name = g_list_append (template->name,
+ template->alias = g_list_append (template->alias,
xmlGetProp (alias_node, "name"));
gl_debug (DEBUG_TEMPLATE, "END");
node = xmlNewChild (root, ns, "Sheet", NULL);
- xmlSetProp (node, "name", template->name->data);
+ xmlSetProp (node, "name", template->name);
xmlSetProp (node, "size", template->page_size);
if (xmlStrEqual (template->page_size, "Other")) {
xml_add_label (template, node, ns);
- for ( p=template->name->next; p != NULL; p=p->next ) {
- xml_add_alias( p->data, node, ns );
+ for ( p=template->alias; p != NULL; p=p->next ) {
+ if (!xmlStrEqual (template->name, p->data)) {
+ xml_add_alias( p->data, node, ns );
+ }
}
gl_debug (DEBUG_TEMPLATE, "END");