import gobject
import ibus
from gtk import gdk, glade
-import dbus.mainloop.glib
(
NAME_COLUMN,
class Setup(object):
def __init__(self):
super(Setup, self).__init__()
- self._conn = ibus.Connection()
- self._ibus = self._conn.get_ibus()
+ try:
+ self.__ibus = ibus.IBus()
+ except:
+ self.__ibus = None
+
glade_file = path.join(path.dirname(__file__), "./setup.glade")
- self._xml = glade.XML(glade_file)
- self._dialog = self._xml.get_widget("dialog_setup")
- self._tree = self._xml.get_widget("treeview_engines")
+ self.__xml = glade.XML(glade_file)
+ self.__dialog = self.__xml.get_widget("dialog_setup")
+ self.__tree = self.__xml.get_widget("treeview_engines")
model = self.__create_model()
- self._tree.set_model(model)
+ self.__tree.set_model(model)
# add icon search path
icon_theme = gtk.icon_theme_get_default()
column.pack_start(renderer)
column.set_attributes(renderer, text = NAME_COLUMN)
- self._tree.append_column(column)
+ self.__tree.append_column(column)
# column for holiday names
renderer = gtk.CellRendererToggle()
column.set_clickable(True)
column.set_resizable(False)
column.set_fixed_width(50)
- self._tree.append_column(column)
-
+ self.__tree.append_column(column)
- def _init_ui(self):
- model = self.__create_model()
def __item_toggled_cb(self, cell, path_str, model):
# do something with the value
if data[6] == False:
try:
- self._ibus.RegisterStartEngine(data[1], data[0])
+ self.__ibus.register_start_engine(data[1], data[0])
except Exception, e:
dlg = gtk.MessageDialog(type = gtk.MESSAGE_ERROR,
buttons = gtk.BUTTONS_CLOSE,
return
else:
try:
- self._ibus.RegisterStopEngine(data[1], data[0])
+ self.__ibus.register_stop_engine(data[1], data[0])
except Exception, e:
dlg = gtk.MessageDialog(type = gtk.MESSAGE_ERROR,
buttons = gtk.BUTTONS_CLOSE,
langs = dict()
- for name, lang, icon, author, credits, _exec, started in self._ibus.RegisterListEngines():
+ for name, lang, icon, author, credits, _exec, started in self.__ibus.register_list_engines():
_lang = ibus.LANGUAGES.get(lang, "other")
if _lang not in langs:
- langs[_lang] = []
+ langs[_lang] = list()
langs[_lang].append([name, lang, icon, author, credits, _exec, started])
keys = langs.keys()
def run(self):
- return self._dialog.run()
+ return self.__dialog.run()
if __name__ == "__main__":
- dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
Setup().run()
<?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 Jul 10 15:52:05 2008 -->
+<!--Generated with glade3 3.4.4 on Mon Jul 28 13:34:26 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="homogeneous">True</property>
<child>
- <placeholder/>
+ <widget class="GtkCheckButton" id="checkbutton1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Enable IBus</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
</child>
<child>
- <placeholder/>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
</child>
</widget>
</child>
<widget class="GtkTreeView" id="treeview_engines">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_clickable">True</property>
<property name="reorderable">True</property>
</widget>
</child>