aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-11-05 23:33:06 +0000
committerTarmac <Unknown>2013-11-05 23:33:06 +0000
commitb50ff233a42e3ceac11d35dea5aab3ba11e9f00b (patch)
tree5ef65c8aa58eacf3eb0d17de8241f23dd9003a56 /lib
parent7bba3d50684b55a18feffdee01db79b5ccff0b5c (diff)
parentc01d6f3fa3e8663da142f23b9e36dcf57622c57d (diff)
downloadayatana-indicator-keyboard-b50ff233a42e3ceac11d35dea5aab3ba11e9f00b.tar.gz
ayatana-indicator-keyboard-b50ff233a42e3ceac11d35dea5aab3ba11e9f00b.tar.bz2
ayatana-indicator-keyboard-b50ff233a42e3ceac11d35dea5aab3ba11e9f00b.zip
Enable middle click and mouse wheel scrolling. Fixes: https://bugs.launchpad.net/bugs/887139.
Approved by Charles Kerr, PS Jenkins bot.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/main.vala31
2 files changed, 31 insertions, 3 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index fd8a945e..fc6eeb42 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,8 +2,7 @@ libexec_PROGRAMS = indicator-keyboard-service
AM_CFLAGS = -w -DGNOME_DESKTOP_USE_UNSTABLE_API
AM_LDFLAGS = -lm
-AM_VALAFLAGS = --enable-experimental-non-null \
- --metadatadir $(top_srcdir)/deps \
+AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
--vapidir $(top_srcdir)/deps
indicator_keyboard_service_SOURCES = main.vala \
diff --git a/lib/main.vala b/lib/main.vala
index 195ee140..66147b18 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -571,13 +571,40 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private void handle_middle_click (Variant? parameter) {
+ handle_scroll_wheel (new Variant.int32 (-1));
+ }
+
+ [DBus (visible = false)]
+ private void handle_scroll_wheel (Variant? parameter) {
+ if (parameter != null) {
+ var sources = source_settings.get_value ("sources");
+ var current = source_settings.get_uint ("current");
+ var length = (int) sources.n_children ();
+
+ if (length > 0) {
+ var offset = parameter.get_int32 () % length;
+ source_settings.set_uint ("current", (current + (length - offset)) % length);
+ }
+ }
+ }
+
+ [DBus (visible = false)]
protected virtual SimpleActionGroup create_action_group (Action root_action) {
var group = new SimpleActionGroup ();
group.insert (root_action);
group.insert (source_settings.create_action ("current"));
- var action = new SimpleAction ("map", null);
+ var action = new SimpleAction ("next", null);
+ action.activate.connect (handle_middle_click);
+ group.insert (action);
+
+ action = new SimpleAction ("scroll", VariantType.INT32);
+ action.activate.connect (handle_scroll_wheel);
+ group.insert (action);
+
+ action = new SimpleAction ("map", null);
action.activate.connect (handle_activate_map);
group.insert (action);
@@ -655,6 +682,8 @@ public class Indicator.Keyboard.Service : Object {
var indicator = new MenuItem.submenu ("x", submenu);
indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
+ indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next");
+ indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll");
indicator.set_detailed_action ("indicator.indicator");
menu.append_item (indicator);