diff options
author | Yair Hershkovitz <yairhr@src.gnome.org> | 2007-07-22 06:39:29 +0000 |
---|---|---|
committer | Yair Hershkovitz <yairhr@src.gnome.org> | 2007-07-22 06:39:29 +0000 |
commit | 8bbccb91f79fa10e4196d977a1b88e942436f693 (patch) | |
tree | 77a2837ff2fca17c7abcfa5d0dac83fa82080ede /src | |
parent | 9c2e546f5365957a404eeac1d0b25019a7685b94 (diff) | |
download | metacity-8bbccb91f79fa10e4196d977a1b88e942436f693.tar.gz |
Reverse window buttons and align them to the left for RTL locales. (#92212)
svn path=/trunk/; revision=3271
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/prefs.c | 85 | ||||
-rw-r--r-- | src/theme.c | 11 |
3 files changed, 72 insertions, 33 deletions
@@ -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], |