Compare commits
7 Commits
async-dial
...
wip/pbor/c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4231331485 | ||
|
|
906e604c35 | ||
|
|
797f6af5bc | ||
|
|
789ba318dd | ||
|
|
75b96426f5 | ||
|
|
28dd08b134 | ||
|
|
625e9ffa63 |
@@ -553,6 +553,52 @@ _gtk_css_font_stretch_value_get (const GtkCssValue *value)
|
|||||||
return value->value;
|
return value->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GtkTextDecorationLine */
|
||||||
|
|
||||||
|
static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
|
||||||
|
gtk_css_value_enum_free,
|
||||||
|
gtk_css_value_enum_compute,
|
||||||
|
gtk_css_value_enum_equal,
|
||||||
|
gtk_css_value_enum_transition,
|
||||||
|
gtk_css_value_enum_print
|
||||||
|
};
|
||||||
|
|
||||||
|
static GtkCssValue text_decoration_line_values[] = {
|
||||||
|
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
|
||||||
|
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
|
||||||
|
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" },
|
||||||
|
};
|
||||||
|
|
||||||
|
GtkCssValue *
|
||||||
|
_gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (line < G_N_ELEMENTS (text_decoration_line_values), NULL);
|
||||||
|
|
||||||
|
return _gtk_css_value_ref (&text_decoration_line_values[line]);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkCssValue *_gtk_css_text_decoration_line_value_try_parse (GtkCssParser *parser)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (parser != NULL, NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (text_decoration_line_values); i++)
|
||||||
|
{
|
||||||
|
if (_gtk_css_parser_try (parser, text_decoration_line_values[i].name, TRUE))
|
||||||
|
return _gtk_css_value_ref (&text_decoration_line_values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkTextDecorationLine _gtk_css_text_decoration_line_value_get (const GtkCssValue *value)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (value->class == >K_CSS_VALUE_TEXT_DECORATION_LINE, GTK_CSS_TEXT_DECORATION_LINE_NONE);
|
||||||
|
|
||||||
|
return value->value;
|
||||||
|
}
|
||||||
|
|
||||||
/* GtkCssArea */
|
/* GtkCssArea */
|
||||||
|
|
||||||
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ GtkCssValue * _gtk_css_font_stretch_value_new (PangoStretch stretc
|
|||||||
GtkCssValue * _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser);
|
GtkCssValue * _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser);
|
||||||
PangoStretch _gtk_css_font_stretch_value_get (const GtkCssValue *value);
|
PangoStretch _gtk_css_font_stretch_value_get (const GtkCssValue *value);
|
||||||
|
|
||||||
|
GtkCssValue * _gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line);
|
||||||
|
GtkCssValue * _gtk_css_text_decoration_line_value_try_parse (GtkCssParser *parser);
|
||||||
|
GtkTextDecorationLine _gtk_css_text_decoration_line_value_get (const GtkCssValue *value);
|
||||||
|
|
||||||
GtkCssValue * _gtk_css_area_value_new (GtkCssArea area);
|
GtkCssValue * _gtk_css_area_value_new (GtkCssArea area);
|
||||||
GtkCssValue * _gtk_css_area_value_try_parse (GtkCssParser *parser);
|
GtkCssValue * _gtk_css_area_value_try_parse (GtkCssParser *parser);
|
||||||
GtkCssArea _gtk_css_area_value_get (const GtkCssValue *value);
|
GtkCssArea _gtk_css_area_value_get (const GtkCssValue *value);
|
||||||
|
|||||||
@@ -823,6 +823,38 @@ parse_animation (GtkCssShorthandProperty *shorthand,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_text_decoration (GtkCssShorthandProperty *shorthand,
|
||||||
|
GtkCssValue **values,
|
||||||
|
GtkCssParser *parser)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (values[0] == NULL &&
|
||||||
|
(values[0] = _gtk_css_text_decoration_line_value_try_parse (parser)))
|
||||||
|
{
|
||||||
|
if (values[0] == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (values[1] == NULL)
|
||||||
|
{
|
||||||
|
values[1] = _gtk_css_color_value_parse (parser);
|
||||||
|
if (values[1] == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We parsed and there's still stuff left?
|
||||||
|
* Pretend we didn't notice and let the normal code produce
|
||||||
|
* a 'junk at end of value' error */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!value_is_done_parsing (parser));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_all (GtkCssShorthandProperty *shorthand,
|
parse_all (GtkCssShorthandProperty *shorthand,
|
||||||
GtkCssValue **values,
|
GtkCssValue **values,
|
||||||
@@ -1170,6 +1202,7 @@ _gtk_css_shorthand_property_init_properties (void)
|
|||||||
const char *transition_subproperties[] = { "transition-property", "transition-duration", "transition-delay", "transition-timing-function", NULL };
|
const char *transition_subproperties[] = { "transition-property", "transition-duration", "transition-delay", "transition-timing-function", NULL };
|
||||||
const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay",
|
const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay",
|
||||||
"animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
|
"animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
|
||||||
|
const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-color", NULL };
|
||||||
|
|
||||||
const char **all_subproperties;
|
const char **all_subproperties;
|
||||||
|
|
||||||
@@ -1281,6 +1314,12 @@ _gtk_css_shorthand_property_init_properties (void)
|
|||||||
parse_animation,
|
parse_animation,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
_gtk_css_shorthand_property_register ("text-decoration",
|
||||||
|
G_TYPE_NONE,
|
||||||
|
text_decoration_subproperties,
|
||||||
|
parse_text_decoration,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
all_subproperties = get_all_subproperties ();
|
all_subproperties = get_all_subproperties ();
|
||||||
_gtk_css_shorthand_property_register ("all",
|
_gtk_css_shorthand_property_register ("all",
|
||||||
|
|||||||
@@ -610,6 +610,25 @@ bindings_value_assign (GtkCssStyleProperty *property,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkCssValue *
|
||||||
|
parse_letter_spacing (GtkCssStyleProperty *property,
|
||||||
|
GtkCssParser *parser)
|
||||||
|
{
|
||||||
|
return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkCssValue *
|
||||||
|
parse_text_decoration_line (GtkCssStyleProperty *property,
|
||||||
|
GtkCssParser *parser)
|
||||||
|
{
|
||||||
|
GtkCssValue *value = _gtk_css_text_decoration_line_value_try_parse (parser);
|
||||||
|
|
||||||
|
if (value == NULL)
|
||||||
|
_gtk_css_parser_error (parser, "unknown value for property");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static GtkCssValue *
|
static GtkCssValue *
|
||||||
box_shadow_value_parse (GtkCssStyleProperty *property,
|
box_shadow_value_parse (GtkCssStyleProperty *property,
|
||||||
GtkCssParser *parser)
|
GtkCssParser *parser)
|
||||||
@@ -1065,6 +1084,36 @@ _gtk_css_style_property_init_properties (void)
|
|||||||
assign_pango_stretch,
|
assign_pango_stretch,
|
||||||
_gtk_css_font_stretch_value_new (PANGO_STRETCH_NORMAL));
|
_gtk_css_font_stretch_value_new (PANGO_STRETCH_NORMAL));
|
||||||
|
|
||||||
|
gtk_css_style_property_register ("letter-spacing",
|
||||||
|
GTK_CSS_PROPERTY_LETTER_SPACING,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
|
||||||
|
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
|
||||||
|
parse_letter_spacing,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
|
||||||
|
|
||||||
|
gtk_css_style_property_register ("text-decoration-line",
|
||||||
|
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
GTK_STYLE_PROPERTY_ANIMATED,
|
||||||
|
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
|
||||||
|
parse_text_decoration_line,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
_gtk_css_text_decoration_line_value_new (GTK_CSS_TEXT_DECORATION_LINE_NONE));
|
||||||
|
|
||||||
|
gtk_css_style_property_register ("text-decoration-color",
|
||||||
|
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
GTK_STYLE_PROPERTY_ANIMATED,
|
||||||
|
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
|
||||||
|
color_parse,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
_gtk_css_color_value_new_current_color ());
|
||||||
|
|
||||||
gtk_css_style_property_register ("text-shadow",
|
gtk_css_style_property_register ("text-shadow",
|
||||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||||
G_TYPE_NONE,
|
G_TYPE_NONE,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ typedef enum { /*< skip >*/
|
|||||||
* @GTK_CSS_AFFECTS_FONT: The font is affected and should be reloaded
|
* @GTK_CSS_AFFECTS_FONT: The font is affected and should be reloaded
|
||||||
* if it was cached.
|
* if it was cached.
|
||||||
* @GTK_CSS_AFFECTS_TEXT: Text rendering is affected.
|
* @GTK_CSS_AFFECTS_TEXT: Text rendering is affected.
|
||||||
|
* @GTK_CSS_AFFECTS_TEXT_ATTRS: Text attributes are affected.
|
||||||
* @GTK_CSS_AFFECTS_ICON: Icons and icon rendering is affected.
|
* @GTK_CSS_AFFECTS_ICON: Icons and icon rendering is affected.
|
||||||
* @GTK_CSS_AFFECTS_OUTLINE: The outline styling is affected. Outlines
|
* @GTK_CSS_AFFECTS_OUTLINE: The outline styling is affected. Outlines
|
||||||
* only affect elements that can be focused.
|
* only affect elements that can be focused.
|
||||||
@@ -99,10 +100,11 @@ typedef enum {
|
|||||||
GTK_CSS_AFFECTS_BORDER = (1 << 2),
|
GTK_CSS_AFFECTS_BORDER = (1 << 2),
|
||||||
GTK_CSS_AFFECTS_FONT = (1 << 3),
|
GTK_CSS_AFFECTS_FONT = (1 << 3),
|
||||||
GTK_CSS_AFFECTS_TEXT = (1 << 4),
|
GTK_CSS_AFFECTS_TEXT = (1 << 4),
|
||||||
GTK_CSS_AFFECTS_ICON = (1 << 5),
|
GTK_CSS_AFFECTS_TEXT_ATTRS = (1 << 5),
|
||||||
GTK_CSS_AFFECTS_OUTLINE = (1 << 6),
|
GTK_CSS_AFFECTS_ICON = (1 << 6),
|
||||||
GTK_CSS_AFFECTS_CLIP = (1 << 7),
|
GTK_CSS_AFFECTS_OUTLINE = (1 << 7),
|
||||||
GTK_CSS_AFFECTS_SIZE = (1 << 8)
|
GTK_CSS_AFFECTS_CLIP = (1 << 8),
|
||||||
|
GTK_CSS_AFFECTS_SIZE = (1 << 9)
|
||||||
} GtkCssAffects;
|
} GtkCssAffects;
|
||||||
|
|
||||||
enum { /*< skip >*/
|
enum { /*< skip >*/
|
||||||
@@ -116,6 +118,9 @@ enum { /*< skip >*/
|
|||||||
GTK_CSS_PROPERTY_FONT_VARIANT,
|
GTK_CSS_PROPERTY_FONT_VARIANT,
|
||||||
GTK_CSS_PROPERTY_FONT_WEIGHT,
|
GTK_CSS_PROPERTY_FONT_WEIGHT,
|
||||||
GTK_CSS_PROPERTY_FONT_STRETCH,
|
GTK_CSS_PROPERTY_FONT_STRETCH,
|
||||||
|
GTK_CSS_PROPERTY_LETTER_SPACING,
|
||||||
|
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
|
||||||
|
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
|
||||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||||
GTK_CSS_PROPERTY_BOX_SHADOW,
|
GTK_CSS_PROPERTY_BOX_SHADOW,
|
||||||
GTK_CSS_PROPERTY_MARGIN_TOP,
|
GTK_CSS_PROPERTY_MARGIN_TOP,
|
||||||
@@ -235,6 +240,12 @@ typedef enum /*< skip >*/ {
|
|||||||
GTK_CSS_FONT_SIZE_XX_LARGE
|
GTK_CSS_FONT_SIZE_XX_LARGE
|
||||||
} GtkCssFontSize;
|
} GtkCssFontSize;
|
||||||
|
|
||||||
|
typedef enum /*< skip >*/ {
|
||||||
|
GTK_CSS_TEXT_DECORATION_LINE_NONE,
|
||||||
|
GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE,
|
||||||
|
GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH
|
||||||
|
} GtkTextDecorationLine;
|
||||||
|
|
||||||
/* for the order in arrays */
|
/* for the order in arrays */
|
||||||
typedef enum /*< skip >*/ {
|
typedef enum /*< skip >*/ {
|
||||||
GTK_CSS_TOP,
|
GTK_CSS_TOP,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkmenu.h"
|
#include "gtkmenu.h"
|
||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitem.h"
|
||||||
|
#include "gtkpango.h"
|
||||||
#include "gtkseparatormenuitem.h"
|
#include "gtkseparatormenuitem.h"
|
||||||
#include "gtkselection.h"
|
#include "gtkselection.h"
|
||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
@@ -6250,8 +6251,10 @@ gtk_entry_create_layout (GtkEntry *entry,
|
|||||||
{
|
{
|
||||||
GtkEntryPrivate *priv = entry->priv;
|
GtkEntryPrivate *priv = entry->priv;
|
||||||
GtkWidget *widget = GTK_WIDGET (entry);
|
GtkWidget *widget = GTK_WIDGET (entry);
|
||||||
|
GtkStyleContext *context;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoAttrList *tmp_attrs;
|
PangoAttrList *tmp_attrs;
|
||||||
|
PangoAttrList *style_attrs;
|
||||||
gboolean placeholder_layout;
|
gboolean placeholder_layout;
|
||||||
|
|
||||||
gchar *preedit_string = NULL;
|
gchar *preedit_string = NULL;
|
||||||
@@ -6261,12 +6264,21 @@ gtk_entry_create_layout (GtkEntry *entry,
|
|||||||
gchar *display_text;
|
gchar *display_text;
|
||||||
guint n_bytes;
|
guint n_bytes;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
|
||||||
layout = gtk_widget_create_pango_layout (widget, NULL);
|
layout = gtk_widget_create_pango_layout (widget, NULL);
|
||||||
pango_layout_set_single_paragraph_mode (layout, TRUE);
|
pango_layout_set_single_paragraph_mode (layout, TRUE);
|
||||||
|
|
||||||
tmp_attrs = priv->attrs ? pango_attr_list_ref (priv->attrs)
|
tmp_attrs = priv->attrs ? pango_attr_list_ref (priv->attrs)
|
||||||
: pango_attr_list_new ();
|
: pango_attr_list_new ();
|
||||||
|
|
||||||
|
style_attrs = _gtk_style_context_get_pango_attributes (context);
|
||||||
|
if (style_attrs)
|
||||||
|
{
|
||||||
|
_gtk_pango_attr_list_merge (tmp_attrs, style_attrs);
|
||||||
|
pango_attr_list_unref (style_attrs);
|
||||||
|
}
|
||||||
|
|
||||||
placeholder_layout = show_placeholder_text (entry);
|
placeholder_layout = show_placeholder_text (entry);
|
||||||
if (placeholder_layout)
|
if (placeholder_layout)
|
||||||
display_text = g_strdup (priv->placeholder_text);
|
display_text = g_strdup (priv->placeholder_text);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "gtkbuilderprivate.h"
|
#include "gtkbuilderprivate.h"
|
||||||
#include "gtkclipboard.h"
|
#include "gtkclipboard.h"
|
||||||
#include "gtkcssshadowsvalueprivate.h"
|
#include "gtkcssshadowsvalueprivate.h"
|
||||||
|
#include "gtkcssstylepropertyprivate.h"
|
||||||
#include "gtkdnd.h"
|
#include "gtkdnd.h"
|
||||||
#include "gtkimage.h"
|
#include "gtkimage.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
@@ -2145,21 +2146,6 @@ gtk_label_set_use_underline_internal (GtkLabel *label,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
my_pango_attr_list_merge_filter (PangoAttribute *attribute,
|
|
||||||
gpointer list)
|
|
||||||
{
|
|
||||||
pango_attr_list_change (list, pango_attribute_copy (attribute));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
my_pango_attr_list_merge (PangoAttrList *into,
|
|
||||||
PangoAttrList *from)
|
|
||||||
{
|
|
||||||
pango_attr_list_filter (from, my_pango_attr_list_merge_filter, into);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculates text, attrs and mnemonic_keyval from
|
/* Calculates text, attrs and mnemonic_keyval from
|
||||||
* label, use_underline and use_markup
|
* label, use_underline and use_markup
|
||||||
*/
|
*/
|
||||||
@@ -3427,6 +3413,7 @@ gtk_label_update_layout_attributes (GtkLabel *label)
|
|||||||
GtkWidget *widget = GTK_WIDGET (label);
|
GtkWidget *widget = GTK_WIDGET (label);
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
PangoAttrList *attrs;
|
PangoAttrList *attrs;
|
||||||
|
PangoAttrList *style_attrs;
|
||||||
|
|
||||||
if (priv->layout == NULL)
|
if (priv->layout == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -3477,10 +3464,21 @@ gtk_label_update_layout_attributes (GtkLabel *label)
|
|||||||
else
|
else
|
||||||
attrs = NULL;
|
attrs = NULL;
|
||||||
|
|
||||||
|
style_attrs = _gtk_style_context_get_pango_attributes (context);
|
||||||
|
if (style_attrs)
|
||||||
|
{
|
||||||
|
if (attrs)
|
||||||
|
_gtk_pango_attr_list_merge (attrs, style_attrs);
|
||||||
|
else
|
||||||
|
attrs = pango_attr_list_ref (style_attrs);
|
||||||
|
|
||||||
|
pango_attr_list_unref (style_attrs);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->markup_attrs)
|
if (priv->markup_attrs)
|
||||||
{
|
{
|
||||||
if (attrs)
|
if (attrs)
|
||||||
my_pango_attr_list_merge (attrs, priv->markup_attrs);
|
_gtk_pango_attr_list_merge (attrs, priv->markup_attrs);
|
||||||
else
|
else
|
||||||
attrs = pango_attr_list_ref (priv->markup_attrs);
|
attrs = pango_attr_list_ref (priv->markup_attrs);
|
||||||
}
|
}
|
||||||
@@ -3488,7 +3486,7 @@ gtk_label_update_layout_attributes (GtkLabel *label)
|
|||||||
if (priv->attrs)
|
if (priv->attrs)
|
||||||
{
|
{
|
||||||
if (attrs)
|
if (attrs)
|
||||||
my_pango_attr_list_merge (attrs, priv->attrs);
|
_gtk_pango_attr_list_merge (attrs, priv->attrs);
|
||||||
else
|
else
|
||||||
attrs = pango_attr_list_ref (priv->attrs);
|
attrs = pango_attr_list_ref (priv->attrs);
|
||||||
}
|
}
|
||||||
@@ -4139,12 +4137,22 @@ gtk_label_state_flags_changed (GtkWidget *widget,
|
|||||||
static void
|
static void
|
||||||
gtk_label_style_updated (GtkWidget *widget)
|
gtk_label_style_updated (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
static GtkBitmask *affects_text_attrs = NULL;
|
||||||
GtkLabel *label = GTK_LABEL (widget);
|
GtkLabel *label = GTK_LABEL (widget);
|
||||||
GtkLabelPrivate *priv = label->priv;
|
GtkLabelPrivate *priv = label->priv;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
const GtkBitmask *changes;;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (affects_text_attrs == NULL))
|
||||||
|
affects_text_attrs = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_TEXT_ATTRS);
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
|
||||||
|
|
||||||
if (priv->select_info && priv->select_info->links)
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
changes = _gtk_style_context_get_changes (context);
|
||||||
|
|
||||||
|
if (changes == NULL || _gtk_bitmask_intersects (changes, affects_text_attrs) ||
|
||||||
|
(priv->select_info && priv->select_info->links))
|
||||||
gtk_label_update_layout_attributes (label);
|
gtk_label_update_layout_attributes (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,6 @@ static void gtk_link_button_set_property (GObject *object,
|
|||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static void gtk_link_button_add (GtkContainer *container,
|
|
||||||
GtkWidget *widget);
|
|
||||||
static gboolean gtk_link_button_button_press (GtkWidget *widget,
|
static gboolean gtk_link_button_button_press (GtkWidget *widget,
|
||||||
GdkEventButton *event);
|
GdkEventButton *event);
|
||||||
static void gtk_link_button_clicked (GtkButton *button);
|
static void gtk_link_button_clicked (GtkButton *button);
|
||||||
@@ -138,18 +136,15 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
|
||||||
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
|
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->set_property = gtk_link_button_set_property;
|
gobject_class->set_property = gtk_link_button_set_property;
|
||||||
gobject_class->get_property = gtk_link_button_get_property;
|
gobject_class->get_property = gtk_link_button_get_property;
|
||||||
gobject_class->finalize = gtk_link_button_finalize;
|
gobject_class->finalize = gtk_link_button_finalize;
|
||||||
|
|
||||||
widget_class->button_press_event = gtk_link_button_button_press;
|
widget_class->button_press_event = gtk_link_button_button_press;
|
||||||
widget_class->popup_menu = gtk_link_button_popup_menu;
|
widget_class->popup_menu = gtk_link_button_popup_menu;
|
||||||
widget_class->unrealize = gtk_link_button_unrealize;
|
widget_class->unrealize = gtk_link_button_unrealize;
|
||||||
|
|
||||||
container_class->add = gtk_link_button_add;
|
|
||||||
|
|
||||||
button_class->clicked = gtk_link_button_clicked;
|
button_class->clicked = gtk_link_button_clicked;
|
||||||
|
|
||||||
@@ -292,36 +287,6 @@ gtk_link_button_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
set_link_underline (GtkLinkButton *link_button)
|
|
||||||
{
|
|
||||||
GtkWidget *label;
|
|
||||||
|
|
||||||
label = gtk_bin_get_child (GTK_BIN (link_button));
|
|
||||||
if (GTK_IS_LABEL (label))
|
|
||||||
{
|
|
||||||
PangoAttrList *attributes;
|
|
||||||
PangoAttribute *uline;
|
|
||||||
|
|
||||||
uline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
|
|
||||||
uline->start_index = 0;
|
|
||||||
uline->end_index = G_MAXUINT;
|
|
||||||
attributes = pango_attr_list_new ();
|
|
||||||
pango_attr_list_insert (attributes, uline);
|
|
||||||
gtk_label_set_attributes (GTK_LABEL (label), attributes);
|
|
||||||
pango_attr_list_unref (attributes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_link_button_add (GtkContainer *container,
|
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GTK_CONTAINER_CLASS (gtk_link_button_parent_class)->add (container, widget);
|
|
||||||
|
|
||||||
set_link_underline (GTK_LINK_BUTTON (container));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_hand_cursor (GtkWidget *widget,
|
set_hand_cursor (GtkWidget *widget,
|
||||||
gboolean show_hand)
|
gboolean show_hand)
|
||||||
|
|||||||
@@ -1289,3 +1289,18 @@ _gtk_pango_get_text_at (PangoLayout *layout,
|
|||||||
|
|
||||||
return g_utf8_substring (text, start, end);
|
return g_utf8_substring (text, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
attr_list_merge_filter (PangoAttribute *attribute,
|
||||||
|
gpointer list)
|
||||||
|
{
|
||||||
|
pango_attr_list_change (list, pango_attribute_copy (attribute));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gtk_pango_attr_list_merge (PangoAttrList *into,
|
||||||
|
PangoAttrList *from)
|
||||||
|
{
|
||||||
|
pango_attr_list_filter (from, attr_list_merge_filter, into);
|
||||||
|
}
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ gchar *_gtk_pango_get_text_after (PangoLayout *layout,
|
|||||||
gint *start_offset,
|
gint *start_offset,
|
||||||
gint *end_offset);
|
gint *end_offset);
|
||||||
|
|
||||||
|
void _gtk_pango_attr_list_merge (PangoAttrList *into,
|
||||||
|
PangoAttrList *from);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_PANGO_H__ */
|
#endif /* __GTK_PANGO_H__ */
|
||||||
|
|||||||
@@ -3148,6 +3148,62 @@ _gtk_style_context_get_icon_extents (GtkStyleContext *context,
|
|||||||
extents->height += border.top + border.bottom;
|
extents->height += border.top + border.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PangoAttrList *
|
||||||
|
add_pango_attr(PangoAttrList *attrs, PangoAttribute *attr)
|
||||||
|
{
|
||||||
|
if (attrs == NULL)
|
||||||
|
attrs = pango_attr_list_new ();
|
||||||
|
|
||||||
|
pango_attr_list_insert (attrs, attr);
|
||||||
|
|
||||||
|
return attrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
PangoAttrList *
|
||||||
|
_gtk_style_context_get_pango_attributes (GtkStyleContext *context)
|
||||||
|
{
|
||||||
|
PangoAttrList *attrs = NULL;
|
||||||
|
GtkTextDecorationLine decoration_line;
|
||||||
|
const GdkRGBA *color;
|
||||||
|
const GdkRGBA *decoration_color;
|
||||||
|
gint letter_spacing;
|
||||||
|
|
||||||
|
/* text-decoration */
|
||||||
|
decoration_line = _gtk_css_text_decoration_line_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_DECORATION_LINE));
|
||||||
|
color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
|
||||||
|
decoration_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR));
|
||||||
|
|
||||||
|
switch (decoration_line)
|
||||||
|
{
|
||||||
|
case GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE:
|
||||||
|
attrs = add_pango_attr (attrs, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
|
||||||
|
if (!gdk_rgba_equal(color, decoration_color))
|
||||||
|
attrs = add_pango_attr (attrs, pango_attr_underline_color_new (decoration_color->red * 65535. + 0.5,
|
||||||
|
decoration_color->green * 65535. + 0.5,
|
||||||
|
decoration_color->blue * 65535. + 0.5));
|
||||||
|
break;
|
||||||
|
case GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH:
|
||||||
|
attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
|
||||||
|
if (!gdk_rgba_equal(color, decoration_color))
|
||||||
|
attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
|
||||||
|
decoration_color->green * 65535. + 0.5,
|
||||||
|
decoration_color->blue * 65535. + 0.5));
|
||||||
|
break;
|
||||||
|
case GTK_CSS_TEXT_DECORATION_LINE_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* letter-spacing */
|
||||||
|
letter_spacing = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_LETTER_SPACING), 100);
|
||||||
|
if (letter_spacing != 0)
|
||||||
|
{
|
||||||
|
attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
|
||||||
|
}
|
||||||
|
|
||||||
|
return attrs;
|
||||||
|
}
|
||||||
|
|
||||||
static AtkAttributeSet *
|
static AtkAttributeSet *
|
||||||
add_attribute (AtkAttributeSet *attributes,
|
add_attribute (AtkAttributeSet *attributes,
|
||||||
AtkTextAttribute attr,
|
AtkTextAttribute attr,
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ void _gtk_style_context_get_icon_extents (GtkStyleContext
|
|||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
|
PangoAttrList *_gtk_style_context_get_pango_attributes (GtkStyleContext *context);
|
||||||
|
|
||||||
/* Accessibility support */
|
/* Accessibility support */
|
||||||
AtkAttributeSet *_gtk_style_context_get_attributes (AtkAttributeSet *attributes,
|
AtkAttributeSet *_gtk_style_context_get_attributes (AtkAttributeSet *attributes,
|
||||||
GtkStyleContext *context,
|
GtkStyleContext *context,
|
||||||
|
|||||||
@@ -811,6 +811,9 @@ GtkColorButton.button {
|
|||||||
//a weird transition which for some reason
|
//a weird transition which for some reason
|
||||||
//makes borders blink on hover
|
//makes borders blink on hover
|
||||||
}
|
}
|
||||||
|
& .label {
|
||||||
|
text-decoration-line: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
|
|||||||
@@ -1274,6 +1274,8 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
|
|||||||
text-shadow: none; }
|
text-shadow: none; }
|
||||||
.button:link:hover, .button:link:active, .button:link:checked, .button:visited:hover, .button:visited:active, .button:visited:checked {
|
.button:link:hover, .button:link:active, .button:link:checked, .button:visited:hover, .button:visited:active, .button:visited:checked {
|
||||||
text-shadow: none; }
|
text-shadow: none; }
|
||||||
|
.button:link .label, .button:visited .label {
|
||||||
|
text-decoration-line: underline; }
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
* GtkSpinButton *
|
* GtkSpinButton *
|
||||||
|
|||||||
@@ -1274,6 +1274,8 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
|
|||||||
text-shadow: none; }
|
text-shadow: none; }
|
||||||
.button:link:hover, .button:link:active, .button:link:checked, .button:visited:hover, .button:visited:active, .button:visited:checked {
|
.button:link:hover, .button:link:active, .button:link:checked, .button:visited:hover, .button:visited:active, .button:visited:checked {
|
||||||
text-shadow: none; }
|
text-shadow: none; }
|
||||||
|
.button:link .label, .button:visited .label {
|
||||||
|
text-decoration-line: underline; }
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
* GtkSpinButton *
|
* GtkSpinButton *
|
||||||
|
|||||||
@@ -323,6 +323,9 @@ testdata = \
|
|||||||
label-width-chars-dont-shrink.ui \
|
label-width-chars-dont-shrink.ui \
|
||||||
label-wrap-justify.ref.ui \
|
label-wrap-justify.ref.ui \
|
||||||
label-wrap-justify.ui \
|
label-wrap-justify.ui \
|
||||||
|
letter-spacing.css \
|
||||||
|
letter-spacing.ui \
|
||||||
|
letter-spacing.ref.ui \
|
||||||
linear-gradient.css \
|
linear-gradient.css \
|
||||||
linear-gradient.ref.ui \
|
linear-gradient.ref.ui \
|
||||||
linear-gradient.ui \
|
linear-gradient.ui \
|
||||||
@@ -498,6 +501,7 @@ libreftest_la_LIBADD = $(gtk_reftest_LDADD)
|
|||||||
libreftest_la_SOURCES = \
|
libreftest_la_SOURCES = \
|
||||||
expand-expander.c \
|
expand-expander.c \
|
||||||
label-text-shadow-changes-modify-clip.c \
|
label-text-shadow-changes-modify-clip.c \
|
||||||
|
letter-spacing.c \
|
||||||
set-default-direction.c \
|
set-default-direction.c \
|
||||||
statusbar-remove-all.c \
|
statusbar-remove-all.c \
|
||||||
textview-border-windows.c \
|
textview-border-windows.c \
|
||||||
|
|||||||
30
testsuite/reftests/letter-spacing.c
Normal file
30
testsuite/reftests/letter-spacing.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
|
G_MODULE_EXPORT void
|
||||||
|
set_letter_spacing (GtkLabel *label)
|
||||||
|
{
|
||||||
|
PangoAttrList *attrs;
|
||||||
|
|
||||||
|
attrs = pango_attr_list_new ();
|
||||||
|
pango_attr_list_insert (attrs, pango_attr_letter_spacing_new (10 * PANGO_SCALE));
|
||||||
|
gtk_label_set_attributes (label, attrs);
|
||||||
|
pango_attr_list_unref (attrs);
|
||||||
|
}
|
||||||
3
testsuite/reftests/letter-spacing.css
Normal file
3
testsuite/reftests/letter-spacing.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#spaced {
|
||||||
|
letter-spacing: 10px;
|
||||||
|
}
|
||||||
17
testsuite/reftests/letter-spacing.ref.ui
Normal file
17
testsuite/reftests/letter-spacing.ref.ui
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.0"/>
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label">abc</property>
|
||||||
|
<signal name="map" handler="reftest:set_letter_spacing" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
16
testsuite/reftests/letter-spacing.ui
Normal file
16
testsuite/reftests/letter-spacing.ui
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="name">spaced</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label">abc</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
Reference in New Issue
Block a user