summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYair Hershkovitz <yairhr@src.gnome.org>2007-07-22 06:39:29 +0000
committerYair Hershkovitz <yairhr@src.gnome.org>2007-07-22 06:39:29 +0000
commit8bbccb91f79fa10e4196d977a1b88e942436f693 (patch)
tree77a2837ff2fca17c7abcfa5d0dac83fa82080ede
parent9c2e546f5365957a404eeac1d0b25019a7685b94 (diff)
downloadmetacity-8bbccb91f79fa10e4196d977a1b88e942436f693.tar.gz
Reverse window buttons and align them to the left for RTL locales. (#92212)
svn path=/trunk/; revision=3271
-rw-r--r--ChangeLog17
-rw-r--r--src/main.c9
-rw-r--r--src/prefs.c85
-rw-r--r--src/theme.c11
4 files changed, 88 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index 825c79f8..a81147d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-07-22 Yair Hershkovitz <yairhr@gmail.com>
+
+ Reverse window buttons and align them to the left for RTL locales.
+ Fixed #92212.
+
+ * src/prefs.c (button_layout, init_button_layout, update_button_layout):
+ Support reversing and left-aligning of buttons for both Gconf and
+ NO-Gconf modes.
+ * src/main.c (main): Call meta_ui_init() before meta_prefs_init().
+ meta_prefs_init() check for RTL locales which is initialized in
+ meta_ui_init().
+ * src/theme.c (meta_frame_layout_calc_geometry): Fixed access to
+ button_layout to stop iterating when getting to a
+ META_BUTTON_FUNCTION_LAST value.
+
2007-06-23 Thomas Thurman <thomas@thurman.org.uk>
* src/window.c (MetaWindow): Put all bitfields together to
@@ -53,7 +68,7 @@
Refactor thrice-duplicated queue code in window.c. Closes #376760.
* src/window.c (meta_window_queue, meta_window_unqueue):
- New functions.
+ New functiortl.patchns.
* src/window.[ch] (meta_window_unqueue_*, meta_window_queue_*):
Removed functions.
* src/window.c (meta_window_new_with_attrs, meta_window_free,
diff --git a/src/main.c b/src/main.c
index a00e1ffe..d9d915bc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -293,15 +293,16 @@ main (int argc, char **argv)
g_type_init ();
- /* Load prefs */
- meta_prefs_init ();
- meta_prefs_add_listener (prefs_changed_callback, NULL);
-
meta_ui_init (&argc, &argv);
/* must be after UI init so we can override GDK handlers */
meta_errors_init ();
+ /* Load prefs */
+ meta_prefs_init ();
+ meta_prefs_add_listener (prefs_changed_callback, NULL);
+
+
#if 1
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
diff --git a/src/prefs.c b/src/prefs.c
index 39fddf39..efc6ec4f 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -109,20 +109,7 @@ static int cursor_size = 24;
static gboolean compositing_manager = FALSE;
static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
-static MetaButtonLayout button_layout = {
- {
- META_BUTTON_FUNCTION_MENU,
- META_BUTTON_FUNCTION_LAST,
- META_BUTTON_FUNCTION_LAST,
- META_BUTTON_FUNCTION_LAST
- },
- {
- META_BUTTON_FUNCTION_MINIMIZE,
- META_BUTTON_FUNCTION_MAXIMIZE,
- META_BUTTON_FUNCTION_CLOSE,
- META_BUTTON_FUNCTION_LAST
- }
-};
+static MetaButtonLayout button_layout;
/* The screenshot commands are at the end */
static char *commands[MAX_COMMANDS] = { NULL, };
@@ -195,6 +182,7 @@ static gboolean update_list_binding (MetaKeyPref *binding,
static void init_bindings (void);
static void init_commands (void);
static void init_workspace_names (void);
+static void init_button_layout (void);
typedef struct
@@ -530,6 +518,8 @@ meta_prefs_init (void)
*/
titlebar_font = pango_font_description_from_string ("Sans Bold 10");
current_theme = g_strdup ("Atlanta");
+
+ init_button_layout();
#endif /* HAVE_GCONF */
/* Load keybindings prefs */
@@ -1461,14 +1451,6 @@ update_button_layout (const char *value)
if (value == NULL)
return FALSE;
- i = 0;
- while (i < MAX_BUTTONS_PER_CORNER)
- {
- new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
- new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
- ++i;
- }
-
/* We need to ignore unknown button functions, for
* compat with future versions
*/
@@ -1515,6 +1497,8 @@ update_button_layout (const char *value)
++b;
}
+ new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
+
g_strfreev (buttons);
}
@@ -1558,11 +1542,32 @@ update_button_layout (const char *value)
++b;
}
+ new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
+
g_strfreev (buttons);
}
g_strfreev (sides);
+ /* Invert the button layout for RTL languages */
+ if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+ {
+ MetaButtonLayout rtl_layout;
+ int j;
+
+ for (i = 0; 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];
+ rtl_layout.right_buttons[j] = META_BUTTON_FUNCTION_LAST;
+
+ for (i = 0; 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];
+ rtl_layout.left_buttons[j] = META_BUTTON_FUNCTION_LAST;
+
+ new_layout = rtl_layout;
+ }
+
changed = !button_layout_equal (&button_layout, &new_layout);
button_layout = new_layout;
@@ -3036,3 +3041,39 @@ meta_prefs_get_compositing_manager (void)
{
return compositing_manager;
}
+
+static void
+init_button_layout(void)
+{
+ MetaButtonLayout button_layout_ltr = {
+ {
+ /* buttons in the group on the left side */
+ META_BUTTON_FUNCTION_MENU,
+ META_BUTTON_FUNCTION_LAST
+ },
+ {
+ /* buttons in the group on the right side */
+ META_BUTTON_FUNCTION_MINIMIZE,
+ META_BUTTON_FUNCTION_MAXIMIZE,
+ META_BUTTON_FUNCTION_CLOSE,
+ META_BUTTON_FUNCTION_LAST
+ }
+ };
+ MetaButtonLayout button_layout_rtl = {
+ {
+ /* buttons in the group on the left side */
+ META_BUTTON_FUNCTION_CLOSE,
+ META_BUTTON_FUNCTION_MAXIMIZE,
+ META_BUTTON_FUNCTION_MINIMIZE,
+ META_BUTTON_FUNCTION_LAST
+ },
+ {
+ /* buttons in the group on the right side */
+ META_BUTTON_FUNCTION_MENU,
+ META_BUTTON_FUNCTION_LAST
+ }
+ };
+
+ button_layout = meta_ui_get_direction() == META_UI_DIRECTION_LTR ?
+ button_layout_ltr : button_layout_rtl;
+};
diff --git a/src/theme.c b/src/theme.c
index b1ac7282..92ff558f 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -596,14 +596,11 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
n_left = 0;
n_right = 0;
- for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++)
- {
- /* NULL all unused */
- left_func_rects[i] = NULL;
- right_func_rects[i] = NULL;
+ if (!layout->hide_buttons)
+ {
/* Try to fill in rects */
- if (button_layout->left_buttons[i] != META_BUTTON_FUNCTION_LAST && !layout->hide_buttons)
+ for (i = 0; i < MAX_BUTTONS_PER_CORNER && button_layout->left_buttons[i] != META_BUTTON_FUNCTION_LAST; i++)
{
left_func_rects[n_left] = rect_for_function (fgeom, flags,
button_layout->left_buttons[i],
@@ -612,7 +609,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
++n_left;
}
- if (button_layout->right_buttons[i] != META_BUTTON_FUNCTION_LAST && !layout->hide_buttons)
+ for (i = 0; i < MAX_BUTTONS_PER_CORNER && button_layout->right_buttons[i] != META_BUTTON_FUNCTION_LAST; i++)
{
right_func_rects[n_right] = rect_for_function (fgeom, flags,
button_layout->right_buttons[i],