summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-07-05 10:08:10 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-07-05 10:08:10 -0400
commit85f2a721cfae94ed9497c56a72b3dce0677f4317 (patch)
tree4347a0d38bf25f7a67be72c79151d99c34f58ecc
parentda324fa2d5723739b9a74996e1e11df93b300aec (diff)
downloadgtk+-85f2a721cfae94ed9497c56a72b3dce0677f4317.tar.gz
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.
-rw-r--r--modules/engines/pixbuf/pixbuf-draw.c12
-rw-r--r--modules/engines/pixbuf/pixbuf-rc-style.c37
-rw-r--r--modules/engines/pixbuf/pixbuf.h9
3 files changed, 54 insertions, 4 deletions
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index 38f2761232..9239bd1a5e 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -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)
{
diff --git a/modules/engines/pixbuf/pixbuf-rc-style.c b/modules/engines/pixbuf/pixbuf-rc-style.c
index a3367c4a0e..35970872a2 100644
--- a/modules/engines/pixbuf/pixbuf-rc-style.c
+++ b/modules/engines/pixbuf/pixbuf-rc-style.c
@@ -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;
diff --git a/modules/engines/pixbuf/pixbuf.h b/modules/engines/pixbuf/pixbuf.h
index 77e19d4a4c..d0c74e9159 100644
--- a/modules/engines/pixbuf/pixbuf.h
+++ b/modules/engines/pixbuf/pixbuf.h
@@ -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