summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-10-21 09:47:14 +0200
committerDanny Baumann <dannybaumann@web.de>2009-03-08 13:17:36 +0100
commit29810e06cf116e5fbe819aa64d0d738589af316f (patch)
tree82d7e810a868b7d167015085f4ba3b11292689b6 /gtk
parent8e9b2eb4de0bef3087a5c2f032e729e42c0cd897 (diff)
downloadzcomp-29810e06cf116e5fbe819aa64d0d738589af316f.tar.gz
zcomp-29810e06cf116e5fbe819aa64d0d738589af316f.tar.bz2
Invert button layout for RTL languages.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/window-decorator/gtk-window-decorator.c77
1 files changed, 62 insertions, 15 deletions
diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
index 3b284a4..edfbe0c 100644
--- a/gtk/window-decorator/gtk-window-decorator.c
+++ b/gtk/window-decorator/gtk-window-decorator.c
@@ -5887,6 +5887,22 @@ meta_button_opposite_function (MetaButtonFunction ofwhat)
}
static void
+meta_initialize_button_layout (MetaButtonLayout *layout)
+{
+ int i;
+
+ for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++)
+ {
+ layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST;
+ layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST;
+#ifdef HAVE_METACITY_2_23_2
+ layout->left_buttons_has_spacer[i] = FALSE;
+ layout->right_buttons_has_spacer[i] = FALSE;
+#endif
+ }
+}
+
+static void
meta_update_button_layout (const char *value)
{
MetaButtonLayout new_layout;
@@ -5894,11 +5910,7 @@ meta_update_button_layout (const char *value)
char **sides;
int i;
- for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++)
- {
- new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
- new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
- }
+ meta_initialize_button_layout (&new_layout);
sides = g_strsplit (value, ":", 2);
@@ -5909,12 +5921,7 @@ meta_update_button_layout (const char *value)
gboolean used[META_BUTTON_FUNCTION_LAST];
for (i = 0; i < META_BUTTON_FUNCTION_LAST; i++)
- {
used[i] = FALSE;
-#ifdef HAVE_METACITY_2_23_2
- new_layout.left_buttons_has_spacer[i] = FALSE;
-#endif
- }
buttons = g_strsplit (sides[0], ",", -1);
@@ -5961,12 +5968,7 @@ meta_update_button_layout (const char *value)
if (sides[1] != NULL)
{
for (i = 0; i < META_BUTTON_FUNCTION_LAST; i++)
- {
used[i] = FALSE;
-#ifdef HAVE_METACITY_2_23_2
- new_layout.right_buttons_has_spacer[i] = FALSE;
-#endif
- }
buttons = g_strsplit (sides[1], ",", -1);
@@ -6012,6 +6014,51 @@ meta_update_button_layout (const char *value)
g_strfreev (sides);
+ /* Invert the button layout for RTL languages */
+ if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
+ {
+ MetaButtonLayout rtl_layout;
+ int j;
+
+ meta_initialize_button_layout (&rtl_layout);
+
+ i = 0;
+ while (new_layout.left_buttons[i] != META_BUTTON_FUNCTION_LAST)
+ i++;
+
+ for (j = 0; j < i; j++)
+ {
+ rtl_layout.right_buttons[j] = new_layout.left_buttons[i - j - 1];
+#ifdef HAVE_METACITY_2_23_2
+ if (j == 0)
+ rtl_layout.right_buttons_has_spacer[i - 1] =
+ new_layout.left_buttons_has_spacer[i - j - 1];
+ else
+ rtl_layout.right_buttons_has_spacer[j - 1] =
+ new_layout.left_buttons_has_spacer[i - j - 1];
+#endif
+ }
+
+ i = 0;
+ while (new_layout.right_buttons[i] != META_BUTTON_FUNCTION_LAST)
+ i++;
+
+ for (j = 0; j < i; j++)
+ {
+ rtl_layout.left_buttons[j] = new_layout.right_buttons[i - j - 1];
+#ifdef HAVE_METACITY_2_23_2
+ if (j == 0)
+ rtl_layout.left_buttons_has_spacer[i - 1] =
+ new_layout.right_buttons_has_spacer[i - j - 1];
+ else
+ rtl_layout.left_buttons_has_spacer[j - 1] =
+ new_layout.right_buttons_has_spacer[i - j - 1];
+#endif
+ }
+
+ new_layout = rtl_layout;
+ }
+
meta_button_layout = new_layout;
}
#endif