updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / ibus-3beol / 00_2011.11.29.1.issue5437062_4001.patch
blob8fc46de5c42eb8f5c419d6639b2b440e849d578f
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__()
13 self.__name = name
14 self.__longname = longname
15 @@ -44,6 +44,7 @@ class EngineDesc(Serializable):
16 self.__rank = rank
17 self.__hotkeys = hotkeys
18 self.__symbol = symbol
19 + self.__setup = setup
21 def get_name(self):
22 return self.__name
23 @@ -78,6 +79,9 @@ class EngineDesc(Serializable):
24 def get_symbol(self):
25 return self.__symbol
27 + def get_setup(self):
28 + return self.__setup
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)
55 def test():
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
66 @@ -23,8 +23,10 @@
67 prefix=@prefix@
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 $@
77 Index: setup/main.py
78 diff --git a/setup/main.py b/setup/main.py
79 index a22bb0c3ef87464044e329aed3af415087ce4b6b..6c0fb0e086f1088129f54c585a89313d65ebfb97 100644
80 --- a/setup/main.py
81 +++ b/setup/main.py
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):
98 + args = []
99 + if engine == None:
100 + return args
101 + setup = str(engine.setup)
102 + if len(setup) != 0:
103 + args = setup.split()
104 + args.insert(1, path.basename(args[0]))
105 + return args
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))
113 + return args
115 def __treeview_notify_cb(self, treeview, property):
116 if property.name != "active-engine" and property.name != "engines":
117 return
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)
125 + else:
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):
132 about.run()
133 about.destroy()
135 + def __button_engine_preferences_cb(self, button):
136 + engine = self.__treeview.get_active_engine()
137 + args = self.__get_engine_setup_exec_args(engine)
138 + if len(args) == 0:
139 + return
140 + name = engine.name
141 + if name in self.__engine_setup_exec_list.keys():
142 + try:
143 + wpid, sts = os.waitpid(self.__engine_setup_exec_list[name],
144 + os.WNOHANG)
145 + # the setup is still running.
146 + if wpid == 0:
147 + return
148 + except OSError:
149 + pass
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):
154 try:
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
159 --- a/setup/setup.ui
160 +++ b/setup/setup.ui
161 @@ -726,6 +726,22 @@
162 <property name="position">4</property>
163 </packing>
164 </child>
165 + <child>
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>
174 + </object>
175 + <packing>
176 + <property name="expand">False</property>
177 + <property name="fill">False</property>
178 + <property name="position">5</property>
179 + </packing>
180 + </child>
181 </object>
182 </child>
183 </object>
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 {
190 PROP_RANK,
191 PROP_HOTKEYS,
192 PROP_SYMBOL,
193 + PROP_SETUP,
197 @@ -56,6 +57,7 @@ struct _IBusEngineDescPrivate {
198 guint rank;
199 gchar *hotkeys;
200 gchar *symbol;
201 + gchar *setup;
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));
210 + /**
211 + * IBusEngineDesc:setup:
213 + * The exec lists of the engine setup command
214 + */
215 + g_object_class_install_property (gobject_class,
216 + PROP_SETUP,
217 + g_param_spec_string ("setup",
218 + "setup args",
219 + "The exec lists of the engine setup command",
220 + "",
221 + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
224 static void
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;
232 static void
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);
244 break;
245 + case PROP_SETUP:
246 + g_assert (desc->priv->setup == NULL);
247 + desc->priv->setup = g_value_dup_string (value);
248 + break;
249 default:
250 G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
252 @@ -379,6 +400,9 @@ ibus_engine_desc_get_property (IBusEngineDesc *desc,
253 case PROP_SYMBOL:
254 g_value_set_string (value, ibus_engine_desc_get_symbol (desc));
255 break;
256 + case PROP_SETUP:
257 + g_value_set_string (value, ibus_engine_desc_get_setup (desc));
258 + break;
259 default:
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));
267 #undef NOTNULL
269 return TRUE;
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);
276 return retval;
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);
283 return TRUE;
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);
293 #undef OUTPUT_ENTRY
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);
299 #undef PARSE_ENTRY
300 #undef PARSE_ENTRY_1
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
309 IBusEngineDesc *
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);
316 return desc;
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);
331 +/**
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.
337 + */
338 +const gchar *ibus_engine_desc_get_setup (IBusEngineDesc *info);
341 * ibus_engine_desc_output: