mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
pixbuf-engine: add a GtkRC option for widget direction
Add a GtkRC option to select for an LTR/RTL widget direction in the pixbuf engine; this will allow the engine to apply different theming assets according to the text direction, which is useful when theming e.g. a spinbutton or a combobox entry.
This commit is contained in:
parent
da324fa2d5
commit
85f2a721cf
@ -72,6 +72,10 @@ match_theme_image (GtkStyle *style,
|
||||
match_data->orientation != image->match_data.orientation)
|
||||
continue;
|
||||
|
||||
if ((flags & THEME_MATCH_DIRECTION) &&
|
||||
match_data->direction != image->match_data.direction)
|
||||
continue;
|
||||
|
||||
if ((flags & THEME_MATCH_GAP_SIDE) &&
|
||||
match_data->gap_side != image->match_data.gap_side)
|
||||
continue;
|
||||
@ -126,7 +130,13 @@ draw_simple_image(GtkStyle *style,
|
||||
else
|
||||
match_data->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
}
|
||||
|
||||
|
||||
if (!(match_data->flags & THEME_MATCH_DIRECTION))
|
||||
{
|
||||
match_data->flags |= THEME_MATCH_DIRECTION;
|
||||
match_data->direction = gtk_widget_get_direction (widget);
|
||||
}
|
||||
|
||||
image = match_theme_image (style, match_data);
|
||||
if (image)
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ theme_symbols[] =
|
||||
{ "overlay_stretch", TOKEN_OVERLAY_STRETCH },
|
||||
{ "arrow_direction", TOKEN_ARROW_DIRECTION },
|
||||
{ "orientation", TOKEN_ORIENTATION },
|
||||
{ "direction", TOKEN_DIRECTION },
|
||||
{ "expander_style", TOKEN_EXPANDER_STYLE },
|
||||
{ "window_edge", TOKEN_WINDOW_EDGE },
|
||||
|
||||
@ -130,7 +131,10 @@ theme_symbols[] =
|
||||
{ "EAST", TOKEN_EAST },
|
||||
{ "SOUTH_WEST", TOKEN_SOUTH_WEST },
|
||||
{ "SOUTH", TOKEN_SOUTH },
|
||||
{ "SOUTH_EAST", TOKEN_SOUTH_EAST }
|
||||
{ "SOUTH_EAST", TOKEN_SOUTH_EAST },
|
||||
|
||||
{ "LTR", TOKEN_LTR },
|
||||
{ "RTL", TOKEN_RTL }
|
||||
};
|
||||
|
||||
static GtkRcStyleClass *parent_class;
|
||||
@ -609,6 +613,34 @@ theme_parse_window_edge(GScanner * scanner,
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
static guint
|
||||
theme_parse_direction(GScanner * scanner,
|
||||
ThemeImage * data)
|
||||
{
|
||||
guint token;
|
||||
|
||||
token = g_scanner_get_next_token(scanner);
|
||||
if (token != TOKEN_DIRECTION)
|
||||
return TOKEN_DIRECTION;
|
||||
|
||||
token = g_scanner_get_next_token(scanner);
|
||||
if (token != G_TOKEN_EQUAL_SIGN)
|
||||
return G_TOKEN_EQUAL_SIGN;
|
||||
|
||||
token = g_scanner_get_next_token(scanner);
|
||||
|
||||
if (token == TOKEN_LTR)
|
||||
data->match_data.direction = GTK_TEXT_DIR_LTR;
|
||||
else if (token == TOKEN_RTL)
|
||||
data->match_data.direction = GTK_TEXT_DIR_RTL;
|
||||
else
|
||||
return TOKEN_LTR;
|
||||
|
||||
data->match_data.flags |= THEME_MATCH_DIRECTION;
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
theme_image_ref (ThemeImage *data)
|
||||
{
|
||||
@ -741,6 +773,9 @@ theme_parse_image(GtkSettings *settings,
|
||||
case TOKEN_WINDOW_EDGE:
|
||||
token = theme_parse_window_edge(scanner, data);
|
||||
break;
|
||||
case TOKEN_DIRECTION:
|
||||
token = theme_parse_direction(scanner, data);
|
||||
break;
|
||||
default:
|
||||
g_scanner_get_next_token(scanner);
|
||||
token = G_TOKEN_RIGHT_CURLY;
|
||||
|
@ -111,7 +111,10 @@ enum
|
||||
TOKEN_EAST,
|
||||
TOKEN_SOUTH_WEST,
|
||||
TOKEN_SOUTH,
|
||||
TOKEN_SOUTH_EAST
|
||||
TOKEN_SOUTH_EAST,
|
||||
TOKEN_DIRECTION,
|
||||
TOKEN_LTR,
|
||||
TOKEN_RTL
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -135,7 +138,8 @@ typedef enum {
|
||||
THEME_MATCH_SHADOW = 1 << 3,
|
||||
THEME_MATCH_ARROW_DIRECTION = 1 << 4,
|
||||
THEME_MATCH_EXPANDER_STYLE = 1 << 5,
|
||||
THEME_MATCH_WINDOW_EDGE = 1 << 6
|
||||
THEME_MATCH_WINDOW_EDGE = 1 << 6,
|
||||
THEME_MATCH_DIRECTION = 1 << 7
|
||||
} ThemeMatchFlags;
|
||||
|
||||
typedef enum {
|
||||
@ -170,6 +174,7 @@ struct _ThemeMatchData
|
||||
GtkArrowType arrow_direction;
|
||||
GtkExpanderStyle expander_style;
|
||||
GdkWindowEdge window_edge;
|
||||
GtkTextDirection direction;
|
||||
};
|
||||
|
||||
struct _ThemeImage
|
||||
|
Loading…
Reference in New Issue
Block a user