aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2015-03-10 17:20:35 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2015-03-10 17:20:35 +0000
commit1573d7106b4c949a5b146873f676e0dd120b7a4f (patch)
treed97fb63931d89eb1ef9ce6ff78c5b4acfd49f911
parentd2738506d81c742ab5b7d0f2ab6d19535a43ca71 (diff)
parentec6c31099a0e001554f3ab167b60545808e87301 (diff)
downloadayatana-indicator-keyboard-1573d7106b4c949a5b146873f676e0dd120b7a4f.tar.gz
ayatana-indicator-keyboard-1573d7106b4c949a5b146873f676e0dd120b7a4f.tar.bz2
ayatana-indicator-keyboard-1573d7106b4c949a5b146873f676e0dd120b7a4f.zip
Basic support for Fcitx input sources. Fixes: #1363150
Approved by: Ted Gould, PS Jenkins bot, Ryan Lortie, Sebastien Bacher
-rw-r--r--.bzrignore19
-rw-r--r--configure.ac33
-rw-r--r--data/Makefile.am8
-rw-r--r--debian/control2
-rw-r--r--deps/Fcitx-1.0.metadata7
-rw-r--r--deps/GnomeDesktop-3.0.metadata1
-rw-r--r--deps/accountsservice.vapi151
-rw-r--r--deps/fontconfig.vapi13
-rw-r--r--deps/freetype2.vapi20
-rw-r--r--deps/gnome-desktop-3.0.vapi320
-rw-r--r--deps/pangoft2.vapi33
-rw-r--r--lib/Makefile.am7
-rw-r--r--lib/ibus-menu.vala26
-rw-r--r--lib/indicator-menu.vala83
-rw-r--r--lib/main.vala329
-rw-r--r--lib/source.vala153
-rw-r--r--tests/indicator-keyboard-test.in1
17 files changed, 430 insertions, 776 deletions
diff --git a/.bzrignore b/.bzrignore
index d1af5121..f59e91ad 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -10,15 +10,19 @@
.timestamp
Makefile
Makefile.in
+aclocal.m4
autom4te.cache
build-aux
config.log
config.status
configure
data/com.canonical.indicator.keyboard
+data/gschemas.compiled
data/indicator-keyboard-icon-generator
+data/indicator-keyboard.conf
+data/indicator-keyboard.desktop
data/indicator-keyboard.service
-data/gschemas.compiled
+data/upstart/indicator-keyboard.desktop
debian/autoreconf.after
debian/autoreconf.before
debian/files
@@ -26,6 +30,12 @@ debian/indicator-keyboard
debian/tmp
lib/indicator-keyboard-service
libtool
+m4/intltool.m4
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
po/POTFILES
po/stamp-it
tests/config.vala
@@ -35,10 +45,3 @@ tests/indicator-keyboard-test
tests/indicator-keyboard-test.trs
tests/indicator-keyboard-tests
tests/services/indicator-keyboard.service
-aclocal.m4
-m4/intltool.m4
-m4/libtool.m4
-m4/lt~obsolete.m4
-m4/ltoptions.m4
-m4/ltsugar.m4
-m4/ltversion.m4
diff --git a/configure.ac b/configure.ac
index 5c09f8fc..ba599e72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,48 +35,17 @@ IT_PROG_INTLTOOL
GLIB_GSETTINGS
PKG_CHECK_MODULES([GEE], [gee-1.0])
-AC_SUBST([GEE_CFLAGS])
-AC_SUBST([GEE_LIBS])
-
PKG_CHECK_MODULES([GIO], [gio-2.0])
-AC_SUBST([GIO_CFLAGS])
-AC_SUBST([GIO_LIBS])
-
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
-AC_SUBST([GTK_CFLAGS])
-AC_SUBST([GTK_LIBS])
-
PKG_CHECK_MODULES([PANGOFT2], [pangoft2])
-AC_SUBST([PANGOFT2_CFLAGS])
-AC_SUBST([PANGOFT2_LIBS])
-
PKG_CHECK_MODULES([PANGOCAIRO], [pangocairo])
-AC_SUBST([PANGOCAIRO_CFLAGS])
-AC_SUBST([PANGOCAIRO_LIBS])
-
PKG_CHECK_MODULES([GNOME_DESKTOP], [gnome-desktop-3.0])
-AC_SUBST([GNOME_DESKTOP_CFLAGS])
-AC_SUBST([GNOME_DESKTOP_LIBS])
-
PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier])
-AC_SUBST([LIBXKLAVIER_CFLAGS])
-AC_SUBST([LIBXKLAVIER_LIBS])
-
PKG_CHECK_MODULES([LIBGNOMEKBD], [libgnomekbdui])
-AC_SUBST([LIBGNOMEKBD_CFLAGS])
-AC_SUBST([LIBGNOMEKBD_LIBS])
-
PKG_CHECK_MODULES([IBUS], [ibus-1.0])
-AC_SUBST([IBUS_CFLAGS])
-AC_SUBST([IBUS_LIBS])
-
+PKG_CHECK_MODULES([FCITX_GCLIENT], [fcitx-gclient])
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])
m4_include([m4/gcov.m4])
AC_TDD_GCOV
diff --git a/data/Makefile.am b/data/Makefile.am
index 06ed4662..61e5c37f 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -17,12 +17,12 @@ indicator_keyboard_icon_generator_SOURCES = main.vala \
$(top_srcdir)/lib/common.vala
indicator_keyboard_icon_generator_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg gee-1.0 \
- --pkg fontconfig \
- --pkg freetype2 \
- --pkg pangoft2 \
+ --pkg fontconfig-2.0 \
+ --pkg freetype2-2.0 \
+ --pkg PangoFT2-1.0 \
--pkg gtk+-3.0 \
--pkg GDesktopEnums-3.0 \
- --pkg gnome-desktop-3.0 \
+ --pkg GnomeDesktop-3.0 \
--pkg Xkl-1.0
indicator_keyboard_icon_generator_CFLAGS = $(AM_CFLAGS) \
$(GEE_CFLAGS) \
diff --git a/debian/control b/debian/control
index 585af9c5..acee03dc 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,8 @@ Build-Depends: debhelper (>= 9.0.0),
dh-autoreconf,
dh-translations,
dbus,
+ fcitx-libs-dev (>= 1:4.2.8.3),
+ gir1.2-fcitx-1.0,
libaccountsservice-dev,
libgee-dev,
libgirepository1.0-dev,
diff --git a/deps/Fcitx-1.0.metadata b/deps/Fcitx-1.0.metadata
new file mode 100644
index 00000000..81c20f3c
--- /dev/null
+++ b/deps/Fcitx-1.0.metadata
@@ -0,0 +1,7 @@
+Client cheader_filename="fcitx-gclient/fcitxclient.h"
+Connection cheader_filename="fcitx-gclient/fcitxconnection.h"
+IMItem cheader_filename="fcitx-gclient/fcitxinputmethod.h"
+InputMethod cheader_filename="fcitx-gclient/fcitxinputmethod.h"
+Kbd cheader_filename="fcitx-gclient/fcitxkbd.h"
+LayoutItem cheader_filename="fcitx-gclient/fcitxkbd.h"
+PreeditItem cheader_filename="fcitx-gclient/fcitxclient.h"
diff --git a/deps/GnomeDesktop-3.0.metadata b/deps/GnomeDesktop-3.0.metadata
new file mode 100644
index 00000000..3e4f88f4
--- /dev/null
+++ b/deps/GnomeDesktop-3.0.metadata
@@ -0,0 +1 @@
+RRScreen.new_async skip
diff --git a/deps/accountsservice.vapi b/deps/accountsservice.vapi
deleted file mode 100644
index 809726d0..00000000
--- a/deps/accountsservice.vapi
+++ /dev/null
@@ -1,151 +0,0 @@
-/* accountsservice.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "Act", gir_namespace = "AccountsService", gir_version = "1.0", lower_case_cprefix = "act_")]
-namespace Act {
- [CCode (cheader_filename = "act/act.h", type_id = "act_user_get_type ()")]
- public class User : GLib.Object {
- [CCode (has_construct_function = false)]
- protected User ();
- public int collate (Act.User user2);
- public Act.UserAccountType get_account_type ();
- public bool get_automatic_login ();
- public unowned string get_email ();
- public unowned string get_formats_locale ();
- public unowned string get_home_dir ();
- public unowned string get_icon_file ();
- public unowned GLib.Variant get_input_sources ();
- public unowned string get_language ();
- public unowned string get_location ();
- public bool get_locked ();
- public int get_login_frequency ();
- public unowned GLib.Variant get_login_history ();
- public int64 get_login_time ();
- public uint get_num_sessions ();
- public uint get_num_sessions_anywhere ();
- public unowned string get_object_path ();
- public unowned string get_password_hint ();
- public Act.UserPasswordMode get_password_mode ();
- public unowned string get_primary_session_id ();
- public unowned string get_real_name ();
- public unowned string get_shell ();
- public uint get_uid ();
- public unowned string get_user_name ();
- public unowned string get_x_session ();
- public bool is_local_account ();
- public bool is_logged_in ();
- public bool is_logged_in_anywhere ();
- public bool is_nonexistent ();
- public bool is_system_account ();
- public void set_account_type (Act.UserAccountType account_type);
- public void set_automatic_login (bool enabled);
- public void set_email (string email);
- public void set_formats_locale (string formats_locale);
- public void set_icon_file (string icon_file);
- public void set_input_sources (GLib.Variant sources);
- public void set_language (string language);
- public void set_location (string location);
- public void set_locked (bool locked);
- public void set_multiple_passwords (GLib.HashTable<uint,string> password_map);
- public void set_password (string password, string hint);
- public void set_password_mode (Act.UserPasswordMode password_mode);
- public void set_real_name (string real_name);
- public void set_user_name (string user_name);
- public void set_x_session (string x_session);
- public int account_type { get; }
- public bool automatic_login { get; }
- [NoAccessorMethod]
- public string background_file { owned get; }
- public string email { get; }
- public string formats_locale { get; }
- [NoAccessorMethod]
- public string home_directory { owned get; }
- public string icon_file { get; }
- public GLib.Variant input_sources { get; }
- [NoAccessorMethod]
- public bool is_loaded { get; }
- public string language { get; }
- [NoAccessorMethod]
- public bool local_account { get; }
- public string location { get; }
- public bool locked { get; }
- public int login_frequency { get; }
- public GLib.Variant login_history { get; }
- public int64 login_time { get; }
- [NoAccessorMethod]
- public bool nonexistent { get; }
- public string password_hint { get; }
- public int password_mode { get; }
- public string real_name { get; }
- public string shell { get; }
- [NoAccessorMethod]
- public bool system_account { get; }
- public int uid { get; }
- public string user_name { get; }
- public string x_session { get; }
- [NoAccessorMethod]
- public bool xhas_messages { get; }
- [CCode (array_length = false, array_null_terminated = true)]
- [NoAccessorMethod]
- public string[] xkeyboard_layouts { owned get; }
- public signal void changed ();
- public signal void sessions_changed ();
- }
- [CCode (cheader_filename = "act/act.h", type_id = "act_user_manager_get_type ()")]
- public class UserManager : GLib.Object {
- [CCode (has_construct_function = false)]
- protected UserManager ();
- public bool activate_user_session (Act.User user);
- public Act.User cache_user (string username) throws GLib.Error;
- public async Act.User cache_user_async (string username, GLib.Cancellable? cancellable) throws GLib.Error;
- public bool can_switch ();
- public Act.User create_user (string username, string fullname, Act.UserAccountType accounttype) throws GLib.Error;
- public async Act.User create_user_async (string username, string fullname, Act.UserAccountType accounttype, GLib.Cancellable? cancellable) throws GLib.Error;
- public bool delete_user (Act.User user, bool remove_files) throws GLib.Error;
- public async bool delete_user_async (Act.User user, bool remove_files, GLib.Cancellable? cancellable) throws GLib.Error;
- public static unowned Act.UserManager get_default ();
- public unowned Act.User get_user (string username);
- public unowned Act.User get_user_by_id (uint id);
- public bool goto_login_session ();
- public GLib.SList<weak Act.User> list_users ();
- public bool no_service ();
- public bool uncache_user (string username) throws GLib.Error;
- [NoAccessorMethod]
- public void* exclude_usernames_list { get; set; }
- [NoAccessorMethod]
- public bool has_multiple_users { get; }
- [NoAccessorMethod]
- public void* include_usernames_list { get; set; }
- [NoAccessorMethod]
- public bool is_loaded { get; }
- public virtual signal void user_added (Act.User user);
- public virtual signal void user_changed (Act.User user);
- public virtual signal void user_is_logged_in_changed (Act.User user);
- public virtual signal void user_removed (Act.User user);
- }
- [CCode (cheader_filename = "act/act.h", cprefix = "ACT_USER_ACCOUNT_TYPE_", type_id = "act_user_account_type_get_type ()")]
- public enum UserAccountType {
- STANDARD,
- ADMINISTRATOR
- }
- [CCode (cheader_filename = "act/act.h", cprefix = "ACT_USER_PASSWORD_MODE_", type_id = "act_user_password_mode_get_type ()")]
- public enum UserPasswordMode {
- REGULAR,
- SET_AT_LOGIN,
- NONE
- }
- [CCode (cheader_filename = "act/act.h", cprefix = "ACT_USER_PASSWORD_", type_id = "act_user_password_type_get_type ()")]
- public enum UserPasswordType {
- REGULAR,
- HINT,
- PIN
- }
- [CCode (cheader_filename = "act/act.h", cprefix = "ACT_USER_MANAGER_ERROR_")]
- public errordomain UserManagerError {
- FAILED,
- USER_EXISTS,
- USER_DOES_NOT_EXIST,
- PERMISSION_DENIED,
- NOT_SUPPORTED;
- public static GLib.Quark quark ();
- }
-}
diff --git a/deps/fontconfig.vapi b/deps/fontconfig.vapi
deleted file mode 100644
index dc3f450b..00000000
--- a/deps/fontconfig.vapi
+++ /dev/null
@@ -1,13 +0,0 @@
-/* fontconfig.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "Fc", gir_namespace = "fontconfig", gir_version = "2.0", lower_case_cprefix = "fc_")]
-namespace Fc {
- [CCode (cheader_filename = "fontconfig-2.0.h", has_type_id = false)]
- public struct CharSet {
- }
- [CCode (cheader_filename = "fontconfig-2.0.h", has_type_id = false)]
- public struct Pattern {
- }
- [CCode (cheader_filename = "fontconfig-2.0.h", cname = "FcInit")]
- public static void init ();
-}
diff --git a/deps/freetype2.vapi b/deps/freetype2.vapi
deleted file mode 100644
index 5403be26..00000000
--- a/deps/freetype2.vapi
+++ /dev/null
@@ -1,20 +0,0 @@
-/* freetype2.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "FT", gir_namespace = "freetype2", gir_version = "2.0", lower_case_cprefix = "FT_")]
-namespace FT {
- [CCode (cheader_filename = "freetype2-2.0.h", cname = "FT_Bitmap", has_type_id = false)]
- public struct Bitmap {
- }
- [CCode (cheader_filename = "freetype2-2.0.h", cname = "FT_Face", has_type_id = false)]
- public struct Face {
- }
- [CCode (cheader_filename = "freetype2-2.0.h", cname = "FT_Int32")]
- [SimpleType]
- public struct Int32 : int32 {
- }
- [CCode (cheader_filename = "freetype2-2.0.h", cname = "FT_Library", has_type_id = false)]
- public struct Library {
- }
- [CCode (cheader_filename = "freetype2-2.0.h", cname = "FT_Library_Version")]
- public static void library_version ();
-}
diff --git a/deps/gnome-desktop-3.0.vapi b/deps/gnome-desktop-3.0.vapi
deleted file mode 100644
index 80f38b35..00000000
--- a/deps/gnome-desktop-3.0.vapi
+++ /dev/null
@@ -1,320 +0,0 @@
-/* gnome-desktop-3.0.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "Gnome", gir_namespace = "GnomeDesktop", gir_version = "3.0", lower_case_cprefix = "gnome_")]
-namespace Gnome {
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_bg_get_type ()")]
- public class BG : GLib.Object {
- [CCode (has_construct_function = false)]
- public BG ();
- public bool changes_with_time ();
- public Gdk.Pixbuf create_frame_thumbnail (Gnome.DesktopThumbnailFactory factory, Gdk.Screen screen, int dest_width, int dest_height, int frame_num);
- public Cairo.Surface create_surface (Gdk.Window window, int width, int height, bool root);
- public Gdk.Pixbuf create_thumbnail (Gnome.DesktopThumbnailFactory factory, Gdk.Screen screen, int dest_width, int dest_height);
- public void draw (Gdk.Pixbuf dest, Gdk.Screen screen, bool is_root);
- public void get_color (GDesktop.BackgroundShading type, Gdk.Color primary, Gdk.Color secondary);
- public bool get_draw_background ();
- public unowned string get_filename ();
- public bool get_image_size (Gnome.DesktopThumbnailFactory factory, int best_width, int best_height, int width, int height);
- public GDesktop.BackgroundStyle get_placement ();
- public static Cairo.Surface get_surface_from_root (Gdk.Screen screen);
- public bool has_multiple_sizes ();
- public bool is_dark (int dest_width, int dest_height);
- public void load_from_preferences (GLib.Settings settings);
- public void save_to_preferences (GLib.Settings settings);
- public void set_color (GDesktop.BackgroundShading type, Gdk.Color primary, Gdk.Color secondary);
- public void set_draw_background (bool draw_background);
- public void set_filename (string filename);
- public void set_placement (GDesktop.BackgroundStyle placement);
- public static void set_surface_as_root (Gdk.Screen screen, Cairo.Surface surface);
- public static Gnome.BGCrossfade set_surface_as_root_with_crossfade (Gdk.Screen screen, Cairo.Surface surface);
- public signal void changed ();
- public signal void transitioned ();
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_bg_crossfade_get_type ()")]
- public class BGCrossfade : GLib.Object {
- [CCode (has_construct_function = false)]
- public BGCrossfade (int width, int height);
- public bool is_started ();
- public bool set_end_surface (Cairo.Surface surface);
- public bool set_start_surface (Cairo.Surface surface);
- public void start (Gdk.Window window);
- public void stop ();
- [NoAccessorMethod]
- public int height { get; construct; }
- [NoAccessorMethod]
- public int width { get; construct; }
- public virtual signal void finished (GLib.Object window);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_bg_slide_show_get_type ()")]
- public class BGSlideShow : GLib.Object {
- [CCode (has_construct_function = false)]
- public BGSlideShow (string filename);
- public void get_current_slide (int width, int height, out double progress, out double duration, out bool is_fixed, out unowned string file1, out unowned string file2);
- public bool get_has_multiple_sizes ();
- public int get_num_slides ();
- public bool get_slide (int frame_number, int width, int height, double progress, out double duration, out bool is_fixed, out unowned string file1, out unowned string file2);
- public double get_start_time ();
- public double get_total_duration ();
- public bool load () throws GLib.Error;
- public async void load_async (GLib.Cancellable? cancellable);
- [NoAccessorMethod]
- public string filename { owned get; construct; }
- public bool has_multiple_sizes { get; }
- public double start_time { get; }
- public double total_duration { get; }
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_desktop_thumbnail_factory_get_type ()")]
- public class DesktopThumbnailFactory : GLib.Object {
- [CCode (has_construct_function = false)]
- public DesktopThumbnailFactory (Gnome.DesktopThumbnailSize size);
- public bool can_thumbnail (string uri, string mime_type, long mtime);
- public void create_failed_thumbnail (string uri, long mtime);
- public Gdk.Pixbuf generate_thumbnail (string uri, string mime_type);
- public bool has_valid_failed_thumbnail (string uri, long mtime);
- public string lookup (string uri, long mtime);
- public void save_thumbnail (Gdk.Pixbuf thumbnail, string uri, long original_mtime);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_idle_monitor_get_type ()")]
- public class IdleMonitor : GLib.Object, GLib.Initable {
- [CCode (has_construct_function = false)]
- public IdleMonitor ();
- public uint add_idle_watch (uint64 interval_msec, owned Gnome.IdleMonitorWatchFunc? callback);
- public uint add_user_active_watch (owned Gnome.IdleMonitorWatchFunc? callback);
- [CCode (has_construct_function = false)]
- public IdleMonitor.for_device (Gdk.Device device);
- public int64 get_idletime ();
- public void remove_watch (uint id);
- [NoAccessorMethod]
- public Gdk.Device device { owned get; construct; }
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_pnp_ids_get_type ()")]
- public class PnpIds : GLib.Object {
- [CCode (has_construct_function = false)]
- public PnpIds ();
- public string get_pnp_id (string pnp_id);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_rr_config_get_type ()")]
- public class RRConfig : GLib.Object {
- [CCode (has_construct_function = false)]
- protected RRConfig ();
- public bool applicable (Gnome.RRScreen screen) throws GLib.Error;
- public static bool apply_from_filename_with_time (Gnome.RRScreen screen, string filename, uint32 timestamp) throws GLib.Error;
- public bool apply_with_time (Gnome.RRScreen screen, uint32 timestamp) throws GLib.Error;
- [CCode (has_construct_function = false)]
- public RRConfig.current (Gnome.RRScreen screen) throws GLib.Error;
- public bool ensure_primary ();
- public bool equal (Gnome.RRConfig config2);
- public static string get_backup_filename ();
- public bool get_clone ();
- public static string get_intended_filename ();
- [CCode (array_length = false, array_null_terminated = true)]
- public unowned Gnome.RROutputInfo[] get_outputs ();
- public bool load_current () throws GLib.Error;
- public bool load_filename (string filename) throws GLib.Error;
- public bool match (Gnome.RRConfig config2);
- public void sanitize ();
- public bool save () throws GLib.Error;
- public void set_clone (bool clone);
- [CCode (has_construct_function = false)]
- public RRConfig.stored (Gnome.RRScreen screen) throws GLib.Error;
- public Gnome.RRScreen screen { construct; }
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gnome_rr_crtc_get_type ()")]
- [Compact]
- public class RRCrtc {
- public bool can_drive_output (Gnome.RROutput output);
- public Gnome.RRMode get_current_mode ();
- public Gnome.RRRotation get_current_rotation ();
- public bool get_gamma (int size, ushort red, ushort green, ushort blue);
- public uint32 get_id ();
- public void get_position (out int x, out int y);
- public Gnome.RRRotation get_rotations ();
- public bool set_config_with_time (uint32 timestamp, int x, int y, Gnome.RRMode mode, Gnome.RRRotation rotation, Gnome.RROutput outputs, int n_outputs) throws GLib.Error;
- public void set_gamma (int size, ushort red, ushort green, ushort blue);
- public bool supports_rotation (Gnome.RRRotation rotation);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gnome_rr_mode_get_type ()")]
- [Compact]
- public class RRMode {
- public int get_freq ();
- public uint get_height ();
- public uint32 get_id ();
- public uint get_width ();
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gnome_rr_output_get_type ()")]
- [Compact]
- public class RROutput {
- public bool can_clone (Gnome.RROutput clone);
- public int get_backlight () throws GLib.Error;
- public int get_backlight_max ();
- public int get_backlight_min ();
- public unowned string get_connector_type ();
- public Gnome.RRCrtc get_crtc ();
- public Gnome.RRMode get_current_mode ();
- public unowned string get_display_name ();
- public uint8 get_edid_data (size_t size);
- public int get_height_mm ();
- public uint32 get_id ();
- public bool get_ids_from_edid (out string vendor, out int product, out int serial);
- public bool get_is_primary ();
- public unowned string get_name ();
- public void get_position (out int x, out int y);
- public Gnome.RRCrtc get_possible_crtcs ();
- public Gnome.RRMode get_preferred_mode ();
- public int get_size_inches ();
- public int get_width_mm ();
- public bool is_connected ();
- public bool is_laptop ();
- public Gnome.RRMode list_modes ();
- public bool set_backlight (int value) throws GLib.Error;
- public bool supports_mode (Gnome.RRMode mode);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_rr_output_info_get_type ()")]
- public class RROutputInfo : GLib.Object {
- [CCode (has_construct_function = false)]
- protected RROutputInfo ();
- public double get_aspect_ratio ();
- public unowned string get_display_name ();
- public void get_geometry (out int x, out int y, out int width, out int height);
- public unowned string get_name ();
- public int get_preferred_height ();
- public int get_preferred_width ();
- public bool get_primary ();
- public uint get_product ();
- public int get_refresh_rate ();
- public Gnome.RRRotation get_rotation ();
- public uint get_serial ();
- public void get_vendor ([CCode (array_length = false)] out unowned string[] vendor);
- public bool is_active ();
- public bool is_connected ();
- public void set_active (bool active);
- public void set_geometry (int x, int y, int width, int height);
- public void set_primary (bool primary);
- public void set_refresh_rate (int rate);
- public void set_rotation (Gnome.RRRotation rotation);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_rr_screen_get_type ()")]
- public class RRScreen : GLib.Object, GLib.Initable {
- [CCode (has_construct_function = false)]
- public RRScreen (Gdk.Screen screen) throws GLib.Error;
- public Gnome.RRMode create_clone_modes ();
- public unowned Gnome.RRCrtc get_crtc_by_id (uint32 id);
- public bool get_dpms_mode (out Gnome.RRDpmsMode mode) throws GLib.Error;
- public unowned Gnome.RROutput get_output_by_id (uint32 id);
- public unowned Gnome.RROutput get_output_by_name (string name);
- public void get_ranges (out int min_width, out int max_width, out int min_height, out int max_height);
- public void get_timestamps (out uint32 change_timestamp_ret, out uint32 config_timestamp_ret);
- [CCode (array_length = false, array_null_terminated = true)]
- public unowned Gnome.RRMode[] list_clone_modes ();
- [CCode (array_length = false, array_null_terminated = true)]
- public unowned Gnome.RRCrtc[] list_crtcs ();
- [CCode (array_length = false, array_null_terminated = true)]
- public unowned Gnome.RRMode[] list_modes ();
- [CCode (array_length = false, array_null_terminated = true)]
- public unowned Gnome.RROutput[] list_outputs ();
- public bool refresh () throws GLib.Error;
- public bool set_dpms_mode (Gnome.RRDpmsMode mode) throws GLib.Error;
- public void set_primary_output (Gnome.RROutput output);
- public void set_size (int width, int height, int mm_width, int mm_height);
- [NoAccessorMethod]
- public Gdk.Screen gdk_screen { owned get; construct; }
- public virtual signal void changed ();
- public virtual signal void output_connected (void* output);
- public virtual signal void output_disconnected (void* output);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_wall_clock_get_type ()")]
- public class WallClock : GLib.Object {
- [CCode (has_construct_function = false)]
- public WallClock ();
- public unowned string get_clock ();
- public unowned GLib.TimeZone get_timezone ();
- public string clock { get; }
- [NoAccessorMethod]
- public bool time_only { get; set; }
- public GLib.TimeZone timezone { get; }
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", type_id = "gnome_xkb_info_get_type ()")]
- public class XkbInfo : GLib.Object {
- [CCode (has_construct_function = false)]
- public XkbInfo ();
- public unowned string description_for_group (string group_id);
- public unowned string description_for_option (string group_id, string id);
- public GLib.List<weak string> get_all_layouts ();
- public GLib.List<weak string> get_all_option_groups ();
- public bool get_layout_info (string id, out unowned string display_name, out unowned string short_name, out unowned string xkb_layout, out unowned string xkb_variant);
- public GLib.List<weak string> get_layouts_for_country (string country_code);
- public GLib.List<weak string> get_layouts_for_language (string language_code);
- public GLib.List<weak string> get_options_for_group (string group_id);
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", cprefix = "GNOME_DESKTOP_THUMBNAIL_SIZE_", has_type_id = false)]
- public enum DesktopThumbnailSize {
- NORMAL,
- LARGE
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", cprefix = "GNOME_RR_DPMS_", has_type_id = false)]
- public enum RRDpmsMode {
- ON,
- STANDBY,
- SUSPEND,
- OFF,
- DISABLED,
- UNKNOWN
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", cprefix = "GNOME_RR_", has_type_id = false)]
- [Flags]
- public enum RRRotation {
- ROTATION_NEXT,
- ROTATION_0,
- ROTATION_90,
- ROTATION_180,
- ROTATION_270,
- REFLECT_X,
- REFLECT_Y
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", cprefix = "GNOME_RR_ERROR_")]
- public errordomain RRError {
- UNKNOWN,
- NO_RANDR_EXTENSION,
- RANDR_ERROR,
- BOUNDS_ERROR,
- CRTC_ASSIGNMENT,
- NO_MATCHING_CONFIG,
- NO_DPMS_EXTENSION;
- public static GLib.Quark quark ();
- }
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", instance_pos = 2.9)]
- public delegate void IdleMonitorWatchFunc (Gnome.IdleMonitor monitor, uint id);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h", cname = "GNOME_RR_CONNECTOR_TYPE_PANEL")]
- public const string RR_CONNECTOR_TYPE_PANEL;
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static bool desktop_thumbnail_has_uri (Gdk.Pixbuf pixbuf, string uri);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static bool desktop_thumbnail_is_valid (Gdk.Pixbuf pixbuf, string uri, long mtime);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- [Deprecated (since = "2.22")]
- public static string desktop_thumbnail_md5 (string uri);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string desktop_thumbnail_path_for_uri (string uri, Gnome.DesktopThumbnailSize size);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static Gdk.Pixbuf desktop_thumbnail_scale_down_pixbuf (Gdk.Pixbuf pixbuf, int dest_width, int dest_height);
- [CCode (array_length = false, array_null_terminated = true, cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string[] get_all_languages ();
- [CCode (array_length = false, array_null_terminated = true, cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string[] get_all_locales ();
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string get_country_from_code (string code, string? translation);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string get_country_from_locale (string locale, string? translation);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static bool get_input_source_from_locale (string locale, out unowned string type, out unowned string id);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string get_language_from_code (string code, string? translation);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string get_language_from_locale (string locale, string? translation);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static bool language_has_translations (string code);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static string normalize_locale (string locale);
- [CCode (cheader_filename = "libgnome-desktop/gnome-bg-crossfade.h,libgnome-desktop/gnome-bg-slide-show.h,libgnome-desktop/gnome-bg.h,libgnome-desktop/gnome-desktop-thumbnail.h,libgnome-desktop/gnome-idle-monitor.h,libgnome-desktop/gnome-languages.h,libgnome-desktop/gnome-pnp-ids.h,libgnome-desktop/gnome-rr-config.h,libgnome-desktop/gnome-rr.h,libgnome-desktop/gnome-wall-clock.h,libgnome-desktop/gnome-xkb-info.h")]
- public static bool parse_locale (string locale, out string language_codep, out string country_codep, out string codesetp, out string modifierp);
-}
diff --git a/deps/pangoft2.vapi b/deps/pangoft2.vapi
deleted file mode 100644
index 8dc85109..00000000
--- a/deps/pangoft2.vapi
+++ /dev/null
@@ -1,33 +0,0 @@
-/* pangoft2.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "PangoFT2", gir_namespace = "PangoFT2", gir_version = "1.0", lower_case_cprefix = "pango_ft2_")]
-namespace PangoFT2 {
- [CCode (cheader_filename = "pango/pangoft2.h", type_id = "pango_ft2_font_map_get_type ()")]
- public class FontMap : Pango.FontMap {
- [CCode (has_construct_function = false, type = "PangoFontMap*")]
- public FontMap ();
- public void set_default_substitute (owned PangoFT2.SubstituteFunc func);
- public void set_resolution (double dpi_x, double dpi_y);
- public void substitute_changed ();
- }
- [CCode (cheader_filename = "pango/pangoft2.h", has_target = false)]
- public delegate void SubstituteFunc (Fc.Pattern pattern, void* data);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static int font_get_kerning (Pango.Font font, Pango.Glyph left, Pango.Glyph right);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static Pango.Glyph get_unknown_glyph (Pango.Font font);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render (FT.Bitmap bitmap, Pango.Font font, Pango.GlyphString glyphs, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render_layout (FT.Bitmap bitmap, Pango.Layout layout, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render_layout_line (FT.Bitmap bitmap, Pango.LayoutLine line, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render_layout_line_subpixel (FT.Bitmap bitmap, Pango.LayoutLine line, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render_layout_subpixel (FT.Bitmap bitmap, Pango.Layout layout, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void render_transformed (FT.Bitmap bitmap, Pango.Matrix matrix, Pango.Font font, Pango.GlyphString glyphs, int x, int y);
- [CCode (cheader_filename = "pango/pangoft2.h")]
- public static void shutdown_display ();
-}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index c57725c1..d45b98dd 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -22,11 +22,12 @@ indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg pangocairo \
--pkg gtk+-3.0 \
--pkg GDesktopEnums-3.0 \
- --pkg gnome-desktop-3.0 \
+ --pkg GnomeDesktop-3.0 \
--pkg Xkl-1.0 \
--pkg Gkbd-3.0 \
--pkg ibus-1.0 \
- --pkg accountsservice \
+ --pkg Fcitx-1.0 \
+ --pkg AccountsService-1.0 \
--pkg liblightdm-gobject-1
indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
$(GEE_CFLAGS) \
@@ -36,6 +37,7 @@ indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
$(LIBXKLAVIER_CFLAGS) \
$(LIBGNOMEKBD_CFLAGS) \
$(IBUS_CFLAGS) \
+ $(FCITX_GCLIENT_CFLAGS) \
$(ACCOUNTSSERVICE_CFLAGS) \
$(LIGHTDM_CFLAGS) \
$(COVERAGE_CFLAGS)
@@ -47,6 +49,7 @@ indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
$(LIBXKLAVIER_LIBS) \
$(LIBGNOMEKBD_LIBS) \
$(IBUS_LIBS) \
+ $(FCITX_GCLIENT_LIBS) \
$(ACCOUNTSSERVICE_LIBS) \
$(LIGHTDM_LIBS) \
$(COVERAGE_LDFLAGS)
diff --git a/lib/ibus-menu.vala b/lib/ibus-menu.vala
index c0862ac3..a240f00b 100644
--- a/lib/ibus-menu.vala
+++ b/lib/ibus-menu.vala
@@ -128,10 +128,6 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
var state = new Variant.boolean (property.state == IBus.PropState.CHECKED);
var action = new SimpleAction.stateful (name, null, state);
- action.activate.connect ((parameter) => {
- action.change_state (new Variant.boolean (!action.get_state ().get_boolean ()));
- });
-
action.change_state.connect ((value) => {
if (value != null) {
action.set_state ((!) value);
@@ -154,26 +150,26 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
/* Create a single action for all radio properties. */
if (action_map != null && radio_name == null) {
radio_counter++;
- radio_name = @"-private-radio-$radio_counter";
- radio_action = new SimpleAction.stateful ((!) radio_name, VariantType.STRING, new Variant.string (""));
- ((!) radio_action).activate.connect ((parameter) => {
- ((!) radio_action).change_state (parameter);
- });
+ var name = @"-private-radio-$radio_counter";
+ var action = new SimpleAction.stateful (name, VariantType.STRING, new Variant.string (""));
- ((!) radio_action).change_state.connect ((value) => {
+ action.change_state.connect ((value) => {
if (value != null) {
var key = ((!) value).get_string ();
if (radio_properties.has_key (key)) {
- ((!) radio_action).set_state ((!) value);
+ action.set_state ((!) value);
activate (radio_properties[key], IBus.PropState.CHECKED);
}
}
});
- ((!) action_map).add_action ((!) radio_action);
- names.add ((!) radio_name);
+ ((!) action_map).add_action (action);
+ names.add (name);
+
+ radio_name = name;
+ radio_action = action;
}
radio_properties[property.key] = property;
@@ -195,7 +191,7 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
private void append_menu_property (IBus.Property property) {
if (property.prop_type == IBus.PropType.MENU) {
- var submenu = new IBusMenu (action_map, ((!) property).sub_props);
+ var submenu = new IBusMenu (action_map, property.sub_props);
submenu.activate.connect ((property, state) => { activate (property, state); });
menu.append_submenu (get_label (property), submenu);
}
@@ -295,7 +291,7 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
return menu.get_item_link (item_index, link);
}
- public override void get_item_links (int item_index, out HashTable<string, MenuModel>? links) {
+ public override void get_item_links (int item_index, out HashTable<string, MenuModel> links) {
menu.get_item_links (item_index, out links);
}
diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala
index 8e5661e2..96bf64d6 100644
--- a/lib/indicator-menu.vala
+++ b/lib/indicator-menu.vala
@@ -19,10 +19,11 @@
public class Indicator.Keyboard.IndicatorMenu : MenuModel {
public enum Options {
- NONE = 0x0,
- DCONF = 0x1,
- IBUS = 0x2,
- SETTINGS = 0x4
+ NONE = 0,
+ DCONF = 1 << 0,
+ XKB = 1 << 1,
+ IBUS = 1 << 2,
+ SETTINGS = 1 << 3
}
private Options options;
@@ -32,42 +33,45 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel {
private IBusMenu properties_section;
public IndicatorMenu (ActionMap? action_map = null, Options options = Options.NONE) {
- var submenu = new Menu ();
+ this.options = options;
+ indicator_menu = new Menu ();
sources_section = new Menu ();
- submenu.append_section (null, sources_section);
- if ((options & Options.IBUS) != Options.NONE) {
- properties_section = new IBusMenu (action_map);
- properties_section.activate.connect ((property, state) => { activate (property, state); });
- submenu.append_section (null, properties_section);
- }
+ if ((options & ~Options.DCONF) != Options.NONE) {
+ var submenu = new Menu ();
- if ((options & Options.SETTINGS) != Options.NONE) {
- var settings_section = new Menu ();
- settings_section.append (_ ("Character Map"), "indicator.map");
- settings_section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
- settings_section.append (_ ("Text Entry Settings..."), "indicator.settings");
- submenu.append_section (null, settings_section);
- }
+ submenu.append_section (null, sources_section);
- var indicator = new MenuItem.submenu (null, submenu);
- indicator.set_detailed_action ("indicator.indicator");
- indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
-
- /* We need special mouse actions on the lock screen. */
- if ((options & Options.DCONF) != Options.NONE) {
- indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next");
- indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll");
- } else {
- indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.locked_next");
- indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.locked_scroll");
- }
+ if (Options.IBUS in options) {
+ properties_section = new IBusMenu (action_map);
+ properties_section.activate.connect ((property, state) => { activate (property, state); });
+ submenu.append_section (null, properties_section);
+ }
- indicator_menu = new Menu ();
- indicator_menu.append_item (indicator);
+ if (Options.SETTINGS in options) {
+ var settings_section = new Menu ();
+ settings_section.append (_ ("Character Map"), "indicator.map");
+ settings_section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
+ settings_section.append (_ ("Text Entry Settings..."), "indicator.settings");
+ submenu.append_section (null, settings_section);
+ }
- this.options = options;
+ var indicator = new MenuItem.submenu (null, submenu);
+ indicator.set_detailed_action ("indicator.indicator");
+ indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
+
+ /* We need special mouse actions on the lock screen. */
+ if (Options.DCONF in options) {
+ indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next");
+ indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll");
+ } else {
+ indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.locked_next");
+ indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.locked_scroll");
+ }
+
+ indicator_menu.append_item (indicator);
+ }
}
public signal void activate (IBus.Property property, IBus.PropState state);
@@ -76,10 +80,13 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel {
sources_section.remove_all ();
for (var i = 0; i < sources.length; i++) {
- if (!sources[i].is_ibus || (options & Options.IBUS) != Options.NONE) {
+ var visible = (sources[i].is_xkb && Options.XKB in options) ||
+ (sources[i].is_ibus && Options.IBUS in options);
+
+ if (visible) {
string action;
- if ((options & Options.DCONF) != Options.NONE) {
+ if (Options.DCONF in options) {
action = "indicator.current";
} else {
action = "indicator.active";
@@ -99,13 +106,13 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel {
}
public void set_properties (IBus.PropList properties) {
- if ((options & Options.IBUS) != Options.NONE) {
+ if (Options.IBUS in options) {
properties_section.set_properties (properties);
}
}
public void update_property (IBus.Property property) {
- if ((options & Options.IBUS) != Options.NONE) {
+ if (Options.IBUS in options) {
properties_section.update_property (property);
}
}
@@ -122,7 +129,7 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel {
indicator_menu.get_item_attributes (item_index, out attributes);
}
- public override void get_item_links (int item_index, out HashTable<string, MenuModel>? links) {
+ public override void get_item_links (int item_index, out HashTable<string, MenuModel> links) {
indicator_menu.get_item_links (item_index, out links);
}
diff --git a/lib/main.vala b/lib/main.vala
index 1cb3896c..d3e063d1 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -33,7 +33,7 @@ public class Indicator.Keyboard.Service : Object {
private SList<Act.User> users;
private WindowStack? window_stack;
- private Gee.HashMap<uint, uint>? window_sources;
+ private Gee.HashMap<uint, Source>? window_sources;
private uint focused_window_id;
private IBus.Bus? ibus;
@@ -41,6 +41,9 @@ public class Indicator.Keyboard.Service : Object {
private ulong ibus_connected_id;
private uint panel_timeout;
+ private Fcitx.InputMethod? fcitx;
+ private bool fcitx_initialized;
+
private Source[]? sources;
private SimpleActionGroup? action_group;
@@ -118,11 +121,13 @@ public class Indicator.Keyboard.Service : Object {
handle_unity_name_appeared,
handle_unity_name_vanished);
- Bus.watch_name (BusType.SESSION,
- "com.canonical.Unity.WindowStack",
- BusNameWatcherFlags.NONE,
- handle_window_stack_name_appeared,
- handle_window_stack_name_vanished);
+ if (!is_fcitx_active ()) {
+ Bus.watch_name (BusType.SESSION,
+ "com.canonical.Unity.WindowStack",
+ BusNameWatcherFlags.NONE,
+ handle_window_stack_name_appeared,
+ handle_window_stack_name_vanished);
+ }
}
indicator_settings = new Settings ("com.canonical.indicator.keyboard");
@@ -146,11 +151,33 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private static bool is_ibus_active () {
+ if (is_login_user ()) {
+ return false;
+ }
+
+ var module = Environment.get_variable ("GTK_IM_MODULE");
+ return module != null && (!) module == "ibus";
+ }
+
+ [DBus (visible = false)]
+ private static bool is_fcitx_active () {
+ if (is_login_user ()) {
+ return false;
+ }
+
+ var module = Environment.get_variable ("GTK_IM_MODULE");
+ return module != null && (!) module == "fcitx";
+ }
+
+ [DBus (visible = false)]
private IBus.Bus get_ibus () {
if (ibus == null) {
IBus.init ();
- ibus = new IBus.Bus ();
- ((!) ibus).connected.connect (() => {
+
+ var proxy = new IBus.Bus ();
+
+ proxy.connected.connect (() => {
if (desktop_menu != null) {
get_desktop_menu ().set_sources (get_sources ());
}
@@ -167,6 +194,8 @@ public class Indicator.Keyboard.Service : Object {
update_indicator_action ();
}
});
+
+ ibus = proxy;
}
return (!) ibus;
@@ -180,9 +209,9 @@ public class Indicator.Keyboard.Service : Object {
var path = "/org/freedesktop/IBus/Panel";
try {
- ibus_panel = connection.get_proxy_sync (name, path);
+ var proxy = connection.get_proxy_sync<IBusPanel> (name, path);
- ((!) ibus_panel).properties_registered.connect ((variant) => {
+ proxy.properties_registered.connect ((variant) => {
var properties = new IBus.PropList ();
properties.deserialize (variant);
@@ -190,7 +219,7 @@ public class Indicator.Keyboard.Service : Object {
handle_properties_registered ((!) (properties as IBus.PropList));
}
});
- ((!) ibus_panel).property_updated.connect ((variant) => {
+ proxy.property_updated.connect ((variant) => {
var type = IBus.PropType.NORMAL;
var state = IBus.PropState.INCONSISTENT;
var text = new IBus.Text.from_static_string ("");
@@ -201,6 +230,8 @@ public class Indicator.Keyboard.Service : Object {
handle_property_updated ((!) (property as IBus.Property));
}
});
+
+ ibus_panel = proxy;
} catch (IOError error) {
warning ("error: %s", error.message);
}
@@ -210,10 +241,30 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private Fcitx.InputMethod? get_fcitx () {
+ if (!fcitx_initialized) {
+ fcitx_initialized = true;
+
+ if (is_fcitx_active ()) {
+ try {
+ var proxy = new Fcitx.InputMethod (BusType.SESSION, DBusProxyFlags.NONE, 0);
+ proxy.notify["current-im"].connect ((pspec) => { handle_changed_current ("current"); });
+ fcitx = proxy;
+ } catch (Error error) {
+ warning ("error: %s", error.message);
+ }
+ }
+ }
+
+ return fcitx;
+ }
+
+ [DBus (visible = false)]
public void up () {
if (loop == null) {
- loop = new MainLoop ();
- ((!) loop).run ();
+ var main_loop = new MainLoop ();
+ loop = main_loop;
+ main_loop.run ();
}
}
@@ -254,17 +305,13 @@ public class Indicator.Keyboard.Service : Object {
Act.User? user = manager.get_user ((!) greeter_user);
if (user != null && ((!) user).is_loaded) {
- VariantIter outer;
- VariantIter inner;
-
- var sources = ((!) user).input_sources;
- sources.get ("aa{ss}", out outer);
+ foreach (var outer in ((!) user).input_sources) {
+ foreach (var inner in (!) outer) {
+ unowned string key;
+ unowned string value;
- while (outer.next ("a{ss}", out inner)) {
- unowned string key;
- unowned string value;
+ ((!) inner).get ("{&s&s}", out key, out value);
- while (inner.next ("{&s&s}", out key, out value)) {
if (key == "xkb") {
source = value;
break;
@@ -289,9 +336,7 @@ public class Indicator.Keyboard.Service : Object {
}
if (layouts.length > 0) {
- source = layouts[0];
- source = ((!) source).replace (" ", "+");
- source = ((!) source).replace ("\t", "+");
+ source = layouts[0].replace (" ", "+").replace ("\t", "+");
}
}
}
@@ -340,7 +385,7 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void migrate_keyboard_layouts () {
if (is_login_user ()) {
- lightdm_current = source_settings.get_uint ("current");
+ lightdm_current = get_current ();
var manager = Act.UserManager.get_default ();
@@ -450,17 +495,13 @@ public class Indicator.Keyboard.Service : Object {
if (user.is_loaded) {
var done = false;
- VariantIter outer;
- VariantIter inner;
-
- var sources = user.input_sources;
- sources.get ("aa{ss}", out outer);
+ foreach (var outer in user.input_sources) {
+ foreach (var inner in (!) outer) {
+ unowned string key;
+ unowned string source;
- while (outer.next ("a{ss}", out inner)) {
- unowned string key;
- unowned string source;
+ ((!) inner).get ("{&s&s}", out key, out source);
- while (inner.next ("{&s&s}", out key, out source)) {
if (key == "xkb") {
done = true;
@@ -548,7 +589,7 @@ public class Indicator.Keyboard.Service : Object {
private void update_login_layout () {
if (is_login_user ()) {
unowned List<LightDM.Layout> layouts = LightDM.get_layouts ();
- var current = source_settings.get_uint ("current");
+ var current = get_current ();
if (current < get_sources ().length) {
var source = get_sources ()[current];
@@ -594,10 +635,12 @@ public class Indicator.Keyboard.Service : Object {
warning ("error: %s", error.message);
}
- window_sources = new Gee.HashMap<uint, uint> ();
+ window_sources = new Gee.HashMap<uint, Source> ();
+ ((!) window_stack).window_destroyed.connect (handle_window_destroyed);
((!) window_stack).focused_window_changed.connect (handle_focused_window_changed);
} else {
((!) window_stack).focused_window_changed.disconnect (handle_focused_window_changed);
+ ((!) window_stack).window_destroyed.disconnect (handle_window_destroyed);
window_sources = null;
}
}
@@ -610,22 +653,49 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private void handle_window_destroyed (uint window_id, string app_id) {
+ ((!) window_sources).unset (window_id);
+ }
+
+ [DBus (visible = false)]
private void handle_focused_window_changed (uint window_id, string app_id, uint stage) {
- var old_current = source_settings.get_uint ("current");
+ var sources = get_sources ();
+ var old_current = get_current ();
- ((!) window_sources)[focused_window_id] = old_current;
+ if (old_current < sources.length) {
+ ((!) window_sources)[focused_window_id] = sources[old_current];
+ }
if (!(((!) window_sources).has_key (window_id))) {
var default_group = per_window_settings.get_int ("default-group");
- if (default_group >= 0 && default_group != old_current) {
- source_settings.set_uint ("current", (uint) default_group);
+ if (default_group >= 0) {
+ for (var offset = 0; offset < sources.length; offset++) {
+ var current = (default_group + offset) % sources.length;
+ var source = sources[current];
+
+ if (source.is_xkb ||
+ (source.is_ibus && is_ibus_active ()) ||
+ (source.is_fcitx && is_fcitx_active ())) {
+ if (current != old_current) {
+ source_settings.set_uint ("current", current);
+ }
+
+ break;
+ }
+ }
}
} else {
- var current = ((!) window_sources)[window_id];
+ var source = ((!) window_sources)[window_id];
+
+ for (var current = 0; current < sources.length; current++) {
+ if (sources[current] == source) {
+ if (current != old_current) {
+ source_settings.set_uint ("current", current);
+ }
- if (current != old_current) {
- source_settings.set_uint ("current", current);
+ break;
+ }
}
}
@@ -633,6 +703,44 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private uint get_current () {
+ if (is_fcitx_active () && get_fcitx () != null) {
+ string? engine = ((!) get_fcitx ()).current_im;
+
+ if (engine != null) {
+ var is_xkb = ((!) engine).has_prefix ("fcitx-keyboard-");
+ var type = is_xkb ? "xkb" : "fcitx";
+ var name = (!) engine;
+
+ if (is_xkb) {
+ name = name.substring ("fcitx-keyboard-".length);
+ var index = name.index_of ("-");
+ if (index >= 0) {
+ name.data[index] = '+';
+ }
+ }
+
+ var i = 0;
+
+ foreach (var pair in source_settings.get_value ("sources")) {
+ unowned string source_type;
+ unowned string source_name;
+
+ ((!) pair).get ("(&s&s)", out source_type, out source_name);
+
+ if (source_name == name && source_type == type) {
+ return i;
+ }
+
+ i++;
+ }
+ }
+ }
+
+ return source_settings.get_uint ("current");
+ }
+
+ [DBus (visible = false)]
private Source[] get_sources () {
if (sources == null) {
var array = source_settings.get_value ("sources");
@@ -743,7 +851,7 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void update_active_action () {
if (active_action != null) {
- ((!) active_action).set_state (source_settings.get_value ("current"));
+ ((!) active_action).set_state (new Variant.uint32 (get_current ()));
update_indicator_action ();
}
}
@@ -751,10 +859,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private Action get_active_action () {
if (active_action == null) {
- var current = source_settings.get_value ("current");
- active_action = new SimpleAction.stateful ("active", VariantType.UINT32, current);
- ((!) active_action).activate.connect ((parameter) => { ((!) active_action).change_state (parameter); });
- ((!) active_action).change_state.connect (handle_changed_active);
+ var action = new SimpleAction.stateful ("active", VariantType.UINT32, new Variant.uint32 (get_current ()));
+ action.change_state.connect (handle_changed_active);
+ active_action = action;
}
return (!) active_action;
@@ -768,13 +875,45 @@ public class Indicator.Keyboard.Service : Object {
[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 ();
+ var old_current = get_current ();
+ var sources = get_sources ();
+ var length = 0;
+
+ foreach (var source in sources) {
+ if (source.is_xkb ||
+ (source.is_ibus && is_ibus_active ()) ||
+ (source.is_fcitx && is_fcitx_active ())) {
+ length++;
+ }
+ }
+
+ if (length > 1) {
+ var current = old_current;
+ var offset = -((!) parameter).get_int32 () % length;
+ var jump = 1;
+
+ if (offset < 0) {
+ offset = -offset;
+ jump = sources.length - jump;
+ }
+
+ /*
+ * We need to cycle through offset valid input sources, skipping those that aren't
+ * valid for this session (i.e. skipping Fcitx ones if IBus is active and vice-versa.
+ * jump is the direction we need to cycle in, which is 1 if we want to cycle forward
+ * and -1 (mod sources.length) if we want to cycle backward.
+ */
+
+ for (; offset > 0; offset--) {
+ do {
+ current = (current + jump) % sources.length;
+ } while ((sources[current].is_ibus && !is_ibus_active ()) ||
+ (sources[current].is_fcitx && !is_fcitx_active ()));
+ }
- if (length > 0) {
- var offset = ((!) parameter).get_int32 () % length;
- source_settings.set_uint ("current", (current + (length - offset)) % length);
+ if (current != old_current) {
+ source_settings.set_uint ("current", current);
+ }
}
}
}
@@ -788,30 +927,30 @@ public class Indicator.Keyboard.Service : Object {
private void handle_scroll_wheel_when_locked (Variant? parameter) {
if (parameter != null) {
var sources = get_sources ();
- var non_ibus_length = 0;
+ var xkb_length = 0;
- /* Figure out how many non-IBus sources we have. */
+ /* Figure out how many Xkb sources we have. */
foreach (var source in sources) {
- if (!source.is_ibus) {
- non_ibus_length++;
+ if (source.is_xkb) {
+ xkb_length++;
}
}
- if (non_ibus_length > 1) {
+ if (xkb_length > 1) {
var active_action = get_active_action ();
var active = active_action.get_state ().get_uint32 ();
- var offset = -((!) parameter).get_int32 () % non_ibus_length;
+ var offset = -((!) parameter).get_int32 () % xkb_length;
- /* Make offset positive modulo non_ibus_length. */
+ /* Make offset positive modulo xkb_length. */
if (offset < 0) {
- offset += non_ibus_length;
+ offset += xkb_length;
}
- /* We need to cycle through non-IBus sources only. */
+ /* We need to cycle through Xkb sources only. */
while (offset > 0) {
do {
active = (active + 1) % sources.length;
- } while (sources[active].is_ibus);
+ } while (!sources[active].is_xkb);
offset--;
}
@@ -881,13 +1020,20 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
public IndicatorMenu get_desktop_menu () {
if (desktop_menu == null) {
- var options = IndicatorMenu.Options.DCONF
- | IndicatorMenu.Options.IBUS
- | IndicatorMenu.Options.SETTINGS;
+ var options = IndicatorMenu.Options.DCONF;
+
+ if (!is_fcitx_active ()) {
+ options |= IndicatorMenu.Options.XKB | IndicatorMenu.Options.SETTINGS;
+
+ if (is_ibus_active ()) {
+ options |= IndicatorMenu.Options.IBUS;
+ }
+ }
- desktop_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_menu).set_sources (get_sources ());
- ((!) desktop_menu).activate.connect ((property, state) => {
+ var menu = new IndicatorMenu (get_action_group (), options);
+
+ menu.set_sources (get_sources ());
+ menu.activate.connect ((property, state) => {
var panel = get_ibus_panel ();
if (panel != null) {
@@ -898,6 +1044,8 @@ public class Indicator.Keyboard.Service : Object {
}
}
});
+
+ desktop_menu = menu;
}
return (!) desktop_menu;
@@ -906,10 +1054,12 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
public IndicatorMenu get_desktop_greeter_menu () {
if (desktop_greeter_menu == null) {
- var options = IndicatorMenu.Options.DCONF;
+ var options = IndicatorMenu.Options.DCONF |
+ IndicatorMenu.Options.XKB;
- desktop_greeter_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_greeter_menu).set_sources (get_sources ());
+ var menu = new IndicatorMenu (get_action_group (), options);
+ menu.set_sources (get_sources ());
+ desktop_greeter_menu = menu;
}
return (!) desktop_greeter_menu;
@@ -918,10 +1068,11 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
public IndicatorMenu get_desktop_lockscreen_menu () {
if (desktop_lockscreen_menu == null) {
- var options = IndicatorMenu.Options.NONE;
+ var options = IndicatorMenu.Options.XKB;
- desktop_lockscreen_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_lockscreen_menu).set_sources (get_sources ());
+ var menu = new IndicatorMenu (get_action_group (), options);
+ menu.set_sources (get_sources ());
+ desktop_lockscreen_menu = menu;
}
return (!) desktop_lockscreen_menu;
@@ -965,7 +1116,7 @@ public class Indicator.Keyboard.Service : Object {
string? variant = null;
var sources = get_sources ();
- var current = source_settings.get_uint ("current");
+ var current = get_current ();
if (current < sources.length) {
layout = sources[current].layout;
@@ -1004,8 +1155,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_unity_greeter_name_appeared (DBusConnection connection, string name, string name_owner) {
try {
- unity_greeter = Bus.get_proxy_sync (BusType.SESSION, name, "/list");
- ((!) unity_greeter).entry_selected.connect (handle_entry_selected);
+ var greeter = Bus.get_proxy_sync<UnityGreeter> (BusType.SESSION, name, "/list");
+ greeter.entry_selected.connect (handle_entry_selected);
+ unity_greeter = greeter;
} catch (IOError error) {
warning ("error: %s", error.message);
}
@@ -1033,16 +1185,17 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_unity_name_appeared (DBusConnection connection, string name, string name_owner) {
try {
- unity_session = Bus.get_proxy_sync (BusType.SESSION, name, "/com/canonical/Unity/Session");
- ((!) unity_session).locked.connect (() => {
+ var session = Bus.get_proxy_sync<UnitySession> (BusType.SESSION, name, "/com/canonical/Unity/Session");
+
+ session.locked.connect (() => {
var sources = get_sources ();
if (sources.length > 0) {
- var current = source_settings.get_uint ("current");
+ var current = get_current ();
- if (current < sources.length && sources[current].is_ibus) {
+ if (current < sources.length && !sources[current].is_xkb) {
for (var i = 0; i < sources.length; i++) {
- if (!sources[i].is_ibus) {
+ if (sources[i].is_xkb) {
get_active_action ().change_state (new Variant.uint32 (i));
break;
}
@@ -1050,9 +1203,11 @@ public class Indicator.Keyboard.Service : Object {
}
}
});
- ((!) unity_session).unlocked.connect (() => {
- get_active_action ().change_state (source_settings.get_value ("current"));
+ session.unlocked.connect (() => {
+ get_active_action ().change_state (new Variant.uint32 (get_current ()));
});
+
+ unity_session = session;
} catch (IOError error) {
warning ("error: %s", error.message);
}
diff --git a/lib/source.vala b/lib/source.vala
index 5fe7157d..b7d7a971 100644
--- a/lib/source.vala
+++ b/lib/source.vala
@@ -19,10 +19,12 @@
public class Indicator.Keyboard.Source : Object {
private static Gnome.XkbInfo? xkb_info;
- private static IBus.Bus? bus;
+ private static IBus.Bus? ibus_bus;
+ private static Fcitx.InputMethod? fcitx_proxy;
private string? xkb;
private string? ibus;
+ private string? fcitx;
private string? _name;
private string? _short_name;
@@ -77,6 +79,10 @@ public class Indicator.Keyboard.Source : Object {
get { return ibus != null; }
}
+ public bool is_fcitx {
+ get { return fcitx != null; }
+ }
+
public Source (Variant variant, bool use_gtk = false) {
Object (use_gtk: use_gtk);
@@ -90,19 +96,22 @@ public class Indicator.Keyboard.Source : Object {
xkb = name;
} else if (type == "ibus") {
ibus = name;
+ } else if (type == "fcitx") {
+ fcitx = name;
}
} else if (variant.is_of_type (new VariantType ("a{ss}"))) {
- VariantIter iter;
- unowned string key;
- unowned string value;
+ foreach (var pair in variant) {
+ unowned string key;
+ unowned string value;
- variant.get ("a{ss}", out iter);
+ ((!) pair).get ("{&s&s}", out key, out value);
- while (iter.next ("{&s&s}", out key, out value)) {
if (key == "xkb") {
xkb = value;
} else if (key == "ibus") {
ibus = value;
+ } else if (key == "fcitx") {
+ fcitx = value;
}
}
}
@@ -116,13 +125,21 @@ public class Indicator.Keyboard.Source : Object {
return (!) xkb_info;
}
- private static IBus.Bus get_bus () {
- if (bus == null) {
+ private static IBus.Bus get_ibus_bus () {
+ if (ibus_bus == null) {
IBus.init ();
- bus = new IBus.Bus ();
+ ibus_bus = new IBus.Bus ();
}
- return (!) bus;
+ return (!) ibus_bus;
+ }
+
+ private static Fcitx.InputMethod get_fcitx_proxy () throws Error {
+ if (fcitx_proxy == null) {
+ fcitx_proxy = new Fcitx.InputMethod (BusType.SESSION, DBusProxyFlags.NONE, 0);
+ }
+
+ return (!) fcitx_proxy;
}
private IBus.EngineDesc? get_engine () {
@@ -132,7 +149,7 @@ public class Indicator.Keyboard.Source : Object {
var names = new string[2];
names[0] = (!) ibus;
- var engines = get_bus ().get_engines_by_names (names);
+ var engines = get_ibus_bus ().get_engines_by_names (names);
if (engines.length > 0) {
engine = engines[0];
@@ -145,31 +162,7 @@ public class Indicator.Keyboard.Source : Object {
protected virtual string? _get_name () {
string? name = null;
- var engine = get_engine ();
-
- if (engine != null) {
- string? language = ((!) engine).get_language ();
- string? display_name = ((!) engine).get_longname ();
- var has_language = language != null && ((!) language).get_char () != '\0';
- var has_display_name = display_name != null && ((!) display_name).get_char () != '\0';
-
- if (has_language) {
- language = Xkl.get_language_name ((!) language);
- has_language = language != null && ((!) language).get_char () != '\0';
- }
-
- if (has_language && has_display_name) {
- name = @"$((!) language) ($((!) display_name))";
- } else if (has_language) {
- name = language;
- } else if (has_display_name) {
- name = display_name;
- }
- }
-
- var has_name = name != null && ((!) name).get_char () != '\0';
-
- if (!has_name && xkb != null) {
+ if (xkb != null) {
string? display_name = null;
string? layout = null;
@@ -194,14 +187,53 @@ public class Indicator.Keyboard.Source : Object {
name = country;
}
}
- }
- if (name == null || ((!) name).get_char () == '\0') {
- if (ibus != null) {
- name = ibus;
- } else if (xkb != null) {
+ if (name == null || ((!) name).get_char () == '\0') {
name = xkb;
}
+ } else if (ibus != null) {
+ var engine = get_engine ();
+
+ if (engine != null) {
+ string? language = ((!) engine).get_language ();
+ string? display_name = ((!) engine).get_longname ();
+ var has_language = language != null && ((!) language).get_char () != '\0';
+ var has_display_name = display_name != null && ((!) display_name).get_char () != '\0';
+
+ if (has_language) {
+ language = Xkl.get_language_name ((!) language);
+ has_language = language != null && ((!) language).get_char () != '\0';
+ }
+
+ if (has_language && has_display_name) {
+ name = @"$((!) language) ($((!) display_name))";
+ } else if (has_language) {
+ name = language;
+ } else if (has_display_name) {
+ name = display_name;
+ }
+ }
+
+ if (name == null || ((!) name).get_char () == '\0') {
+ name = ibus;
+ }
+ } else if (fcitx != null) {
+ try {
+ var input_methods = get_fcitx_proxy ().get_imlist_nofree ();
+
+ for (var i = 0; i < input_methods.length; i++) {
+ if (input_methods.get (i).unique_name == (!) fcitx) {
+ name = input_methods.get (i).name;
+ break;
+ }
+ }
+ } catch (Error error) {
+ warning ("error: %s", error.message);
+ }
+
+ if (name == null || ((!) name).get_char () == '\0') {
+ name = fcitx;
+ }
}
return name;
@@ -212,23 +244,36 @@ public class Indicator.Keyboard.Source : Object {
if (xkb != null) {
get_xkb_info ().get_layout_info ((!) xkb, null, out short_name, null, null);
- }
-
- var has_short_name = short_name != null && ((!) short_name).get_char () != '\0';
- if (!has_short_name) {
+ if (short_name == null || ((!) short_name).get_char () == '\0') {
+ short_name = xkb;
+ }
+ } else if (ibus != null) {
var engine = get_engine ();
if (engine != null) {
short_name = ((!) engine).get_name ();
}
- }
- if (short_name == null || ((!) short_name).get_char () == '\0') {
- if (ibus != null) {
+ if (short_name == null || ((!) short_name).get_char () == '\0') {
short_name = ibus;
- } else if (xkb != null) {
- short_name = xkb;
+ }
+ } else if (fcitx != null) {
+ try {
+ var input_methods = get_fcitx_proxy ().get_imlist_nofree ();
+
+ for (var i = 0; i < input_methods.length; i++) {
+ if (input_methods.get (i).unique_name == (!) fcitx) {
+ short_name = input_methods.get (i).langcode;
+ break;
+ }
+ }
+ } catch (Error error) {
+ warning ("error: %s", error.message);
+ }
+
+ if (short_name == null || ((!) short_name).get_char () == '\0') {
+ short_name = fcitx;
}
}
@@ -290,12 +335,14 @@ public class Indicator.Keyboard.Source : Object {
Gdk.Screen? screen = Gdk.Screen.get_default ();
if (screen != null) {
- context = new Gtk.StyleContext ();
- ((!) context).set_screen ((!) screen);
+ var style_context = new Gtk.StyleContext ();
+ style_context.set_screen ((!) screen);
var path = new Gtk.WidgetPath ();
path.append_type (typeof (Gtk.MenuItem));
- ((!) context).set_path (path);
+ style_context.set_path (path);
+
+ context = style_context;
}
}
diff --git a/tests/indicator-keyboard-test.in b/tests/indicator-keyboard-test.in
index 621133dd..3d43d8ab 100644
--- a/tests/indicator-keyboard-test.in
+++ b/tests/indicator-keyboard-test.in
@@ -4,6 +4,7 @@ export PATH="@abs_top_builddir@/tests/execute:$PATH"
export DCONF_PROFILE="@abs_top_builddir@/tests/profiles/indicator-keyboard-test"
export GSETTINGS_SCHEMA_DIR="@abs_top_builddir@/data"
export XDG_RUNTIME_DIR="@abs_top_builddir@/tests"
+export GTK_IM_MODULE="ibus"
if xvfb-run -a ./indicator-keyboard-tests
then