aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2015-02-19 12:15:59 -0500
committerWilliam Hua <william.hua@canonical.com>2015-02-19 12:15:59 -0500
commit9cdbb03cab972221b36151e852d8412179483c4a (patch)
treeb4297e0099373e9c6faefd8aeb352d4d36ac1a21
parentc34cf40e28eed1842ee691603fe6940f04302e10 (diff)
downloadayatana-indicator-keyboard-9cdbb03cab972221b36151e852d8412179483c4a.tar.gz
ayatana-indicator-keyboard-9cdbb03cab972221b36151e852d8412179483c4a.tar.bz2
ayatana-indicator-keyboard-9cdbb03cab972221b36151e852d8412179483c4a.zip
Simplify input source cycling.
-rw-r--r--lib/main.vala13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 170e0335..877d7b7b 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -890,19 +890,16 @@ public class Indicator.Keyboard.Service : Object {
if (length > 1) {
var current = old_current;
var offset = -((!) parameter).get_int32 () % length;
+ var jump = 1;
- /* Go backward. */
- for (; offset < 0; offset++) {
- do {
- current = (current + sources.length - 1) % sources.length;
- } while ((sources[current].is_ibus && !is_ibus_active ()) ||
- (sources[current].is_fcitx && !is_fcitx_active ()));
+ if (offset < 0) {
+ offset = -offset;
+ jump = sources.length - jump;
}
- /* Go forward. */
for (; offset > 0; offset--) {
do {
- current = (current + 1) % sources.length;
+ current = (current + jump) % sources.length;
} while ((sources[current].is_ibus && !is_ibus_active ()) ||
(sources[current].is_fcitx && !is_fcitx_active ()));
}