import signal
import glob
import ibus
+import locale
+
+locale.setlocale(locale.LC_ALL, "")
+LANG = locale.getlocale()[0], locale.getlocale()[0].split("_")[0]
IBUS_DATAROOTDIR = os.getenv("IBUS_DATAROOTDIR")
class Engine(ibus.Object):
- def __init__(self, name, lang = "other", icon = "", author = "", credits = "", _exec = "", pid = 0):
+ def __init__(self, name, local_name, lang = "other", icon = "", author = "", credits = "", _exec = "", pid = 0):
super(Engine, self).__init__()
self.name = name
+ self.local_name = local_name
self.lang = lang
self.icon = icon
self.author = author
self._exec == o._exec
def __str__(self):
- return "Engine('%s', '%s', '%s', '%s', '%s', '%s', %d" % (self.name, self.lang, \
+ return "Engine('%s', '%s', '%s', '%s', '%s', '%s', '%s', %d" % (self.name, self.local_name, self.lang, \
self.icon, self.author, \
self.credits, self._exec, \
self.pid)
def list_engines(self):
engines = []
for key, e in self.__engines.items():
- engines.append((e.name, e.lang, e.icon, e.author, e.credits, e._exec, e.pid != 0))
+ engines.append((e.name, e.local_name, e.lang, e.icon, e.author, e.credits, e._exec, e.pid != 0))
return engines
def reload_engines(self):
def __load_engine(self, _file):
f = file(_file)
name = None
+ local_name = None
lang = "other"
icon = ""
author = ""
n, v = l.split("=")
if n == "Name":
name = v
+ if local_name == None:
+ local_name = name
+ elif n.startswith("Name."):
+ if n[5:] in LANG:
+ local_name = v
elif n == "Lang":
lang = v
elif n == "Icon":
if _exec == None:
raise Exception("%s: no exec" % _file)
- return Engine(name, lang, icon, author, credits, _exec)
+ return Engine(name, local_name, lang, icon, author, credits, _exec)
if __name__ == "__main__":
import time
(
DATA_NAME,
+ DATA_LOCAL_NAME,
DATA_LANG,
DATA_ICON,
DATA_AUTHOR,
DATA_EXEC,
DATA_STARTED,
DATA_PRELOAD
-) = range(8)
+) = range(9)
CONFIG_GENERAL_SHORTCUT = "/general/keyboard_shortcut_%s"
CONFIG_PRELOAD_ENGINES = "/general/preload_engines"
buttons = gtk.BUTTONS_CLOSE,
message_format = str(e))
dlg.run()
+ dlg.destroy()
+ self.__flush_gtk_events()
return
else:
try:
buttons = gtk.BUTTONS_CLOSE,
message_format = str(e))
dlg.run()
+ dlg.destroy()
+ self.__flush_gtk_events()
return
data[DATA_STARTED] = not data[DATA_STARTED]
langs = dict()
- for name, lang, icon, author, credits, _exec, started in self.__bus.register_list_engines():
+ for name, local_name, lang, icon, author, credits, _exec, started in self.__bus.register_list_engines():
_lang = ibus.LANGUAGES.get(lang, "other")
_lang = _(_lang)
if _lang not in langs:
langs[_lang] = list()
- langs[_lang].append([name, lang, icon, author, credits, _exec, started])
+ langs[_lang].append([name, local_name, lang, icon, author, credits, _exec, started])
keys = langs.keys()
keys.sort()
COLUMN_DATA, None)
langs[key].sort()
- for name, lang, icon, author, credits, _exec, started in langs[key]:
+ for name, local_name, lang, icon, author, credits, _exec, started in langs[key]:
child_iter = model.append(iter)
is_preload = "%s:%s" % (lang, name) in self.__preload_engines
pixbuf = pixbuf_missing
model.set(child_iter,
- COLUMN_NAME, name,
+ COLUMN_NAME, local_name,
COLUMN_ENABLE, started,
COLUMN_PRELOAD, is_preload,
COLUMN_VISIBLE, True,
COLUMN_ICON, pixbuf,
COLUMN_DATA,
- [name, lang, icon, author, credits, _exec, started, is_preload])
+ [name, local_name, lang, icon, author, credits, _exec, started, is_preload])
return model
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.4 on Thu Aug 21 13:47:06 2008 -->
+<!--Generated with glade3 3.4.4 on Fri Aug 22 11:28:43 2008 -->
<glade-interface>
<widget class="GtkDialog" id="dialog_setup">
<property name="border_width">5</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
+ <property name="spacing">2</property>
<child>
<widget class="GtkCheckButton" id="checkbutton_auto_start">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">3</property>
<child>
- <widget class="GtkButton" id="button_prev_engine">
+ <widget class="GtkLabel" id="label7">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">...</property>
- <property name="response_id">0</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Trigger:</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkButton" id="button_next_engine">
+ <widget class="GtkEntry" id="entry_trigger">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">...</property>
- <property name="response_id">0</property>
+ <property name="editable">False</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="entry_prev_engine">
+ <widget class="GtkLabel" id="label8">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Next engine:</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="entry_next_engine">
+ <widget class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Previous engine:</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label9">
+ <widget class="GtkEntry" id="entry_next_engine">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Previous engine:</property>
- <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
</widget>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label8">
+ <widget class="GtkEntry" id="entry_prev_engine">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Next engine:</property>
- <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
</widget>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="entry_trigger">
+ <widget class="GtkButton" id="button_next_engine">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="response_id">0</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>
<property name="y_padding">4</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label7">
+ <widget class="GtkButton" id="button_prev_engine">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Trigger:</property>
- <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="response_id">0</property>
</widget>
<packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">4</property>