class EngineDesc(Serializable):
__gtype_name__ = "PYIBusEngineDesc"
__NAME__ = "IBusEngineDesc"
- def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0, symbol=""):
+ def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0, symbol="", setup=""):
super(EngineDesc, self).__init__()
self.__name = name
self.__longname = longname
self.__rank = rank
self.__hotkeys = hotkeys
self.__symbol = symbol
+ self.__setup = setup
def get_name(self):
return self.__name
def get_symbol(self):
return self.__symbol
+ def get_setup(self):
+ return self.__setup
+
name = property(get_name)
longname = property(get_longname)
description = property(get_description)
rank = property(get_rank)
hotkeys = property(get_hotkeys)
symbol = property(get_symbol)
+ setup = property(get_setup)
def serialize(self, struct):
super(EngineDesc, self).serialize(struct)
struct.append(dbus.UInt32(self.__rank))
struct.append(dbus.String(self.__hotkeys))
struct.append(dbus.String(self.__symbol))
+ struct.append(dbus.String(self.__setup))
def deserialize(self, struct):
super(EngineDesc, self).deserialize(struct)
self.__rank = struct.pop(0)
self.__hotkeys = struct.pop(0)
self.__symbol = struct.pop(0)
+ self.__setup = struct.pop(0)
def test():
- engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "")
+ engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "", "")
value = serialize_object(engine)
engine = deserialize_object(value)
prefix=@prefix@
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
+libexecdir=@libexecdir@
export IBUS_PREFIX=@prefix@
export IBUS_DATAROOTDIR=@datarootdir@
export IBUS_LOCALEDIR=@localedir@
+export IBUS_LIBEXECDIR=${libexecdir}
exec @PYTHON@ @prefix@/share/ibus/setup/main.py $@
button = self.__builder.get_object("button_engine_about")
button.connect("clicked", self.__button_engine_about_cb)
+ self.__engine_setup_exec_list = {}
+ button = self.__builder.get_object("button_engine_preferences")
+ button.connect("clicked", self.__button_engine_preferences_cb)
+
self.__combobox.connect("notify::active-engine", self.__combobox_notify_active_engine_cb)
self.__treeview.connect("notify", self.__treeview_notify_cb)
button = self.__builder.get_object("button_engine_add")
button.set_sensitive(engine != None and engine not in self.__treeview.get_engines())
+ def __get_engine_setup_exec_args(self, engine):
+ args = []
+ if engine == None:
+ return args
+ setup = str(engine.setup)
+ if len(setup) != 0:
+ args = setup.split()
+ args.insert(1, path.basename(args[0]))
+ return args
+ name = str(engine.name)
+ libexecdir = os.environ['IBUS_LIBEXECDIR']
+ setup_path = (libexecdir + '/' + 'ibus-setup-' if libexecdir != None \
+ else 'ibus-setup-') + name.split(':')[0]
+ if path.exists(setup_path):
+ args.append(setup_path)
+ args.append(path.basename(setup_path))
+ return args
+
def __treeview_notify_cb(self, treeview, property):
if property.name != "active-engine" and property.name != "engines":
return
self.__builder.get_object("button_engine_up").set_sensitive(engine not in engines[:1])
self.__builder.get_object("button_engine_down").set_sensitive(engine not in engines[-1:])
+ obj = self.__builder.get_object("button_engine_preferences")
+ if len(self.__get_engine_setup_exec_args(engine)) != 0:
+ obj.set_sensitive(True)
+ else:
+ obj.set_sensitive(False)
+
if property.name == "engines":
engine_names = map(lambda e: e.name, engines)
self.__config.set_list("general", "preload_engines", engine_names, "s")
about.run()
about.destroy()
+ def __button_engine_preferences_cb(self, button):
+ engine = self.__treeview.get_active_engine()
+ args = self.__get_engine_setup_exec_args(engine)
+ if len(args) == 0:
+ return
+ name = engine.name
+ if name in self.__engine_setup_exec_list.keys():
+ try:
+ wpid, sts = os.waitpid(self.__engine_setup_exec_list[name],
+ os.WNOHANG)
+ # the setup is still running.
+ if wpid == 0:
+ return
+ except OSError:
+ pass
+ del self.__engine_setup_exec_list[name]
+ self.__engine_setup_exec_list[name] = os.spawnl(os.P_NOWAIT, *args)
+
def __init_bus(self):
try:
self.__bus = ibus.Bus()
<property name="position">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="button_engine_preferences">
+ <property name="label">gtk-preferences</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Show setup of the selected input method</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
</object>
</child>
</object>
PROP_RANK,
PROP_HOTKEYS,
PROP_SYMBOL,
+ PROP_SETUP,
};
guint rank;
gchar *hotkeys;
gchar *symbol;
+ gchar *setup;
};
#define IBUS_ENGINE_DESC_GET_PRIVATE(o) \
"The icon symbol chars of engine description",
"",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * IBusEngineDesc:setup:
+ *
+ * The exec lists of the engine setup command
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_SETUP,
+ g_param_spec_string ("setup",
+ "setup args",
+ "The exec lists of the engine setup command",
+ "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
desc->priv->rank = 0;
desc->priv->hotkeys = NULL;
desc->priv->symbol = NULL;
+ desc->priv->setup = NULL;
}
static void
g_free (desc->priv->layout);
g_free (desc->priv->hotkeys);
g_free (desc->priv->symbol);
+ g_free (desc->priv->setup);
IBUS_OBJECT_CLASS (ibus_engine_desc_parent_class)->destroy (IBUS_OBJECT (desc));
}
g_assert (desc->priv->symbol == NULL);
desc->priv->symbol = g_value_dup_string (value);
break;
+ case PROP_SETUP:
+ g_assert (desc->priv->setup == NULL);
+ desc->priv->setup = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
}
case PROP_SYMBOL:
g_value_set_string (value, ibus_engine_desc_get_symbol (desc));
break;
+ case PROP_SETUP:
+ g_value_set_string (value, ibus_engine_desc_get_setup (desc));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
}
g_variant_builder_add (builder, "u", desc->priv->rank);
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->hotkeys));
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->symbol));
+ g_variant_builder_add (builder, "s", NOTNULL (desc->priv->setup));
#undef NOTNULL
return TRUE;
g_variant_get_child (variant, retval++, "u", &desc->priv->rank);
g_variant_get_child (variant, retval++, "s", &desc->priv->hotkeys);
g_variant_get_child (variant, retval++, "s", &desc->priv->symbol);
+ g_variant_get_child (variant, retval++, "s", &desc->priv->setup);
return retval;
}
dest->priv->rank = src->priv->rank;
dest->priv->hotkeys = g_strdup (src->priv->hotkeys);
dest->priv->symbol = g_strdup (src->priv->symbol);
+ dest->priv->setup = g_strdup (src->priv->setup);
return TRUE;
}
OUTPUT_ENTRY_1(layout);
OUTPUT_ENTRY_1(hotkeys);
OUTPUT_ENTRY_1(symbol);
+ OUTPUT_ENTRY_1(setup);
g_string_append_indent (output, indent + 1);
g_string_append_printf (output, "<rank>%u</rank>\n", desc->priv->rank);
#undef OUTPUT_ENTRY
PARSE_ENTRY_1(layout);
PARSE_ENTRY_1(hotkeys);
PARSE_ENTRY_1(symbol);
+ PARSE_ENTRY_1(setup);
#undef PARSE_ENTRY
#undef PARSE_ENTRY_1
if (g_strcmp0 (sub_node->name , "rank") == 0) {
IBUS_ENGINE_DESC_GET_PROPERTY (rank, guint)
IBUS_ENGINE_DESC_GET_PROPERTY (hotkeys, const gchar *)
IBUS_ENGINE_DESC_GET_PROPERTY (symbol, const gchar *)
+IBUS_ENGINE_DESC_GET_PROPERTY (setup, const gchar *)
#undef IBUS_ENGINE_DESC_GET_PROPERTY
IBusEngineDesc *
g_assert (desc->priv->layout);
g_assert (desc->priv->hotkeys);
g_assert (desc->priv->symbol);
+ g_assert (desc->priv->setup);
return desc;
}
*
* Return the symbol property in IBusEngineDesc. It should not be freed.
*/
-const gchar *ibus_engine_desc_get_symbol
- (IBusEngineDesc *info);
+const gchar *ibus_engine_desc_get_symbol (IBusEngineDesc *info);
+
+/**
+ * ibus_engine_desc_get_setup:
+ * @info: An IBusEngineDesc
+ * @returns: setup property in IBusEngineDesc
+ *
+ * Return the setup property in IBusEngineDesc. It should not be freed.
+ */
+const gchar *ibus_engine_desc_get_setup (IBusEngineDesc *info);
/**
* ibus_engine_desc_output: