aboutsummaryrefslogtreecommitdiff
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
parent9278783913187e1b748817f96b445e1d5c23339e (diff)
downloadayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.tar.gz
ayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.tar.bz2
ayatana-indicator-keyboard-682d07f59ea363a5ab32d78029a93beabda8cac2.zip
Per-window fixes.
-rw-r--r--configure.ac10
-rw-r--r--debian/changelog6
-rw-r--r--debian/control3
-rw-r--r--deps/README4
-rw-r--r--deps/libbamf3.vapi180
-rw-r--r--lib/Makefile.am12
-rw-r--r--lib/main.vala49
7 files changed, 259 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 4b6f4f1c..d00c6f10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,8 @@ IT_PROG_INTLTOOL
GLIB_GSETTINGS
+AM_PATH_PYTHON
+
PKG_CHECK_MODULES([GEE], [gee-1.0])
AC_SUBST([GEE_CFLAGS])
AC_SUBST([GEE_LIBS])
@@ -67,9 +69,15 @@ PKG_CHECK_MODULES([IBUS], [ibus-1.0])
AC_SUBST([IBUS_CFLAGS])
AC_SUBST([IBUS_LIBS])
+PKG_CHECK_MODULES([BAMF], [libbamf3])
+AC_SUBST([BAMF_CFLAGS])
+AC_SUBST([BAMF_LIBS])
+
AC_CONFIG_FILES([Makefile
data/Makefile
lib/Makefile
- po/Makefile.in])
+ po/Makefile.in
+ tests/Makefile
+ tests/autopilot/Makefile])
AC_OUTPUT
diff --git a/debian/changelog b/debian/changelog
index 07ff0ec8..58d9b6ba 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+indicator-keyboard (0.0.0-0ubuntu11) saucy; urgency=low
+
+ * Per-window fixes.
+
+ -- William Hua <william.hua@canonical.com> Wed, 19 Jun 2013 08:52:36 -0400
+
indicator-keyboard (0.0.0-0ubuntu10) saucy; urgency=low
* Build depend on dh-translations.
diff --git a/debian/control b/debian/control
index 74fef31b..5e576573 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,8 @@ Build-Depends: debhelper (>= 9.0.0),
libgtk-3-dev,
libgnome-desktop-3-dev,
libgnomekbd-dev,
- libibus-1.0-dev (>= 1.5.0)
+ libibus-1.0-dev (>= 1.5.0),
+ libbamf3-dev
Standards-Version: 3.9.4
Homepage: https://code.launchpad.net/indicator-keyboard
# If you aren't a member of ~indicator-applet-developers but need to upload
diff --git a/deps/README b/deps/README
index 41775da2..80ca5e0d 100644
--- a/deps/README
+++ b/deps/README
@@ -37,3 +37,7 @@ valadoc --metadatadir . --vapidir /path/to/vapi/dir --pkg gtk+-3.0 --pkg Xkl-1.0
To generate ibus-1.0.vapi docs:
valadoc --vapidir /path/to/vapi/dir -o ibus-1.0 /path/to/ibus-1.0.vapi
+
+To generate libbamf3.vapi:
+
+vapigen --library libbamf3 /path/to/Bamf-3.gir
diff --git a/deps/libbamf3.vapi b/deps/libbamf3.vapi
new file mode 100644
index 00000000..7d48dcbb
--- /dev/null
+++ b/deps/libbamf3.vapi
@@ -0,0 +1,180 @@
+/* libbamf3.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Bamf", gir_namespace = "Bamf", gir_version = "3", lower_case_cprefix = "bamf_")]
+namespace Bamf {
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_application_get_type ()")]
+ public class Application : Bamf.View {
+ [CCode (has_construct_function = false)]
+ protected Application ();
+ public bool get_application_menu (string name, string object_path);
+ public unowned string get_application_type ();
+ public unowned string get_desktop_file ();
+ public unowned Bamf.View get_focusable_child ();
+ public bool get_show_menu_stubs ();
+ [CCode (array_length = false, array_null_terminated = true)]
+ public string[] get_supported_mime_types ();
+ public GLib.List<weak Bamf.Window> get_windows ();
+ public GLib.Array<uint32> get_xids ();
+ public signal void window_added (Bamf.View object);
+ public signal void window_removed (Bamf.View object);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_control_get_type ()")]
+ public class Control : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected Control ();
+ public static unowned Bamf.Control get_default ();
+ public void insert_desktop_file (string desktop_file);
+ public void register_application_for_pid (string application, int32 pid);
+ public void register_tab_provider (string path);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_matcher_get_type ()")]
+ public class Matcher : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected Matcher ();
+ public bool application_is_running (string application);
+ public unowned Bamf.Application get_active_application ();
+ public unowned Bamf.Window get_active_window ();
+ public unowned Bamf.Application get_application_for_desktop_file (string desktop_file_path, bool create_if_not_found);
+ public unowned Bamf.Application get_application_for_window (Bamf.Window window);
+ public unowned Bamf.Application get_application_for_xid (uint32 xid);
+ public GLib.List<weak Bamf.Application> get_applications ();
+ public static Bamf.Matcher get_default ();
+ public GLib.List<weak Bamf.Application> get_running_applications ();
+ public GLib.List<weak Bamf.View> get_tabs ();
+ public GLib.List<weak Bamf.View> get_window_stack_for_monitor (int monitor);
+ public GLib.List<weak Bamf.View> get_windows ();
+ public GLib.Array<uint32> get_xids_for_application (string application);
+ public void register_favorites ([CCode (array_length = false)] string[] favorites);
+ public signal void active_application_changed (Bamf.View object, Bamf.View p0);
+ public signal void active_window_changed (Bamf.View object, Bamf.View p0);
+ public signal void stacking_order_changed ();
+ public signal void view_closed (Bamf.View object);
+ public signal void view_opened (Bamf.View object);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_tab_get_type ()")]
+ public class Tab : Bamf.View {
+ [CCode (has_construct_function = false)]
+ public Tab (string path);
+ public bool close ();
+ public virtual unowned string get_desktop_name ();
+ public virtual bool get_is_foreground_tab ();
+ public virtual unowned string get_location ();
+ public virtual uint64 get_xid ();
+ public bool raise ();
+ [NoAccessorMethod]
+ public string desktop_id { owned get; set; }
+ [NoAccessorMethod]
+ public bool is_foreground_tab { get; set; }
+ [NoAccessorMethod]
+ public string location { owned get; set; }
+ [NoAccessorMethod]
+ public uint64 xid { get; set; }
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_tab_source_get_type ()")]
+ public class TabSource : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected TabSource ();
+ [CCode (array_length = false, array_null_terminated = true)]
+ public unowned string[] get_tab_ids ();
+ public string get_tab_uri (string tab_id);
+ public uint32 get_tab_xid (string tab_id);
+ [NoWrapper]
+ public virtual void show_tab (string tab_id);
+ [NoWrapper]
+ public virtual string tab_uri (string tab_id);
+ [NoWrapper]
+ public virtual uint32 tab_xid (string tab_id);
+ [NoAccessorMethod]
+ public string id { owned get; set construct; }
+ public signal void tab_closed (string object);
+ public signal void tab_opened (string object);
+ public signal void tab_uri_changed (string object, string p0, string p1);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_view_get_type ()")]
+ public class View : GLib.InitiallyUnowned {
+ [CCode (has_construct_function = false)]
+ protected View ();
+ [NoWrapper]
+ public virtual Bamf.ClickBehavior click_behavior ();
+ public virtual GLib.List<weak Bamf.View> get_children ();
+ public Bamf.ClickBehavior get_click_suggestion ();
+ public virtual string get_icon ();
+ public virtual string get_name ();
+ [CCode (vfunc_name = "view_type")]
+ public virtual unowned string get_view_type ();
+ public virtual bool is_active ();
+ public bool is_closed ();
+ public virtual bool is_running ();
+ public bool is_sticky ();
+ public virtual bool is_urgent ();
+ public bool is_user_visible ();
+ [NoWrapper]
+ public virtual void set_path (string path);
+ public virtual void set_sticky (bool value);
+ [NoAccessorMethod]
+ public bool active { get; }
+ [NoAccessorMethod]
+ public string path { owned get; }
+ [NoAccessorMethod]
+ public bool running { get; }
+ [NoAccessorMethod]
+ public bool urgent { get; }
+ [NoAccessorMethod]
+ public bool user_visible { get; }
+ public virtual signal void active_changed (bool active);
+ public virtual signal void child_added (Bamf.View child);
+ public virtual signal void child_moved (Bamf.View child);
+ public virtual signal void child_removed (Bamf.View child);
+ public virtual signal void closed ();
+ public virtual signal void name_changed (string old_name, string new_name);
+ public virtual signal void running_changed (bool running);
+ public virtual signal void urgent_changed (bool urgent);
+ public virtual signal void user_visible_changed (bool user_visible);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", type_id = "bamf_window_get_type ()")]
+ public class Window : Bamf.View {
+ [CCode (has_construct_function = false)]
+ protected Window ();
+ public virtual int get_monitor ();
+ public virtual uint32 get_pid ();
+ public virtual unowned Bamf.Window get_transient ();
+ public virtual string get_utf8_prop (string prop);
+ public virtual Bamf.WindowType get_window_type ();
+ public virtual uint32 get_xid ();
+ public virtual long last_active ();
+ public virtual Bamf.WindowMaximizationType maximized ();
+ public virtual signal void maximized_changed (int old_value, int new_value);
+ public virtual signal void monitor_changed (int old_value, int new_value);
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", cprefix = "BAMF_CLICK_BEHAVIOR_", has_type_id = false)]
+ public enum ClickBehavior {
+ NONE,
+ OPEN,
+ FOCUS,
+ FOCUS_ALL,
+ MINIMIZE,
+ RESTORE,
+ RESTORE_ALL,
+ PICKER
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", cprefix = "BAMF_WINDOW_", has_type_id = false)]
+ public enum WindowMaximizationType {
+ FLOATING,
+ HORIZONTAL_MAXIMIZED,
+ VERTICAL_MAXIMIZED,
+ MAXIMIZED
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", cprefix = "BAMF_WINDOW_", has_type_id = false)]
+ public enum WindowType {
+ NORMAL,
+ DESKTOP,
+ DOCK,
+ DIALOG,
+ TOOLBAR,
+ MENU,
+ UTILITY,
+ SPLASHSCREEN
+ }
+ [CCode (cheader_filename = "libbamf/libbamf.h", instance_pos = 2.9)]
+ public delegate void TabPreviewReadyCallback (Bamf.Tab self, string preview_data);
+}
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 ();