Add support for RTL languages so that alt-tab, etc., go the other way. In

2007-05-25  Yair Hershkovitz  <yairhr@yahoo.com>

        * 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.


svn path=/trunk/; revision=3222
This commit is contained in:
Yair Hershkovitz 2007-05-25 14:36:12 +00:00 committed by Thomas James Alexander Thurman
parent a7053d3d47
commit 5194df842c
9 changed files with 70 additions and 4 deletions

View File

@ -1,3 +1,25 @@
2007-05-25 Yair Hershkovitz <yairhr@yahoo.com>
* 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 <torvalds@woody.linux-foundation.org>
* src/prefs.[ch] (init_action_meta_prefs, meta_prefs_init,

View File

@ -23,6 +23,7 @@
#include <config.h>
#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;

View File

@ -34,6 +34,7 @@
#include "theme.h"
#include "prefs.h"
#include "errors.h"
#include "ui.h"
#ifdef HAVE_SHAPE
#include <X11/extensions/shape.h>
@ -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,

View File

@ -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,

View File

@ -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));

View File

@ -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;
}

View File

@ -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

View File

@ -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) &&

View File

@ -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;