aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac8
-rw-r--r--data/Makefile.am3
-rw-r--r--debian/control2
-rw-r--r--lib/Makefile.am58
-rw-r--r--lib/main.vala203
5 files changed, 208 insertions, 66 deletions
diff --git a/configure.ac b/configure.ac
index 31640e6b..b2503f1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,14 @@ PKG_CHECK_MODULES([IBUS], [ibus-1.0])
AC_SUBST([IBUS_CFLAGS])
AC_SUBST([IBUS_LIBS])
+PKG_CHECK_MODULES([ACCOUNTSSERVICE], [accountsservice])
+AC_SUBST([ACCOUNTSSERVICE_CFLAGS])
+AC_SUBST([ACCOUNTSSERVICE_LIBS])
+
+PKG_CHECK_MODULES([LIGHTDM], [liblightdm-gobject-1])
+AC_SUBST([LIGHTDM_CFLAGS])
+AC_SUBST([LIGHTDM_LIBS])
+
PKG_CHECK_MODULES([BAMF], [libbamf3])
AC_SUBST([BAMF_CFLAGS])
AC_SUBST([BAMF_LIBS])
diff --git a/data/Makefile.am b/data/Makefile.am
index a7f8d39c..10cdfee5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -48,6 +48,9 @@ com.canonical.indicator.keyboard:
echo 'ObjectPath=/com/canonical/indicator/keyboard'; \
echo ''; \
echo '[desktop]'; \
+ echo 'ObjectPath=/com/canonical/indicator/keyboard/desktop'; \
+ echo ''; \
+ echo '[desktop_greeter]'; \
echo 'ObjectPath=/com/canonical/indicator/keyboard/desktop') > $@.tmp && \
mv $@.tmp $@
diff --git a/debian/control b/debian/control
index 90eb2451..4f5289ac 100644
--- a/debian/control
+++ b/debian/control
@@ -14,6 +14,8 @@ Build-Depends: quilt,
libgnome-desktop-3-dev,
libgnomekbd-dev,
libibus-1.0-dev (>= 1.5.0),
+ libaccountsservice-dev,
+ liblightdm-gobject-1-dev,
libbamf3-dev,
dbus,
xvfb,
diff --git a/lib/Makefile.am b/lib/Makefile.am
index cdf41ba2..0e6c70d1 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,32 +9,38 @@ AM_VALAFLAGS = --enable-experimental-non-null \
indicator_keyboard_service_SOURCES = main.vala \
source.vala \
common.vala
-indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
- --pkg gee-1.0 \
- --pkg posix \
- --pkg pangocairo \
- --pkg gtk+-3.0 \
- --pkg GDesktopEnums-3.0 \
- --pkg gnome-desktop-3.0 \
- --pkg Xkl-1.0 \
- --pkg Gkbd-3.0 \
- --pkg ibus-1.0 \
+indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
+ --pkg gee-1.0 \
+ --pkg posix \
+ --pkg pangocairo \
+ --pkg gtk+-3.0 \
+ --pkg GDesktopEnums-3.0 \
+ --pkg gnome-desktop-3.0 \
+ --pkg Xkl-1.0 \
+ --pkg Gkbd-3.0 \
+ --pkg ibus-1.0 \
+ --pkg accountsservice \
+ --pkg liblightdm-gobject-1 \
--pkg libbamf3
-indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
- $(GEE_CFLAGS) \
- $(PANGOCAIRO_CFLAGS) \
- $(GTK_CFLAGS) \
- $(GNOME_DESKTOP_CFLAGS) \
- $(LIBXKLAVIER_CFLAGS) \
- $(LIBGNOMEKBD_CFLAGS) \
- $(IBUS_CFLAGS) \
+indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
+ $(GEE_CFLAGS) \
+ $(PANGOCAIRO_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GNOME_DESKTOP_CFLAGS) \
+ $(LIBXKLAVIER_CFLAGS) \
+ $(LIBGNOMEKBD_CFLAGS) \
+ $(IBUS_CFLAGS) \
+ $(ACCOUNTSSERVICE_CFLAGS) \
+ $(LIGHTDM_CFLAGS) \
$(BAMF_CFLAGS)
-indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
- $(GEE_LIBS) \
- $(PANGOCAIRO_LIBS) \
- $(GTK_LIBS) \
- $(GNOME_DESKTOP_LIBS) \
- $(LIBXKLAVIER_LIBS) \
- $(LIBGNOMEKBD_LIBS) \
- $(IBUS_LIBS) \
+indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
+ $(GEE_LIBS) \
+ $(PANGOCAIRO_LIBS) \
+ $(GTK_LIBS) \
+ $(GNOME_DESKTOP_LIBS) \
+ $(LIBXKLAVIER_LIBS) \
+ $(LIBGNOMEKBD_LIBS) \
+ $(IBUS_LIBS) \
+ $(ACCOUNTSSERVICE_LIBS) \
+ $(LIGHTDM_LIBS) \
$(BAMF_LIBS)
diff --git a/lib/main.vala b/lib/main.vala
index 91466f8c..ef94b2f2 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -29,6 +29,7 @@ public class Indicator.Keyboard.Service : Object {
private Settings indicator_settings;
private Settings source_settings;
private Settings per_window_settings;
+ private SList<Act.User> users;
private Bamf.Matcher? matcher;
private Gee.HashMap<string, uint>? window_sources;
@@ -67,6 +68,11 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private static bool is_login_user () {
+ return Environment.get_user_name () == "lightdm";
+ }
+
+ [DBus (visible = false)]
private static IBus.Bus get_ibus () {
if (ibus == null) {
IBus.init ();
@@ -91,64 +97,177 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void migrate_keyboard_layouts () {
- if (!indicator_settings.get_boolean ("migrated")) {
- var builder = new VariantBuilder (new VariantType ("a(ss)"));
- var length = 0;
+ if (is_login_user ()) {
+ Act.UserManager manager = Act.UserManager.get_default ();
+
+ if (manager.is_loaded) {
+ users = manager.list_users ();
+
+ foreach (var user in users) {
+ if (user.is_loaded) {
+ migrate_input_sources ();
+ } else {
+ user.notify["is-loaded"].connect ((pspec) => {
+ if (user.is_loaded) {
+ migrate_input_sources ();
+ }
+ });
+ }
+ }
+ } else {
+ manager.notify["is-loaded"].connect ((pspec) => {
+ if (manager.is_loaded) {
+ users = manager.list_users ();
+
+ foreach (var user in users) {
+ if (user.is_loaded) {
+ migrate_input_sources ();
+ } else {
+ user.notify["is-loaded"].connect ((pspec) => {
+ if (user.is_loaded) {
+ migrate_input_sources ();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ } else {
+ if (!indicator_settings.get_boolean ("migrated")) {
+ var builder = new VariantBuilder (new VariantType ("a(ss)"));
+ var length = 0;
+
+ var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard");
+ var layouts = layout_settings.get_strv ("layouts");
+
+ foreach (var layout in layouts) {
+ var source = layout;
+ source = source.replace (" ", "+");
+ source = source.replace ("\t", "+");
- var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard");
- var layouts = layout_settings.get_strv ("layouts");
+ builder.add ("(ss)", "xkb", source);
+ length++;
+ }
- foreach (var layout in layouts) {
- var source = layout;
+ var engines = get_ibus ().list_active_engines ();
- source = source.replace (" ", "+");
- source = source.replace ("\t", "+");
+ foreach (var engine in engines) {
+ if (length == 0 || engine.name.has_prefix ("xkb")) {
+ var source = "us";
+ string? layout = engine.get_layout ();
+ string? variant = engine.get_layout_variant ();
- builder.add ("(ss)", "xkb", source);
- length++;
- }
+ if (layout != null && ((!) layout).length == 0) {
+ layout = null;
+ }
- var engines = get_ibus ().list_active_engines ();
+ if (variant != null && ((!) variant).length == 0) {
+ variant = null;
+ }
- foreach (var engine in engines) {
- if (length == 0 || engine.name.has_prefix ("xkb")) {
- var source = "us";
- string? layout = engine.get_layout ();
- string? variant = engine.get_layout_variant ();
+ if (layout != null && variant != null) {
+ source = @"$((!) layout)+$((!) variant)";
+ } else if (layout != null) {
+ source = (!) layout;
+ }
- if (layout != null && ((!) layout).length == 0) {
- layout = null;
+ builder.add ("(ss)", "xkb", source);
+ length++;
}
- if (variant != null && ((!) variant).length == 0) {
- variant = null;
+ if (!engine.name.has_prefix ("xkb")) {
+ builder.add ("(ss)", "ibus", engine.name);
+ length++;
}
+ }
- if (layout != null && variant != null) {
- source = @"$((!) layout)+$((!) variant)";
- } else if (layout != null) {
- source = (!) layout;
- }
+ source_settings.set_value ("sources", builder.end ());
+ indicator_settings.set_boolean ("migrated", true);
+ }
+ }
+ }
- builder.add ("(ss)", "xkb", source);
- length++;
+ [DBus (visible = false)]
+ private void migrate_input_sources () {
+ var list = new Gee.LinkedList<string> ();
+ var added = new Gee.HashSet<string> ();
+
+ foreach (var user in users) {
+ if (user.is_loaded) {
+ var sources = user.input_sources;
+ var layouts = user.xkeyboard_layouts;
+
+ VariantIter outer;
+ VariantIter inner;
+
+ sources.get ("aa{ss}", out outer);
+
+ while (outer.next ("a{ss}", out inner)) {
+ unowned string key;
+ unowned string source;
+
+ while (inner.next ("{&s&s}", out key, out source)) {
+ if (key == "xkb") {
+ if (!added.contains (source)) {
+ list.add (source);
+ added.add (source);
+ }
+ }
+ }
}
- if (!engine.name.has_prefix ("xkb")) {
- builder.add ("(ss)", "ibus", engine.name);
- length++;
+ foreach (var layout in layouts) {
+ var source = layout;
+ source = source.replace (" ", "+");
+ source = source.replace ("\t", "+");
+
+ if (!added.contains (source)) {
+ list.add (source);
+ added.add (source);
+ }
}
}
+ }
- source_settings.set_value ("sources", builder.end ());
+ var builder = new VariantBuilder (new VariantType ("a(ss)"));
- indicator_settings.set_boolean ("migrated", true);
+ foreach (var layout in list) {
+ builder.add ("(ss)", "xkb", layout);
+ }
+
+ source_settings.set_value ("sources", builder.end ());
+ }
+
+ [DBus (visible = false)]
+ private void update_login_layout () {
+ unowned List<LightDM.Layout> layouts = LightDM.get_layouts ();
+ var current = source_settings.get_uint ("current");
+
+ if (current < get_sources ().length) {
+ var source = get_sources ()[current];
+ string? name = null;
+
+ if (source.layout != null && source.variant != null) {
+ name = @"$((!) source.layout)\t$((!) source.variant)";
+ } else if (source.layout != null) {
+ name = source.layout;
+ }
+
+ if (name != null) {
+ foreach (var layout in layouts) {
+ if (layout.name == (!) name) {
+ LightDM.set_layout (layout);
+ break;
+ }
+ }
+ }
}
}
[DBus (visible = false)]
private void update_window_sources () {
- if (use_bamf) {
+ if (use_bamf && !is_login_user ()) {
var group_per_window = per_window_settings.get_boolean ("group-per-window");
if (group_per_window != (window_sources != null)) {
@@ -318,11 +437,13 @@ public class Indicator.Keyboard.Service : Object {
submenu.append_section (null, section_menu);
- var section = new Menu ();
- section.append (_ ("Character Map"), "indicator.map");
- section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
- section.append (_ ("Text Entry Settings..."), "indicator.settings");
- submenu.append_section (null, section);
+ if (!is_login_user ()) {
+ var section = new Menu ();
+ section.append (_ ("Character Map"), "indicator.map");
+ section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
+ section.append (_ ("Text Entry Settings..."), "indicator.settings");
+ submenu.append_section (null, section);
+ }
var indicator = new MenuItem.submenu ("x", submenu);
indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
@@ -349,6 +470,7 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_changed_current (string key) {
update_indicator_action ();
+ update_login_layout ();
}
[DBus (visible = false)]
@@ -357,6 +479,7 @@ public class Indicator.Keyboard.Service : Object {
update_sources_menu ();
update_indicator_action ();
+ update_login_layout ();
}
[DBus (visible = false)]