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:
parent
a7053d3d47
commit
5194df842c
22
ChangeLog
22
ChangeLog
@ -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>
|
2007-04-24 Linus Torvalds <torvalds@woody.linux-foundation.org>
|
||||||
|
|
||||||
* src/prefs.[ch] (init_action_meta_prefs, meta_prefs_init,
|
* src/prefs.[ch] (init_action_meta_prefs, meta_prefs_init,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "fixedtip.h"
|
#include "fixedtip.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
static GtkWidget *tip = NULL;
|
static GtkWidget *tip = NULL;
|
||||||
static GtkWidget *label = 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_label_set_markup (GTK_LABEL (label), markup_text);
|
||||||
|
|
||||||
gtk_window_get_size (GTK_WINDOW (tip), &w, &h);
|
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)
|
if ((root_x + w) > screen_right_edge)
|
||||||
root_x -= (root_x + w) - screen_right_edge;
|
root_x -= (root_x + w) - screen_right_edge;
|
||||||
|
|
||||||
|
10
src/frames.c
10
src/frames.c
@ -34,6 +34,7 @@
|
|||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
#ifdef HAVE_SHAPE
|
#ifdef HAVE_SHAPE
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
@ -1134,6 +1135,11 @@ show_tip_now (MetaFrames *frames)
|
|||||||
/* get conversion delta for root-to-frame coords */
|
/* get conversion delta for root-to-frame coords */
|
||||||
dx = root_x - x;
|
dx = root_x - x;
|
||||||
dy = root_y - y;
|
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)));
|
screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames)));
|
||||||
|
|
||||||
meta_fixed_tip_show (gdk_display,
|
meta_fixed_tip_show (gdk_display,
|
||||||
@ -1432,6 +1438,10 @@ meta_frames_button_press_event (GtkWidget *widget,
|
|||||||
dx = event->x_root - event->x;
|
dx = event->x_root - event->x;
|
||||||
dy = event->y_root - event->y;
|
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,
|
meta_core_show_window_menu (gdk_display,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
rect->x + dx,
|
rect->x + dx,
|
||||||
|
@ -3229,6 +3229,9 @@ handle_activate_menu (MetaDisplay *display,
|
|||||||
meta_window_get_position (display->focus_window,
|
meta_window_get_position (display->focus_window,
|
||||||
&x, &y);
|
&x, &y);
|
||||||
|
|
||||||
|
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
||||||
|
x += display->focus_window->rect.width;
|
||||||
|
|
||||||
meta_window_show_menu (display->focus_window,
|
meta_window_show_menu (display->focus_window,
|
||||||
x, y,
|
x, y,
|
||||||
0,
|
0,
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "themewidget.h"
|
#include "themewidget.h"
|
||||||
#include "metaaccellabel.h"
|
#include "metaaccellabel.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
typedef struct _MenuItem MenuItem;
|
typedef struct _MenuItem MenuItem;
|
||||||
typedef struct _MenuData MenuData;
|
typedef struct _MenuData MenuData;
|
||||||
@ -119,6 +120,9 @@ popup_position_func (GtkMenu *menu,
|
|||||||
*x = pos->x;
|
*x = pos->x;
|
||||||
*y = pos->y;
|
*y = pos->y;
|
||||||
|
|
||||||
|
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
||||||
|
*x = MAX (0, *x - req.width);
|
||||||
|
|
||||||
/* Ensure onscreen */
|
/* Ensure onscreen */
|
||||||
*x = CLAMP (*x, 0, MAX (0, gdk_screen_width () - req.width));
|
*x = CLAMP (*x, 0, MAX (0, gdk_screen_width () - req.width));
|
||||||
*y = CLAMP (*y, 0, MAX (0, gdk_screen_height () - req.height));
|
*y = CLAMP (*y, 0, MAX (0, gdk_screen_height () - req.height));
|
||||||
|
9
src/ui.c
9
src/ui.c
@ -952,3 +952,12 @@ meta_ui_get_drag_threshold (MetaUI *ui)
|
|||||||
|
|
||||||
return threshold;
|
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;
|
||||||
|
}
|
||||||
|
8
src/ui.h
8
src/ui.h
@ -40,6 +40,12 @@ typedef struct _MetaImageWindow MetaImageWindow;
|
|||||||
|
|
||||||
typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
|
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);
|
void meta_ui_init (int *argc, char ***argv);
|
||||||
|
|
||||||
Display* meta_ui_get_display (void);
|
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);
|
int meta_ui_get_drag_threshold (MetaUI *ui);
|
||||||
|
|
||||||
|
MetaUIDirection meta_ui_get_direction (void);
|
||||||
|
|
||||||
#include "tabpopup.h"
|
#include "tabpopup.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6454,6 +6454,7 @@ meta_window_show_menu (MetaWindow *window,
|
|||||||
MetaWindowMenu *menu;
|
MetaWindowMenu *menu;
|
||||||
MetaWorkspaceLayout layout;
|
MetaWorkspaceLayout layout;
|
||||||
int n_workspaces;
|
int n_workspaces;
|
||||||
|
gboolean ltr;
|
||||||
|
|
||||||
if (window->display->window_menu)
|
if (window->display->window_menu)
|
||||||
{
|
{
|
||||||
@ -6484,12 +6485,13 @@ meta_window_show_menu (MetaWindow *window,
|
|||||||
|
|
||||||
if (!window->on_all_workspaces)
|
if (!window->on_all_workspaces)
|
||||||
{
|
{
|
||||||
|
ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR;
|
||||||
|
|
||||||
if (layout.current_col > 0)
|
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) &&
|
if ((layout.current_col < layout.cols - 1) &&
|
||||||
(layout.current_row * layout.cols + (layout.current_col + 1) < n_workspaces))
|
(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)
|
if (layout.current_row > 0)
|
||||||
ops |= META_MENU_OP_MOVE_UP;
|
ops |= META_MENU_OP_MOVE_UP;
|
||||||
if ((layout.current_row < layout.rows - 1) &&
|
if ((layout.current_row < layout.rows - 1) &&
|
||||||
|
@ -721,6 +721,7 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
|
|||||||
{
|
{
|
||||||
MetaWorkspaceLayout layout;
|
MetaWorkspaceLayout layout;
|
||||||
int i, current_space, num_workspaces;
|
int i, current_space, num_workspaces;
|
||||||
|
gboolean ltr;
|
||||||
|
|
||||||
current_space = meta_workspace_index (workspace);
|
current_space = meta_workspace_index (workspace);
|
||||||
num_workspaces = meta_screen_get_n_workspaces (workspace->screen);
|
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",
|
meta_verbose ("Getting neighbor of %d in direction %s\n",
|
||||||
current_space, meta_motion_direction_to_string (direction));
|
current_space, meta_motion_direction_to_string (direction));
|
||||||
|
|
||||||
|
ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR;
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case META_MOTION_LEFT:
|
case META_MOTION_LEFT:
|
||||||
layout.current_col -= 1;
|
layout.current_col -= ltr ? 1 : -1;
|
||||||
break;
|
break;
|
||||||
case META_MOTION_RIGHT:
|
case META_MOTION_RIGHT:
|
||||||
layout.current_col += 1;
|
layout.current_col += ltr ? 1 : -1;
|
||||||
break;
|
break;
|
||||||
case META_MOTION_UP:
|
case META_MOTION_UP:
|
||||||
layout.current_row -= 1;
|
layout.current_row -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user