---
widgets/src/HubWindow.c | 36 +++++++++++++++++++++++++++++++-----
widgets/src/StandaloneWindow.c | 40 +++++++++++++++++++++++++++++++++++-----
2 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/widgets/src/HubWindow.c b/widgets/src/HubWindow.c
index 6756a31..b776016 100644
--- a/widgets/src/HubWindow.c
+++ b/widgets/src/HubWindow.c
@@ -100,18 +100,36 @@ static int get_sidebar_height(GtkWidget *window) {
/* function to override default drawing to insert sidebar image */
static gboolean anaconda_hub_window_on_draw(GtkWidget *win, cairo_t *cr) {
+ GtkStyleContext *context;
+ gdouble sidebar_x;
+ gdouble sidebar_width;
+
/* calls parent class' draw handler */
GTK_WIDGET_CLASS(anaconda_hub_window_parent_class)->draw(win,cr);
- GtkStyleContext * context = gtk_widget_get_style_context(win);
+ sidebar_width = get_sidebar_width(win);
+
+ /* For RTL languages, move the sidebar to the right edge */
+ if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR)
+ {
+ sidebar_x = 0;
+ }
+ else
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(win, &allocation);
+ sidebar_x = allocation.width - sidebar_width;
+ }
+
+ context = gtk_widget_get_style_context(win);
gtk_style_context_save (context);
gtk_style_context_add_class(context, "logo-sidebar");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win),
get_sidebar_height(win));
+ gtk_render_background(context, cr, sidebar_x, 0, sidebar_width,
get_sidebar_height(win));
gtk_style_context_remove_class(context, "logo-sidebar");
gtk_style_context_add_class(context, "logo");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win),
get_sidebar_height(win));
+ gtk_render_background(context, cr, sidebar_x, 0, sidebar_width,
get_sidebar_height(win));
gtk_style_context_remove_class(context, "logo");
gtk_style_context_restore (context);
@@ -119,7 +137,7 @@ static gboolean anaconda_hub_window_on_draw(GtkWidget *win, cairo_t
*cr) {
return TRUE; /* TRUE to avoid default draw handler */
}
-/* Move base window content appropriate amount of space to the right to make room for
sidebar */
+/* Move base window content appropriate amount of space to make room for sidebar */
static void anaconda_hub_window_size_allocate (GtkWidget *window, GtkAllocation
*allocation) {
GtkAllocation child_allocation;
GtkWidget *child;
@@ -127,11 +145,19 @@ static void anaconda_hub_window_size_allocate (GtkWidget *window,
GtkAllocation
gtk_widget_set_allocation(window, allocation);
sidebar_width = get_sidebar_width(window);
- child_allocation.x = allocation->x+sidebar_width;
child_allocation.y = allocation->y;
child_allocation.width = allocation->width-sidebar_width;
child_allocation.height = allocation->height;
+ if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR)
+ {
+ child_allocation.x = allocation->x+sidebar_width;
+ }
+ else
+ {
+ child_allocation.x = allocation->x;
+ }
+
child = gtk_bin_get_child (GTK_BIN (window));
if (child && gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &child_allocation);
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c
index 0ccf56e..53a4b49 100644
--- a/widgets/src/StandaloneWindow.c
+++ b/widgets/src/StandaloneWindow.c
@@ -88,18 +88,36 @@ static int get_sidebar_height(GtkWidget *window) {
/* function to override default drawing to insert sidebar image */
static gboolean anaconda_standalone_window_on_draw(GtkWidget *win, cairo_t *cr) {
+ GtkStyleContext *context;
+ gdouble sidebar_x;
+ gdouble sidebar_width;
+
/* calls parent class' draw handler */
GTK_WIDGET_CLASS(anaconda_standalone_window_parent_class)->draw(win,cr);
- GtkStyleContext * context = gtk_widget_get_style_context(win);
+ sidebar_width = get_sidebar_width(win);
+
+ /* For RTL languages, move the sidebar to the right edge */
+ if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR)
+ {
+ sidebar_x = 0;
+ }
+ else
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(win, &allocation);
+ sidebar_x = allocation.width - sidebar_width;
+ }
+
+ context = gtk_widget_get_style_context(win);
gtk_style_context_save (context);
gtk_style_context_add_class(context, "logo-sidebar");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win),
get_sidebar_height(win));
+ gtk_render_background(context, cr, sidebar_x, 0, sidebar_width,
get_sidebar_height(win));
gtk_style_context_remove_class(context, "logo-sidebar");
gtk_style_context_add_class(context, "logo");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win),
get_sidebar_height(win));
+ gtk_render_background(context, cr, sidebar_x, 0, sidebar_width,
get_sidebar_height(win));
gtk_style_context_remove_class(context, "logo");
gtk_style_context_restore (context);
@@ -107,19 +125,31 @@ static gboolean anaconda_standalone_window_on_draw(GtkWidget *win,
cairo_t *cr)
return TRUE; /* TRUE to avoid default draw handler */
}
-/* Move base window content appropriate amount of space to the right to make room for
sidebar */
+/* Move base window content appropriate amount of space to make room for sidebar */
static void anaconda_standalone_window_size_allocate (GtkWidget *window, GtkAllocation
*allocation) {
GtkAllocation child_allocation;
GtkWidget *child;
int sidebar_width;
+ /*
+ * For RTL languages, the width is reduced by the same amount, but the
+ * start of the window does not need to move.
+ */
gtk_widget_set_allocation(window, allocation);
sidebar_width = get_sidebar_width(window);
- child_allocation.x = allocation->x+sidebar_width;
child_allocation.y = allocation->y;
child_allocation.width = allocation->width-sidebar_width;
child_allocation.height = allocation->height;
+ if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR)
+ {
+ child_allocation.x = allocation->x+sidebar_width;
+ }
+ else
+ {
+ child_allocation.x = allocation->x;
+ }
+
child = gtk_bin_get_child (GTK_BIN (window));
if (child && gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &child_allocation);
--
1.8.5.3