diff --git a/ChangeLog b/ChangeLog index 36467c9ab..7b620e935 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2007-05-25 Yair Hershkovitz + + * src/workspace.c (meta_workspace_get_neighbor): Add support + for RTL languages so that alt-tab, etc., go the other way. + * src/keybindings.c (handle_activate_menu): In RTL locales, + pop up the menu on the right-hand side when the menu keystroke + is pressed. + * src/fixedtip.c (meta_fixed_tip_show): right-justify tooltips + in RTL locales. + * src/menu.c (popup_position_func): popup menus in RTL locales + are flush with the right-hand side of the window where possible. + * src/frames.c (show_tip_now, meta_frames_button_press_event): + tooltips are aligned with the right-hand side of buttons in + RTL locales. + * src/ui.[ch] (meta_ui_get_direction, enum MetaUIDirection): + New content. + * src/window.c (meta_window_show_menu): "move left" appears above + "move right" in the window menu for LTR locales, and vice versa + for RTL locales. + + This is all to close bug #387893. + 2007-04-24 Linus Torvalds * src/prefs.[ch] (init_action_meta_prefs, meta_prefs_init, diff --git a/src/fixedtip.c b/src/fixedtip.c index 8ea3f3f77..a1470224c 100644 --- a/src/fixedtip.c +++ b/src/fixedtip.c @@ -23,6 +23,7 @@ #include #include "fixedtip.h" +#include "ui.h" static GtkWidget *tip = NULL; static GtkWidget *label = NULL; @@ -87,6 +88,10 @@ meta_fixed_tip_show (Display *xdisplay, int screen_number, gtk_label_set_markup (GTK_LABEL (label), markup_text); gtk_window_get_size (GTK_WINDOW (tip), &w, &h); + + if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) + root_x = MAX(0, root_x - w); + if ((root_x + w) > screen_right_edge) root_x -= (root_x + w) - screen_right_edge; diff --git a/src/frames.c b/src/frames.c index 0c82f1d46..623563bb6 100644 --- a/src/frames.c +++ b/src/frames.c @@ -34,6 +34,7 @@ #include "theme.h" #include "prefs.h" #include "errors.h" +#include "ui.h" #ifdef HAVE_SHAPE #include @@ -1134,6 +1135,11 @@ show_tip_now (MetaFrames *frames) /* get conversion delta for root-to-frame coords */ dx = root_x - x; dy = root_y - y; + + /* Align the tooltip to the button right end if RTL */ + if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) + dx += rect->width; + screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames))); meta_fixed_tip_show (gdk_display, @@ -1432,6 +1438,10 @@ meta_frames_button_press_event (GtkWidget *widget, dx = event->x_root - event->x; dy = event->y_root - event->y; + /* Align to the right end of the menu rectangle if RTL */ + if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) + dx += rect->width; + meta_core_show_window_menu (gdk_display, frame->xwindow, rect->x + dx, diff --git a/src/keybindings.c b/src/keybindings.c index 189a61af0..cd04c4f1c 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -3229,6 +3229,9 @@ handle_activate_menu (MetaDisplay *display, meta_window_get_position (display->focus_window, &x, &y); + if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) + x += display->focus_window->rect.width; + meta_window_show_menu (display->focus_window, x, y, 0, diff --git a/src/menu.c b/src/menu.c index 674c5dfe6..8e8360daf 100644 --- a/src/menu.c +++ b/src/menu.c @@ -32,6 +32,7 @@ #include "core.h" #include "themewidget.h" #include "metaaccellabel.h" +#include "ui.h" typedef struct _MenuItem MenuItem; typedef struct _MenuData MenuData; @@ -119,6 +120,9 @@ popup_position_func (GtkMenu *menu, *x = pos->x; *y = pos->y; + if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) + *x = MAX (0, *x - req.width); + /* Ensure onscreen */ *x = CLAMP (*x, 0, MAX (0, gdk_screen_width () - req.width)); *y = CLAMP (*y, 0, MAX (0, gdk_screen_height () - req.height)); diff --git a/src/ui.c b/src/ui.c index 6f0e8789c..452dcbefc 100644 --- a/src/ui.c +++ b/src/ui.c @@ -952,3 +952,12 @@ meta_ui_get_drag_threshold (MetaUI *ui) return threshold; } + +MetaUIDirection +meta_ui_get_direction (void) +{ + if (gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL) + return META_UI_DIRECTION_RTL; + + return META_UI_DIRECTION_LTR; +} diff --git a/src/ui.h b/src/ui.h index 6038a7675..4ca4afcbc 100644 --- a/src/ui.h +++ b/src/ui.h @@ -40,6 +40,12 @@ typedef struct _MetaImageWindow MetaImageWindow; typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data); +typedef enum +{ + META_UI_DIRECTION_LTR, + META_UI_DIRECTION_RTL +} MetaUIDirection; + void meta_ui_init (int *argc, char ***argv); Display* meta_ui_get_display (void); @@ -194,6 +200,8 @@ gboolean meta_ui_window_is_widget (MetaUI *ui, int meta_ui_get_drag_threshold (MetaUI *ui); +MetaUIDirection meta_ui_get_direction (void); + #include "tabpopup.h" #endif diff --git a/src/window.c b/src/window.c index de58c8905..090aed6da 100644 --- a/src/window.c +++ b/src/window.c @@ -6454,6 +6454,7 @@ meta_window_show_menu (MetaWindow *window, MetaWindowMenu *menu; MetaWorkspaceLayout layout; int n_workspaces; + gboolean ltr; if (window->display->window_menu) { @@ -6484,12 +6485,13 @@ meta_window_show_menu (MetaWindow *window, if (!window->on_all_workspaces) { + ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR; if (layout.current_col > 0) - ops |= META_MENU_OP_MOVE_LEFT; + ops |= ltr ? META_MENU_OP_MOVE_LEFT : META_MENU_OP_MOVE_RIGHT; if ((layout.current_col < layout.cols - 1) && (layout.current_row * layout.cols + (layout.current_col + 1) < n_workspaces)) - ops |= META_MENU_OP_MOVE_RIGHT; + ops |= ltr ? META_MENU_OP_MOVE_RIGHT : META_MENU_OP_MOVE_LEFT; if (layout.current_row > 0) ops |= META_MENU_OP_MOVE_UP; if ((layout.current_row < layout.rows - 1) && diff --git a/src/workspace.c b/src/workspace.c index d11fcecd7..bd131d720 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -721,6 +721,7 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace, { MetaWorkspaceLayout layout; int i, current_space, num_workspaces; + gboolean ltr; current_space = meta_workspace_index (workspace); num_workspaces = meta_screen_get_n_workspaces (workspace->screen); @@ -730,13 +731,15 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace, meta_verbose ("Getting neighbor of %d in direction %s\n", current_space, meta_motion_direction_to_string (direction)); + ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR; + switch (direction) { case META_MOTION_LEFT: - layout.current_col -= 1; + layout.current_col -= ltr ? 1 : -1; break; case META_MOTION_RIGHT: - layout.current_col += 1; + layout.current_col += ltr ? 1 : -1; break; case META_MOTION_UP: layout.current_row -= 1;