Permalink
Browse files

Add version property in IBusEngineDesc.

  • Loading branch information...
1 parent afdb7f6 commit cf5de7501e28fe929ff86d9b1d7689e15bc1cc4a @fujiwarat fujiwarat committed Oct 20, 2012
Showing with 55 additions and 1 deletion.
  1. +11 −1 ibus/enginedesc.py
  2. +33 −0 src/ibusenginedesc.c
  3. +11 −0 src/ibusenginedesc.h
View
@@ -34,7 +34,8 @@ class EngineDesc(Serializable):
def __init__(self, name="", longname="", description="", language="",
license="", author="", icon="", layout="us", hotkeys="",
rank=0, symbol="", setup="",
- layout_variant="", layout_option=""):
+ layout_variant="", layout_option="",
+ version=""):
super(EngineDesc, self).__init__()
self.__name = name
self.__longname = longname
@@ -50,6 +51,7 @@ def __init__(self, name="", longname="", description="", language="",
self.__hotkeys = hotkeys
self.__symbol = symbol
self.__setup = setup
+ self.__version = version
def get_name(self):
return self.__name
@@ -93,6 +95,9 @@ def get_symbol(self):
def get_setup(self):
return self.__setup
+ def get_version(self):
+ return self.__version
+
name = property(get_name)
longname = property(get_longname)
description = property(get_description)
@@ -107,6 +112,7 @@ def get_setup(self):
hotkeys = property(get_hotkeys)
symbol = property(get_symbol)
setup = property(get_setup)
+ version = property(get_version)
def serialize(self, struct):
super(EngineDesc, self).serialize(struct)
@@ -125,6 +131,7 @@ def serialize(self, struct):
struct.append(dbus.String(self.__setup))
struct.append(dbus.String(self.__layout_variant))
struct.append(dbus.String(self.__layout_option))
+ struct.append(dbus.String(self.__version))
def deserialize(self, struct):
super(EngineDesc, self).deserialize(struct)
@@ -145,6 +152,9 @@ def deserialize(self, struct):
return
self.__layout_variant = struct.pop(0)
self.__layout_option = struct.pop(0)
+ if len(struct) < 1:
+ return
+ self.__version = struct.pop(0)
def test():
engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "", "")
View
@@ -43,6 +43,7 @@ enum {
PROP_HOTKEYS,
PROP_SYMBOL,
PROP_SETUP,
+ PROP_VERSION,
};
@@ -62,6 +63,7 @@ struct _IBusEngineDescPrivate {
gchar *hotkeys;
gchar *symbol;
gchar *setup;
+ gchar *version;
};
#define IBUS_ENGINE_DESC_GET_PRIVATE(o) \
@@ -292,6 +294,19 @@ ibus_engine_desc_class_init (IBusEngineDescClass *class)
"The exec lists of the engine setup command",
"",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * IBusEngineDesc:version:
+ *
+ * The version number of engine description
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VERSION,
+ g_param_spec_string ("version",
+ "version number",
+ "The version number of engine description",
+ "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -313,6 +328,7 @@ ibus_engine_desc_init (IBusEngineDesc *desc)
desc->priv->hotkeys = NULL;
desc->priv->symbol = NULL;
desc->priv->setup = NULL;
+ desc->priv->version = NULL;
}
static void
@@ -331,6 +347,7 @@ ibus_engine_desc_destroy (IBusEngineDesc *desc)
g_free (desc->priv->hotkeys);
g_free (desc->priv->symbol);
g_free (desc->priv->setup);
+ g_free (desc->priv->version);
IBUS_OBJECT_CLASS (ibus_engine_desc_parent_class)->destroy (IBUS_OBJECT (desc));
}
@@ -397,6 +414,10 @@ ibus_engine_desc_set_property (IBusEngineDesc *desc,
g_assert (desc->priv->setup == NULL);
desc->priv->setup = g_value_dup_string (value);
break;
+ case PROP_VERSION:
+ g_assert (desc->priv->version == NULL);
+ desc->priv->version = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
}
@@ -451,6 +472,9 @@ ibus_engine_desc_get_property (IBusEngineDesc *desc,
case PROP_SETUP:
g_value_set_string (value, ibus_engine_desc_get_setup (desc));
break;
+ case PROP_VERSION:
+ g_value_set_string (value, ibus_engine_desc_get_version (desc));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
}
@@ -486,6 +510,7 @@ ibus_engine_desc_serialize (IBusEngineDesc *desc,
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->setup));
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->layout_variant));
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->layout_option));
+ g_variant_builder_add (builder, "s", NOTNULL (desc->priv->version));
#undef NOTNULL
return TRUE;
@@ -521,6 +546,9 @@ ibus_engine_desc_deserialize (IBusEngineDesc *desc,
return retval;
g_variant_get_child (variant, retval++, "s", &desc->priv->layout_variant);
g_variant_get_child (variant, retval++, "s", &desc->priv->layout_option);
+ if (g_variant_n_children (variant) < retval + 1)
+ return retval;
+ g_variant_get_child (variant, retval++, "s", &desc->priv->version);
return retval;
}
@@ -549,6 +577,7 @@ ibus_engine_desc_copy (IBusEngineDesc *dest,
dest->priv->hotkeys = g_strdup (src->priv->hotkeys);
dest->priv->symbol = g_strdup (src->priv->symbol);
dest->priv->setup = g_strdup (src->priv->setup);
+ dest->priv->version = g_strdup (src->priv->version);
return TRUE;
}
@@ -590,6 +619,7 @@ ibus_engine_desc_output (IBusEngineDesc *desc,
OUTPUT_ENTRY_1(hotkeys);
OUTPUT_ENTRY_1(symbol);
OUTPUT_ENTRY_1(setup);
+ OUTPUT_ENTRY_1(version);
g_string_append_indent (output, indent + 1);
g_string_append_printf (output, "<rank>%u</rank>\n", desc->priv->rank);
#undef OUTPUT_ENTRY
@@ -627,6 +657,7 @@ ibus_engine_desc_parse_xml_node (IBusEngineDesc *desc,
PARSE_ENTRY_1(hotkeys);
PARSE_ENTRY_1(symbol);
PARSE_ENTRY_1(setup);
+ PARSE_ENTRY_1(version);
#undef PARSE_ENTRY
#undef PARSE_ENTRY_1
if (g_strcmp0 (sub_node->name , "rank") == 0) {
@@ -659,6 +690,7 @@ 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 *)
+IBUS_ENGINE_DESC_GET_PROPERTY (version, const gchar *)
#undef IBUS_ENGINE_DESC_GET_PROPERTY
IBusEngineDesc *
@@ -710,6 +742,7 @@ ibus_engine_desc_new_varargs (const gchar *first_property_name, ...)
g_assert (desc->priv->hotkeys);
g_assert (desc->priv->symbol);
g_assert (desc->priv->setup);
+ g_assert (desc->priv->version);
return desc;
}
View
@@ -92,6 +92,8 @@ typedef struct _IBusEngineDescClass IBusEngineDescClass;
* the front.
* hotkeys: One or more hotkeys for switching to this engine, separated by
* semi-colon.
+ * setup: Exec lists of the engine setup command.
+ * version: Version number of the input method engine.
*/
struct _IBusEngineDesc {
IBusSerializable parent;
@@ -288,6 +290,15 @@ const gchar *ibus_engine_desc_get_symbol (IBusEngineDesc *info);
*/
const gchar *ibus_engine_desc_get_setup (IBusEngineDesc *info);
+/**
+ * ibus_engine_desc_get_version:
+ * @info: An IBusEngineDesc
+ * @returns: version in IBusEngineDesc
+ *
+ * Return the version property in IBusEngineDesc. It should not be freed.
+ */
+const gchar *ibus_engine_desc_get_version (IBusEngineDesc *info);
+
/**
* ibus_engine_desc_output:
* @info: An IBusEngineDesc

0 comments on commit cf5de75

Please sign in to comment.