textview: Add line-spacing plumbing
This adds a line-spacing property to GtkTextAttributes and GtkTextTag.
This commit is contained in:
@@ -387,6 +387,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
|
||||
if (tag->priv->pixels_inside_wrap_set)
|
||||
dest->pixels_inside_wrap = vals->pixels_inside_wrap;
|
||||
|
||||
if (tag->priv->line_spacing_set)
|
||||
dest->line_spacing = vals->line_spacing;
|
||||
|
||||
if (tag->priv->tabs_set)
|
||||
{
|
||||
if (dest->tabs)
|
||||
@@ -457,6 +460,7 @@ _gtk_text_tag_affects_size (GtkTextTag *tag)
|
||||
priv->pixels_above_lines_set ||
|
||||
priv->pixels_below_lines_set ||
|
||||
priv->pixels_inside_wrap_set ||
|
||||
priv->line_spacing_set ||
|
||||
priv->tabs_set ||
|
||||
priv->underline_set ||
|
||||
priv->overline_set ||
|
||||
|
||||
@@ -147,6 +147,8 @@ struct _GtkTextAttributes
|
||||
int pixels_below_lines;
|
||||
int pixels_inside_wrap;
|
||||
|
||||
float line_spacing;
|
||||
|
||||
int letter_spacing;
|
||||
|
||||
guint invisible : 1;
|
||||
|
||||
@@ -1277,6 +1277,8 @@ set_para_values (GtkTextLayout *layout,
|
||||
pango_layout_set_spacing (display->layout,
|
||||
style->pixels_inside_wrap * PANGO_SCALE);
|
||||
|
||||
pango_layout_set_line_spacing (display->layout, style->line_spacing);
|
||||
|
||||
if (style->tabs)
|
||||
pango_layout_set_tabs (display->layout, style->tabs);
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ enum {
|
||||
PROP_PIXELS_ABOVE_LINES,
|
||||
PROP_PIXELS_BELOW_LINES,
|
||||
PROP_PIXELS_INSIDE_WRAP,
|
||||
PROP_LINE_SPACING,
|
||||
PROP_EDITABLE,
|
||||
PROP_WRAP_MODE,
|
||||
PROP_JUSTIFICATION,
|
||||
@@ -150,6 +151,7 @@ enum {
|
||||
PROP_PIXELS_ABOVE_LINES_SET,
|
||||
PROP_PIXELS_BELOW_LINES_SET,
|
||||
PROP_PIXELS_INSIDE_WRAP_SET,
|
||||
PROP_LINE_SPACING_SET,
|
||||
PROP_EDITABLE_SET,
|
||||
PROP_WRAP_MODE_SET,
|
||||
PROP_JUSTIFICATION_SET,
|
||||
@@ -585,6 +587,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
* GtkTextTag:pixels-inside-wrap:
|
||||
*
|
||||
* Pixels of blank space between wrapped lines in a paragraph.
|
||||
*
|
||||
* Ignored if line-spacing is set.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXELS_INSIDE_WRAP,
|
||||
@@ -596,6 +600,21 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTextag:line-spacing:
|
||||
*
|
||||
* The line spacing factor that is applied between consecutive lines.
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LINE_SPACING,
|
||||
g_param_spec_float ("line-spacing",
|
||||
P_("Linespacing"),
|
||||
P_("The factor for spacing between lines"),
|
||||
0.0, 10.0, 0.0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTextTag:strikethrough:
|
||||
*
|
||||
@@ -936,6 +955,10 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
P_("Pixels inside wrap set"),
|
||||
P_("Whether this tag affects the number of pixels between wrapped lines"));
|
||||
|
||||
ADD_SET_PROP ("line-spacing-set", PROP_LINE_SPACING_SET,
|
||||
P_("Linespacing set"),
|
||||
P_("Whether this tag affects spacing between wrapped lines"));
|
||||
|
||||
ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
|
||||
P_("Strikethrough set"),
|
||||
P_("Whether this tag affects strikethrough"));
|
||||
@@ -1573,6 +1596,13 @@ gtk_text_tag_set_property (GObject *object,
|
||||
size_changed = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_LINE_SPACING:
|
||||
priv->line_spacing_set = TRUE;
|
||||
priv->values->line_spacing = g_value_get_float (value);
|
||||
g_object_notify (object, "line-spacing-set");
|
||||
size_changed = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
priv->editable_set = TRUE;
|
||||
priv->values->editable = g_value_get_boolean (value);
|
||||
|
||||
@@ -71,6 +71,7 @@ struct _GtkTextTagPrivate
|
||||
guint pixels_above_lines_set : 1;
|
||||
guint pixels_below_lines_set : 1;
|
||||
guint pixels_inside_wrap_set : 1;
|
||||
guint line_spacing_set : 1;
|
||||
guint tabs_set : 1;
|
||||
guint underline_set : 1;
|
||||
guint overline_set : 1;
|
||||
|
||||
Reference in New Issue
Block a user