aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-19 09:09:41 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-19 09:09:41 -0400
commit682d07f59ea363a5ab32d78029a93beabda8cac2 (patch)
tree812238b26ec491caf7f40da93d6612393c8d3800 /lib
parent9278783913187e1b748817f96b445e1d5c23339e (diff)
downloadayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.tar.gz
ayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.tar.bz2
ayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.zip
Per-window fixes.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am12
-rw-r--r--lib/main.vala49
2 files changed, 58 insertions, 3 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b9aa2394..8edeb33b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,6 +8,7 @@ libexec_PROGRAMS = indicator-keyboard-service
indicator_keyboard_service_SOURCES = main.vala \
common.vala
indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
+ --pkg gee-1.0 \
--pkg posix \
--pkg pangocairo \
--pkg gtk+-3.0 \
@@ -15,18 +16,23 @@ indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg gnome-desktop-3.0 \
--pkg Xkl-1.0 \
--pkg libgnomekbd \
- --pkg ibus-1.0
+ --pkg ibus-1.0 \
+ --pkg libbamf3
indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
+ $(GEE_CFLAGS) \
$(PANGOCAIRO_CFLAGS) \
$(GTK_CFLAGS) \
$(GNOME_DESKTOP_CFLAGS) \
$(LIBXKLAVIER_CFLAGS) \
$(LIBGNOMEKBD_CFLAGS) \
- $(IBUS_CFLAGS)
+ $(IBUS_CFLAGS) \
+ $(BAMF_CFLAGS)
indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
+ $(GEE_LIBS) \
$(PANGOCAIRO_LIBS) \
$(GTK_LIBS) \
$(GNOME_DESKTOP_LIBS) \
$(LIBXKLAVIER_LIBS) \
$(LIBGNOMEKBD_LIBS) \
- $(IBUS_LIBS)
+ $(IBUS_LIBS) \
+ $(BAMF_LIBS)
diff --git a/lib/main.vala b/lib/main.vala
index 9d438381..ec4ceafa 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -4,8 +4,11 @@ public class Indicator.Keyboard.Service : Object {
private MainLoop loop;
private Settings indicator_settings;
private Settings source_settings;
+ private Settings per_window_settings;
private Gnome.XkbInfo xkb_info;
private IBus.Bus ibus;
+ private Bamf.Matcher matcher;
+ private Gee.HashMap <string, uint> window_sources;
private SimpleActionGroup action_group;
private SimpleAction indicator_action;
@@ -33,13 +36,59 @@ public class Indicator.Keyboard.Service : Object {
this.source_settings.changed["current"].connect (this.handle_changed_current);
this.source_settings.changed["sources"].connect (this.handle_changed_sources);
+ this.per_window_settings = new Settings ("org.gnome.libgnomekbd.desktop");
+ this.per_window_settings.changed["group-per-window"].connect (this.handle_changed_group_per_window);
+
this.xkb_info = new Gnome.XkbInfo ();
+ update_window_sources ();
+
this.loop = new MainLoop ();
this.loop.run ();
}
[DBus (visible = false)]
+ private void update_window_sources () {
+ var group_per_window = this.per_window_settings.get_boolean ("group-per-window");
+
+ if (group_per_window != (this.window_sources != null)) {
+ if (group_per_window) {
+ this.window_sources = new Gee.HashMap <string, uint> ();
+ this.matcher = Bamf.Matcher.get_default ();
+ this.matcher.active_window_changed.connect (this.handle_active_window_changed);
+ } else {
+ this.matcher.active_window_changed.disconnect (this.handle_active_window_changed);
+ this.matcher = null;
+ this.window_sources = null;
+ }
+ }
+ }
+
+ [DBus (visible = false)]
+ private void handle_changed_group_per_window (string key) {
+ update_window_sources ();
+ }
+
+ [DBus (visible = false)]
+ private void handle_active_window_changed (Bamf.View? old_view, Bamf.View? new_view) {
+ if (old_view != null) {
+ this.window_sources[old_view.path] = this.source_settings.get_uint ("current");
+ }
+
+ if (new_view != null) {
+ if (!this.window_sources.has_key (new_view.path)) {
+ var default_group = this.per_window_settings.get_int ("default-group");
+
+ if (default_group >= 0) {
+ this.source_settings.set_uint ("current", (uint) default_group);
+ }
+ } else {
+ this.source_settings.set_uint ("current", this.window_sources[new_view.path]);
+ }
+ }
+ }
+
+ [DBus (visible = false)]
private Gtk.StyleContext get_style_context () {
var context = new Gtk.StyleContext ();