diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-07 10:15:05 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-07 10:15:05 +0800 |
| commit | 825081a3d719d9816e323325fabb33b0f0f36598 (patch) | |
| tree | 3b86d0a29f7907887b24a60b8142cf9f6c7c0a0b /setup | |
| parent | c93bd8b15a6368ac4aadb17e527f63c9e724f3c4 (diff) | |
| download | ibus-825081a3d719d9816e323325fabb33b0f0f36598.tar.gz ibus-825081a3d719d9816e323325fabb33b0f0f36598.tar.xz ibus-825081a3d719d9816e323325fabb33b0f0f36598.zip | |
Implement auto start ibus.
Diffstat (limited to 'setup')
| -rw-r--r-- | setup/main.py | 27 | ||||
| -rw-r--r-- | setup/setup.glade | 4 |
2 files changed, 28 insertions, 3 deletions
diff --git a/setup/main.py b/setup/main.py index 77a9324..2e11c98 100644 --- a/setup/main.py +++ b/setup/main.py @@ -59,7 +59,7 @@ class Setup(object): def __flush_gtk_events(self): while gtk.events_pending(): gtk.main_iteration() - + def __init__(self): super(Setup, self).__init__() glade.textdomain("ibus") @@ -107,6 +107,9 @@ class Setup(object): self.__dialog = self.__xml.get_widget("dialog_setup") + self.__checkbutton_auto_start = self.__xml.get_widget("checkbutton_auto_start") + self.__checkbutton_auto_start.set_active(self.__is_auto_start()) + self.__checkbutton_auto_start.connect("toggled", self.__checkbutton_auto_start_toggled_cb) self.__tree = self.__xml.get_widget("treeview_engines") self.__preload_engines = set(self.__bus.config_get_value(CONFIG_PRELOAD_ENGINES, [])) model = self.__create_model() @@ -284,6 +287,28 @@ class Setup(object): return model + def __is_auto_start(self): + link_file = path.join(BaseDirectory.xdg_config_home, "autostart/ibus.desktop") + ibus_desktop = path.join(os.getenv("IBUS_PREFIX"), "share/applications/ibus.desktop") + + if not path.exists(link_file): + return False + if not path.islink(link_file): + return False + if path.realpath(link_file) != ibus_desktop: + return False + return True + + def __checkbutton_auto_start_toggled_cb(self, button): + link_file = path.join(BaseDirectory.xdg_config_home, "autostart/ibus.desktop") + ibus_desktop = path.join(os.getenv("IBUS_PREFIX"), "share/applications/ibus.desktop") + # unlink file + try: + os.unlink(link_file) + except: + pass + if self.__checkbutton_auto_start.get_active(): + os.symlink(ibus_desktop, link_file) def run(self): return self.__dialog.run() diff --git a/setup/setup.glade b/setup/setup.glade index 2ea708a..ef05f3d 100644 --- a/setup/setup.glade +++ b/setup/setup.glade @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.4 on Wed Aug 6 22:38:17 2008 --> +<!--Generated with glade3 3.4.4 on Thu Aug 7 09:58:25 2008 --> <glade-interface> <widget class="GtkDialog" id="dialog_setup"> <property name="border_width">5</property> @@ -21,7 +21,7 @@ <widget class="GtkVBox" id="vbox2"> <property name="visible">True</property> <child> - <widget class="GtkCheckButton" id="checkbutton2"> + <widget class="GtkCheckButton" id="checkbutton_auto_start"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Auto start IBus on session login</property> |
