diff options
author | William Hua <william.hua@canonical.com> | 2015-02-19 12:15:59 -0500 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2015-02-19 12:15:59 -0500 |
commit | 9cdbb03cab972221b36151e852d8412179483c4a (patch) | |
tree | b4297e0099373e9c6faefd8aeb352d4d36ac1a21 | |
parent | c34cf40e28eed1842ee691603fe6940f04302e10 (diff) | |
download | ayatana-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.vala | 13 |
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 ())); } |