Skip to content

Instantly share code, notes, and snippets.

@kokutoto
Created October 14, 2010 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokutoto/626026 to your computer and use it in GitHub Desktop.
Save kokutoto/626026 to your computer and use it in GitHub Desktop.
diff -ur ibus-1.2.0.20091215.orig/bus/ibusimpl.c ibus-1.2.0.20091215/bus/ibusimpl.c
--- ibus-1.2.0.20091215.orig/bus/ibusimpl.c 2010-06-22 01:53:33.000000000 +0900
+++ ibus-1.2.0.20091215/bus/ibusimpl.c 2010-06-22 01:48:51.000000000 +0900
@@ -182,6 +182,30 @@
}
static void
+bus_ibus_impl_set_enable (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("enable");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
+}
+
+static void
+bus_ibus_impl_set_disable (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("disable");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
+}
+
+static void
+bus_ibus_impl_set_vi_collaboration (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("vi_collaboration");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
+}
+
+static void
bus_ibus_impl_set_next_engine (BusIBusImpl *ibus,
GValue *value)
{
@@ -330,6 +354,9 @@
{ "general/hotkey", "trigger", bus_ibus_impl_set_trigger },
{ "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine },
{ "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine },
+ { "general/hotkey", "enable", bus_ibus_impl_set_enable },
+ { "general/hotkey", "disable", bus_ibus_impl_set_disable },
+ { "general/hotkey", "vi_collaboration", bus_ibus_impl_set_vi_collaboration },
{ "general", "preload_engines", bus_ibus_impl_set_preload_engines },
{ "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout },
{ NULL, NULL, NULL },
@@ -373,6 +400,9 @@
{ "general/hotkey", "trigger", bus_ibus_impl_set_trigger },
{ "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine },
{ "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine },
+ { "general/hotkey", "enable", bus_ibus_impl_set_enable },
+ { "general/hotkey", "disable", bus_ibus_impl_set_disable },
+ { "general/hotkey", "vi_collaboration", bus_ibus_impl_set_vi_collaboration },
{ "general", "preload_engines", bus_ibus_impl_set_preload_engines },
{ "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout },
{ NULL, NULL, NULL },
diff -ur ibus-1.2.0.20091215.orig/bus/inputcontext.c ibus-1.2.0.20091215/bus/inputcontext.c
--- ibus-1.2.0.20091215.orig/bus/inputcontext.c 2010-06-22 01:53:33.000000000 +0900
+++ ibus-1.2.0.20091215/bus/inputcontext.c 2010-06-22 01:51:21.000000000 +0900
@@ -1931,6 +1931,9 @@
static GQuark trigger;
static GQuark next_factory;
static GQuark prev_factory;
+ static GQuark enable;
+ static GQuark disable;
+ static GQuark vi_collaboration;
GQuark event;
@@ -1949,6 +1952,9 @@
trigger = g_quark_from_static_string ("trigger");
next_factory = g_quark_from_static_string ("next-engine");
prev_factory = g_quark_from_static_string ("prev-engine");
+ enable = g_quark_from_static_string ("enable");
+ disable = g_quark_from_static_string ("disable");
+ vi_collaboration = g_quark_from_static_string ("vi_collaboration");
}
if (context->filter_release){
@@ -2001,6 +2007,24 @@
retval = TRUE;
}
}
+ else if (event == enable){
+ if(!context->enabled){
+ bus_input_context_enable (context);
+ }
+ retval = TRUE;
+ }
+ else if (event == disable){
+ if(context->enabled){
+ bus_input_context_disable (context);
+ }
+ retval = TRUE;
+ }
+ else if (event == vi_collaboration){
+ if(context->enabled){
+ bus_input_context_disable (context);
+ }
+ retval = FALSE;
+ }
if (retval == TRUE) {
/* begine filter release key event */
diff -ur ibus-1.2.0.20091215.orig/ibus/common.py ibus-1.2.0.20091215/ibus/common.py
--- ibus-1.2.0.20091215.orig/ibus/common.py 2010-06-22 01:53:33.000000000 +0900
+++ ibus-1.2.0.20091215/ibus/common.py 2010-06-22 01:52:08.000000000 +0900
@@ -39,9 +39,15 @@
"CONFIG_GENERAL_SHORTCUT_TRIGGER",
"CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE",
"CONFIG_GENERAL_SHORTCUT_PREV_ENGINE",
+ "CONFIG_GENERAL_SHORTCUT_ENABLE",
+ "CONFIG_GENERAL_SHORTCUT_DISABLE",
+ "CONFIG_GENERAL_SHORTCUT_VI_COLLABORATION",
"CONFIG_GENERAL_SHORTCUT_TRIGGER_DEFAULT",
"CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT",
"CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT",
+ "CONFIG_GENERAL_SHORTCUT_ENABLE_DEFAULT",
+ "CONFIG_GENERAL_SHORTCUT_DISABLE_DEFAULT",
+ "CONFIG_GENERAL_SHORTCUT_VI_COLLABORATION_DEFAULT",
"main",
"main_quit",
"main_iteration",
@@ -149,6 +155,12 @@
CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT = []
CONFIG_GENERAL_SHORTCUT_PREV_ENGINE = "/general/keyboard_shortcut_prev_engine"
CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT = []
+CONFIG_GENERAL_SHORTCUT_ENABLE = "/general/keyboard_shortcut_enable"
+CONFIG_GENERAL_SHORTCUT_ENABLE_DEFAULT = []
+CONFIG_GENERAL_SHORTCUT_DISABLE = "/general/keyboard_shortcut_disable"
+CONFIG_GENERAL_SHORTCUT_DISABLE_DEFAULT = []
+CONFIG_GENERAL_SHORTCUT_VI_COLLABORATION = "/general/keyboard_shortcut_vi_collaboration"
+CONFIG_GENERAL_SHORTCUT_VI_COLLABORATION_DEFAULT = []
__mainloop = None
diff -ur ibus-1.2.0.20091215.orig/setup/main.py ibus-1.2.0.20091215/setup/main.py
--- ibus-1.2.0.20091215.orig/setup/main.py 2010-06-22 01:53:33.000000000 +0900
+++ ibus-1.2.0.20091215/setup/main.py 2010-06-22 01:52:58.000000000 +0900
@@ -127,6 +127,39 @@
button.connect("clicked", self.__shortcut_button_clicked_cb,
N_("previous input method"), "general/hotkey", "prev_engine", entry)
+ # enable
+ shortcuts = self.__config.get_value(
+ "general/hotkey", "enable",
+ ibus.CONFIG_GENERAL_SHORTCUT_ENABLE_DEFAULT)
+ button = self.__builder.get_object("button_enable")
+ entry = self.__builder.get_object("entry_enable")
+ entry.set_text("; ".join(shortcuts))
+ entry.set_tooltip_text("\n".join(shortcuts))
+ button.connect("clicked", self.__shortcut_button_clicked_cb,
+ N_("enable"), "general/hotkey", "enable", entry)
+
+ # disable
+ shortcuts = self.__config.get_value(
+ "general/hotkey", "disable",
+ ibus.CONFIG_GENERAL_SHORTCUT_DISABLE_DEFAULT)
+ button = self.__builder.get_object("button_disable")
+ entry = self.__builder.get_object("entry_disable")
+ entry.set_text("; ".join(shortcuts))
+ entry.set_tooltip_text("\n".join(shortcuts))
+ button.connect("clicked", self.__shortcut_button_clicked_cb,
+ N_("disable"), "general/hotkey", "disable", entry)
+
+ # vi_collaboration
+ shortcuts = self.__config.get_value(
+ "general/hotkey", "vi_collaboration",
+ ibus.CONFIG_GENERAL_SHORTCUT_VI_COLLABORATION_DEFAULT)
+ button = self.__builder.get_object("button_vi_collaboration")
+ entry = self.__builder.get_object("entry_vi_collaboration")
+ entry.set_text("; ".join(shortcuts))
+ entry.set_tooltip_text("\n".join(shortcuts))
+ button.connect("clicked", self.__shortcut_button_clicked_cb,
+ N_("vi_collaboration"), "general/hotkey", "vi_collaboration", entry)
+
# lookup table orientation
self.__combobox_lookup_table_orientation = self.__builder.get_object("combobox_lookup_table_orientation")
self.__combobox_lookup_table_orientation.set_active(
diff -ur ibus-1.2.0.20091215.orig/setup/setup.ui ibus-1.2.0.20091215/setup/setup.ui
--- ibus-1.2.0.20091215.orig/setup/setup.ui 2010-06-22 01:53:33.000000000 +0900
+++ ibus-1.2.0.20091215/setup/setup.ui 2010-06-22 01:47:04.000000000 +0900
@@ -73,7 +73,7 @@
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -223,6 +223,153 @@
<property name="bottom_attach">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Enable:</property>
+ </object>
+ <packing>
+ <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="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Disable:</property>
+ </object>
+ <packing>
+ <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>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Vi Collaboration:</property>
+ </object>
+ <packing>
+ <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>
+ <object class="GtkHBox" id="hbox10">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry_enable">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_enable">
+ <property name="label" translatable="yes">...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox11">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry_disable">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_disable">
+ <property name="label" translatable="yes">...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry_vi_collaboration">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_vi_collaboration">
+ <property name="label" translatable="yes">...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@kokutoto
Copy link
Author

iBusの有効/無効に個別のホットキーを割り当てるseparate hotkey patchを作りました(ついでにvi協調機能付き)
http://d.hatena.ne.jp/kokutoto/20100622/p1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment