summaryrefslogtreecommitdiffstats
path: root/setup
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-08-21 08:18:48 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-08-21 08:18:48 +0800
commit3e6fc7dde3feda5c11d67b15be3c765e15f1ea2d (patch)
tree535725b10a1f0bc6c01ad8ec59543b2733a1d79b /setup
parentfeef446a21ea0e701de13d301dbe64877a91e79c (diff)
downloadibus-3e6fc7dde3feda5c11d67b15be3c765e15f1ea2d.tar.gz
ibus-3e6fc7dde3feda5c11d67b15be3c765e15f1ea2d.tar.xz
ibus-3e6fc7dde3feda5c11d67b15be3c765e15f1ea2d.zip
WIP.
Diffstat (limited to 'setup')
-rw-r--r--setup/keyboardshortcut.py9
-rw-r--r--setup/main.py28
-rw-r--r--setup/setup.glade5
3 files changed, 38 insertions, 4 deletions
diff --git a/setup/keyboardshortcut.py b/setup/keyboardshortcut.py
index 621f17b..eeca766 100644
--- a/setup/keyboardshortcut.py
+++ b/setup/keyboardshortcut.py
@@ -124,7 +124,7 @@ class KeyboardShortcutSelection(gtk.VBox):
model.clear()
for shortcut in shortcuts:
model.insert(0, (shortcut,))
- self.__shortcut_view.set_model(model)
+ # self.__shortcut_view.set_model(model)
def get_shortcuts(self):
model = self.__shortcut_view.get_model()
@@ -188,13 +188,15 @@ class KeyboardShortcutSelection(gtk.VBox):
shortcut = self.__get_shortcut_from_buttons()
selected_shortcut = self.__get_selected_shortcut()
self.__add_button.set_sensitive(shortcut != None)
- self.__apply_button.set_sensitive(shortcut != selected_shortcut and shortcut != None and selected_shortcut != None)
+ can_apply = shortcut != selected_shortcut and shortcut != None and selected_shortcut != None
+ self.__apply_button.set_sensitive(can_apply)
def __keycode_entry_notify_cb(self, entry, arg):
shortcut = self.__get_shortcut_from_buttons()
selected_shortcut = self.__get_selected_shortcut()
self.__add_button.set_sensitive(shortcut != None)
- self.__apply_button.set_sensitive(shortcut != selected_shortcut and shortcut != None and selected_shortcut != None)
+ can_apply = shortcut != selected_shortcut and shortcut != None and selected_shortcut != None
+ self.__apply_button.set_sensitive(can_apply)
def __keycode_button_clicked_cb(self, button):
out = []
@@ -256,6 +258,7 @@ if __name__ == "__main__":
title = "Select test",
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
dlg.add_shortcut("Ctrl+Shift+space")
+ dlg.set_shortcuts(None)
print dlg.run()
print dlg.get_shortcuts()
diff --git a/setup/main.py b/setup/main.py
index 9e7f4e2..9b0315b 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -28,6 +28,7 @@ import gtk
import gobject
import ibus
from gtk import gdk, glade
+import keyboardshortcut
from gettext import dgettext
_ = lambda a : dgettext("ibus", a)
@@ -53,6 +54,7 @@ N_ = lambda a : a
DATA_PRELOAD
) = range(8)
+CONFIG_GENERAL_SHORTCUT = "/general/keyboard_shortcut_%s"
CONFIG_PRELOAD_ENGINES = "/general/preload_engines"
CONFIG_PANEL_LOOKUP_TABLE_ORIENTATION = "/panel/lookup_table_orientation"
@@ -85,6 +87,14 @@ class Setup(object):
self.__checkbutton_auto_start.set_active(self.__is_auto_start())
self.__checkbutton_auto_start.connect("toggled", self.__checkbutton_auto_start_toggled_cb)
+ # keyboard shortcut
+ for name in (N_("trigger"), N_("next_engine"), N_("prev_engine")):
+ shortcuts = self.__bus.config_get_value(CONFIG_GENERAL_SHORTCUT % name, [])
+ button = self.__xml.get_widget("button_%s" % name)
+ entry = self.__xml.get_widget("entry_%s" % name)
+ entry.set_text(";".join(shortcuts))
+ button.connect("clicked", self.__shortcut_button_clicked_cb, name, entry)
+
# lookup table orientation
self.__combobox_lookup_table_orientation = self.__xml.get_widget("combobox_lookup_table_orientation")
self.__combobox_lookup_table_orientation.set_active(
@@ -181,6 +191,24 @@ class Setup(object):
column = gtk.TreeViewColumn("", renderer)
self.__tree.append_column(column)
+ def __shortcut_button_clicked_cb(self, button, name, entry):
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)
+ title = _("Select keyboart shortcut for %s") % _(name)
+ dialog = keyboardshortcut.KeyboardShortcutSelectionDialog(buttons = buttons, title = title)
+ text = entry.get_text()
+ if text:
+ shortcuts = text.split(';')
+ else:
+ shortcuts = None
+ dialog.set_shortcuts(shortcuts)
+ id = dialog.run()
+ shortcuts = dialog.get_shortcuts()
+ dialog.destroy()
+ if id != gtk.RESPONSE_OK:
+ return
+ self.__bus.config_set_value(CONFIG_GENERAL_SHORTCUT % name, shortcuts)
+ entry.set_text(";".join(shortcuts))
+
def __item_started_column_toggled_cb(self, cell, path_str, model):
diff --git a/setup/setup.glade b/setup/setup.glade
index 1744a5d..79294cd 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 Thu Aug 21 07:12:36 2008 -->
+<!--Generated with glade3 3.4.4 on Thu Aug 21 07:52:13 2008 -->
<glade-interface>
<widget class="GtkDialog" id="dialog_setup">
<property name="border_width">5</property>
@@ -66,6 +66,7 @@
<widget class="GtkEntry" id="entry_trigger">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="editable">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -128,6 +129,7 @@
<widget class="GtkEntry" id="entry_next_engine">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="editable">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -143,6 +145,7 @@
<widget class="GtkEntry" id="entry_prev_engine">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="editable">False</property>
</widget>
<packing>
<property name="left_attach">1</property>