1 Index: ibus/enginedesc.py
2 diff --git a/ibus/enginedesc.py b/ibus/enginedesc.py
3 index 3ca7f2484cc406e92a80663e16a88f3e9763bb26..055a3a0d7587bd7b4f9a8ce2c6f0bdfe3fa2153e 100644
4 --- a/ibus/enginedesc.py
5 +++ b/ibus/enginedesc.py
6 @@ -31,7 +31,7 @@ from serializable import *
7 class EngineDesc(Serializable):
8 __gtype_name__ = "PYIBusEngineDesc"
9 __NAME__ = "IBusEngineDesc"
10 - def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0, symbol=""):
11 + def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0, symbol="", setup=""):
12 super(EngineDesc, self).__init__()
14 self.__longname = longname
15 @@ -44,6 +44,7 @@ class EngineDesc(Serializable):
17 self.__hotkeys = hotkeys
18 self.__symbol = symbol
19 + self.__setup = setup
23 @@ -78,6 +79,9 @@ class EngineDesc(Serializable):
27 + def get_setup(self):
30 name = property(get_name)
31 longname = property(get_longname)
32 description = property(get_description)
33 @@ -89,6 +93,7 @@ class EngineDesc(Serializable):
34 rank = property(get_rank)
35 hotkeys = property(get_hotkeys)
36 symbol = property(get_symbol)
37 + setup = property(get_setup)
39 def serialize(self, struct):
40 super(EngineDesc, self).serialize(struct)
41 @@ -103,6 +108,7 @@ class EngineDesc(Serializable):
42 struct.append(dbus.UInt32(self.__rank))
43 struct.append(dbus.String(self.__hotkeys))
44 struct.append(dbus.String(self.__symbol))
45 + struct.append(dbus.String(self.__setup))
47 def deserialize(self, struct):
48 super(EngineDesc, self).deserialize(struct)
49 @@ -117,9 +123,10 @@ class EngineDesc(Serializable):
50 self.__rank = struct.pop(0)
51 self.__hotkeys = struct.pop(0)
52 self.__symbol = struct.pop(0)
53 + self.__setup = struct.pop(0)
56 - engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "")
57 + engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "", "")
58 value = serialize_object(engine)
59 engine = deserialize_object(value)
61 Index: setup/ibus-setup.in
62 diff --git a/setup/ibus-setup.in b/setup/ibus-setup.in
63 index 72bc1a4f2282ec9a016fea8be2332ad96a53b8eb..f3c37309bce8a828ef422230b679af693f87ff80 100644
64 --- a/setup/ibus-setup.in
65 +++ b/setup/ibus-setup.in
68 exec_prefix=@exec_prefix@
69 datarootdir=@datarootdir@
70 +libexecdir=@libexecdir@
71 export IBUS_PREFIX=@prefix@
72 export IBUS_DATAROOTDIR=@datarootdir@
73 export IBUS_LOCALEDIR=@localedir@
74 +export IBUS_LIBEXECDIR=${libexecdir}
75 exec @PYTHON@ @prefix@/share/ibus/setup/main.py $@
78 diff --git a/setup/main.py b/setup/main.py
79 index a22bb0c3ef87464044e329aed3af415087ce4b6b..6c0fb0e086f1088129f54c585a89313d65ebfb97 100644
82 @@ -238,6 +238,10 @@ class Setup(object):
83 button = self.__builder.get_object("button_engine_about")
84 button.connect("clicked", self.__button_engine_about_cb)
86 + self.__engine_setup_exec_list = {}
87 + button = self.__builder.get_object("button_engine_preferences")
88 + button.connect("clicked", self.__button_engine_preferences_cb)
90 self.__combobox.connect("notify::active-engine", self.__combobox_notify_active_engine_cb)
91 self.__treeview.connect("notify", self.__treeview_notify_cb)
93 @@ -246,6 +250,24 @@ class Setup(object):
94 button = self.__builder.get_object("button_engine_add")
95 button.set_sensitive(engine != None and engine not in self.__treeview.get_engines())
97 + def __get_engine_setup_exec_args(self, engine):
101 + setup = str(engine.setup)
102 + if len(setup) != 0:
103 + args = setup.split()
104 + args.insert(1, path.basename(args[0]))
106 + name = str(engine.name)
107 + libexecdir = os.environ['IBUS_LIBEXECDIR']
108 + setup_path = (libexecdir + '/' + 'ibus-setup-' if libexecdir != None \
109 + else 'ibus-setup-') + name.split(':')[0]
110 + if path.exists(setup_path):
111 + args.append(setup_path)
112 + args.append(path.basename(setup_path))
115 def __treeview_notify_cb(self, treeview, property):
116 if property.name != "active-engine" and property.name != "engines":
118 @@ -258,6 +280,12 @@ class Setup(object):
119 self.__builder.get_object("button_engine_up").set_sensitive(engine not in engines[:1])
120 self.__builder.get_object("button_engine_down").set_sensitive(engine not in engines[-1:])
122 + obj = self.__builder.get_object("button_engine_preferences")
123 + if len(self.__get_engine_setup_exec_args(engine)) != 0:
124 + obj.set_sensitive(True)
126 + obj.set_sensitive(False)
128 if property.name == "engines":
129 engine_names = map(lambda e: e.name, engines)
130 self.__config.set_list("general", "preload_engines", engine_names, "s")
131 @@ -273,6 +301,24 @@ class Setup(object):
135 + def __button_engine_preferences_cb(self, button):
136 + engine = self.__treeview.get_active_engine()
137 + args = self.__get_engine_setup_exec_args(engine)
141 + if name in self.__engine_setup_exec_list.keys():
143 + wpid, sts = os.waitpid(self.__engine_setup_exec_list[name],
145 + # the setup is still running.
150 + del self.__engine_setup_exec_list[name]
151 + self.__engine_setup_exec_list[name] = os.spawnl(os.P_NOWAIT, *args)
153 def __init_bus(self):
155 self.__bus = ibus.Bus()
156 Index: setup/setup.ui
157 diff --git a/setup/setup.ui b/setup/setup.ui
158 index 0a69df8c1e093786de434709feb49eeeab18a34c..c7ff564097e65239103167ac6851e409d30ab0d6 100644
162 <property name="position">4</property>
166 + <object class="GtkButton" id="button_engine_preferences">
167 + <property name="label">gtk-preferences</property>
168 + <property name="visible">True</property>
169 + <property name="sensitive">False</property>
170 + <property name="can_focus">True</property>
171 + <property name="receives_default">True</property>
172 + <property name="tooltip_text" translatable="yes">Show setup of the selected input method</property>
173 + <property name="use_stock">True</property>
176 + <property name="expand">False</property>
177 + <property name="fill">False</property>
178 + <property name="position">5</property>
184 Index: src/ibusenginedesc.c
185 diff --git a/src/ibusenginedesc.c b/src/ibusenginedesc.c
186 index fa3a76820f15fae68d6b3fb8f9ed21b906fbe371..48ecb07d6baf5c3d8b47dd6929d766ca757e31a0 100644
187 --- a/src/ibusenginedesc.c
188 +++ b/src/ibusenginedesc.c
189 @@ -40,6 +40,7 @@ enum {
197 @@ -56,6 +57,7 @@ struct _IBusEngineDescPrivate {
204 #define IBUS_ENGINE_DESC_GET_PRIVATE(o) \
205 @@ -247,6 +249,19 @@ ibus_engine_desc_class_init (IBusEngineDescClass *class)
206 "The icon symbol chars of engine description",
208 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
211 + * IBusEngineDesc:setup:
213 + * The exec lists of the engine setup command
215 + g_object_class_install_property (gobject_class,
217 + g_param_spec_string ("setup",
219 + "The exec lists of the engine setup command",
221 + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
225 @@ -265,6 +280,7 @@ ibus_engine_desc_init (IBusEngineDesc *desc)
226 desc->priv->rank = 0;
227 desc->priv->hotkeys = NULL;
228 desc->priv->symbol = NULL;
229 + desc->priv->setup = NULL;
233 @@ -280,6 +296,7 @@ ibus_engine_desc_destroy (IBusEngineDesc *desc)
234 g_free (desc->priv->layout);
235 g_free (desc->priv->hotkeys);
236 g_free (desc->priv->symbol);
237 + g_free (desc->priv->setup);
239 IBUS_OBJECT_CLASS (ibus_engine_desc_parent_class)->destroy (IBUS_OBJECT (desc));
241 @@ -334,6 +351,10 @@ ibus_engine_desc_set_property (IBusEngineDesc *desc,
242 g_assert (desc->priv->symbol == NULL);
243 desc->priv->symbol = g_value_dup_string (value);
246 + g_assert (desc->priv->setup == NULL);
247 + desc->priv->setup = g_value_dup_string (value);
250 G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
252 @@ -379,6 +400,9 @@ ibus_engine_desc_get_property (IBusEngineDesc *desc,
254 g_value_set_string (value, ibus_engine_desc_get_symbol (desc));
257 + g_value_set_string (value, ibus_engine_desc_get_setup (desc));
260 G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
262 @@ -410,6 +434,7 @@ ibus_engine_desc_serialize (IBusEngineDesc *desc,
263 g_variant_builder_add (builder, "u", desc->priv->rank);
264 g_variant_builder_add (builder, "s", NOTNULL (desc->priv->hotkeys));
265 g_variant_builder_add (builder, "s", NOTNULL (desc->priv->symbol));
266 + g_variant_builder_add (builder, "s", NOTNULL (desc->priv->setup));
270 @@ -439,6 +464,7 @@ ibus_engine_desc_deserialize (IBusEngineDesc *desc,
271 g_variant_get_child (variant, retval++, "u", &desc->priv->rank);
272 g_variant_get_child (variant, retval++, "s", &desc->priv->hotkeys);
273 g_variant_get_child (variant, retval++, "s", &desc->priv->symbol);
274 + g_variant_get_child (variant, retval++, "s", &desc->priv->setup);
278 @@ -464,6 +490,7 @@ ibus_engine_desc_copy (IBusEngineDesc *dest,
279 dest->priv->rank = src->priv->rank;
280 dest->priv->hotkeys = g_strdup (src->priv->hotkeys);
281 dest->priv->symbol = g_strdup (src->priv->symbol);
282 + dest->priv->setup = g_strdup (src->priv->setup);
286 @@ -502,6 +529,7 @@ ibus_engine_desc_output (IBusEngineDesc *desc,
287 OUTPUT_ENTRY_1(layout);
288 OUTPUT_ENTRY_1(hotkeys);
289 OUTPUT_ENTRY_1(symbol);
290 + OUTPUT_ENTRY_1(setup);
291 g_string_append_indent (output, indent + 1);
292 g_string_append_printf (output, "<rank>%u</rank>\n", desc->priv->rank);
294 @@ -536,6 +564,7 @@ ibus_engine_desc_parse_xml_node (IBusEngineDesc *desc,
295 PARSE_ENTRY_1(layout);
296 PARSE_ENTRY_1(hotkeys);
297 PARSE_ENTRY_1(symbol);
298 + PARSE_ENTRY_1(setup);
301 if (g_strcmp0 (sub_node->name , "rank") == 0) {
302 @@ -565,6 +594,7 @@ IBUS_ENGINE_DESC_GET_PROPERTY (layout, const gchar *)
303 IBUS_ENGINE_DESC_GET_PROPERTY (rank, guint)
304 IBUS_ENGINE_DESC_GET_PROPERTY (hotkeys, const gchar *)
305 IBUS_ENGINE_DESC_GET_PROPERTY (symbol, const gchar *)
306 +IBUS_ENGINE_DESC_GET_PROPERTY (setup, const gchar *)
307 #undef IBUS_ENGINE_DESC_GET_PROPERTY
310 @@ -613,6 +643,7 @@ ibus_engine_desc_new_varargs (const gchar *first_property_name, ...)
311 g_assert (desc->priv->layout);
312 g_assert (desc->priv->hotkeys);
313 g_assert (desc->priv->symbol);
314 + g_assert (desc->priv->setup);
318 Index: src/ibusenginedesc.h
319 diff --git a/src/ibusenginedesc.h b/src/ibusenginedesc.h
320 index 76a7adcf09cb43977ba388eb83b9944e730833ee..928743e863dfc0d6c1fa853d6907bbda5cb76856 100644
321 --- a/src/ibusenginedesc.h
322 +++ b/src/ibusenginedesc.h
323 @@ -255,8 +255,16 @@ const gchar *ibus_engine_desc_get_hotkeys (IBusEngineDesc *info);
325 * Return the symbol property in IBusEngineDesc. It should not be freed.
327 -const gchar *ibus_engine_desc_get_symbol
328 - (IBusEngineDesc *info);
329 +const gchar *ibus_engine_desc_get_symbol (IBusEngineDesc *info);
332 + * ibus_engine_desc_get_setup:
333 + * @info: An IBusEngineDesc
334 + * @returns: setup property in IBusEngineDesc
336 + * Return the setup property in IBusEngineDesc. It should not be freed.
338 +const gchar *ibus_engine_desc_get_setup (IBusEngineDesc *info);
341 * ibus_engine_desc_output: