summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2012-10-05 21:24:54 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2012-10-05 21:24:54 +0900
commitacaaa1578cbff50806bbd977e42b37f6358b0734 (patch)
tree402ac6b6e446d4e785a72e19e695b7f9a802db08
parent70dc912db827c333995c09e06dda88ab076e792d (diff)
downloadibus-anthy-acaaa1578cbff50806bbd977e42b37f6358b0734.tar.gz
Added keyboard layout customization.
-rw-r--r--configure.ac9
-rw-r--r--engine/Makefile.am18
-rw-r--r--engine/_config.py.in4
-rw-r--r--engine/anthy.xml.in.in22
-rw-r--r--engine/default.xml.in.in16
-rw-r--r--engine/engine.py20
-rw-r--r--engine/main.py45
-rw-r--r--po/ibus-anthy.pot288
-rw-r--r--setup/Makefile.am2
-rw-r--r--setup/anthyprefs.py.in7
-rw-r--r--setup/ibus-setup-anthy.desktop.in.in2
-rw-r--r--setup/main.py108
-rw-r--r--setup/setup.ui92
13 files changed, 454 insertions, 179 deletions
diff --git a/configure.ac b/configure.ac
index 10586b3..e0f49c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,6 +308,7 @@ AC_SUBST(HOTKEYS_XML)
dnl - check symbol in IBus.EngineDesc
AC_MSG_CHECKING([if IBus.EngineDesc has get_symbol])
SYMBOL_CHAR='&#x3042;'
+SYMBOL_CHAR_INT=0x3042
SYMBOL_TEST="from gi.repository import IBus
exit(not hasattr(IBus.EngineDesc, 'get_symbol'))
"
@@ -319,6 +320,7 @@ else
SYMBOL_XML="<!-- <symbol>${SYMBOL_CHAR}</symbol> -->"
AC_MSG_ERROR([ibus 1.4 or later supports symbol in IBus.EngineDesc])
fi
+AC_SUBST(SYMBOL_CHAR_INT)
AC_SUBST(SYMBOL_XML)
dnl - check symbol in IBus.Property
@@ -341,10 +343,10 @@ AC_ARG_WITH(layout,
[LAYOUT="$withval"],
[LAYOUT="jp"])
if test x"$LAYOUT" = x; then
- LAYOUT_XML="<layout>jp</layout>"
-else
- LAYOUT_XML="<layout>${LAYOUT}</layout>"
+ LAYOUT="jp"
fi
+LAYOUT_XML="<layout>${LAYOUT}</layout>"
+AC_SUBST(LAYOUT)
AC_SUBST(LAYOUT_XML)
dnl libtool versioning
@@ -379,6 +381,7 @@ gir/Makefile
engine/Makefile
engine/ibus-engine-anthy
engine/anthy.xml.in
+engine/default.xml.in
setup/Makefile
setup/ibus-setup-anthy
icons/Makefile
diff --git a/engine/Makefile.am b/engine/Makefile.am
index 8991c90..8faf0b9 100644
--- a/engine/Makefile.am
+++ b/engine/Makefile.am
@@ -75,8 +75,10 @@ PYGTK2_ANTHY_GEN =
endif
libexec_SCRIPTS = ibus-engine-anthy
-engine_DATA = anthy.xml
-enginedir = $(datadir)/ibus/component
+component_DATA = anthy.xml
+componentdir = $(datadir)/ibus/component
+engine_DATA = default.xml
+enginedir = $(pkgdatadir)/engine
anthy.xml: anthy.xml.in
( \
@@ -86,11 +88,21 @@ anthy.xml: anthy.xml.in
eval "echo \"$${s}\""; \
) > $@
+default.xml: default.xml.in
+ ( \
+ libexecdir=${libexecdir}; \
+ pkgdatadir=${pkgdatadir}; \
+ s=`cat $<`; \
+ eval "echo \"$${s}\""; \
+ ) > $@
+
_config.py: _config.py.in
( \
PKGDATADIR=$(pkgdatadir); \
LIBEXECDIR=$(libexecdir); \
DATADIR=$(datadir); \
+ LAYOUT=$(LAYOUT); \
+ SYMBOL_CHAR_INT=$(SYMBOL_CHAR_INT); \
s=`cat $<`; \
eval "echo \"$${s}\""; \
) > $@
@@ -107,6 +119,7 @@ EXTRA_DIST = \
$(engine_anthy_built_in_files) \
$(PYGTK2_ANTHY_RAW) \
anthy.xml.in.in \
+ default.xml.in.in \
ibus-engine-anthy.in \
$(NULL)
@@ -114,6 +127,7 @@ CLEANFILES = \
$(BUILT_SOURCES) \
$(PYGTK2_ANTHY_GEN) \
anthy.xml \
+ default.xml \
*.pyc \
$(NULL)
diff --git a/engine/_config.py.in b/engine/_config.py.in
index 17c2274..d543829 100644
--- a/engine/_config.py.in
+++ b/engine/_config.py.in
@@ -23,4 +23,6 @@
PKGDATADIR = '${PKGDATADIR}'
LIBEXECDIR = '${LIBEXECDIR}'
-LOCALEDIR= '${DATADIR}/locale'
+LOCALEDIR = '${DATADIR}/locale'
+LAYOUT = '${LAYOUT}'
+SYMBOL_CHAR = unichr(${SYMBOL_CHAR_INT})
diff --git a/engine/anthy.xml.in.in b/engine/anthy.xml.in.in
index 0162cf6..9a93744 100644
--- a/engine/anthy.xml.in.in
+++ b/engine/anthy.xml.in.in
@@ -10,20 +10,10 @@
<homepage>http://code.google.com/p/ibus</homepage>
<textdomain>ibus-anthy</textdomain>
- <!-- for static engines -->
- <engines>
- <engine>
- <name>anthy</name>
- <language>ja</language>
- <license>GPL</license>
- <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
- <icon>ibus-anthy</icon>
- @LAYOUT_XML@
- <longname>Anthy</longname>
- <description>Anthy Input Method</description>
- <rank>99</rank>
- @HOTKEYS_XML@
- @SYMBOL_XML@
- </engine>
- </engines>
+ <!-- for engines -->
+ <observed-paths>
+ <path>~/.config/ibus-anthy/engines.xml</path>
+ <path>${pkgdatadir}/engine/default.xml</path>
+ </observed-paths>
+ <engines exec=\"${libexecdir}/ibus-engine-anthy --xml\" />
</component>
diff --git a/engine/default.xml.in.in b/engine/default.xml.in.in
new file mode 100644
index 0000000..c130285
--- /dev/null
+++ b/engine/default.xml.in.in
@@ -0,0 +1,16 @@
+<?xml version=\"1.0\" encoding=\"utf-8\"?>
+<engines>
+ <engine>
+ <name>anthy</name>
+ <language>ja</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <icon>ibus-anthy</icon>
+ @LAYOUT_XML@
+ <longname>Anthy</longname>
+ <description>Anthy Input Method</description>
+ <rank>99</rank>
+ @HOTKEYS_XML@
+ @SYMBOL_XML@
+ </engine>
+</engines>
diff --git a/engine/engine.py b/engine/engine.py
index cef6aa0..1915f5b 100644
--- a/engine/engine.py
+++ b/engine/engine.py
@@ -27,6 +27,8 @@ import signal
import sys
from gettext import dgettext
+from main import get_userhome
+
try:
from locale import getpreferredencoding
except:
@@ -1633,16 +1635,6 @@ class Engine(IBus.EngineSimple):
cls.__thumb.reset()
@classmethod
- def _get_userhome(cls):
- if 'HOME' not in environ:
- import pwd
- userhome = pwd.getpwuid(os.getuid()).pw_dir
- else:
- userhome = environ['HOME']
- userhome = userhome.rstrip('/')
- return userhome
-
- @classmethod
def _get_quoted_id(cls, file):
id = file
has_mbcs = False
@@ -1686,10 +1678,10 @@ class Engine(IBus.EngineSimple):
if id == None:
return
if link_mode == LINK_DICT_EMBEDDED:
- directory = cls._get_userhome() + '/.anthy/' + IMPORTED_EMBEDDED_DICT_DIR
+ directory = get_userhome() + '/.anthy/' + IMPORTED_EMBEDDED_DICT_DIR
name = IMPORTED_EMBEDDED_DICT_PREFIX + id
elif link_mode == LINK_DICT_SINGLE:
- directory = cls._get_userhome() + '/.anthy'
+ directory = get_userhome() + '/.anthy'
name = IMPORTED_SINGLE_DICT_PREFIX + id
else:
return
@@ -1718,10 +1710,10 @@ class Engine(IBus.EngineSimple):
if id == None:
return
if link_mode == LINK_DICT_EMBEDDED:
- directory = cls._get_userhome() + '/.anthy/' + IMPORTED_EMBEDDED_DICT_DIR
+ directory = get_userhome() + '/.anthy/' + IMPORTED_EMBEDDED_DICT_DIR
name = IMPORTED_EMBEDDED_DICT_PREFIX + id
elif link_mode == LINK_DICT_SINGLE:
- directory = cls._get_userhome() + '/.anthy'
+ directory = get_userhome() + '/.anthy'
name = IMPORTED_SINGLE_DICT_PREFIX + id
else:
return
diff --git a/engine/main.py b/engine/main.py
index ccb66d5..d339bd2 100644
--- a/engine/main.py
+++ b/engine/main.py
@@ -44,13 +44,15 @@ class IMApp:
command_line=command_line,
textdomain='ibus-anthy')
engine = IBus.EngineDesc(name='anthy',
- longname='anthy',
- description='Japanese Anthy',
+ longname='Anthy',
+ description='Anthy Input Method',
language='ja',
license='GPL',
author='Peng Huang <shawn.p.huang@gmail.com>',
icon='ibus-anthy',
- layout='en')
+ layout=config.LAYOUT,
+ symbol=config.SYMBOL_CHAR,
+ rank=99)
self.__component.add_engine(engine)
self.__mainloop = GObject.MainLoop()
self.__bus = IBus.Bus()
@@ -71,10 +73,36 @@ class IMApp:
def launch_engine(exec_by_ibus):
IMApp(exec_by_ibus).run()
+def get_userhome():
+ if 'HOME' not in os.environ:
+ import pwd
+ userhome = pwd.getpwuid(os.getuid()).pw_dir
+ else:
+ userhome = os.environ['HOME']
+ userhome = userhome.rstrip('/')
+ return userhome
+
+def print_xml():
+ user_config = os.path.join(get_userhome(), '.config',
+ 'ibus-anthy', 'engines.xml')
+ system_config = os.path.join(config.PKGDATADIR, 'engine', 'default.xml')
+ xml = None
+ for f in [user_config, system_config]:
+ if os.path.exists(f):
+ xml = f
+ break
+ if xml == None:
+ print >> sys.stderr, 'Not exist: %s' % system_config
+ return
+ file = open(xml, 'r')
+ print file.read()
+ file.close()
+
def print_help(out, v = 0):
print >> out, '-i, --ibus executed by ibus.'
print >> out, '-h, --help show this message.'
print >> out, '-d, --daemonize daemonize ibus.'
+ print >> out, '-x, --xml print engine xml.'
sys.exit(v)
def main():
@@ -85,9 +113,10 @@ def main():
exec_by_ibus = False
daemonize = False
+ xml = False
- shortopt = 'ihd'
- longopt = ['ibus', 'helpn', 'daemonize']
+ shortopt = 'ihdx'
+ longopt = ['ibus', 'help', 'daemonize', 'xml']
try:
opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt)
@@ -101,6 +130,8 @@ def main():
daemonize = True
elif o in ('-i', '--ibus'):
exec_by_ibus = True
+ elif o in ('-x', '--xml'):
+ xml = True
else:
print >> sys.stderr, 'Unknown argument: %s' % o
print_help(sys.stderr, 1)
@@ -109,6 +140,10 @@ def main():
if os.fork():
sys.exit()
+ if xml:
+ print_xml()
+ return
+
launch_engine(exec_by_ibus)
if __name__ == '__main__':
diff --git a/po/ibus-anthy.pot b/po/ibus-anthy.pot
index c1292d3..0aa1fbd 100644
--- a/po/ibus-anthy.pot
+++ b/po/ibus-anthy.pot
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ibus-anthy HEAD\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2012-09-14 11:38+0900\n"
+"POT-Creation-Date: 2012-10-05 21:22+0900\n"
"PO-Revision-Date: 2011-05-13 14:54+0900\n"
"Last-Translator: Takao Fujiwara <takao.fujiwara1@gmail.com>\n"
"Language-Team: Source\n"
@@ -17,143 +17,143 @@ msgstr ""
#. Translators: Specify the order of %s with your translation.
#. It will be "Input Mode (A)" for example.
-#: ../engine/engine.py:201 ../engine/engine.py:275 ../engine/engine.py:352
-#: ../engine/engine.py:417 ../engine/engine.py:739 ../engine/engine.py:767
-#: ../engine/engine.py:788 ../engine/engine.py:814 ../engine/engine.py:881
+#: ../engine/engine.py:203 ../engine/engine.py:277 ../engine/engine.py:354
+#: ../engine/engine.py:419 ../engine/engine.py:741 ../engine/engine.py:769
+#: ../engine/engine.py:790 ../engine/engine.py:816 ../engine/engine.py:883
#, python-format
msgid "%(description)s (%(symbol)s)"
msgstr ""
-#: ../engine/engine.py:202 ../engine/engine.py:740
+#: ../engine/engine.py:204 ../engine/engine.py:742
msgid "Input mode"
msgstr ""
-#: ../engine/engine.py:208
+#: ../engine/engine.py:210
msgid "Switch input mode"
msgstr ""
-#: ../engine/engine.py:218 ../setup/setup.ui.h:1
+#: ../engine/engine.py:220 ../setup/setup.ui.h:1
msgid "Hiragana"
msgstr ""
-#: ../engine/engine.py:227 ../setup/setup.ui.h:2
+#: ../engine/engine.py:229 ../setup/setup.ui.h:2
msgid "Katakana"
msgstr ""
-#: ../engine/engine.py:236 ../setup/setup.ui.h:3
+#: ../engine/engine.py:238 ../setup/setup.ui.h:3
msgid "Halfwidth Katakana"
msgstr ""
-#: ../engine/engine.py:245 ../setup/setup.ui.h:4
+#: ../engine/engine.py:247 ../setup/setup.ui.h:4
msgid "Latin"
msgstr ""
-#: ../engine/engine.py:254 ../setup/setup.ui.h:5
+#: ../engine/engine.py:256 ../setup/setup.ui.h:5
msgid "Wide Latin"
msgstr ""
-#: ../engine/engine.py:276 ../engine/engine.py:768 ../engine/engine.py:789
+#: ../engine/engine.py:278 ../engine/engine.py:770 ../engine/engine.py:791
msgid "Typing method"
msgstr ""
-#: ../engine/engine.py:282
+#: ../engine/engine.py:284
msgid "Switch typing method"
msgstr ""
-#: ../engine/engine.py:292 ../setup/setup.ui.h:12
+#: ../engine/engine.py:294 ../setup/setup.ui.h:12
msgid "Romaji"
msgstr ""
-#: ../engine/engine.py:301 ../setup/setup.ui.h:13
+#: ../engine/engine.py:303 ../setup/setup.ui.h:13
msgid "Kana"
msgstr ""
-#: ../engine/engine.py:310 ../setup/setup.ui.h:14
+#: ../engine/engine.py:312 ../setup/setup.ui.h:14
msgid "Thumb shift"
msgstr ""
-#: ../engine/engine.py:332
+#: ../engine/engine.py:334
msgid "Preferences - Anthy"
msgstr ""
-#: ../engine/engine.py:334
+#: ../engine/engine.py:336
msgid "Configure Anthy"
msgstr ""
-#: ../engine/engine.py:353 ../engine/engine.py:815
+#: ../engine/engine.py:355 ../engine/engine.py:817
msgid "Segment mode"
msgstr ""
-#: ../engine/engine.py:359
+#: ../engine/engine.py:361
msgid "Switch conversion mode"
msgstr ""
-#: ../engine/engine.py:369 ../setup/setup.ui.h:15
+#: ../engine/engine.py:371 ../setup/setup.ui.h:15
msgid "Multiple segment"
msgstr ""
-#: ../engine/engine.py:378 ../setup/setup.ui.h:16
+#: ../engine/engine.py:380 ../setup/setup.ui.h:16
msgid "Single segment"
msgstr ""
-#: ../engine/engine.py:387 ../setup/setup.ui.h:17
+#: ../engine/engine.py:389 ../setup/setup.ui.h:17
msgid "Immediate conversion (multiple segment)"
msgstr ""
-#: ../engine/engine.py:396 ../setup/setup.ui.h:18
+#: ../engine/engine.py:398 ../setup/setup.ui.h:18
msgid "Immediate conversion (single segment)"
msgstr ""
-#: ../engine/engine.py:418 ../engine/engine.py:882
+#: ../engine/engine.py:420 ../engine/engine.py:884
msgid "Dictionary mode"
msgstr ""
-#: ../engine/engine.py:424
+#: ../engine/engine.py:426
msgid "Switch dictionary"
msgstr ""
-#: ../engine/engine.py:488
+#: ../engine/engine.py:490
msgid "Dictionary - Anthy"
msgstr ""
#. Translators: "Dic" means 'dictionary', One kanji may be good.
-#: ../engine/engine.py:494
+#: ../engine/engine.py:496
msgid "Dic"
msgstr ""
-#: ../engine/engine.py:501
+#: ../engine/engine.py:503
msgid "Configure dictionaries"
msgstr ""
-#: ../engine/engine.py:511
+#: ../engine/engine.py:513
msgid "Edit dictionaries"
msgstr ""
-#: ../engine/engine.py:513
+#: ../engine/engine.py:515
msgid "Launch the dictionary tool"
msgstr ""
-#: ../engine/engine.py:520
+#: ../engine/engine.py:522
msgid "Add words"
msgstr ""
-#: ../engine/engine.py:522
+#: ../engine/engine.py:524
msgid "Add words to the dictionary"
msgstr ""
-#: ../setup/anthyprefs.py.in:841
+#: ../setup/anthyprefs.py.in:848
msgid "General"
msgstr ""
-#: ../setup/anthyprefs.py.in:852
+#: ../setup/anthyprefs.py.in:859
msgid "Zip Code Conversion"
msgstr ""
-#: ../setup/anthyprefs.py.in:864
+#: ../setup/anthyprefs.py.in:871
msgid "Symbol"
msgstr ""
-#: ../setup/anthyprefs.py.in:875
+#: ../setup/anthyprefs.py.in:882
msgid "Old Character Style"
msgstr ""
@@ -166,231 +166,241 @@ msgid "Set up IBus Anthy engine"
msgstr ""
#. self.__run_message_dialog needs self.__builder.
-#: ../setup/main.py:84
+#: ../setup/main.py:85
msgid "ibus is not running."
msgstr ""
-#: ../setup/main.py:133
+#: ../setup/main.py:134
msgid "Command"
msgstr ""
-#: ../setup/main.py:137
+#: ../setup/main.py:138
msgid "Shortcut"
msgstr ""
-#: ../setup/main.py:178
+#: ../setup/main.py:187
msgid "Description"
msgstr ""
#. Translators: "Embd" is an abbreviation of "embedded".
-#: ../setup/main.py:186
+#: ../setup/main.py:195
msgid "Embd"
msgstr ""
#. Translators: "Sgl" is an abbreviation of "single".
-#: ../setup/main.py:194
+#: ../setup/main.py:203
msgid "Sgl"
msgstr ""
-#: ../setup/main.py:332 ../setup/main.py:361
+#: ../setup/main.py:341 ../setup/main.py:370
msgid "Input Chars"
msgstr ""
-#: ../setup/main.py:334 ../setup/main.py:363
+#: ../setup/main.py:343 ../setup/main.py:372
msgid "Output Chars"
msgstr ""
-#: ../setup/main.py:402
+#: ../setup/main.py:411
msgid "Input"
msgstr ""
-#: ../setup/main.py:404
+#: ../setup/main.py:413
msgid "Single"
msgstr ""
-#: ../setup/main.py:406
+#: ../setup/main.py:415
msgid "Left"
msgstr ""
-#: ../setup/main.py:408
+#: ../setup/main.py:417
msgid "Right"
msgstr ""
-#: ../setup/main.py:483
+#: ../setup/main.py:492
msgid "Customize Romaji Key Table"
msgstr ""
-#: ../setup/main.py:484 ../setup/setup.ui.h:49
+#: ../setup/main.py:493 ../setup/setup.ui.h:49
msgid "_Romaji Key Table:"
msgstr ""
-#: ../setup/main.py:485 ../setup/main.py:491
+#: ../setup/main.py:494 ../setup/main.py:500
msgid "_Output Chars"
msgstr ""
-#: ../setup/main.py:486 ../setup/main.py:492 ../setup/setup.ui.h:26
+#: ../setup/main.py:495 ../setup/main.py:501 ../setup/main.py:901
+#: ../setup/main.py:930 ../setup/setup.ui.h:26
msgid "Default"
msgstr ""
-#: ../setup/main.py:489
+#: ../setup/main.py:498
msgid "Customize Kana Key Table"
msgstr ""
-#: ../setup/main.py:490 ../setup/setup.ui.h:51
+#: ../setup/main.py:499 ../setup/setup.ui.h:51
msgid "_Kana Key Table:"
msgstr ""
-#: ../setup/main.py:495
+#: ../setup/main.py:504
msgid "Customize Thumb Shift Key Table"
msgstr ""
-#: ../setup/main.py:496
+#: ../setup/main.py:505
msgid "_Thumb Shift Key Table:"
msgstr ""
-#: ../setup/main.py:497
+#: ../setup/main.py:506
msgid "Single _Output Chars"
msgstr ""
-#: ../setup/main.py:498
+#: ../setup/main.py:507
msgid "Base"
msgstr ""
-#: ../setup/main.py:499
+#: ../setup/main.py:508
msgid "NICOLA-J key extension"
msgstr ""
-#: ../setup/main.py:500
+#: ../setup/main.py:509
msgid "NICOLA-A key extension"
msgstr ""
-#: ../setup/main.py:501
+#: ../setup/main.py:510
msgid "NICOLA-F key extension"
msgstr ""
-#: ../setup/main.py:502
+#: ../setup/main.py:511
msgid "FMV KB231-J key extension"
msgstr ""
-#: ../setup/main.py:503
+#: ../setup/main.py:512
msgid "FMV KB231-A key extension"
msgstr ""
-#: ../setup/main.py:504
+#: ../setup/main.py:513
msgid "FMV KB231-F key extension"
msgstr ""
-#: ../setup/main.py:505
+#: ../setup/main.py:514
msgid "FMV KB611-J key extension"
msgstr ""
-#: ../setup/main.py:506
+#: ../setup/main.py:515
msgid "FMV KB611-A key extension"
msgstr ""
-#: ../setup/main.py:507
+#: ../setup/main.py:516
msgid "FMV KB611-F key extension"
msgstr ""
-#: ../setup/main.py:667
+#: ../setup/main.py:676
msgid "Your choosed file has already been added: "
msgstr ""
-#: ../setup/main.py:671
+#: ../setup/main.py:680
msgid "The file you have chosen does not exist: "
msgstr ""
-#: ../setup/main.py:675
+#: ../setup/main.py:684
msgid "Your choosed file is a directory: "
msgstr ""
-#: ../setup/main.py:679
+#: ../setup/main.py:688
msgid "You cannot add dictionaries in the anthy private directory: "
msgstr ""
-#: ../setup/main.py:686
+#: ../setup/main.py:695
msgid "Your file path is not good: "
msgstr ""
-#: ../setup/main.py:843
+#: ../setup/main.py:842
+msgid "The engine xml file does not exist: "
+msgstr ""
+
+#: ../setup/main.py:883
+msgid ""
+"Anthy keyboard layout is changed. Please restart ibus to reload the layout."
+msgstr ""
+
+#: ../setup/main.py:947
msgid "Confirmation"
msgstr ""
-#: ../setup/main.py:845
+#: ../setup/main.py:949
msgid "You are about to close the setup dialog, is that OK?"
msgstr ""
-#: ../setup/main.py:859
+#: ../setup/main.py:963
msgid "Notice!"
msgstr ""
-#: ../setup/main.py:861
+#: ../setup/main.py:965
msgid ""
"You are about to close the setup dialog without saving your changes, is that "
"OK?"
msgstr ""
-#: ../setup/main.py:966
+#: ../setup/main.py:1070
msgid "Please specify Input Chars"
msgstr ""
-#: ../setup/main.py:969
+#: ../setup/main.py:1073
msgid "Please specify Output Chars"
msgstr ""
-#: ../setup/main.py:972
+#: ../setup/main.py:1076
msgid "Please specify Left Thumb Shift Chars"
msgstr ""
-#: ../setup/main.py:975
+#: ../setup/main.py:1079
msgid "Please specify Right Thumb Shift Chars"
msgstr ""
-#: ../setup/main.py:988 ../setup/main.py:1028
+#: ../setup/main.py:1092 ../setup/main.py:1132
msgid "Your custom key is not assigned in any sections. Maybe a bug."
msgstr ""
-#: ../setup/main.py:1088 ../setup/main.py:1174
+#: ../setup/main.py:1192 ../setup/main.py:1278
msgid "Your file does not exist: "
msgstr ""
-#: ../setup/main.py:1098
+#: ../setup/main.py:1202
msgid "Open Dictionary File"
msgstr ""
-#: ../setup/main.py:1104
+#: ../setup/main.py:1208
msgid "Edit Dictionary File"
msgstr ""
-#: ../setup/main.py:1118
+#: ../setup/main.py:1222
msgid "Your choosed file is not correct."
msgstr ""
-#: ../setup/main.py:1147
+#: ../setup/main.py:1251
msgid "You cannot delete the system dictionary."
msgstr ""
-#: ../setup/main.py:1170
+#: ../setup/main.py:1274
msgid "Your file is not good."
msgstr ""
-#: ../setup/main.py:1200
+#: ../setup/main.py:1304
msgid "View Dictionary File"
msgstr ""
-#: ../setup/main.py:1354
+#: ../setup/main.py:1458
msgid "Please press a key (or a key combination)"
msgstr ""
-#: ../setup/main.py:1355
+#: ../setup/main.py:1459
msgid "The dialog will be closed when the key is released"
msgstr ""
-#: ../setup/main.py:1374 ../setup/main.py:1394
+#: ../setup/main.py:1478 ../setup/main.py:1498
msgid "Invalid keysym"
msgstr ""
-#: ../setup/main.py:1375 ../setup/main.py:1395
+#: ../setup/main.py:1479 ../setup/main.py:1499
msgid "This keysym is not valid"
msgstr ""
@@ -543,182 +553,190 @@ msgid "<b>Kana</b>"
msgstr ""
#: ../setup/setup.ui.h:53
-msgid "_Typing Method"
+msgid "Keyboad _layout:"
msgstr ""
#: ../setup/setup.ui.h:54
-msgid "_Left Thumb Shift Key:"
+msgid "<b>Keyboard layout</b>"
msgstr ""
#: ../setup/setup.ui.h:55
-msgid "Right _Thumb Shift Key:"
+msgid "_Typing Method"
msgstr ""
#: ../setup/setup.ui.h:56
-msgid "Adjust _input method layout to system keyboard layout"
+msgid "_Left Thumb Shift Key:"
msgstr ""
#: ../setup/setup.ui.h:57
-msgid "Adjust IM layout to XKB layout"
+msgid "Right _Thumb Shift Key:"
msgstr ""
#: ../setup/setup.ui.h:58
-msgid "Input _Method Layout:"
+msgid "Adjust _input method layout to system keyboard layout"
msgstr ""
#: ../setup/setup.ui.h:59
-msgid "Restart IBus when you change the keyboard layout"
+msgid "Adjust IM layout to XKB layout"
msgstr ""
#: ../setup/setup.ui.h:60
-msgid "Restart IBus when you change XKB"
+msgid "Input _Method Layout:"
msgstr ""
#: ../setup/setup.ui.h:61
+msgid "Restart IBus when you change the keyboard layout"
+msgstr ""
+
+#: ../setup/setup.ui.h:62
+msgid "Restart IBus when you change XKB"
+msgstr ""
+
+#: ../setup/setup.ui.h:63
msgid ""
"Strongly recommend to enable \"Use system keyboard layout\" check button in "
"\"Advanced\" tab using 'ibus-setup' command"
msgstr ""
-#: ../setup/setup.ui.h:62
+#: ../setup/setup.ui.h:64
msgid "_Additional Key Arrangement:"
msgstr ""
-#: ../setup/setup.ui.h:63
+#: ../setup/setup.ui.h:65
msgid ""
"'&#xFF5E;', '&#x300E;', '&#xA2;', '&#xA3;' and so on can be output with "
"Thumb Shift key"
msgstr ""
-#: ../setup/setup.ui.h:64
+#: ../setup/setup.ui.h:66
msgid ""
"You do not have to reconfigure the system keyboard layout for \"Additional "
"Key Arrangement\" since this option changes input method layout only in case "
"input method is turned on."
msgstr ""
-#: ../setup/setup.ui.h:65
+#: ../setup/setup.ui.h:67
msgid ""
"You do not have to reconfigure XKB since this option changes IM layout only "
"with IM on."
msgstr ""
-#: ../setup/setup.ui.h:66
+#: ../setup/setup.ui.h:68
msgid "_Enable semi-voiced sound mark with Shift key"
msgstr ""
-#: ../setup/setup.ui.h:67
+#: ../setup/setup.ui.h:69
msgid "Seion + Shift can output Handakuon"
msgstr ""
-#: ../setup/setup.ui.h:68
+#: ../setup/setup.ui.h:70
msgid "Thumb _Shift Key Table:"
msgstr ""
-#: ../setup/setup.ui.h:69
+#: ../setup/setup.ui.h:71
msgid "<b>Thumb Shift Layout</b>"
msgstr ""
-#: ../setup/setup.ui.h:70
+#: ../setup/setup.ui.h:72
msgid "Thumb S_hift"
msgstr ""
-#: ../setup/setup.ui.h:71
+#: ../setup/setup.ui.h:73
msgid "_Edit Dictionary Command:"
msgstr ""
-#: ../setup/setup.ui.h:72
+#: ../setup/setup.ui.h:74
msgid "_Add Word Command:"
msgstr ""
-#: ../setup/setup.ui.h:73
+#: ../setup/setup.ui.h:75
msgid "<b>Default Dictionary Configuration</b>"
msgstr ""
-#: ../setup/setup.ui.h:74
+#: ../setup/setup.ui.h:76
msgid "_View"
msgstr ""
-#: ../setup/setup.ui.h:75
+#: ../setup/setup.ui.h:77
msgid "You can change the order on language bar"
msgstr ""
-#: ../setup/setup.ui.h:76
+#: ../setup/setup.ui.h:78
msgid "<b>Extended Dictionaries</b>"
msgstr ""
-#: ../setup/setup.ui.h:77
+#: ../setup/setup.ui.h:79
msgid "Dictionar_y"
msgstr ""
-#: ../setup/setup.ui.h:78
+#: ../setup/setup.ui.h:80
msgid "Abo_ut"
msgstr ""
-#: ../setup/setup.ui.h:79
+#: ../setup/setup.ui.h:81
msgid "Edit Shortcut"
msgstr ""
-#: ../setup/setup.ui.h:80
+#: ../setup/setup.ui.h:82
msgid "Key Code:"
msgstr ""
-#: ../setup/setup.ui.h:81
+#: ../setup/setup.ui.h:83
msgid "Modifier:"
msgstr ""
-#: ../setup/setup.ui.h:82
+#: ../setup/setup.ui.h:84
msgid "A_lternate"
msgstr ""
-#: ../setup/setup.ui.h:83
+#: ../setup/setup.ui.h:85
msgid "Co_ntrol"
msgstr ""
-#: ../setup/setup.ui.h:84
+#: ../setup/setup.ui.h:86
msgid "_Shift"
msgstr ""
-#: ../setup/setup.ui.h:85
+#: ../setup/setup.ui.h:87
msgid "_Input Characters"
msgstr ""
-#: ../setup/setup.ui.h:86
+#: ../setup/setup.ui.h:88
msgid "_Output Characters"
msgstr ""
-#: ../setup/setup.ui.h:87
+#: ../setup/setup.ui.h:89
msgid "_Left Thumb Shift"
msgstr ""
-#: ../setup/setup.ui.h:88
+#: ../setup/setup.ui.h:90
msgid "_Right Thumb Shift"
msgstr ""
-#: ../setup/setup.ui.h:89
+#: ../setup/setup.ui.h:91
msgid "_Short Label:"
msgstr ""
-#: ../setup/setup.ui.h:90
+#: ../setup/setup.ui.h:92
msgid "_Description:"
msgstr ""
-#: ../setup/setup.ui.h:91
+#: ../setup/setup.ui.h:93
msgid "_Use your dictionary alone with switching dictionaries"
msgstr ""
-#: ../setup/setup.ui.h:92
+#: ../setup/setup.ui.h:94
msgid "_Embed your dictionary in the system dictionary"
msgstr ""
-#: ../setup/setup.ui.h:93
+#: ../setup/setup.ui.h:95
msgid "Enable the _reverse conversion"
msgstr ""
-#: ../setup/setup.ui.h:94
+#: ../setup/setup.ui.h:96
msgid "The Anthy engine for the IBus input platform"
msgstr ""
-#: ../setup/setup.ui.h:95
+#: ../setup/setup.ui.h:97
msgid "translator_credits"
msgstr ""
diff --git a/setup/Makefile.am b/setup/Makefile.am
index e38a141..93ff8af 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -89,6 +89,8 @@ _config.py: _config.py.in
PKGDATADIR=$(pkgdatadir); \
LIBEXECDIR=$(libexecdir); \
DATADIR=$(datadir); \
+ LAYOUT=$(LAYOUT); \
+ SYMBOL_CHAR_INT=$(SYMBOL_CHAR_INT); \
s=`cat $<`; \
eval "echo \"$${s}\""; \
) > $@
diff --git a/setup/anthyprefs.py.in b/setup/anthyprefs.py.in
index 9028ef5..ba89330 100644
--- a/setup/anthyprefs.py.in
+++ b/setup/anthyprefs.py.in
@@ -242,6 +242,13 @@ _config = {
'dict_admin_command': ['@KASUMI_EXEC_FILE@', 'kasumi'],
'add_word_command': ['@KASUMI_EXEC_FILE@', 'kasumi', '-a'],
'dict_config_icon': '@KASUMI_ICON_FILE@',
+ 'keyboard_layouts': [
+ 'default', 'jp', 'us',
+ # XKB options requires ibus 1.5.
+ 'jp[ctrl:swapcaps]', 'us[ctrl:swapcaps]',
+ 'jp[ctrl:swapcaps,compose:rctrl]',
+ 'us[ctrl:swapcaps,compose:rctrl]',
+ ],
},
'romaji_typing_rule': {
diff --git a/setup/ibus-setup-anthy.desktop.in.in b/setup/ibus-setup-anthy.desktop.in.in
index 87e7338..1dd35f9 100644
--- a/setup/ibus-setup-anthy.desktop.in.in
+++ b/setup/ibus-setup-anthy.desktop.in.in
@@ -2,7 +2,7 @@
_Name=IBus Anthy Setup
_Comment=Set up IBus Anthy engine
Exec=@libexecdir@/ibus-setup-anthy
-Icon=@pkgdatadir@/icons/ibus-anthy.png
+Icon=ibus-anthy
NoDisplay=true
Type=Application
StartupNotify=true
diff --git a/setup/main.py b/setup/main.py
index 663db1b..2dd9152 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -34,6 +34,7 @@ except:
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import GObject
from gi.repository import Pango
from gi.repository import IBus
@@ -144,6 +145,14 @@ class AnthySetup(object):
ls.append([k, l_to_s(self.prefs.get_value(sec, k))])
tv.set_model(ls)
+ self.__keymap = None
+ treeview = self.__builder.get_object('keymap:treeview_custom_table')
+ treeview.append_column(Gtk.TreeViewColumn('',
+ Gtk.CellRendererText(),
+ text=0))
+ GObject.idle_add(self.__update_keymap_label,
+ priority = GObject.PRIORITY_LOW)
+
self.__thumb_kb_layout_mode = builder.get_object('thumb:keyboard_layout_mode')
self.__thumb_kb_layout = builder.get_object('thumb:keyboard_layout')
self.__set_thumb_kb_label()
@@ -820,6 +829,91 @@ class AnthySetup(object):
active = l.get_value(iter, id)
renderer.set_property('active', active)
+ def __get_engine_file(self):
+ user_config = path.join(self.__get_userhome(), '.config',
+ 'ibus-anthy', 'engines.xml')
+ system_config = path.join(config.PKGDATADIR, 'engine', 'default.xml')
+ engine_file = None
+ for f in [user_config, system_config]:
+ if path.exists(f):
+ engine_file = f
+ break
+ if engine_file == None:
+ self.__run_message_dialog(_("The engine xml file does not exist: ") + system_config,
+ Gtk.MessageType.ERROR)
+ return None
+ return engine_file
+
+ def __get_keymap(self):
+ engine_file = self.__get_engine_file()
+ if engine_file == None:
+ return None
+
+ import xml.dom.minidom
+ dom = xml.dom.minidom.parse(engine_file)
+ keymap = dom.getElementsByTagName('layout')[0].childNodes[0].data
+ if type(keymap) == unicode:
+ keymap = str(keymap)
+ return keymap
+
+ def __save_keymap(self):
+ engine_file = self.__get_engine_file()
+ if engine_file == None:
+ return None
+
+ import xml.dom.minidom
+ dom = xml.dom.minidom.parse(engine_file)
+ node = dom.getElementsByTagName('layout')[0].childNodes[0]
+ node.data = self.__keymap
+ node = dom.getElementsByTagName('symbol')[0].childNodes[0]
+ # unicode will causes UnicodeEncodeError in write stream.
+ if type(node.data) == unicode:
+ node.data = node.data.encode('utf-8')
+
+ user_config = path.join(self.__get_userhome(), '.config',
+ 'ibus-anthy', 'engines.xml')
+ dir = path.dirname(user_config)
+ if not path.exists(dir):
+ os.makedirs(dir, 0700)
+ f = open(user_config, 'w')
+ dom.writexml(f, '', '', '', 'utf-8')
+ f.close()
+ os.chmod(user_config, 0600)
+ self.__keymap = None
+ self.__run_message_dialog(_("Anthy keyboard layout is changed. "
+ "Please restart ibus to reload the layout."))
+
+ def __update_keymap_label(self):
+ prefs = self.prefs
+ keymap = self.__get_keymap()
+ if keymap == None:
+ return
+ self.__keymap = keymap
+ keymap_list = prefs.get_value('common', 'keyboard_layouts')
+ if keymap != None and not keymap in keymap_list:
+ keymap_list.append(keymap)
+ index = -1
+ if keymap != None:
+ index = keymap_list.index(keymap)
+ model = Gtk.ListStore(str)
+ for k in keymap_list:
+ if k == 'default':
+ k = _("Default")
+ model.append([k])
+ treeview = self.__builder.get_object('keymap:treeview_custom_table')
+ treeview.set_model(model)
+ if index >= 0:
+ iter = model.get_iter(index)
+ treeview.get_selection().select_iter(iter)
+ treeview.get_selection().connect_after('changed',
+ self.on_selection_keymap_changed,
+ 0)
+
+ def __save_preferences(self):
+ self.prefs.commit_all()
+ if self.__keymap != None:
+ self.__save_keymap()
+
def on_selection_changed(self, widget, id):
set_sensitive = lambda a, b: self.__builder.get_object(a).set_sensitive(b)
flg = True if widget.get_selected()[1] else False
@@ -830,6 +924,16 @@ class AnthySetup(object):
button = self.__builder.get_object('button_remove_custom_key')
button.set_sensitive(True)
+ def on_selection_keymap_changed(self, widget, id):
+ ls, it = widget.get_selected()
+ keymap = ls[it][0]
+ if keymap == _("Default"):
+ keymap = 'default'
+ if self.__keymap == keymap:
+ return
+ self.__keymap = keymap
+ self.__builder.get_object('btn_apply').set_sensitive(True)
+
def on_main_delete(self, widget, event):
self.on_btn_cancel_clicked(widget)
return True
@@ -846,7 +950,7 @@ class AnthySetup(object):
id = dlg.run()
dlg.hide()
if id == Gtk.ResponseType.YES:
- self.prefs.commit_all()
+ self.__save_preferences()
Gtk.main_quit()
return True
@@ -866,7 +970,7 @@ class AnthySetup(object):
return True
def on_btn_apply_clicked(self, widget):
- self.prefs.commit_all()
+ self.__save_preferences()
widget.set_sensitive(False)
def on_cb_changed(self, widget):
diff --git a/setup/setup.ui b/setup/setup.ui
index 229403d..670df85 100644
--- a/setup/setup.ui
+++ b/setup/setup.ui
@@ -1022,6 +1022,98 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame33">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment33">
+ <property name="visible">True</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">8</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox33">
+ <property name="visible">True</property>
+ <property name="border_width">4</property>
+ <property name="spacing">4</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkTable" id="table33">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">8</property>
+ <property name="row_spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label322">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Keyboad _layout:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">keymap:treeview_custom_table</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <!-- The fill need to be True so that
+ GtkTable do not have extra space
+ in y axis. -->
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow320">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">1</property>
+ <property name="width_request">240</property>
+ <property name="height_request">140</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="keymap:treeview_custom_table">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label321">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Keyboard layout&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <!-- The fill need to be True so that
+ GtkTable do not have extra space
+ in y axis. -->
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
<child type="tab">