2011-06-29 09:31:10 +00:00
|
|
|
From cf1fa1bc72d6d7ad71e928df1c3aa938069cfd9e Mon Sep 17 00:00:00 2001
|
2011-06-21 08:49:07 +00:00
|
|
|
From: fujiwarat <takao.fujiwara1@gmail.com>
|
2011-06-29 09:31:10 +00:00
|
|
|
Date: Wed, 29 Jun 2011 16:50:51 +0900
|
|
|
|
Subject: [PATCH] Add symbol property in IBusEngineDesc.
|
2011-06-21 08:49:07 +00:00
|
|
|
|
|
|
|
---
|
2011-06-29 09:31:10 +00:00
|
|
|
ibus/enginedesc.py | 15 +++++++++------
|
|
|
|
src/ibusenginedesc.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
|
|
|
src/ibusenginedesc.h | 10 ++++++++++
|
|
|
|
3 files changed, 59 insertions(+), 6 deletions(-)
|
2011-06-21 08:49:07 +00:00
|
|
|
|
2011-06-22 03:38:34 +00:00
|
|
|
diff --git a/ibus/enginedesc.py b/ibus/enginedesc.py
|
2011-06-29 09:31:10 +00:00
|
|
|
index e8a8982..3ca7f24 100644
|
2011-06-22 03:38:34 +00:00
|
|
|
--- a/ibus/enginedesc.py
|
|
|
|
+++ b/ibus/enginedesc.py
|
|
|
|
@@ -31,7 +31,7 @@ from serializable import *
|
|
|
|
class EngineDesc(Serializable):
|
|
|
|
__gtype_name__ = "PYIBusEngineDesc"
|
|
|
|
__NAME__ = "IBusEngineDesc"
|
|
|
|
- def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0):
|
2011-06-29 09:31:10 +00:00
|
|
|
+ def __init__(self, name="", longname="", description="", language="", license="", author="", icon="", layout="", hotkeys="", rank=0, symbol=""):
|
2011-06-22 03:38:34 +00:00
|
|
|
super(EngineDesc, self).__init__()
|
|
|
|
self.__name = name
|
|
|
|
self.__longname = longname
|
|
|
|
@@ -43,6 +43,7 @@ class EngineDesc(Serializable):
|
|
|
|
self.__layout = layout
|
|
|
|
self.__rank = rank
|
|
|
|
self.__hotkeys = hotkeys
|
2011-06-29 09:31:10 +00:00
|
|
|
+ self.__symbol = symbol
|
2011-06-22 03:38:34 +00:00
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return self.__name
|
|
|
|
@@ -74,6 +75,9 @@ class EngineDesc(Serializable):
|
|
|
|
def get_hotkeys(self):
|
|
|
|
return self.__hotkeys
|
|
|
|
|
2011-06-29 09:31:10 +00:00
|
|
|
+ def get_symbol(self):
|
|
|
|
+ return self.__symbol
|
2011-06-22 03:38:34 +00:00
|
|
|
+
|
|
|
|
name = property(get_name)
|
|
|
|
longname = property(get_longname)
|
|
|
|
description = property(get_description)
|
|
|
|
@@ -84,6 +88,7 @@ class EngineDesc(Serializable):
|
|
|
|
layout = property(get_layout)
|
|
|
|
rank = property(get_rank)
|
|
|
|
hotkeys = property(get_hotkeys)
|
2011-06-29 09:31:10 +00:00
|
|
|
+ symbol = property(get_symbol)
|
2011-06-22 03:38:34 +00:00
|
|
|
|
|
|
|
def serialize(self, struct):
|
|
|
|
super(EngineDesc, self).serialize(struct)
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -97,8 +102,7 @@ class EngineDesc(Serializable):
|
|
|
|
struct.append(dbus.String(self.__layout))
|
2011-06-22 03:38:34 +00:00
|
|
|
struct.append(dbus.UInt32(self.__rank))
|
|
|
|
struct.append(dbus.String(self.__hotkeys))
|
2011-06-29 09:31:10 +00:00
|
|
|
- # New properties of EngineDesc will use dict for serialize
|
2011-06-22 03:38:34 +00:00
|
|
|
- struct.append(dbus.Array({}, signature=None))
|
2011-06-29 09:31:10 +00:00
|
|
|
+ struct.append(dbus.String(self.__symbol))
|
2011-06-22 03:38:34 +00:00
|
|
|
|
|
|
|
def deserialize(self, struct):
|
|
|
|
super(EngineDesc, self).deserialize(struct)
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -112,11 +116,10 @@ class EngineDesc(Serializable):
|
|
|
|
self.__layout = struct.pop(0)
|
2011-06-22 03:38:34 +00:00
|
|
|
self.__rank = struct.pop(0)
|
|
|
|
self.__hotkeys = struct.pop(0)
|
2011-06-29 09:31:10 +00:00
|
|
|
- # New properties of EngineDesc will use dict for serialize
|
2011-06-22 03:38:34 +00:00
|
|
|
- #value = struct.pop(0)
|
2011-06-29 09:31:10 +00:00
|
|
|
+ self.__symbol = struct.pop(0)
|
2011-06-22 03:38:34 +00:00
|
|
|
|
|
|
|
def test():
|
|
|
|
- engine = EngineDesc("Hello", "", "", "", "", "", "", "", "")
|
|
|
|
+ engine = EngineDesc("Hello", "", "", "", "", "", "", "", "", 0, "")
|
|
|
|
value = serialize_object(engine)
|
|
|
|
engine = deserialize_object(value)
|
|
|
|
|
2011-06-21 08:49:07 +00:00
|
|
|
diff --git a/src/ibusenginedesc.c b/src/ibusenginedesc.c
|
2011-06-29 09:31:10 +00:00
|
|
|
index ca5ef60..fa3a768 100644
|
2011-06-21 08:49:07 +00:00
|
|
|
--- a/src/ibusenginedesc.c
|
|
|
|
+++ b/src/ibusenginedesc.c
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -39,6 +39,7 @@ enum {
|
2011-06-21 08:49:07 +00:00
|
|
|
PROP_LAYOUT,
|
|
|
|
PROP_RANK,
|
|
|
|
PROP_HOTKEYS,
|
2011-06-29 09:31:10 +00:00
|
|
|
+ PROP_SYMBOL,
|
2011-06-21 08:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -54,6 +55,7 @@ struct _IBusEngineDescPrivate {
|
2011-06-21 08:49:07 +00:00
|
|
|
gchar *layout;
|
|
|
|
guint rank;
|
|
|
|
gchar *hotkeys;
|
2011-06-29 09:31:10 +00:00
|
|
|
+ gchar *symbol;
|
2011-06-21 08:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IBUS_ENGINE_DESC_GET_PRIVATE(o) \
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -232,6 +234,19 @@ ibus_engine_desc_class_init (IBusEngineDescClass *class)
|
2011-06-21 08:49:07 +00:00
|
|
|
"The hotkeys of engine description",
|
|
|
|
"",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
+
|
|
|
|
+ /**
|
2011-06-29 09:31:10 +00:00
|
|
|
+ * IBusEngineDesc:symbol:
|
2011-06-21 08:49:07 +00:00
|
|
|
+ *
|
|
|
|
+ * The symbol chars of engine description instead of icon image
|
|
|
|
+ */
|
|
|
|
+ g_object_class_install_property (gobject_class,
|
2011-06-29 09:31:10 +00:00
|
|
|
+ PROP_SYMBOL,
|
|
|
|
+ g_param_spec_string ("symbol",
|
|
|
|
+ "description symbol",
|
2011-06-21 08:49:07 +00:00
|
|
|
+ "The icon symbol chars of engine description",
|
|
|
|
+ "",
|
2011-06-29 09:31:10 +00:00
|
|
|
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-06-21 08:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -249,6 +264,7 @@ ibus_engine_desc_init (IBusEngineDesc *desc)
|
2011-06-21 08:49:07 +00:00
|
|
|
desc->priv->layout = NULL;
|
|
|
|
desc->priv->rank = 0;
|
|
|
|
desc->priv->hotkeys = NULL;
|
2011-06-29 09:31:10 +00:00
|
|
|
+ desc->priv->symbol = NULL;
|
2011-06-21 08:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -263,6 +279,7 @@ ibus_engine_desc_destroy (IBusEngineDesc *desc)
|
2011-06-21 08:49:07 +00:00
|
|
|
g_free (desc->priv->icon);
|
|
|
|
g_free (desc->priv->layout);
|
|
|
|
g_free (desc->priv->hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ g_free (desc->priv->symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
|
|
|
|
IBUS_OBJECT_CLASS (ibus_engine_desc_parent_class)->destroy (IBUS_OBJECT (desc));
|
|
|
|
}
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -313,6 +330,10 @@ ibus_engine_desc_set_property (IBusEngineDesc *desc,
|
2011-06-21 08:49:07 +00:00
|
|
|
g_assert (desc->priv->hotkeys == NULL);
|
|
|
|
desc->priv->hotkeys = g_value_dup_string (value);
|
|
|
|
break;
|
2011-06-29 09:31:10 +00:00
|
|
|
+ case PROP_SYMBOL:
|
|
|
|
+ g_assert (desc->priv->symbol == NULL);
|
|
|
|
+ desc->priv->symbol = g_value_dup_string (value);
|
2011-06-21 08:49:07 +00:00
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
|
|
|
|
}
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -355,6 +376,9 @@ ibus_engine_desc_get_property (IBusEngineDesc *desc,
|
2011-06-21 08:49:07 +00:00
|
|
|
case PROP_HOTKEYS:
|
|
|
|
g_value_set_string (value, ibus_engine_desc_get_hotkeys (desc));
|
|
|
|
break;
|
2011-06-29 09:31:10 +00:00
|
|
|
+ case PROP_SYMBOL:
|
|
|
|
+ g_value_set_string (value, ibus_engine_desc_get_symbol (desc));
|
2011-06-21 08:49:07 +00:00
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (desc, prop_id, pspec);
|
|
|
|
}
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -371,6 +395,10 @@ ibus_engine_desc_serialize (IBusEngineDesc *desc,
|
|
|
|
/* End dict iter */
|
|
|
|
|
|
|
|
#define NOTNULL(s) ((s) != NULL ? (s) : "")
|
|
|
|
+ /* If you will add a new property, you can append it at the end and
|
|
|
|
+ * you should not change the serialized order of name, longname,
|
|
|
|
+ * description, ... because the order is also used in other applications
|
|
|
|
+ * likes ibus-qt. */
|
|
|
|
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->name));
|
|
|
|
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->longname));
|
|
|
|
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->description));
|
|
|
|
@@ -381,7 +409,9 @@ ibus_engine_desc_serialize (IBusEngineDesc *desc,
|
|
|
|
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->layout));
|
2011-06-21 08:49:07 +00:00
|
|
|
g_variant_builder_add (builder, "u", desc->priv->rank);
|
|
|
|
g_variant_builder_add (builder, "s", NOTNULL (desc->priv->hotkeys));
|
2011-06-29 09:31:10 +00:00
|
|
|
+ g_variant_builder_add (builder, "s", NOTNULL (desc->priv->symbol));
|
2011-06-21 08:49:07 +00:00
|
|
|
#undef NOTNULL
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -394,6 +424,10 @@ ibus_engine_desc_deserialize (IBusEngineDesc *desc,
|
|
|
|
retval = IBUS_SERIALIZABLE_CLASS (ibus_engine_desc_parent_class)->deserialize ((IBusSerializable *)desc, variant);
|
|
|
|
g_return_val_if_fail (retval, 0);
|
|
|
|
|
|
|
|
+ /* If you will add a new property, you can append it at the end and
|
|
|
|
+ * you should not change the serialized order of name, longname,
|
|
|
|
+ * description, ... because the order is also used in other applications
|
|
|
|
+ * likes ibus-qt. */
|
|
|
|
g_variant_get_child (variant, retval++, "s", &desc->priv->name);
|
|
|
|
g_variant_get_child (variant, retval++, "s", &desc->priv->longname);
|
|
|
|
g_variant_get_child (variant, retval++, "s", &desc->priv->description);
|
|
|
|
@@ -404,6 +438,7 @@ ibus_engine_desc_deserialize (IBusEngineDesc *desc,
|
|
|
|
g_variant_get_child (variant, retval++, "s", &desc->priv->layout);
|
2011-06-21 08:49:07 +00:00
|
|
|
g_variant_get_child (variant, retval++, "u", &desc->priv->rank);
|
|
|
|
g_variant_get_child (variant, retval++, "s", &desc->priv->hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ g_variant_get_child (variant, retval++, "s", &desc->priv->symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -428,6 +463,7 @@ ibus_engine_desc_copy (IBusEngineDesc *dest,
|
2011-06-21 08:49:07 +00:00
|
|
|
dest->priv->layout = g_strdup (src->priv->layout);
|
|
|
|
dest->priv->rank = src->priv->rank;
|
|
|
|
dest->priv->hotkeys = g_strdup (src->priv->hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ dest->priv->symbol = g_strdup (src->priv->symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -465,6 +501,7 @@ ibus_engine_desc_output (IBusEngineDesc *desc,
|
2011-06-21 08:49:07 +00:00
|
|
|
OUTPUT_ENTRY_1(icon);
|
|
|
|
OUTPUT_ENTRY_1(layout);
|
|
|
|
OUTPUT_ENTRY_1(hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ OUTPUT_ENTRY_1(symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
g_string_append_indent (output, indent + 1);
|
|
|
|
g_string_append_printf (output, "<rank>%u</rank>\n", desc->priv->rank);
|
|
|
|
#undef OUTPUT_ENTRY
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -498,6 +535,7 @@ ibus_engine_desc_parse_xml_node (IBusEngineDesc *desc,
|
2011-06-21 08:49:07 +00:00
|
|
|
PARSE_ENTRY_1(icon);
|
|
|
|
PARSE_ENTRY_1(layout);
|
|
|
|
PARSE_ENTRY_1(hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ PARSE_ENTRY_1(symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
#undef PARSE_ENTRY
|
|
|
|
#undef PARSE_ENTRY_1
|
|
|
|
if (g_strcmp0 (sub_node->name , "rank") == 0) {
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -526,6 +564,7 @@ IBUS_ENGINE_DESC_GET_PROPERTY (icon, const gchar *)
|
2011-06-21 08:49:07 +00:00
|
|
|
IBUS_ENGINE_DESC_GET_PROPERTY (layout, const gchar *)
|
|
|
|
IBUS_ENGINE_DESC_GET_PROPERTY (rank, guint)
|
|
|
|
IBUS_ENGINE_DESC_GET_PROPERTY (hotkeys, const gchar *)
|
2011-06-29 09:31:10 +00:00
|
|
|
+IBUS_ENGINE_DESC_GET_PROPERTY (symbol, const gchar *)
|
2011-06-21 08:49:07 +00:00
|
|
|
#undef IBUS_ENGINE_DESC_GET_PROPERTY
|
|
|
|
|
|
|
|
IBusEngineDesc *
|
2011-06-29 09:31:10 +00:00
|
|
|
@@ -573,6 +612,7 @@ ibus_engine_desc_new_varargs (const gchar *first_property_name, ...)
|
2011-06-21 08:49:07 +00:00
|
|
|
g_assert (desc->priv->icon);
|
|
|
|
g_assert (desc->priv->layout);
|
|
|
|
g_assert (desc->priv->hotkeys);
|
2011-06-29 09:31:10 +00:00
|
|
|
+ g_assert (desc->priv->symbol);
|
2011-06-21 08:49:07 +00:00
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
diff --git a/src/ibusenginedesc.h b/src/ibusenginedesc.h
|
2011-06-29 09:31:10 +00:00
|
|
|
index 9718b15..76a7adc 100644
|
2011-06-21 08:49:07 +00:00
|
|
|
--- a/src/ibusenginedesc.h
|
|
|
|
+++ b/src/ibusenginedesc.h
|
|
|
|
@@ -249,6 +249,16 @@ guint ibus_engine_desc_get_rank (IBusEngineDesc *info);
|
|
|
|
const gchar *ibus_engine_desc_get_hotkeys (IBusEngineDesc *info);
|
|
|
|
|
|
|
|
/**
|
2011-06-29 09:31:10 +00:00
|
|
|
+ * ibus_engine_desc_get_symbol:
|
2011-06-21 08:49:07 +00:00
|
|
|
+ * @info: An IBusEngineDesc
|
2011-06-29 09:31:10 +00:00
|
|
|
+ * @returns: symbol property in IBusEngineDesc
|
2011-06-21 08:49:07 +00:00
|
|
|
+ *
|
2011-06-29 09:31:10 +00:00
|
|
|
+ * Return the symbol property in IBusEngineDesc. It should not be freed.
|
2011-06-21 08:49:07 +00:00
|
|
|
+ */
|
2011-06-29 09:31:10 +00:00
|
|
|
+const gchar *ibus_engine_desc_get_symbol
|
2011-06-21 08:49:07 +00:00
|
|
|
+ (IBusEngineDesc *info);
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
* ibus_engine_desc_output:
|
|
|
|
* @info: An IBusEngineDesc
|
|
|
|
* @output: XML-formatted Input method engine description.
|
|
|
|
--
|
2011-06-29 09:31:10 +00:00
|
|
|
1.7.5.4
|
2011-06-21 08:49:07 +00:00
|
|
|
|