From: James Le Cuirot Date: Mon, 23 Jan 2012 02:27:08 +0000 (-0500) Subject: New text vertical alignment feature. X-Git-Tag: glabels-3_2_0~106 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c821271c41201e099f1f1d491a926d1aea9c22c0;p=glabels New text vertical alignment feature. Adds vertical alignment feature for text objects. Added appropriate icons (evins@snaught.com). --- diff --git a/data/icons/22x22/Makefile.am b/data/icons/22x22/Makefile.am index 955d8609..1587bb6d 100644 --- a/data/icons/22x22/Makefile.am +++ b/data/icons/22x22/Makefile.am @@ -1,11 +1,18 @@ size = 22x22 appiconsdir = $(datadir)/icons/hicolor/$(size)/apps +actioniconsdir = $(datadir)/$(GLABELS_BRANCH)/icons/hicolor/$(size)/actions appicons_DATA = \ apps/glabels-3.0.png +actionicons_DATA = \ + actions/glabels-align-text-bottom.png \ + actions/glabels-align-text-middle.png \ + actions/glabels-align-text-top.png + noinst_DATA = -EXTRA_DIST = $(appicons_DATA) \ +EXTRA_DIST = $(appicons_DATA) \ + $(actionicons_DATA) \ $(noinst_DATA) diff --git a/data/icons/22x22/actions/glabels-align-text-bottom.png b/data/icons/22x22/actions/glabels-align-text-bottom.png new file mode 100644 index 00000000..a9586f9b Binary files /dev/null and b/data/icons/22x22/actions/glabels-align-text-bottom.png differ diff --git a/data/icons/22x22/actions/glabels-align-text-middle.png b/data/icons/22x22/actions/glabels-align-text-middle.png new file mode 100644 index 00000000..2de63421 Binary files /dev/null and b/data/icons/22x22/actions/glabels-align-text-middle.png differ diff --git a/data/icons/22x22/actions/glabels-align-text-top.png b/data/icons/22x22/actions/glabels-align-text-top.png new file mode 100644 index 00000000..fda44201 Binary files /dev/null and b/data/icons/22x22/actions/glabels-align-text-top.png differ diff --git a/data/icons/24x24/Makefile.am b/data/icons/24x24/Makefile.am index 4dd62a04..4af195ef 100644 --- a/data/icons/24x24/Makefile.am +++ b/data/icons/24x24/Makefile.am @@ -7,6 +7,9 @@ appicons_DATA = \ apps/glabels-3.0.png actionicons_DATA = \ + actions/glabels-align-text-bottom.png \ + actions/glabels-align-text-middle.png \ + actions/glabels-align-text-top.png \ actions/glabels-arrow.png \ actions/glabels-barcode.png \ actions/glabels-box.png \ diff --git a/data/icons/24x24/actions/glabels-align-text-bottom.png b/data/icons/24x24/actions/glabels-align-text-bottom.png new file mode 100644 index 00000000..5dbc037f Binary files /dev/null and b/data/icons/24x24/actions/glabels-align-text-bottom.png differ diff --git a/data/icons/24x24/actions/glabels-align-text-middle.png b/data/icons/24x24/actions/glabels-align-text-middle.png new file mode 100644 index 00000000..33220cac Binary files /dev/null and b/data/icons/24x24/actions/glabels-align-text-middle.png differ diff --git a/data/icons/24x24/actions/glabels-align-text-top.png b/data/icons/24x24/actions/glabels-align-text-top.png new file mode 100644 index 00000000..2ece60dd Binary files /dev/null and b/data/icons/24x24/actions/glabels-align-text-top.png differ diff --git a/data/ui/object-editor.ui b/data/ui/object-editor.ui index 582a19e0..422bcca3 100644 --- a/data/ui/object-editor.ui +++ b/data/ui/object-editor.ui @@ -1,7 +1,6 @@ - 1 250 @@ -9,6 +8,29 @@ 1 10 + + 100 + 0.01 + 1 + + + 100 + 0.01 + 1 + + + 100 + 1 + 1 + 10 + + + 1 + 100 + 1 + 1 + 10 + 5 1 @@ -56,70 +78,60 @@ 0.01 1 - - 100 - 0.01 - 1 - - - 100 - 0.01 - 1 - - - 100 - 1 - 1 - 10 - - - 1 - 100 - 1 - 1 - 10 - - - both - - - - - - - - - - - - - - - - - - - True + False 6 dialog1 dialog - + True + False + + + True + False + end + + + gtk-close + True + True + True + False + False + True + + + False + False + 0 + + + + + False + True + end + 0 + + True + False 6 12 True + False 12 True + False False @@ -130,6 +142,7 @@ True + False <span weight="bold" size="larger">Xxx object properties</span> True @@ -154,11 +167,13 @@ True + False 12 6 True + False True @@ -187,10 +202,12 @@ True + False 12 True + False @@ -216,6 +233,7 @@ True + False Text @@ -225,15 +243,18 @@ True + False 12 12 True + False 12 True + False 0 Family: @@ -246,6 +267,7 @@ True + False @@ -266,10 +288,12 @@ True + False 12 True + False 0 Size: @@ -282,6 +306,7 @@ True + False 12 @@ -314,10 +339,12 @@ True + False 12 True + False 0 Style: @@ -330,15 +357,18 @@ True + False 12 True True False + False True + False gtk-bold @@ -354,9 +384,11 @@ True True False + False True + False gtk-italic @@ -384,10 +416,12 @@ True + False 12 True + False 0 0.14000000059604645 Color: @@ -401,10 +435,12 @@ True + False 6 True + False 6 @@ -412,6 +448,7 @@ True True False + False True False True @@ -425,6 +462,7 @@ True + False 12 @@ -446,6 +484,7 @@ True + False 6 @@ -453,6 +492,7 @@ True True False + False True False 0.54000002145767212 @@ -468,6 +508,7 @@ True + False 12 @@ -503,10 +544,12 @@ True + False 12 True + False 0 Alignment: @@ -519,15 +562,18 @@ True + False 12 True True False + False True + False gtk-justify-left @@ -543,9 +589,11 @@ True True False + False True + False gtk-justify-center @@ -561,9 +609,11 @@ True True False + False True + False gtk-justify-right @@ -588,13 +638,116 @@ 4 + + + True + False + 12 + + + True + False + 0 + Vertical alignment: + + + False + False + 0 + + + + + True + False + 12 + + + True + True + False + False + + + True + False + 22 + glabels-align-text-top + + + + + False + False + 0 + + + + + True + True + False + False + 0.47999998927116394 + + + True + False + 22 + glabels-align-text-middle + + + + + False + False + 1 + + + + + True + True + False + False + + + True + False + 22 + glabels-align-text-bottom + + + + + False + False + 2 + + + + + True + True + 1 + + + + + False + False + 5 + + True + False 12 True + False 0 Line Spacing: @@ -607,6 +760,7 @@ True + False 12 @@ -633,7 +787,7 @@ False False - 5 + 6 @@ -642,13 +796,14 @@ True True False + False True True False False - 6 + 7 @@ -660,6 +815,7 @@ True + False 0.46000000834465027 Style @@ -671,15 +827,18 @@ True + False 12 12 True + False 12 True + False 0 Width: @@ -692,6 +851,7 @@ True + False 12 @@ -711,6 +871,7 @@ True + False points @@ -736,10 +897,12 @@ True + False 12 True + False 0 0.14000000059604645 Color: @@ -753,11 +916,12 @@ True + False 6 - False True + False 6 @@ -765,6 +929,7 @@ True False False + False True False True @@ -778,6 +943,7 @@ True + False 12 @@ -799,6 +965,7 @@ True + False 6 @@ -806,6 +973,7 @@ True False False + False True False True @@ -820,6 +988,7 @@ True + False 12 @@ -860,6 +1029,7 @@ True + False Line @@ -870,15 +1040,17 @@ True + False 12 True + False 12 - False True + False 0 0.14000000059604645 Color: @@ -892,10 +1064,12 @@ True + False 6 True + False 6 @@ -903,6 +1077,7 @@ True False False + False True False True @@ -917,6 +1092,7 @@ True + False 12 @@ -938,6 +1114,7 @@ True + False 6 @@ -945,6 +1122,7 @@ True False False + False True False True @@ -959,6 +1137,7 @@ True + False 12 @@ -999,6 +1178,7 @@ True + False Fill @@ -1009,11 +1189,13 @@ True + False 12 12 True + False 12 @@ -1021,6 +1203,7 @@ True True False + False True False True @@ -1034,6 +1217,7 @@ True + False True @@ -1052,6 +1236,7 @@ True + False 12 @@ -1060,6 +1245,7 @@ False True False + False True False True @@ -1074,6 +1260,7 @@ True + False @@ -1099,6 +1286,7 @@ True + False Image @@ -1109,11 +1297,13 @@ True + False 12 12 True + False 12 @@ -1121,6 +1311,7 @@ True True False + False True True @@ -1151,6 +1342,7 @@ True + False 12 @@ -1158,6 +1350,7 @@ True True False + False True True data_literal_radio @@ -1171,6 +1364,7 @@ True + False @@ -1191,10 +1385,12 @@ True + False 12 True + False @@ -1206,6 +1402,7 @@ True + False 2 2 6 @@ -1213,6 +1410,7 @@ True + False 0 format: @@ -1224,6 +1422,7 @@ True + False 0 00000000000 00000 @@ -1237,6 +1436,7 @@ True + False 0 digits: @@ -1250,6 +1450,7 @@ True + False True @@ -1296,6 +1497,7 @@ True + False Data @@ -1306,19 +1508,21 @@ True + False 12 12 True + False 2 2 6 6 - False True + False 0 Backend: @@ -1330,6 +1534,7 @@ True + False 0 Style: @@ -1343,6 +1548,7 @@ True + False @@ -1355,6 +1561,7 @@ True + False @@ -1379,6 +1586,7 @@ True True False + False True True @@ -1394,6 +1602,7 @@ True True False + False True True @@ -1406,11 +1615,12 @@ True + False 12 - False True + False 0 0.14000000059604645 Color: @@ -1424,10 +1634,12 @@ True + False 6 True + False 6 @@ -1435,6 +1647,7 @@ True True False + False True False True @@ -1449,6 +1662,7 @@ True + False 12 @@ -1470,6 +1684,7 @@ True + False 6 @@ -1477,6 +1692,7 @@ True True False + False True False True @@ -1491,6 +1707,7 @@ True + False 12 @@ -1531,6 +1748,7 @@ True + False Style @@ -1541,11 +1759,13 @@ True + False 12 12 True + False 3 3 12 @@ -1553,6 +1773,7 @@ True + False 0 Width: @@ -1564,6 +1785,7 @@ True + False 0 Height: @@ -1577,6 +1799,7 @@ True + False 12 @@ -1597,6 +1820,7 @@ True + False inches @@ -1618,6 +1842,7 @@ True + False 12 @@ -1625,6 +1850,7 @@ True True False + False True @@ -1645,6 +1871,7 @@ True + False 12 @@ -1665,6 +1892,7 @@ True + False inches @@ -1684,6 +1912,7 @@ True + False @@ -1714,6 +1943,7 @@ True + False Size @@ -1724,11 +1954,13 @@ True + False 12 12 True + False 2 2 12 @@ -1736,6 +1968,7 @@ True + False 0 Length: @@ -1747,6 +1980,7 @@ True + False 0 Angle: @@ -1760,6 +1994,7 @@ True + False 12 @@ -1780,6 +2015,7 @@ True + False inches @@ -1798,6 +2034,7 @@ True + False 12 @@ -1818,6 +2055,7 @@ True + False degrees @@ -1851,6 +2089,7 @@ True + False Size @@ -1861,11 +2100,13 @@ True + False 12 12 True + False 2 3 12 @@ -1874,6 +2115,7 @@ 50 True + False 0 X: @@ -1885,6 +2127,7 @@ True + False 0 Y: @@ -1898,6 +2141,7 @@ True + False 0 inches @@ -1911,6 +2155,7 @@ True + False 0 inches @@ -1974,6 +2219,7 @@ True + False Position @@ -1984,6 +2230,7 @@ True + False 12 12 @@ -1992,6 +2239,7 @@ True True False + False True True @@ -2004,15 +2252,17 @@ True + False 12 - False True + False 12 True + False 0 X Offset: @@ -2025,6 +2275,7 @@ True + False 12 @@ -2045,6 +2296,7 @@ True + False inches @@ -2070,10 +2322,12 @@ True + False 12 True + False 0 Y Offset: @@ -2086,6 +2340,7 @@ True + False 12 @@ -2106,6 +2361,7 @@ True + False inches @@ -2131,10 +2387,12 @@ True + False 12 True + False 0 0.14000000059604645 Color: @@ -2148,10 +2406,12 @@ True + False 6 True + False 6 @@ -2159,6 +2419,7 @@ True True False + False True False True @@ -2172,6 +2433,7 @@ True + False 12 @@ -2193,6 +2455,7 @@ True + False 6 @@ -2200,6 +2463,7 @@ True True False + False True False True @@ -2214,6 +2478,7 @@ True + False 12 @@ -2249,10 +2514,12 @@ True + False 12 True + False 0 Opacity: @@ -2265,6 +2532,7 @@ True + False 12 @@ -2282,6 +2550,7 @@ True + False % @@ -2319,6 +2588,7 @@ True + False Shadow @@ -2340,37 +2610,31 @@ 2 - - - True - end - - - gtk-close - True - True - True - False - True - - - False - False - 0 - - - - - False - True - end - 0 - - closebutton1 + + both + + + + + + + + + + + + + + + + + + + diff --git a/data/ui/property-bar.ui b/data/ui/property-bar.ui index 0d3914a9..2bb07e60 100644 --- a/data/ui/property-bar.ui +++ b/data/ui/property-bar.ui @@ -1,14 +1,6 @@ - - - 0.25 - 4 - 1 - 0.25 - 1 - 1 250 @@ -16,20 +8,32 @@ 1 10 + + 0.25 + 4 + 1 + 0.25 + 1 + True + False window1 True + False icons False True + False + False True + False Font family False @@ -45,9 +49,12 @@ True + False + False True + False 6 @@ -68,6 +75,7 @@ True + False False @@ -76,7 +84,9 @@ True + False Bold + False True gtk-bold @@ -88,7 +98,9 @@ True + False Italic + False True gtk-italic @@ -100,6 +112,7 @@ True + False False @@ -108,7 +121,9 @@ True + False Left align + False True gtk-justify-left @@ -120,7 +135,9 @@ True + False Center align + False True gtk-justify-center text_align_left_radio @@ -133,7 +150,9 @@ True + False Right align + False True gtk-justify-right text_align_left_radio @@ -146,6 +165,60 @@ True + False + + + False + + + + + True + False + Top vertical align + False + True + glabels-align-text-top + + + False + True + + + + + True + False + Center vertical align + False + True + glabels-align-text-middle + text_valign_top_radio + + + False + True + + + + + True + False + Bottom vertical align + False + True + glabels-align-text-bottom + text_valign_top_radio + + + False + True + + + + + True + False False @@ -154,9 +227,12 @@ True + False + False True + False Text color False @@ -172,9 +248,12 @@ True + False + False True + False Fill color False @@ -190,9 +269,12 @@ True + False + False True + False Line color False @@ -206,8 +288,9 @@ - + True + False False @@ -216,6 +299,8 @@ True + False + False True diff --git a/src/label-object.c b/src/label-object.c index 92a8ec20..8d48e53a 100644 --- a/src/label-object.c +++ b/src/label-object.c @@ -782,6 +782,28 @@ gl_label_object_set_text_alignment (glLabelObject *object, } +/****************************************************************************/ +/* Set vertical text alignment for all text contained in object. */ +/****************************************************************************/ +void +gl_label_object_set_text_valignment (glLabelObject *object, + glValignment text_valignment, + gboolean checkpoint) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_text_valignment != NULL ) + { + /* We have an object specific method, use it */ + GL_LABEL_OBJECT_GET_CLASS(object)->set_text_valignment (object, text_valignment, checkpoint); + } + + gl_debug (DEBUG_LABEL, "END"); +} + + /****************************************************************************/ /* Set text line spacing for all text contained in object. */ /****************************************************************************/ @@ -946,6 +968,30 @@ gl_label_object_get_text_alignment (glLabelObject *object) } +/****************************************************************************/ +/* Get text alignment for all text contained in object. */ +/****************************************************************************/ +glValignment +gl_label_object_get_text_valignment (glLabelObject *object) +{ + glValignment ret = GL_VALIGN_TOP; + + gl_debug (DEBUG_LABEL, "START"); + + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), GL_VALIGN_TOP); + + if ( GL_LABEL_OBJECT_GET_CLASS(object)->get_text_valignment != NULL ) + { + /* We have an object specific method, use it */ + ret = GL_LABEL_OBJECT_GET_CLASS(object)->get_text_valignment (object); + } + + gl_debug (DEBUG_LABEL, "END"); + + return ret; +} + + /****************************************************************************/ /* Get text line spacing for all text contained in object. */ /****************************************************************************/ diff --git a/src/label-object.h b/src/label-object.h index 8e898a57..4c0e3e1e 100644 --- a/src/label-object.h +++ b/src/label-object.h @@ -29,6 +29,13 @@ G_BEGIN_DECLS +typedef enum { + GL_VALIGN_TOP, + GL_VALIGN_VCENTER, + GL_VALIGN_BOTTOM +} glValignment; + + typedef enum { GL_LABEL_OBJECT_TEXT, GL_LABEL_OBJECT_BOX, @@ -109,6 +116,10 @@ struct _glLabelObjectClass { PangoAlignment text_alignment, gboolean checkpoint); + void (*set_text_valignment) (glLabelObject *object, + glValignment text_valignment, + gboolean checkpoint); + void (*set_text_line_spacing)(glLabelObject *object, gdouble text_line_spacing, gboolean checkpoint); @@ -143,6 +154,8 @@ struct _glLabelObjectClass { PangoAlignment (*get_text_alignment) (glLabelObject *object); + glValignment (*get_text_valignment) (glLabelObject *object); + gdouble (*get_text_line_spacing) (glLabelObject *object); glColorNode * (*get_text_color) (glLabelObject *object); @@ -273,6 +286,10 @@ void gl_label_object_set_text_alignment (glLabelObject *object, PangoAlignment text_alignment, gboolean checkpoint); +void gl_label_object_set_text_valignment (glLabelObject *object, + glValignment text_valignment, + gboolean checkpoint); + void gl_label_object_set_text_color (glLabelObject *object, glColorNode *text_color_node, gboolean checkpoint); @@ -351,6 +368,8 @@ gboolean gl_label_object_get_font_italic_flag (glLabelObject *object) PangoAlignment gl_label_object_get_text_alignment (glLabelObject *object); +glValignment gl_label_object_get_text_valignment (glLabelObject *object); + gdouble gl_label_object_get_text_line_spacing (glLabelObject *object); glColorNode *gl_label_object_get_text_color (glLabelObject *object); diff --git a/src/label-text.c b/src/label-text.c index d9146c42..b2a32317 100644 --- a/src/label-text.c +++ b/src/label-text.c @@ -60,6 +60,7 @@ struct _glLabelTextPrivate { PangoWeight font_weight; gboolean font_italic_flag; PangoAlignment align; + glValignment valign; glColorNode *color_node; gdouble line_spacing; gboolean auto_shrink; @@ -116,6 +117,10 @@ static void set_text_alignment (glLabelObject *object, PangoAlignment text_alignment, gboolean checkpoint); +static void set_text_valignment (glLabelObject *object, + glValignment text_valignment, + gboolean checkpoint); + static void set_text_line_spacing (glLabelObject *object, gdouble text_line_spacing, gboolean checkpoint); @@ -134,6 +139,8 @@ static gboolean get_font_italic_flag (glLabelObject *object); static PangoAlignment get_text_alignment (glLabelObject *object); +static glValignment get_text_valignment (glLabelObject *object); + static gdouble get_text_line_spacing (glLabelObject *object); static glColorNode* get_text_color (glLabelObject *object); @@ -202,6 +209,7 @@ gl_label_text_class_init (glLabelTextClass *class) label_object_class->set_font_weight = set_font_weight; label_object_class->set_font_italic_flag = set_font_italic_flag; label_object_class->set_text_alignment = set_text_alignment; + label_object_class->set_text_valignment = set_text_valignment; label_object_class->set_text_line_spacing = set_text_line_spacing; label_object_class->set_text_color = set_text_color; label_object_class->get_font_family = get_font_family; @@ -209,6 +217,7 @@ gl_label_text_class_init (glLabelTextClass *class) label_object_class->get_font_weight = get_font_weight; label_object_class->get_font_italic_flag = get_font_italic_flag; label_object_class->get_text_alignment = get_text_alignment; + label_object_class->get_text_valignment = get_text_valignment; label_object_class->get_text_line_spacing = get_text_line_spacing; label_object_class->get_text_color = get_text_color; label_object_class->draw_object = draw_object; @@ -290,6 +299,7 @@ gl_label_text_new (glLabel *label, ltext->priv->font_weight = gl_label_get_default_font_weight (label); ltext->priv->font_italic_flag = gl_label_get_default_font_italic_flag (label); ltext->priv->align = gl_label_get_default_text_alignment (label); + ltext->priv->valign = gl_label_get_default_text_valignment (label); ltext->priv->color_node = color_node; ltext->priv->line_spacing = gl_label_get_default_text_line_spacing (label); @@ -328,6 +338,7 @@ copy (glLabelObject *dst_object, new_ltext->priv->font_italic_flag = ltext->priv->font_italic_flag; set_text_color (dst_object, text_color_node, FALSE); new_ltext->priv->align = ltext->priv->align; + new_ltext->priv->valign = ltext->priv->valign; new_ltext->priv->line_spacing = ltext->priv->line_spacing; new_ltext->priv->auto_shrink = ltext->priv->auto_shrink; @@ -733,6 +744,39 @@ set_text_alignment (glLabelObject *object, } +/*****************************************************************************/ +/* Set vertical text alignment method. */ +/*****************************************************************************/ +static void +set_text_valignment (glLabelObject *object, + glValignment text_valignment, + gboolean checkpoint) +{ + glLabelText *ltext = (glLabelText *)object; + glLabel *label; + + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext)); + + if (ltext->priv->valign != text_valignment) + { + if ( checkpoint ) + { + label = gl_label_object_get_parent (GL_LABEL_OBJECT (ltext)); + gl_label_checkpoint (label, _("Vertically align text")); + } + + ltext->priv->size_changed = TRUE; + + ltext->priv->valign = text_valignment; + gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext)); + } + + gl_debug (DEBUG_LABEL, "END"); +} + + /*****************************************************************************/ /* Set text line spacing method. */ /*****************************************************************************/ @@ -879,6 +923,22 @@ get_text_alignment (glLabelObject *object) } +/*****************************************************************************/ +/* Get vertical text alignment method. */ +/*****************************************************************************/ +static glValignment +get_text_valignment (glLabelObject *object) +{ + glLabelText *ltext = (glLabelText *)object; + + gl_debug (DEBUG_LABEL, ""); + + g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), GTK_JUSTIFY_LEFT); + + return ltext->priv->valign; +} + + /*****************************************************************************/ /* Get text line spacing method. */ /*****************************************************************************/ @@ -1025,6 +1085,7 @@ set_text_path (glLabelText *this, gboolean screen_flag, glMergeRecord *record) { + gint iw, ih, y; gdouble object_w, object_h; gdouble raw_w, raw_h; gchar *text; @@ -1092,9 +1153,22 @@ set_text_path (glLabelText *this, } pango_layout_set_wrap (layout, PANGO_WRAP_WORD); pango_layout_set_alignment (layout, this->priv->align); + pango_layout_get_pixel_size (layout, &iw, &ih); + switch (this->priv->valign) + { + case GL_VALIGN_VCENTER: + y = (object_h - ih) / 2; + break; + case GL_VALIGN_BOTTOM: + y = object_h - ih; + break; + default: + y = 0; + break; + } - cairo_move_to (cr, GL_LABEL_TEXT_MARGIN, 0); + cairo_move_to (cr, GL_LABEL_TEXT_MARGIN, y); pango_cairo_layout_path (cr, layout); g_object_unref (layout); diff --git a/src/label.c b/src/label.c index efa117f0..1a7e1b6d 100644 --- a/src/label.c +++ b/src/label.c @@ -75,6 +75,7 @@ struct _glLabelPrivate { gboolean default_font_italic_flag; guint default_text_color; PangoAlignment default_text_alignment; + glValignment default_text_valignment; gdouble default_text_line_spacing; /* Default object line properties */ @@ -2163,6 +2164,39 @@ gl_label_set_selection_text_alignment (glLabel *label, } +/*****************************************************************************/ +/* Set vertical text alignment for all text contained in selected objects. */ +/*****************************************************************************/ +void +gl_label_set_selection_text_valignment (glLabel *label, + glValignment text_valignment) +{ + GList *selection_list; + GList *p; + glLabelObject *object; + + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (label && GL_IS_LABEL (label)); + + begin_selection_op (label); + + selection_list = gl_label_get_selection_list (label); + + for (p = selection_list; p != NULL; p = p->next) + { + object = GL_LABEL_OBJECT (p->data); + gl_label_object_set_text_valignment (object, text_valignment, TRUE); + } + + g_list_free (selection_list); + + end_selection_op (label); + + gl_debug (DEBUG_LABEL, "END"); +} + + /*****************************************************************************/ /* Set text line spacing for all text contained in selected objects. */ /*****************************************************************************/ @@ -2809,6 +2843,22 @@ gl_label_set_default_text_alignment (glLabel *label, } +/****************************************************************************/ +/* Set default vertical text alignment. */ +/****************************************************************************/ +void +gl_label_set_default_text_valignment (glLabel *label, + glValignment text_valignment) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (label && GL_IS_LABEL (label)); + + label->priv->default_text_valignment = text_valignment; + gl_debug (DEBUG_LABEL, "END"); +} + + /****************************************************************************/ /* Set default text line spacing. */ /****************************************************************************/ @@ -2973,6 +3023,22 @@ gl_label_get_default_text_alignment (glLabel *label) } +/****************************************************************************/ +/* Get default vertical text alignment. */ +/****************************************************************************/ +glValignment +gl_label_get_default_text_valignment (glLabel *label) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_val_if_fail (label && GL_IS_LABEL (label), GL_VALIGN_TOP); + + gl_debug (DEBUG_LABEL, "END"); + + return label->priv->default_text_valignment; +} + + /****************************************************************************/ /* Get default text line spacing. */ /****************************************************************************/ diff --git a/src/label.h b/src/label.h index eccd6088..0d593730 100644 --- a/src/label.h +++ b/src/label.h @@ -289,6 +289,9 @@ void gl_label_set_default_text_color (glLabel *label, void gl_label_set_default_text_alignment (glLabel *label, PangoAlignment text_alignment); +void gl_label_set_default_text_valignment (glLabel *label, + glValignment text_valignment); + void gl_label_set_default_line_width (glLabel *label, gdouble line_width); @@ -313,6 +316,8 @@ guint gl_label_get_default_text_color (glLabel *labe PangoAlignment gl_label_get_default_text_alignment (glLabel *label); +glValignment gl_label_get_default_text_valignment (glLabel *label); + gdouble gl_label_get_default_text_line_spacing(glLabel *label); gdouble gl_label_get_default_line_width (glLabel *label); diff --git a/src/object-editor-private.h b/src/object-editor-private.h index 053bcdea..9e778b5b 100644 --- a/src/object-editor-private.h +++ b/src/object-editor-private.h @@ -114,6 +114,9 @@ struct _glObjectEditorPrivate { GtkWidget *text_left_toggle; GtkWidget *text_center_toggle; GtkWidget *text_right_toggle; + GtkWidget *text_top_toggle; + GtkWidget *text_vcenter_toggle; + GtkWidget *text_bottom_toggle; GtkWidget *text_line_spacing_spin; GtkWidget *text_auto_shrink_check; @@ -326,6 +329,11 @@ void gl_object_editor_set_text_alignment (glObjectEditor *editor, PangoAlignment gl_object_editor_get_text_alignment (glObjectEditor *editor); +void gl_object_editor_set_text_valignment (glObjectEditor *editor, + glValignment text_valignment); + +glValignment gl_object_editor_get_text_valignment (glObjectEditor *editor); + void gl_object_editor_set_text_line_spacing (glObjectEditor *editor, gdouble text_line_spacing); diff --git a/src/object-editor-text-page.c b/src/object-editor-text-page.c index 7c82ec90..6acf71a4 100644 --- a/src/object-editor-text-page.c +++ b/src/object-editor-text-page.c @@ -60,6 +60,8 @@ static void align_toggle_cb (GtkToggleButton *toggle, glObjectEditor *editor); +static void valign_toggle_cb (GtkToggleButton *toggle, + glObjectEditor *editor); static void text_radio_toggled_cb (glObjectEditor *editor); @@ -85,6 +87,9 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) "text_left_toggle", &editor->priv->text_left_toggle, "text_center_toggle", &editor->priv->text_center_toggle, "text_right_toggle", &editor->priv->text_right_toggle, + "text_top_toggle", &editor->priv->text_top_toggle, + "text_vcenter_toggle", &editor->priv->text_vcenter_toggle, + "text_bottom_toggle", &editor->priv->text_bottom_toggle, "text_line_spacing_spin", &editor->priv->text_line_spacing_spin, "text_auto_shrink_check", &editor->priv->text_auto_shrink_check, NULL); @@ -162,6 +167,19 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) G_CALLBACK (align_toggle_cb), G_OBJECT (editor)); + g_signal_connect (G_OBJECT (editor->priv->text_top_toggle), + "toggled", + G_CALLBACK (valign_toggle_cb), + G_OBJECT (editor)); + g_signal_connect (G_OBJECT (editor->priv->text_vcenter_toggle), + "toggled", + G_CALLBACK (valign_toggle_cb), + G_OBJECT (editor)); + g_signal_connect (G_OBJECT (editor->priv->text_bottom_toggle), + "toggled", + G_CALLBACK (valign_toggle_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_line_spacing_spin), "value-changed", G_CALLBACK (gl_object_editor_changed_cb), @@ -216,6 +234,46 @@ align_toggle_cb (GtkToggleButton *toggle, } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Vertical alignment togglebutton callback. */ +/*--------------------------------------------------------------------------*/ +static void +valign_toggle_cb (GtkToggleButton *toggle, + glObjectEditor *editor) +{ + if (gtk_toggle_button_get_active (toggle)) { + + if (GTK_WIDGET (toggle) == GTK_WIDGET (editor->priv->text_top_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_vcenter_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_bottom_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (editor->priv->text_vcenter_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_top_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_bottom_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (editor->priv->text_bottom_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_top_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_vcenter_toggle), + FALSE); + } + + gl_object_editor_changed_cb (editor); + } + +} + + /*****************************************************************************/ /* Set font family. */ /*****************************************************************************/ @@ -477,6 +535,69 @@ gl_object_editor_get_text_alignment (glObjectEditor *editor) } +/*****************************************************************************/ +/* Set vertical text alignment. */ +/*****************************************************************************/ +void +gl_object_editor_set_text_valignment (glObjectEditor *editor, + glValignment valign) +{ + gl_debug (DEBUG_EDITOR, "START"); + + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->text_top_toggle), valign_toggle_cb, editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->text_vcenter_toggle), valign_toggle_cb, editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->text_bottom_toggle), valign_toggle_cb, editor); + + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_top_toggle), + (valign == GL_VALIGN_TOP)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_vcenter_toggle), + (valign == GL_VALIGN_VCENTER)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_bottom_toggle), + (valign == GL_VALIGN_BOTTOM)); + + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->text_top_toggle), valign_toggle_cb, editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->text_vcenter_toggle), valign_toggle_cb, editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->text_bottom_toggle), valign_toggle_cb, editor); + + + gl_debug (DEBUG_EDITOR, "END"); +} + + +/*****************************************************************************/ +/* Query vertical text alignment. */ +/*****************************************************************************/ +glValignment +gl_object_editor_get_text_valignment (glObjectEditor *editor) +{ + glValignment valign; + + gl_debug (DEBUG_EDITOR, "START"); + + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_top_toggle))) { + valign = GL_VALIGN_TOP; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_bottom_toggle))) { + valign = GL_VALIGN_BOTTOM; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_vcenter_toggle))) { + valign = GL_VALIGN_VCENTER; + } else { + valign = GL_VALIGN_TOP; /* Should not happen. */ + } + + gl_debug (DEBUG_EDITOR, "END"); + + return valign; +} + + /*****************************************************************************/ /* Set text color. */ /*****************************************************************************/ diff --git a/src/object-editor.c b/src/object-editor.c index 68cfa493..abbce239 100644 --- a/src/object-editor.c +++ b/src/object-editor.c @@ -749,6 +749,7 @@ object_changed_cb (glLabelObject *object, gboolean font_italic_flag; glColorNode *text_color_node; PangoAlignment align; + glValignment valign; gdouble text_line_spacing; gboolean auto_shrink; gdouble image_w, image_h; @@ -825,6 +826,7 @@ object_changed_cb (glLabelObject *object, font_italic_flag = gl_label_object_get_font_italic_flag (object); text_color_node = gl_label_object_get_text_color (object); align = gl_label_object_get_text_alignment (object); + valign = gl_label_object_get_text_valignment (object); text_line_spacing = gl_label_object_get_text_line_spacing (object); auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object)); @@ -835,6 +837,7 @@ object_changed_cb (glLabelObject *object, gl_object_editor_set_font_italic_flag (editor, font_italic_flag); gl_object_editor_set_text_color (editor, (merge != NULL), text_color_node); gl_object_editor_set_text_alignment (editor, align); + gl_object_editor_set_text_valignment (editor, valign); gl_object_editor_set_text_line_spacing (editor, text_line_spacing); gl_object_editor_set_text_auto_shrink (editor, auto_shrink); @@ -913,6 +916,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor) gboolean font_italic_flag; glColorNode *text_color_node; PangoAlignment align; + glValignment valign; gdouble text_line_spacing; gboolean auto_shrink; glTextNode *filename; @@ -995,6 +999,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor) font_italic_flag = gl_object_editor_get_font_italic_flag (editor); text_color_node = gl_object_editor_get_text_color (editor); align = gl_object_editor_get_text_alignment (editor); + valign = gl_object_editor_get_text_valignment (editor); text_line_spacing = gl_object_editor_get_text_line_spacing (editor); auto_shrink = gl_object_editor_get_text_auto_shrink (editor); @@ -1004,6 +1009,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor) gl_label_object_set_font_italic_flag (object, font_italic_flag, TRUE); gl_label_object_set_text_color (object, text_color_node, TRUE); gl_label_object_set_text_alignment (object, align, TRUE); + gl_label_object_set_text_valignment (object, valign, TRUE); gl_label_object_set_text_line_spacing (object, text_line_spacing, TRUE); gl_label_text_set_auto_shrink (GL_LABEL_TEXT (object), auto_shrink, TRUE); diff --git a/src/str-util.c b/src/str-util.c index f8c6d70a..deb939fe 100644 --- a/src/str-util.c +++ b/src/str-util.c @@ -25,6 +25,8 @@ #include #include +#include "label-object.h" + /****************************************************************************/ /* Utilities to deal with PangoAlignment types. */ @@ -62,6 +64,42 @@ gl_str_util_string_to_align (const gchar *string) } +/****************************************************************************/ +/* Utilities to deal with vertical alignment types. */ +/****************************************************************************/ +const gchar * +gl_str_util_valign_to_string (glValignment valign) +{ + switch (valign) { + case GL_VALIGN_TOP: + return "Top"; + case GL_VALIGN_VCENTER: + return "Center"; + case GL_VALIGN_BOTTOM: + return "Bottom"; + default: + return "?"; + } +} + + +glValignment +gl_str_util_string_to_valign (const gchar *string) +{ + + if (g_ascii_strcasecmp (string, "Top") == 0) { + return GL_VALIGN_TOP; + } else if (g_ascii_strcasecmp (string, "Center") == 0) { + return GL_VALIGN_VCENTER; + } else if (g_ascii_strcasecmp (string, "Bottom") == 0) { + return GL_VALIGN_BOTTOM; + } else { + return GL_VALIGN_TOP; + } + +} + + /****************************************************************************/ /* Utilities to deal with PangoWeight types */ /****************************************************************************/ diff --git a/src/ui-property-bar.c b/src/ui-property-bar.c index 4e26f5c8..e4eba227 100644 --- a/src/ui-property-bar.c +++ b/src/ui-property-bar.c @@ -59,11 +59,16 @@ struct _glUIPropertyBarPrivate { GtkWidget *font_bold_toggle; GtkWidget *font_italic_toggle; - /* Text alignemnt radios */ + /* Text alignment radios */ GtkWidget *text_align_left_radio; GtkWidget *text_align_center_radio; GtkWidget *text_align_right_radio; + /* Text vertical alignment radios */ + GtkWidget *text_valign_top_radio; + GtkWidget *text_valign_vcenter_radio; + GtkWidget *text_valign_bottom_radio; + /* Color combos */ GtkWidget *text_color_eventbox; GtkWidget *text_color_button; @@ -129,6 +134,9 @@ static void font_italic_toggled_cb (GtkToggleToolButton *toggle, static void text_align_toggled_cb (GtkToggleToolButton *toggle, glUIPropertyBar *this); +static void text_valign_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *this); + static void set_doc_items_sensitive (glUIPropertyBar *this, gboolean state); @@ -251,18 +259,21 @@ gl_ui_property_bar_construct (glUIPropertyBar *this) } gl_builder_util_get_widgets (builder, - "property_toolbar", &this->priv->tool_bar, - "font_family_eventbox", &this->priv->font_family_eventbox, - "font_size_spin", &this->priv->font_size_spin, - "font_bold_toggle", &this->priv->font_bold_toggle, - "font_italic_toggle", &this->priv->font_italic_toggle, - "text_align_left_radio", &this->priv->text_align_left_radio, - "text_align_center_radio", &this->priv->text_align_center_radio, - "text_align_right_radio", &this->priv->text_align_right_radio, - "text_color_eventbox", &this->priv->text_color_eventbox, - "fill_color_eventbox", &this->priv->fill_color_eventbox, - "line_color_eventbox", &this->priv->line_color_eventbox, - "line_width_spin", &this->priv->line_width_spin, + "property_toolbar", &this->priv->tool_bar, + "font_family_eventbox", &this->priv->font_family_eventbox, + "font_size_spin", &this->priv->font_size_spin, + "font_bold_toggle", &this->priv->font_bold_toggle, + "font_italic_toggle", &this->priv->font_italic_toggle, + "text_align_left_radio", &this->priv->text_align_left_radio, + "text_align_center_radio", &this->priv->text_align_center_radio, + "text_align_right_radio", &this->priv->text_align_right_radio, + "text_valign_top_radio", &this->priv->text_valign_top_radio, + "text_valign_vcenter_radio", &this->priv->text_valign_vcenter_radio, + "text_valign_bottom_radio", &this->priv->text_valign_bottom_radio, + "text_color_eventbox", &this->priv->text_color_eventbox, + "fill_color_eventbox", &this->priv->fill_color_eventbox, + "line_color_eventbox", &this->priv->line_color_eventbox, + "line_width_spin", &this->priv->line_width_spin, NULL); gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar); @@ -344,6 +355,17 @@ gl_ui_property_bar_construct (glUIPropertyBar *this) g_signal_connect (G_OBJECT (this->priv->text_align_right_radio), "toggled", G_CALLBACK (text_align_toggled_cb), this); + /* Text vertical alignment radio group */ + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_top_radio), TRUE); + g_signal_connect (G_OBJECT (this->priv->text_valign_top_radio), + "toggled", G_CALLBACK (text_valign_toggled_cb), this); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_vcenter_radio), FALSE); + g_signal_connect (G_OBJECT (this->priv->text_valign_vcenter_radio), + "toggled", G_CALLBACK (text_valign_toggled_cb), this); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_bottom_radio), FALSE); + g_signal_connect (G_OBJECT (this->priv->text_valign_bottom_radio), + "toggled", G_CALLBACK (text_valign_toggled_cb), this); + /* Text color widget */ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button), gl_prefs_model_get_default_text_color (gl_prefs)); @@ -404,6 +426,13 @@ reset_to_default_properties (glLabel *label, gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio), (gl_label_get_default_text_alignment (label) == PANGO_ALIGN_RIGHT)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_top_radio), + (gl_label_get_default_text_valignment (label) == GL_VALIGN_TOP)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_vcenter_radio), + (gl_label_get_default_text_valignment (label) == GL_VALIGN_VCENTER)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_bottom_radio), + (gl_label_get_default_text_valignment (label) == GL_VALIGN_BOTTOM)); + gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button), gl_label_get_default_text_color (label)); @@ -455,7 +484,7 @@ update_text_properties (glLabel *label, gboolean can_text, is_first_object; gboolean is_same_font_family, is_same_font_size; gboolean is_same_text_color, is_same_is_italic; - gboolean is_same_is_bold, is_same_align; + gboolean is_same_is_bold, is_same_align, is_same_valign; GList *selection_list; GList *p; glLabelObject *object; @@ -466,6 +495,7 @@ update_text_properties (glLabel *label, gboolean selection_is_italic, is_italic; gboolean selection_is_bold, is_bold; PangoAlignment selection_align, align; + glValignment selection_valign, valign; can_text = gl_label_can_selection_text (label); set_text_items_sensitive (this, can_text); @@ -476,6 +506,7 @@ update_text_properties (glLabel *label, is_same_is_italic = is_same_is_bold = is_same_align = + is_same_valign = is_same_text_color = is_same_font_size = is_same_font_family = TRUE; @@ -531,6 +562,7 @@ update_text_properties (glLabel *label, is_italic = gl_label_object_get_font_italic_flag (object); is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD; align = gl_label_object_get_text_alignment (object); + valign = gl_label_object_get_text_valignment (object); if (is_first_object) { @@ -539,6 +571,7 @@ update_text_properties (glLabel *label, selection_is_italic = is_italic; selection_is_bold = is_bold; selection_align = align; + selection_valign = valign; } else { @@ -552,6 +585,8 @@ update_text_properties (glLabel *label, is_same_is_bold = FALSE; if (align != selection_align) is_same_align = FALSE; + if (valign != selection_valign) + is_same_valign = FALSE; } is_first_object = FALSE; } @@ -611,6 +646,18 @@ update_text_properties (glLabel *label, gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio), (selection_align == PANGO_ALIGN_RIGHT) && is_same_align); + + if (is_same_valign) + gl_debug (DEBUG_PROPERTY_BAR, "same valign"); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_top_radio), + (selection_valign == GL_VALIGN_TOP) && + is_same_valign); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_vcenter_radio), + (selection_valign == GL_VALIGN_VCENTER) && + is_same_valign); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_bottom_radio), + (selection_valign == GL_VALIGN_BOTTOM) && + is_same_valign); } @@ -1170,6 +1217,48 @@ text_align_toggled_cb (GtkToggleToolButton *toggle, } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Text vertical align toggled callback. */ +/*---------------------------------------------------------------------------*/ +static void +text_valign_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *this) +{ + if (this->priv->stop_signals) return; + this->priv->stop_signals = TRUE; + + gl_debug (DEBUG_PROPERTY_BAR, "START"); + + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_top_radio))) + { + gl_label_set_selection_text_valignment (this->priv->label, + GL_VALIGN_TOP); + gl_label_set_default_text_valignment (this->priv->label, + GL_VALIGN_TOP); + } + + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_vcenter_radio))) + { + gl_label_set_selection_text_valignment (this->priv->label, + GL_VALIGN_VCENTER); + gl_label_set_default_text_valignment (this->priv->label, + GL_VALIGN_VCENTER); + } + + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_valign_bottom_radio))) + { + gl_label_set_selection_text_valignment (this->priv->label, + GL_VALIGN_BOTTOM); + gl_label_set_default_text_valignment (this->priv->label, + GL_VALIGN_BOTTOM); + } + + gl_debug (DEBUG_PROPERTY_BAR, "END"); + + this->priv->stop_signals = FALSE; +} + + /*---------------------------------------------------------------------------*/ /* PRIVATE. Set sensitivity of doc controls. */ /*---------------------------------------------------------------------------*/ @@ -1177,17 +1266,20 @@ static void set_doc_items_sensitive (glUIPropertyBar *this, gboolean state) { - gtk_widget_set_sensitive (this->priv->font_family_combo, state); - gtk_widget_set_sensitive (this->priv->font_size_spin, state); - gtk_widget_set_sensitive (this->priv->font_bold_toggle, state); - gtk_widget_set_sensitive (this->priv->font_italic_toggle, state); - gtk_widget_set_sensitive (this->priv->text_align_left_radio, state); - gtk_widget_set_sensitive (this->priv->text_align_center_radio, state); - gtk_widget_set_sensitive (this->priv->text_align_right_radio, state); - gtk_widget_set_sensitive (this->priv->text_color_button, state); - gtk_widget_set_sensitive (this->priv->fill_color_button, state); - gtk_widget_set_sensitive (this->priv->line_color_button, state); - gtk_widget_set_sensitive (this->priv->line_width_spin, state); + gtk_widget_set_sensitive (this->priv->font_family_combo, state); + gtk_widget_set_sensitive (this->priv->font_size_spin, state); + gtk_widget_set_sensitive (this->priv->font_bold_toggle, state); + gtk_widget_set_sensitive (this->priv->font_italic_toggle, state); + gtk_widget_set_sensitive (this->priv->text_align_left_radio, state); + gtk_widget_set_sensitive (this->priv->text_align_center_radio, state); + gtk_widget_set_sensitive (this->priv->text_align_right_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_top_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_vcenter_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_bottom_radio, state); + gtk_widget_set_sensitive (this->priv->text_color_button, state); + gtk_widget_set_sensitive (this->priv->fill_color_button, state); + gtk_widget_set_sensitive (this->priv->line_color_button, state); + gtk_widget_set_sensitive (this->priv->line_width_spin, state); } @@ -1198,14 +1290,17 @@ static void set_text_items_sensitive (glUIPropertyBar *this, gboolean state) { - gtk_widget_set_sensitive (this->priv->font_family_combo, state); - gtk_widget_set_sensitive (this->priv->font_size_spin, state); - gtk_widget_set_sensitive (this->priv->font_bold_toggle, state); - gtk_widget_set_sensitive (this->priv->font_italic_toggle, state); - gtk_widget_set_sensitive (this->priv->text_align_left_radio, state); - gtk_widget_set_sensitive (this->priv->text_align_center_radio, state); - gtk_widget_set_sensitive (this->priv->text_align_right_radio, state); - gtk_widget_set_sensitive (this->priv->text_color_button, state); + gtk_widget_set_sensitive (this->priv->font_family_combo, state); + gtk_widget_set_sensitive (this->priv->font_size_spin, state); + gtk_widget_set_sensitive (this->priv->font_bold_toggle, state); + gtk_widget_set_sensitive (this->priv->font_italic_toggle, state); + gtk_widget_set_sensitive (this->priv->text_align_left_radio, state); + gtk_widget_set_sensitive (this->priv->text_align_center_radio, state); + gtk_widget_set_sensitive (this->priv->text_align_right_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_top_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_vcenter_radio, state); + gtk_widget_set_sensitive (this->priv->text_valign_bottom_radio, state); + gtk_widget_set_sensitive (this->priv->text_color_button, state); } diff --git a/src/xml-label.c b/src/xml-label.c index 79b46469..f7743fd5 100644 --- a/src/xml-label.c +++ b/src/xml-label.c @@ -436,6 +436,7 @@ xml_parse_object_text (xmlNodePtr node, gdouble w, h; gchar *string; PangoAlignment align; + glValignment valign; gboolean auto_shrink; xmlNodePtr child; @@ -459,6 +460,12 @@ xml_parse_object_text (xmlNodePtr node, g_free (string); gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), align, FALSE); + /* valign attr */ + string = lgl_xml_get_prop_string (node, "valign", NULL); + valign = gl_str_util_string_to_valign (string); + g_free (string); + gl_label_object_set_text_valignment (GL_LABEL_OBJECT(object), valign, FALSE); + /* auto_shrink attr */ auto_shrink = lgl_xml_get_prop_boolean (node, "auto_shrink", FALSE); gl_label_text_set_auto_shrink (GL_LABEL_TEXT(object), auto_shrink, FALSE); @@ -1321,6 +1328,7 @@ xml_create_object_text (xmlNodePtr parent, gdouble x, y; gdouble w, h; PangoAlignment align; + glValignment valign; gboolean auto_shrink; gl_debug (DEBUG_XML, "START"); @@ -1341,6 +1349,10 @@ xml_create_object_text (xmlNodePtr parent, align = gl_label_object_get_text_alignment (object); lgl_xml_set_prop_string (node, "justify", gl_str_util_align_to_string (align)); + /* valign attr */ + valign = gl_label_object_get_text_valignment (object); + lgl_xml_set_prop_string (node, "valign", gl_str_util_valign_to_string (valign)); + /* auto_shrink attr */ auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object)); lgl_xml_set_prop_boolean (node, "auto_shrink", auto_shrink); diff --git a/templates/glabels-3.0.dtd b/templates/glabels-3.0.dtd index 5e745535..7e8dcc13 100644 --- a/templates/glabels-3.0.dtd +++ b/templates/glabels-3.0.dtd @@ -41,6 +41,7 @@ + @@ -344,6 +345,7 @@ %position_attrs; %size_attrs; justify %JUSTIFY_TYPE; #REQUIRED + valign %VALIGN_TYPE; #REQUIRED auto_shrink %BOOLEAN_TYPE; #IMPLIED %affine_attrs; %shadow_attrs;