diff options
author | fujiwarat <takao.fujiwara1@gmail.com> | 2015-05-21 11:00:20 +0900 |
---|---|---|
committer | fujiwarat <takao.fujiwara1@gmail.com> | 2015-05-21 11:00:20 +0900 |
commit | 85f5433c223118fa8f7e4f4bceafa372d8f1e880 (patch) | |
tree | b7c62b77a60a7028785ebee06b05bc3837654574 | |
parent | 7ae585ac21db4dfac8989887e1a5f97fb863fa17 (diff) | |
download | ibus-85f5433c223118fa8f7e4f4bceafa372d8f1e880.tar.gz |
Use GLib.Idle.add() when ibus-engine-simple loads compose tables
TEST=engine/ibus-engine-simple
Review URL: https://codereview.appspot.com/240820043
-rw-r--r-- | engine/Makefile.am | 1 | ||||
-rw-r--r-- | engine/main.vala | 59 | ||||
-rw-r--r-- | src/ibuscomposetable.c | 4 | ||||
-rw-r--r-- | src/ibusenginesimple.h | 4 |
4 files changed, 35 insertions, 33 deletions
diff --git a/engine/Makefile.am b/engine/Makefile.am index 271e9256..19fb6b0a 100644 --- a/engine/Makefile.am +++ b/engine/Makefile.am @@ -52,7 +52,6 @@ AM_LDADD = \ AM_VALAFLAGS = \ --vapidir=$(top_builddir)/bindings/vala \ --pkg=ibus-1.0 \ - --pkg=posix \ --target-glib="$(VALA_TARGET_GLIB_VERSION)" \ $(NULL) diff --git a/engine/main.vala b/engine/main.vala index 3fecb0a6..2077277d 100644 --- a/engine/main.vala +++ b/engine/main.vala @@ -52,33 +52,38 @@ public int main(string[] args) { typeof(IBus.EngineSimple), name, path.printf(++id), bus.get_connection()); - /* I think "c" + "'" is c with acute U+0107 and - * "c" + "," is c with cedilla U+00E7 and they are - * visually comprehensible. But pt-br people need - * "c" + "'" is c with cedilla and I think the - * cedilla_compose_seqs is needed for the specific keyboards - * or regions. - * X11 uses compose by locale: - * In /usr/share/X11/locale/en_US.UTF-8/Compose , - * <Multi_key> <apostrophe> <c> : U0107 - */ - IBus.EngineSimple? simple = (IBus.EngineSimple ?) engine; - simple.add_table_by_locale(null); - - string user_file = null; - - var home = GLib.Environment.get_home_dir(); - if (home != null) { - user_file = home + "/.XCompose"; - if (GLib.FileUtils.test(user_file, GLib.FileTest.EXISTS)) - simple.add_compose_file(user_file); - } - - user_file = GLib.Environment.get_variable("XCOMPOSEFILE"); - if (user_file != null) { - if (GLib.FileUtils.test(user_file, GLib.FileTest.EXISTS)) - simple.add_compose_file(user_file); - } + /* Use Idle.add() to reduce the lag caused by file io */ + GLib.Idle.add(() => { + /* I think "c" + "'" is c with acute U+0107 and + * "c" + "," is c with cedilla U+00E7 and they are + * visually comprehensible. But pt-br people need + * "c" + "'" is c with cedilla and I think the + * cedilla_compose_seqs is needed for the specific keyboards + * or regions. + * X11 uses compose by locale: + * In /usr/share/X11/locale/en_US.UTF-8/Compose , + * <Multi_key> <apostrophe> <c> : U0107 + */ + IBus.EngineSimple? simple = (IBus.EngineSimple ?) engine; + simple.add_table_by_locale(null); + + string user_file = null; + + var home = GLib.Environment.get_home_dir(); + if (home != null) { + user_file = home + "/.XCompose"; + if (GLib.FileUtils.test(user_file, GLib.FileTest.EXISTS)) + simple.add_compose_file(user_file); + } + + user_file = GLib.Environment.get_variable("XCOMPOSEFILE"); + if (user_file != null) { + if (GLib.FileUtils.test(user_file, GLib.FileTest.EXISTS)) + simple.add_compose_file(user_file); + } + + return false; + }); return engine; }); diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c index e0cf594d..4701ac28 100644 --- a/src/ibuscomposetable.c +++ b/src/ibuscomposetable.c @@ -27,13 +27,11 @@ #include <glib.h> #include <glib/gprintf.h> -#include <X11/Xlib.h> #include <locale.h> -#include <pwd.h> #include <stdlib.h> #include <string.h> #include <strings.h> -#include <unistd.h> + #include "ibuserror.h" #include "ibuskeys.h" #include "ibuskeysyms.h" diff --git a/src/ibusenginesimple.h b/src/ibusenginesimple.h index f2bb4e19..76d46f4b 100644 --- a/src/ibusenginesimple.h +++ b/src/ibusenginesimple.h @@ -1,8 +1,8 @@ /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ /* vim:set et sts=4: */ /* ibus - The Input Bus - * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> - * Copyright (C) 2008-2010 Red Hat, Inc. + * Copyright (C) 2008-2015 Peng Huang <shawn.p.huang@gmail.com> + * Copyright (C) 2008-2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public |