From: Jim Evins Date: Fri, 19 Dec 2003 05:21:02 +0000 (+0000) Subject: Created 2 methods for setting label for mini-preview widget. The first is "by name... X-Git-Tag: glabels-2_3_0~517 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=44e32b0c46bf50195856ebc26b09fcb4f1f3da2a;p=glabels Created 2 methods for setting label for mini-preview widget. The first is "by name" and the second is by template. This second method allows us to use a label's local template, even if its name is not an exact match with an existing template's -- can occur if templates are renamed between versions or if a label uses someone else's custom template. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@377 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/wdgt-media-select.c b/glabels2/src/wdgt-media-select.c index 0dbe82c2..4ec6b35f 100644 --- a/glabels2/src/wdgt-media-select.c +++ b/glabels2/src/wdgt-media-select.c @@ -312,8 +312,8 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) gtk_editable_get_chars (GTK_EDITABLE (media_select->template_entry), 0, -1); gl_debug (DEBUG_MEDIA_SELECT, "name = \"%s\"", name); - gl_wdgt_mini_preview_set_label (GL_WDGT_MINI_PREVIEW (media_select->mini_preview), - name); + gl_wdgt_mini_preview_set_label_by_name (GL_WDGT_MINI_PREVIEW (media_select->mini_preview), + name); details_update (media_select, name); g_free (name); @@ -385,8 +385,8 @@ template_entry_changed_cb (GtkEntry *entry, name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); if ( strlen(name) ) { gl_debug (DEBUG_MEDIA_SELECT, "name = \"%s\"", name); - gl_wdgt_mini_preview_set_label (GL_WDGT_MINI_PREVIEW (media_select->mini_preview), - name); + gl_wdgt_mini_preview_set_label_by_name (GL_WDGT_MINI_PREVIEW (media_select->mini_preview), + name); gl_debug (DEBUG_MEDIA_SELECT, "m1"); details_update (media_select, name); gl_debug (DEBUG_MEDIA_SELECT, "m2"); diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 6108224c..210d6841 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -66,8 +66,8 @@ static void gl_wdgt_mini_preview_finalize (GObject * object); static void gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, gint height, gint width); -static GList *mini_outline_list_new (GnomeCanvas *canvas, - glTemplate *template); +static GList *mini_outline_list_new (GnomeCanvas *canvas, + const glTemplate *template); static void mini_outline_list_free (GList ** list); static gint canvas_event_cb (GnomeCanvas * canvas, @@ -77,7 +77,7 @@ static gint canvas_event_cb (GnomeCanvas * canvas, static GnomeCanvasItem *cdbc_item (GnomeCanvasGroup *group, gdouble x1, gdouble y1, - glTemplate *template); + const glTemplate *template); static void style_set_cb (GtkWidget *widget, GtkStyle *previous_style, @@ -273,10 +273,29 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, /****************************************************************************/ /* Set label for mini-preview to determine geometry. */ /****************************************************************************/ -void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, - gchar *name) +void gl_wdgt_mini_preview_set_label_by_name (glWdgtMiniPreview *preview, + const gchar *name) { glTemplate *template; + + gl_debug (DEBUG_MINI_PREVIEW, "START"); + + /* Fetch template */ + template = gl_template_from_name (name); + + gl_wdgt_mini_preview_set_template (preview, template); + + gl_template_free( &template ); + + gl_debug (DEBUG_MINI_PREVIEW, "END"); +} + +/****************************************************************************/ +/* Set label for mini-preview to determine geometry. */ +/****************************************************************************/ +void gl_wdgt_mini_preview_set_template (glWdgtMiniPreview *preview, + const glTemplate *template) +{ gchar *page_size; gdouble canvas_scale; gdouble w, h; @@ -284,9 +303,6 @@ void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, gl_debug (DEBUG_MINI_PREVIEW, "START"); - /* Fetch template */ - template = gl_template_from_name (name); - gl_debug (DEBUG_MINI_PREVIEW, "page_size = %s, page_width = %g, page_height = %g", template->page_size, template->page_width, template->page_height); @@ -333,8 +349,6 @@ void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, mini_outline_list_new (GNOME_CANVAS(preview->canvas), template); - gl_template_free( &template ); - gl_debug (DEBUG_MINI_PREVIEW, "END"); } @@ -342,8 +356,8 @@ void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, /* PRIVATE. Draw label outlines and return canvas item list. */ /*--------------------------------------------------------------------------*/ static GList * -mini_outline_list_new (GnomeCanvas *canvas, - glTemplate *template) +mini_outline_list_new (GnomeCanvas *canvas, + const glTemplate *template) { GnomeCanvasGroup *group = NULL; GnomeCanvasItem *item = NULL; @@ -632,7 +646,7 @@ static GnomeCanvasItem * cdbc_item (GnomeCanvasGroup *group, gdouble x1, gdouble y1, - glTemplate *template) + const glTemplate *template) { GnomeCanvasPoints *points; gint i_coords, i_theta; diff --git a/glabels2/src/wdgt-mini-preview.h b/glabels2/src/wdgt-mini-preview.h index fdb07483..3e61b871 100644 --- a/glabels2/src/wdgt-mini-preview.h +++ b/glabels2/src/wdgt-mini-preview.h @@ -71,17 +71,20 @@ struct _glWdgtMiniPreviewClass { gpointer user_data); }; -guint gl_wdgt_mini_preview_get_type (void); +guint gl_wdgt_mini_preview_get_type (void); -GtkWidget *gl_wdgt_mini_preview_new (gint height, - gint width); +GtkWidget *gl_wdgt_mini_preview_new (gint height, + gint width); -void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, - gchar *name); +void gl_wdgt_mini_preview_set_label_by_name (glWdgtMiniPreview *preview, + const gchar *name); -void gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview *preview, - gint first_label, - gint last_label); +void gl_wdgt_mini_preview_set_template (glWdgtMiniPreview *preview, + const glTemplate *template); + +void gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview *preview, + gint first_label, + gint last_label); G_END_DECLS #endif diff --git a/glabels2/src/wdgt-print-copies.c b/glabels2/src/wdgt-print-copies.c index 2e2f960e..4166ec86 100644 --- a/glabels2/src/wdgt-print-copies.c +++ b/glabels2/src/wdgt-print-copies.c @@ -163,8 +163,8 @@ gl_wdgt_print_copies_construct (glWdgtPrintCopies *copies, /* mini_preview canvas */ 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); + gl_wdgt_mini_preview_set_template (GL_WDGT_MINI_PREVIEW(copies->mini_preview), + template); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), copies->mini_preview); wvbox = gl_hig_vbox_new (GL_HIG_VBOX_INNER); diff --git a/glabels2/src/wdgt-print-merge.c b/glabels2/src/wdgt-print-merge.c index f635baa6..4b4e6f3e 100644 --- a/glabels2/src/wdgt-print-merge.c +++ b/glabels2/src/wdgt-print-merge.c @@ -160,8 +160,8 @@ gl_wdgt_print_merge_construct (glWdgtPrintMerge * merge, /* mini_preview canvas */ 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 ); + gl_wdgt_mini_preview_set_template( GL_WDGT_MINI_PREVIEW (merge->mini_preview), + template ); 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);