ibus/ibus-xx-no-use.diff

485 lines
27 KiB
Diff

From fdec59545fb94f768c847730854ca03c5af2f652 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Fri, 7 Dec 2012 17:59:49 +0900
Subject: [PATCH] Disabled to show non-used GUI.
---
setup/keyboardshortcut.py | 90 ++++++++++++++++++++++++-----------------------
setup/main.py | 45 +++++++++++++-----------
setup/setup.ui | 51 +++++++++++++++++----------
3 files changed, 103 insertions(+), 83 deletions(-)
diff --git a/setup/keyboardshortcut.py b/setup/keyboardshortcut.py
index 3861d2f..9349e42 100644
--- a/setup/keyboardshortcut.py
+++ b/setup/keyboardshortcut.py
@@ -103,9 +103,8 @@ class KeyboardShortcutSelection(Gtk.VBox):
self.__modifier_buttons.append(("Hyper",
Gtk.CheckButton.new_with_mnemonic("_Hyper"),
Gdk.ModifierType.HYPER_MASK))
- self.__modifier_buttons.append(("Capslock",
- Gtk.CheckButton.new_with_mnemonic("Capsloc_k"),
- Gdk.ModifierType.LOCK_MASK))
+ # <CapsLock> is not parsed by gtk_accelerator_parse()
+ # FIXME: Need to check if ibus gtk panel can enable <Release>.
self.__modifier_buttons.append(("Release",
Gtk.CheckButton.new_with_mnemonic("_Release"),
Gdk.ModifierType.RELEASE_MASK))
@@ -119,7 +118,6 @@ class KeyboardShortcutSelection(Gtk.VBox):
table.attach(self.__modifier_buttons[4][1], 0, 1, 1, 2)
table.attach(self.__modifier_buttons[5][1], 1, 2, 1, 2)
table.attach(self.__modifier_buttons[6][1], 2, 3, 1, 2)
- table.attach(self.__modifier_buttons[7][1], 3, 4, 1, 2)
hbox.pack_start(table, True, True, 4)
self.pack_start(hbox, False, True, 4)
@@ -185,19 +183,20 @@ class KeyboardShortcutSelection(Gtk.VBox):
modifiers.append(name)
if keycode.startswith("_"):
keycode = keycode[1:]
- keys = modifiers + [keycode]
- shortcut = "+".join(keys)
+ shortcut = "".join(map(lambda m: '<' + m + '>', modifiers))
+ shortcut += keycode
return shortcut
def __set_shortcut_to_buttons(self, shortcut):
- keys = shortcut.split("+")
- mods = keys[:-1]
+ (keyval, state) = Gtk.accelerator_parse(shortcut)
+ if keyval == 0 and state == 0:
+ return
for name, button, mask in self.__modifier_buttons:
- if name in mods:
+ if state & mask:
button.set_active(True)
else:
button.set_active(False)
- self.__keycode_entry.set_text(keys[-1])
+ self.__keycode_entry.set_text(shortcut.rsplit('>', 1)[-1])
def __get_selected_shortcut(self):
model = self.__shortcut_view.get_model()
@@ -252,49 +251,52 @@ class KeyboardShortcutSelection(Gtk.VBox):
message = _("Please press a key (or a key combination).\nThe dialog will be closed when the key is released.")
dlg.set_markup(message)
dlg.set_title(_("Please press a key (or a key combination)"))
-
- def __key_press_event(d, k, out):
- out.append(k.copy())
-
- def __key_release_event(d, k, out):
- d.response(Gtk.ResponseType.OK)
-
- dlg.connect("key-press-event", __key_press_event, out)
- dlg.connect("key-release-event", __key_release_event, None)
+ sw = Gtk.ScrolledWindow()
+
+ def __accel_edited_cb(c, path, keyval, state, keycode):
+ out.append(keyval)
+ out.append(state)
+ out.append(keycode)
+ dlg.response(Gtk.ResponseType.OK)
+
+ model = Gtk.ListStore(GObject.TYPE_INT,
+ GObject.TYPE_UINT,
+ GObject.TYPE_UINT)
+ accel_view = Gtk.TreeView(model)
+ sw.add(accel_view)
+ column = Gtk.TreeViewColumn()
+ renderer = Gtk.CellRendererAccel(accel_mode=Gtk.CellRendererAccelMode.OTHER,
+ editable=True)
+ renderer.connect('accel-edited', __accel_edited_cb)
+ column.pack_start(renderer, True)
+ column.add_attribute(renderer, 'accel-mods', 0)
+ column.add_attribute(renderer, 'accel-key', 1)
+ column.add_attribute(renderer, 'keycode', 2)
+ accel_view.append_column(column)
+ it = model.append(None)
+ area = dlg.get_message_area()
+ area.pack_end(sw, True, True, 0)
+ sw.show_all()
id = dlg.run()
dlg.destroy()
- if id != Gtk.ResponseType.OK or not out:
+ if id != Gtk.ResponseType.OK or len(out) < 3:
return
- keyevent = out[len(out) - 1]
- state = keyevent.state & (Gdk.ModifierType.CONTROL_MASK | \
- Gdk.ModifierType.SHIFT_MASK | \
- Gdk.ModifierType.MOD1_MASK | \
- Gdk.ModifierType.META_MASK | \
- Gdk.ModifierType.SUPER_MASK | \
- Gdk.ModifierType.HYPER_MASK)
-
-
- if state == 0:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Control_L, Gdk.KEY_Control_R) and state == Gdk.ModifierType.CONTROL_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Shift_L, Gdk.KEY_Shift_R) and state == Gdk.ModifierType.SHIFT_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Alt_L, Gdk.KEY_Alt_R) and state == Gdk.ModifierType.MOD1_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Meta_L, Gdk.KEY_Meta_R) and state == Gdk.ModifierType.META_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Super_L, Gdk.KEY_Super_R) and state == Gdk.ModifierType.SUPER_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
- elif keyevent.keyval in (Gdk.KEY_Hyper_L, Gdk.KEY_Hyper_R) and state == Gdk.ModifierType.HYPER_MASK:
- state = state | Gdk.ModifierType.RELEASE_MASK
+ keyval = out[0]
+ state = out[1]
+ keycode = out[2]
for name, button, mask in self.__modifier_buttons:
if state & mask:
button.set_active(True)
else:
button.set_active(False)
- self.__keycode_entry.set_text(Gdk.keyval_name(keyevent.keyval))
+
+ shortcut = Gtk.accelerator_name_with_keycode(None,
+ keyval,
+ keycode,
+ state)
+ shortcut = shortcut.replace('<Primary>', '<Control>')
+ self.__keycode_entry.set_text(shortcut.rsplit('>', 1)[-1])
def __add_button_clicked_cb(self, button):
shortcut = self.__get_shortcut_from_buttons()
diff --git a/setup/main.py b/setup/main.py
index 46209b6..aa8e935 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -92,22 +92,24 @@ class Setup(object):
self.__init_ui()
def __init_hotkey(self):
- default_values = {
- "trigger" : (N_("trigger"), ["Control+space"]),
- "enable_unconditional" : (N_("enable"), []),
- "disable_unconditional" : (N_("disable"), [])
- }
-
- values = dict(self.__config.get_values("general/hotkey"))
-
- for name, (label, shortcuts) in default_values.items():
- shortcuts = values.get(name, shortcuts)
- button = self.__builder.get_object("button_%s" % name)
- entry = self.__builder.get_object("entry_%s" % name)
- entry.set_text("; ".join(shortcuts))
- entry.set_tooltip_text("\n".join(shortcuts))
- button.connect("clicked", self.__shortcut_button_clicked_cb,
- label, "general/hotkey", name, entry)
+ name = 'trigger_accel'
+ label = 'switch_engine'
+ variant = self.__config.get_value('general/hotkey', name)
+ if variant != None:
+ shortcuts = variant.unpack()
+ else:
+ shortcuts = ['<Control>space']
+
+ button = self.__builder.get_object("button_%s" % label)
+ entry = self.__builder.get_object("entry_%s" % label)
+ entry.set_text("; ".join(shortcuts))
+ tooltip = "\n".join(shortcuts)
+ tooltip += "\n" + \
+ _("Use shortcut with shift to switch to the previous input method")
+
+ entry.set_tooltip_text(tooltip)
+ button.connect("clicked", self.__shortcut_button_clicked_cb,
+ name, "general/hotkey", label, entry)
def __init_panel(self):
values = dict(self.__config.get_values("panel"))
@@ -449,7 +451,8 @@ class Setup(object):
def __shortcut_button_clicked_cb(self, button, name, section, _name, entry):
buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK)
- title = _("Select keyboard shortcut for %s") % _(name)
+ title = _("Select keyboard shortcut for %s") % \
+ _("switching input methods")
dialog = keyboardshortcut.KeyboardShortcutSelectionDialog(buttons = buttons, title = title)
text = entry.get_text()
if text:
@@ -462,11 +465,13 @@ class Setup(object):
dialog.destroy()
if id != Gtk.ResponseType.OK:
return
- self.__config.set_value(section, _name, GLib.Variant.new_strv(shortcuts))
+ self.__config.set_value(section, name, GLib.Variant.new_strv(shortcuts))
text = "; ".join(shortcuts)
entry.set_text(text)
- entry.set_tooltip_text(text)
-
+ tooltip = "\n".join(shortcuts)
+ tooltip += "\n" + \
+ _("Use shortcut with shift to switch to the previous input method")
+ entry.set_tooltip_text(tooltip)
def __item_started_column_toggled_cb(self, cell, path_str, model):
diff --git a/setup/setup.ui b/setup/setup.ui
index 2026172..aa41453 100644
--- a/setup/setup.ui
+++ b/setup/setup.ui
@@ -121,8 +121,7 @@
</child>
<child>
<object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The shortcut keys for switching to previous input method in the list</property>
<property name="xalign">0</property>
@@ -137,7 +136,7 @@
</child>
<child>
<object class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
@@ -172,6 +171,7 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -180,7 +180,7 @@
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkEntry" id="entry_next_engine">
+ <object class="GtkEntry" id="entry_switch_engine">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
@@ -192,7 +192,7 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="button_next_engine">
+ <object class="GtkButton" id="button_switch_engine">
<property name="label" translatable="yes">...</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
@@ -213,17 +213,17 @@
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox6">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="entry_prev_engine">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
</object>
@@ -237,8 +237,7 @@
<object class="GtkButton" id="button_prev_engine">
<property name="label" translatable="yes">...</property>
<property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
@@ -256,11 +255,12 @@
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The shortcut keys for turning input method on or off</property>
<property name="xalign">0</property>
@@ -273,7 +273,7 @@
</child>
<child>
<object class="GtkLabel" id="label18">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Enable:</property>
@@ -287,7 +287,7 @@
</child>
<child>
<object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
@@ -324,11 +324,12 @@
<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>
</packing>
</child>
<child>
<object class="GtkLabel" id="label19">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disable:</property>
@@ -342,7 +343,7 @@
</child>
<child>
<object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
@@ -379,6 +380,7 @@
<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>
</packing>
</child>
</object>
@@ -431,6 +433,7 @@
</object>
<packing>
<property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -448,11 +451,12 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label10">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Set the behavior of ibus how to show or hide language bar</property>
<property name="xalign">0</property>
@@ -463,6 +467,7 @@
<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>
</packing>
</child>
<child>
@@ -477,11 +482,12 @@
<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>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox_panel_show">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="model">model_panel_show_mode</property>
<child>
@@ -496,6 +502,7 @@
<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>
</packing>
</child>
<child>
@@ -515,6 +522,7 @@
<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>
</packing>
</child>
<child>
@@ -534,13 +542,14 @@
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_show_im_name">
<property name="label" translatable="yes">Show input method name on language bar</property>
<property name="use_action_appearance">False</property>
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Show input method's name on language bar when check the checkbox</property>
@@ -553,6 +562,7 @@
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -572,6 +582,7 @@
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -590,6 +601,7 @@
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -605,6 +617,7 @@
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
@@ -1001,7 +1014,7 @@ You may use up/down buttons to change it.&lt;/i&gt;&lt;/small&gt;</property>
</child>
<child>
<object class="GtkFrame" id="frame5">
- <property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
--
1.8.0