diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-06 23:03:14 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-06 23:03:14 +0800 |
| commit | 1a8fcb322556d258ee3323d062ebd467dce9ff97 (patch) | |
| tree | 9f8210e89d6d860b54d4dd6fc2c444d6fcb04e0d /setup | |
| parent | 91fe33f5bea02a6b6fa68c37e88cc8cfd55997cc (diff) | |
| download | ibus-1a8fcb322556d258ee3323d062ebd467dce9ff97.tar.gz ibus-1a8fcb322556d258ee3323d062ebd467dce9ff97.tar.xz ibus-1a8fcb322556d258ee3323d062ebd467dce9ff97.zip | |
Add start ibus code.
Diffstat (limited to 'setup')
| -rw-r--r-- | setup/main.py | 29 | ||||
| -rw-r--r-- | setup/setup.glade | 32 |
2 files changed, 32 insertions, 29 deletions
diff --git a/setup/main.py b/setup/main.py index f161366..22041cb 100644 --- a/setup/main.py +++ b/setup/main.py @@ -19,8 +19,11 @@ # Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA +import os import sys from os import path +import time +from xdg import BaseDirectory import gtk import gobject import ibus @@ -58,17 +61,29 @@ class Setup(object): glade.textdomain("ibus") glade_file = path.join(path.dirname(__file__), "./setup.glade") self.__xml = glade.XML(glade_file) + self.__bus = None try: self.__bus = ibus.Bus() except: - message = _("Can not connect to ibus-daemon! Please start ibus-daemon.") - print >> sys.stderr, message - dlg = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, - buttons=gtk.BUTTONS_OK, + while self.__bus == None: + message = _("IBus daemon is not started.\nDo you want to start it now?") + print >> sys.stderr, message + dlg = gtk.MessageDialog(type = gtk.MESSAGE_QUESTION, + buttons = gtk.BUTTONS_YES_NO, message_format = message) - dlg.run() - dlg.destroy() - sys.exit(1) + id = dlg.run() + dlg.destroy() + while gtk.events_pending(): + gtk.main_iteration() + if id != gtk.RESPONSE_YES: + sys.exit(0) + pid = os.spawnlp(os.P_NOWAIT, "ibus", "ibus") + print pid + time.sleep(1) + try: + self.__bus = ibus.Bus() + except: + continue # add icon search path icon_theme = gtk.icon_theme_get_default() diff --git a/setup/setup.glade b/setup/setup.glade index c5d3d0c..2ea708a 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 Tue Aug 5 18:27:24 2008 --> +<!--Generated with glade3 3.4.4 on Wed Aug 6 22:38:17 2008 --> <glade-interface> <widget class="GtkDialog" id="dialog_setup"> <property name="border_width">5</property> @@ -20,36 +20,24 @@ <child> <widget class="GtkVBox" id="vbox2"> <property name="visible">True</property> - <property name="homogeneous">True</property> <child> - <widget class="GtkCheckButton" id="checkbutton1"> + <widget class="GtkCheckButton" id="checkbutton2"> + <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Enable IBus</property> + <property name="label" translatable="yes">Auto start IBus on session login</property> <property name="response_id">0</property> <property name="draw_indicator">True</property> </widget> - </child> - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </widget> <packing> - <property name="position">1</property> + <property name="expand">False</property> + <property name="fill">False</property> </packing> </child> <child> - <widget class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="position">2</property> - </packing> + <placeholder/> + </child> + <child> + <placeholder/> </child> </widget> </child> |
