From 2aca1d41a349fdc57374b2a5dcfc4d6df521c2fb Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Wed, 21 Feb 2007 18:27:42 +0000 Subject: fix left/right scroll for RTL 2007-02-21 Vincent Untz * libwnck/tasklist.c: (wnck_tasklist_scroll_cb): fix left/right scroll for RTL svn path=/trunk/; revision=1186 --- ChangeLog | 5 ++++ libwnck/tasklist.c | 68 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1592f93..834a5c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-02-21 Vincent Untz + + * libwnck/tasklist.c: (wnck_tasklist_scroll_cb): fix left/right scroll + for RTL + 2007-02-20 Kjartan Maraas * Makefile.am: Dist MAINTAINERS. diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c index 985562d..848e9f2 100644 --- a/libwnck/tasklist.c +++ b/libwnck/tasklist.c @@ -1692,8 +1692,9 @@ wnck_tasklist_scroll_cb (WnckTasklist *tasklist, GdkEventScroll *event, gpointer user_data) { - /* use the fact that tasklist->priv->windows is sorted is sorted + /* use the fact that tasklist->priv->windows is sorted * see wnck_tasklist_size_allocate() */ + GtkTextDirection ltr; GList *window; gint row = 0; gint col = 0; @@ -1711,6 +1712,8 @@ wnck_tasklist_scroll_cb (WnckTasklist *tasklist, * It occurs if we change the active task too fast. */ return TRUE; + ltr = (gtk_widget_get_direction (GTK_WIDGET (tasklist)) != GTK_TEXT_DIR_RTL); + switch (event->direction) { case GDK_SCROLL_UP: @@ -1727,36 +1730,75 @@ wnck_tasklist_scroll_cb (WnckTasklist *tasklist, window = window->next; break; +#define TASKLIST_GET_MOST_LEFT(ltr, window, tasklist) \ + do \ + { \ + if (ltr) \ + window = tasklist->priv->windows; \ + else \ + window = g_list_last (tasklist->priv->windows); \ + } while (0) + +#define TASKLIST_GET_MOST_RIGHT(ltr, window, tasklist) \ + do \ + { \ + if (ltr) \ + window = g_list_last (tasklist->priv->windows); \ + else \ + window = tasklist->priv->windows; \ + } while (0) + case GDK_SCROLL_LEFT: if (!window) - window = g_list_last (tasklist->priv->windows); + TASKLIST_GET_MOST_RIGHT (ltr, window, tasklist); else { /* Search the first window on the previous colomn at same row */ - while (window && (WNCK_TASK(window->data)->row != row || - WNCK_TASK(window->data)->col != col-1)) - window = window->prev; - /* If no window found, select the first one */ + if (ltr) + { + while (window && (WNCK_TASK(window->data)->row != row || + WNCK_TASK(window->data)->col != col-1)) + window = window->prev; + } + else + { + while (window && (WNCK_TASK(window->data)->row != row || + WNCK_TASK(window->data)->col != col-1)) + window = window->next; + } + /* If no window found, select the top/bottom left one */ if (!window) - window = tasklist->priv->windows; + TASKLIST_GET_MOST_LEFT (ltr, window, tasklist); } break; case GDK_SCROLL_RIGHT: if (!window) - window = tasklist->priv->windows; + TASKLIST_GET_MOST_LEFT (ltr, window, tasklist); else { /* Search the first window on the next colomn at same row */ - while (window && (WNCK_TASK(window->data)->row != row || - WNCK_TASK(window->data)->col != col+1)) - window = window->next; - /* If no window found, select the last one */ + if (ltr) + { + while (window && (WNCK_TASK(window->data)->row != row || + WNCK_TASK(window->data)->col != col+1)) + window = window->next; + } + else + { + while (window && (WNCK_TASK(window->data)->row != row || + WNCK_TASK(window->data)->col != col+1)) + window = window->prev; + } + /* If no window found, select the top/bottom right one */ if (!window) - window = g_list_last (tasklist->priv->windows); + TASKLIST_GET_MOST_RIGHT (ltr, window, tasklist); } break; +#undef TASKLIST_GET_MOST_LEFT +#undef TASKLIST_GET_MOST_RIGHT + default: g_assert_not_reached (); } -- cgit v1.2.1