From: Jim Evins Date: Sun, 24 Oct 2010 21:05:16 +0000 (-0400) Subject: Added support for elliptical labels to template designer. X-Git-Tag: glabels-2_3_1~169 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a1a1ba75805a6b52d44edca62f1a46758f5edcef;p=glabels Added support for elliptical labels to template designer. --- diff --git a/data/ui/template-designer.ui b/data/ui/template-designer.ui index 751edcf3..9e66fe06 100644 --- a/data/ui/template-designer.ui +++ b/data/ui/template-designer.ui @@ -31,6 +31,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -261,6 +262,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -445,6 +447,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -461,6 +464,7 @@ This dialog will assist you in the creation of a custom gLabels template. True + vertical 6 @@ -493,6 +497,21 @@ This dialog will assist you in the creation of a custom gLabels template.1 + + + Elliptical + True + True + False + True + shape_rect_radio + + + False + False + 2 + + CD/DVD (including credit card CDs) @@ -506,7 +525,7 @@ This dialog will assist you in the creation of a custom gLabels template. False False - 2 + 3 @@ -533,6 +552,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -848,10 +868,249 @@ This dialog will assist you in the creation of a custom gLabels template.False + + + True + 18 + vertical + 24 + + + True + 0 + Please enter the following size parameters of a single label or card in your template. + + + False + False + 0 + + + + + True + 12 + + + True + 4 + 3 + 12 + 12 + + + True + 0 + 1. Width: + + + GTK_FILL + + + + + + True + 0 + 2. Height: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + 3. Waste (overprint allowed): + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + inches + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + inches + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + + True + 0 + inches + + + 2 + 3 + 2 + 3 + GTK_FILL + + + + + + True + True + + adjustment3 + 0.0099999997764800008 + + + 1 + 2 + + + + + + True + True + + adjustment4 + 0.0099999997764800008 + + + 1 + 2 + 1 + 2 + + + + + + True + True + + adjustment6 + 0.0099999997764800008 + + + 1 + 2 + 2 + 3 + + + + + + True + 0 + 4. Margin + + + 3 + 4 + GTK_FILL + + + + + + True + True + + adjustment8 + 0.0099999997764800008 + + + 1 + 2 + 3 + 4 + + + + + + True + 0 + inches + + + 2 + 3 + 3 + 4 + GTK_FILL + + + + + + False + False + 0 + + + + + True + 1 + 0 + + + 1 + + + + + False + False + 1 + + + + + 5 + + + + + True + ellipse_page + + + 10 + False + + True 18 + vertical 24 @@ -1025,7 +1284,7 @@ This dialog will assist you in the creation of a custom gLabels template. - 5 + 6 @@ -1034,7 +1293,7 @@ This dialog will assist you in the creation of a custom gLabels template.round_size_page - 5 + 6 False @@ -1042,6 +1301,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -1344,7 +1604,7 @@ This dialog will assist you in the creation of a custom gLabels template. - 6 + 7 @@ -1353,7 +1613,7 @@ This dialog will assist you in the creation of a custom gLabels template.cd_size_page - 6 + 7 False @@ -1361,6 +1621,7 @@ This dialog will assist you in the creation of a custom gLabels template. True 18 + vertical 24 @@ -1385,6 +1646,7 @@ The second example illustrates when two layouts are needed. True + vertical True @@ -1414,6 +1676,7 @@ one layout. True + vertical True @@ -1487,7 +1750,7 @@ two layouts. - 7 + 8 @@ -1496,7 +1759,7 @@ two layouts. nlayouts_page - 7 + 8 False @@ -1504,6 +1767,7 @@ two layouts. True 18 + vertical 12 @@ -1906,6 +2170,7 @@ two layouts. True + vertical 6 @@ -1954,7 +2219,7 @@ two layouts. - 8 + 9 @@ -1963,7 +2228,7 @@ two layouts. layout_page - 8 + 9 False @@ -1979,7 +2244,7 @@ Otherwise, you may click "Cancel" to abandon your design or "Back" to continue editing this design. - 9 + 10 @@ -1988,7 +2253,7 @@ or "Back" to continue editing this design. finish_page - 9 + 10 False diff --git a/src/template-designer.c b/src/template-designer.c index a7a4572b..f6ec6958 100644 --- a/src/template-designer.c +++ b/src/template-designer.c @@ -49,6 +49,10 @@ #define DEFAULT_RECT_R 0.0 #define DEFAULT_RECT_WASTE 0.0 /* Should never exceed 1/2 the distance between items. */ +#define DEFAULT_ELLIPSE_W 252.0 +#define DEFAULT_ELLIPSE_H 144.0 +#define DEFAULT_ELLIPSE_WASTE 0.0 /* Should never exceed 1/2 the distance between items. */ + #define DEFAULT_ROUND_R 72.0 #define DEFAULT_ROUND_WASTE 0.0 /* Should never exceed 1/2 the distance between items. */ @@ -78,6 +82,7 @@ struct _glTemplateDesignerPrivate GtkWidget *pg_size_page; GtkWidget *shape_page; GtkWidget *rect_size_page; + GtkWidget *ellipse_size_page; GtkWidget *round_size_page; GtkWidget *cd_size_page; GtkWidget *nlayouts_page; @@ -100,6 +105,7 @@ struct _glTemplateDesignerPrivate /* Shape page controls */ GtkWidget *shape_rect_radio; + GtkWidget *shape_ellipse_radio; GtkWidget *shape_round_radio; GtkWidget *shape_cd_radio; @@ -118,6 +124,17 @@ struct _glTemplateDesignerPrivate GtkWidget *rect_y_waste_units_label; GtkWidget *rect_margin_units_label; + /* Label size (elliptical) page controls */ + GtkWidget *ellipse_image; + GtkWidget *ellipse_w_spin; + GtkWidget *ellipse_h_spin; + GtkWidget *ellipse_waste_spin; + GtkWidget *ellipse_margin_spin; + GtkWidget *ellipse_w_units_label; + GtkWidget *ellipse_h_units_label; + GtkWidget *ellipse_waste_units_label; + GtkWidget *ellipse_margin_units_label; + /* Label size (round) page controls */ GtkWidget *round_image; GtkWidget *round_r_spin; @@ -187,6 +204,7 @@ enum { PG_SIZE_PAGE_NUM, SHAPE_PAGE_NUM, RECT_SIZE_PAGE_NUM, + ELLIPSE_SIZE_PAGE_NUM, ROUND_SIZE_PAGE_NUM, CD_SIZE_PAGE_NUM, NLAYOUTS_PAGE_NUM, @@ -222,6 +240,9 @@ static void construct_shape_page (glTemplateDesigner *dial static void construct_rect_size_page (glTemplateDesigner *dialog, GdkPixbuf *logo); +static void construct_ellipse_size_page (glTemplateDesigner *dialog, + GdkPixbuf *logo); + static void construct_round_size_page (glTemplateDesigner *dialog, GdkPixbuf *logo); @@ -252,6 +273,8 @@ static void pg_size_page_changed_cb (glTemplateDesigner *dial static void rect_size_page_prepare_cb (glTemplateDesigner *dialog); +static void ellipse_size_page_prepare_cb (glTemplateDesigner *dialog); + static void round_size_page_prepare_cb (glTemplateDesigner *dialog); static void cd_size_page_prepare_cb (glTemplateDesigner *dialog); @@ -291,6 +314,7 @@ gl_template_designer_init (glTemplateDesigner *dialog) "pg_size_page", "shape_page", "rect_size_page", + "ellipse_size_page", "round_size_page", "cd_size_page", "nlayouts_page", @@ -413,6 +437,7 @@ gl_template_designer_construct (glTemplateDesigner *dialog) construct_pg_size_page (dialog, logo); construct_shape_page (dialog, logo); construct_rect_size_page (dialog, logo); + construct_ellipse_size_page (dialog, logo); construct_round_size_page (dialog, logo); construct_cd_size_page (dialog, logo); construct_nlayouts_page (dialog, logo); @@ -599,10 +624,11 @@ construct_shape_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); gl_builder_util_get_widgets (dialog->priv->builder, - "shape_page", &dialog->priv->shape_page, - "shape_rect_radio", &dialog->priv->shape_rect_radio, - "shape_round_radio", &dialog->priv->shape_round_radio, - "shape_cd_radio", &dialog->priv->shape_cd_radio, + "shape_page", &dialog->priv->shape_page, + "shape_rect_radio", &dialog->priv->shape_rect_radio, + "shape_ellipse_radio", &dialog->priv->shape_ellipse_radio, + "shape_round_radio", &dialog->priv->shape_round_radio, + "shape_cd_radio", &dialog->priv->shape_cd_radio, NULL); @@ -728,6 +754,91 @@ construct_rect_size_page (glTemplateDesigner *dialog, } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct ellipse size page. */ +/*--------------------------------------------------------------------------*/ +static void +construct_ellipse_size_page (glTemplateDesigner *dialog, + GdkPixbuf *logo) +{ + gchar *pixbuf_filename; + GdkPixbuf *pixbuf; + + gl_debug (DEBUG_TEMPLATE, "START"); + + gl_builder_util_get_widgets (dialog->priv->builder, + "ellipse_size_page", &dialog->priv->ellipse_size_page, + "ellipse_image", &dialog->priv->ellipse_image, + "ellipse_w_spin", &dialog->priv->ellipse_w_spin, + "ellipse_h_spin", &dialog->priv->ellipse_h_spin, + "ellipse_waste_spin", &dialog->priv->ellipse_waste_spin, + "ellipse_margin_spin", &dialog->priv->ellipse_margin_spin, + "ellipse_w_units_label", &dialog->priv->ellipse_w_units_label, + "ellipse_h_units_label", &dialog->priv->ellipse_h_units_label, + "ellipse_waste_units_label", &dialog->priv->ellipse_waste_units_label, + "ellipse_margin_units_label", &dialog->priv->ellipse_margin_units_label, + NULL); + + + gtk_assistant_append_page (GTK_ASSISTANT (dialog), + dialog->priv->ellipse_size_page); + + gtk_assistant_set_page_title (GTK_ASSISTANT (dialog), + dialog->priv->ellipse_size_page, + _("Label or Card Size")); + gtk_assistant_set_page_header_image (GTK_ASSISTANT (dialog), + dialog->priv->ellipse_size_page, + logo); + gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog), + dialog->priv->ellipse_size_page, + TRUE); + + /* Initialize illustration. */ + pixbuf_filename = g_build_filename (GLABELS_DATA_DIR, "pixmaps", "ex-ellipse-size.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (pixbuf_filename, NULL); + g_free (pixbuf_filename); + gtk_image_set_from_pixbuf (GTK_IMAGE(dialog->priv->ellipse_image), pixbuf); + + /* Apply units to spinbuttons and units labels. */ + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin), + dialog->priv->digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin), + dialog->priv->climb_rate, 10.0*dialog->priv->climb_rate); + gtk_label_set_text (GTK_LABEL(dialog->priv->ellipse_w_units_label), + dialog->priv->units_string); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin), + dialog->priv->digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin), + dialog->priv->climb_rate, 10.0*dialog->priv->climb_rate); + gtk_label_set_text (GTK_LABEL(dialog->priv->ellipse_h_units_label), + dialog->priv->units_string); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin), + dialog->priv->digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin), + dialog->priv->climb_rate, 10.0*dialog->priv->climb_rate); + gtk_label_set_text (GTK_LABEL(dialog->priv->ellipse_waste_units_label), + dialog->priv->units_string); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin), + dialog->priv->digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin), + dialog->priv->climb_rate, 10.0*dialog->priv->climb_rate); + gtk_label_set_text (GTK_LABEL(dialog->priv->ellipse_margin_units_label), + dialog->priv->units_string); + + /* Load some realistic defaults. */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin), + DEFAULT_ELLIPSE_W * dialog->priv->units_per_point); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin), + DEFAULT_ELLIPSE_H * dialog->priv->units_per_point); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin), + DEFAULT_ELLIPSE_WASTE * dialog->priv->units_per_point); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin), + DEFAULT_MARGIN * dialog->priv->units_per_point); + + gl_debug (DEBUG_TEMPLATE, "END"); +} + + /*--------------------------------------------------------------------------*/ /* PRIVATE. Construct round size page. */ /*--------------------------------------------------------------------------*/ @@ -1170,6 +1281,10 @@ gl_template_designer_set_from_name (glTemplateDesigner *dialog, break; case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE: + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->shape_ellipse_radio), TRUE); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin), frame->rect.w*upp); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin), frame->rect.h*upp); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin), frame->rect.y_waste*upp); break; case LGL_TEMPLATE_FRAME_SHAPE_ROUND: @@ -1195,6 +1310,7 @@ gl_template_designer_set_from_name (glTemplateDesigner *dialog, if ( markup->type == LGL_TEMPLATE_MARKUP_MARGIN ) { gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->rect_margin_spin), markup->margin.size*upp); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin), markup->margin.size*upp); gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->round_margin_spin), markup->margin.size*upp); gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->cd_margin_spin), markup->margin.size*upp); } @@ -1314,6 +1430,10 @@ prepare_cb (glTemplateDesigner *dialog, rect_size_page_prepare_cb (dialog); break; + case ELLIPSE_SIZE_PAGE_NUM: + ellipse_size_page_prepare_cb (dialog); + break; + case ROUND_SIZE_PAGE_NUM: round_size_page_prepare_cb (dialog); break; @@ -1358,6 +1478,9 @@ forward_page_function (gint current_page, if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_rect_radio))) { return RECT_SIZE_PAGE_NUM; } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_ellipse_radio))) { + return ELLIPSE_SIZE_PAGE_NUM; + } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_round_radio))) { return ROUND_SIZE_PAGE_NUM; } @@ -1367,6 +1490,7 @@ forward_page_function (gint current_page, break; case RECT_SIZE_PAGE_NUM: + case ELLIPSE_SIZE_PAGE_NUM: case ROUND_SIZE_PAGE_NUM: case CD_SIZE_PAGE_NUM: return NLAYOUTS_PAGE_NUM; @@ -1534,6 +1658,41 @@ rect_size_page_prepare_cb (glTemplateDesigner *dialog) } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare ellipse size page. */ +/*--------------------------------------------------------------------------*/ +static void +ellipse_size_page_prepare_cb (glTemplateDesigner *dialog) +{ + gdouble max_w, max_h; + gdouble w, h, waste, margin; + + /* Limit label size based on already chosen page size. */ + max_w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->pg_w_spin)); + max_h = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->pg_h_spin)); + + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin)); + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin)); + waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin)); + margin = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin)); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->priv->ellipse_w_spin), + dialog->priv->climb_rate, max_w); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->priv->ellipse_h_spin), + dialog->priv->climb_rate, max_h); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->priv->ellipse_waste_spin), + 0.0, MIN(max_w, max_h)/4.0); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->priv->ellipse_margin_spin), + 0.0, MIN(max_w, max_h)/4.0); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin), w); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin), h); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin), waste); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin), margin); + +} + + /*--------------------------------------------------------------------------*/ /* PRIVATE. Prepare round size page. */ /*--------------------------------------------------------------------------*/ @@ -1635,11 +1794,16 @@ layout_page_prepare_cb (glTemplateDesigner *dialog) x_waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->rect_x_waste_spin)); y_waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->rect_y_waste_spin)); } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_ellipse_radio))) { + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin)); + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin)); + y_waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin)); + y_waste = x_waste; + } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_round_radio))) { w = 2*gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->round_r_spin)); h = w; x_waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->round_waste_spin)); - y_waste = x_waste; } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_cd_radio))) { w = 2*gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->cd_radius_spin)); @@ -1831,6 +1995,14 @@ build_template (glTemplateDesigner *dialog) margin = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->rect_margin_spin)); } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_ellipse_radio))) { + shape = LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE; + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_w_spin)); + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_h_spin)); + waste = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_waste_spin)); + margin = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->ellipse_margin_spin)); + } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->priv->shape_round_radio))) { shape = LGL_TEMPLATE_FRAME_SHAPE_ROUND; r = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->round_r_spin)); @@ -1867,18 +2039,16 @@ build_template (glTemplateDesigner *dialog) switch (shape) { case LGL_TEMPLATE_FRAME_SHAPE_RECT: - frame = lgl_template_frame_rect_new ("0", - w/upp, h/upp, r/upp, - x_waste/upp, y_waste/upp); + frame = lgl_template_frame_rect_new ("0", w/upp, h/upp, r/upp, x_waste/upp, y_waste/upp); + break; + case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE: + frame = lgl_template_frame_ellipse_new ("0", w/upp, h/upp, waste/upp); break; case LGL_TEMPLATE_FRAME_SHAPE_ROUND: frame = lgl_template_frame_round_new ("0", r/upp, waste/upp); break; case LGL_TEMPLATE_FRAME_SHAPE_CD: - frame = lgl_template_frame_cd_new ("0", - radius/upp, hole/upp, - w/upp, h/upp, - waste/upp); + frame = lgl_template_frame_cd_new ("0", radius/upp, hole/upp, w/upp, h/upp, waste/upp); break; default: g_assert_not_reached ();