From: fujiwarat Date: Fri, 14 Sep 2012 02:24:30 +0000 (+0900) Subject: Add IBusProperty.symbol for the short label. X-Git-Tag: 1.4.99.20121006~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75826b04b90f78e5c1cb94bfd429b5fc88c1de67;p=platform%2Fupstream%2Fibus.git Add IBusProperty.symbol for the short label. IBusProperty.label had been shared between the panel menu label and language-bar button label so the label is too short against the panel menu. Now we redefines IBusProperty.label as the long label and the new IBusProperty.symbol is defined as the short label for the language-bar and the panel status icon. TEST=Manually Review URL: https://codereview.appspot.com/6495117 --- diff --git a/ibus/property.py b/ibus/property.py index a7ea5a9..a4b1865 100644 --- a/ibus/property.py +++ b/ibus/property.py @@ -63,11 +63,13 @@ class Property(Serializable): __gtype_name__ = "PYIBusProperty" __NAME__ = "IBusProperty" def __init__(self, key="", type=PROP_TYPE_NORMAL, label=u"", icon=u"", tooltip=u"", - sensitive=True, visible=True, state=PROP_STATE_UNCHECKED): + sensitive=True, visible=True, state=PROP_STATE_UNCHECKED, + symbol=u""): super(Property, self).__init__() self.__key = _to_unicode(key) self.__type = type self.label = label + self.symbol = symbol self.icon = icon self.tooltip = tooltip self.sensitive = sensitive @@ -93,6 +95,12 @@ class Property(Serializable): def get_label(self): return self.__label + def set_symbol(self, symbol): + self.__symbol = _to_text(symbol) + + def get_symbol(self): + return self.__symbol + def set_icon(self, icon): self.__icon = _to_unicode(icon) @@ -126,6 +134,7 @@ class Property(Serializable): key = property(get_key) type = property(get_type) label = property(get_label, set_label) + symbol = property(get_symbol, set_symbol) icon = property(get_icon, set_icon) tooltip = property(get_tooltip, set_tooltip) state = property(get_state, set_state) @@ -139,6 +148,7 @@ class Property(Serializable): if not test_all: return True if self.__label != prop.__label or \ + self.__symbol != prop.__symbol or \ self.__icon != prop.__icon or \ self.__tooltip != prop.__tooltip or \ self.__sensitive != prop.__sensitive or \ @@ -160,6 +170,7 @@ class Property(Serializable): struct.append(dbus.UInt32(self.__state)) sub_props = serialize_object(self.__sub_props) struct.append(sub_props) + struct.append(serialize_object(self.__symbol)) def deserialize(self, struct): super(Property, self).deserialize(struct) @@ -174,6 +185,7 @@ class Property(Serializable): props = struct.pop(0) self.__sub_props = deserialize_object(props) + self.__symbol = deserialize_object(struct.pop(0)) class PropList(Serializable): __gtype_name__ = "PYIBusPropList" diff --git a/src/ibusproperty.c b/src/ibusproperty.c index e5480fa..a849319 100644 --- a/src/ibusproperty.c +++ b/src/ibusproperty.c @@ -32,6 +32,7 @@ enum { PROP_KEY, PROP_ICON, PROP_LABEL, + PROP_SYMBOL, PROP_TOOLTIP, PROP_SENSITIVE, PROP_VISIBLE, @@ -45,6 +46,7 @@ struct _IBusPropertyPrivate { gchar *key; gchar *icon; IBusText *label; + IBusText *symbol; IBusText *tooltip; gboolean sensitive; @@ -136,6 +138,19 @@ ibus_property_class_init (IBusPropertyClass *class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); /** + * IBusPropert:symbol: + * + * The symbol of property + */ + g_object_class_install_property (gobject_class, + PROP_SYMBOL, + g_param_spec_object("symbol", + "symbol", + "The symbol of property", + IBUS_TYPE_TEXT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + /** * IBusPropert:tooltip: * * The tooltip of property @@ -221,6 +236,7 @@ ibus_property_init (IBusProperty *prop) prop->priv = IBUS_PROPERTY_GET_PRIVATE (prop); ibus_property_set_label (prop, NULL); + ibus_property_set_symbol (prop, NULL); ibus_property_set_tooltip (prop, NULL); ibus_property_set_sub_props (prop, NULL); @@ -242,6 +258,9 @@ ibus_property_set_property (IBusProperty *prop, case PROP_LABEL: ibus_property_set_label (prop, g_value_get_object (value)); break; + case PROP_SYMBOL: + ibus_property_set_symbol (prop, g_value_get_object (value)); + break; case PROP_TOOLTIP: ibus_property_set_tooltip (prop, g_value_get_object (value)); break; @@ -282,6 +301,9 @@ ibus_property_get_property (IBusProperty *prop, case PROP_LABEL: g_value_set_object (value, ibus_property_get_label (prop)); break; + case PROP_SYMBOL: + g_value_set_object (value, ibus_property_get_symbol (prop)); + break; case PROP_TOOLTIP: g_value_set_object (value, ibus_property_get_tooltip (prop)); break; @@ -319,6 +341,11 @@ ibus_property_destroy (IBusProperty *prop) prop->priv->label = NULL; } + if (prop->priv->symbol) { + g_object_unref (prop->priv->symbol); + prop->priv->symbol = NULL; + } + if (prop->priv->tooltip) { g_object_unref (prop->priv->tooltip); prop->priv->tooltip = NULL; @@ -355,6 +382,9 @@ ibus_property_serialize (IBusProperty *prop, g_variant_builder_add (builder, "u", prop->priv->state); g_variant_builder_add (builder, "v", ibus_serializable_serialize ((IBusSerializable *)prop->priv->sub_props)); + /* Keep the serialized order for the compatibility when add new members. */ + g_variant_builder_add (builder, "v", + ibus_serializable_serialize ((IBusSerializable *)prop->priv->symbol)); return TRUE; } @@ -392,6 +422,12 @@ ibus_property_deserialize (IBusProperty *prop, g_object_ref_sink (prop->priv->sub_props); g_variant_unref (subvar); + /* Keep the serialized order for the compatibility when add new members. */ + subvar = g_variant_get_child_value (variant, retval++); + prop->priv->symbol = IBUS_TEXT (ibus_serializable_deserialize (subvar)); + g_object_ref_sink (prop->priv->symbol); + g_variant_unref (subvar); + return retval; } @@ -414,6 +450,11 @@ ibus_property_copy (IBusProperty *dest, } else dest->priv->label = ibus_text_new_from_static_string (""); + if (src->priv->symbol) { + dest->priv->symbol = (IBusText *) ibus_serializable_copy ((IBusSerializable *) src->priv->symbol); + } + else + dest->priv->symbol = ibus_text_new_from_static_string (""); if (src->priv->tooltip) { dest->priv->tooltip = (IBusText *) ibus_serializable_copy ((IBusSerializable *) src->priv->tooltip); } @@ -446,19 +487,36 @@ ibus_property_new (const gchar *key, type <= PROP_TYPE_SEPARATOR, NULL); + return ibus_property_new_varargs ("key", key, + "prop-type", type, + "label", label, + "icon", icon, + "tooltip", tooltip, + "sensitive", sensitive, + "visible", visible, + "state", state, + "sub-props", props, + NULL); +} + +IBusProperty * +ibus_property_new_varargs (const gchar *first_property_name, ...) +{ + va_list var_args; IBusProperty *prop; - prop = (IBusProperty *)g_object_new (IBUS_TYPE_PROPERTY, - "key", key, - "prop-type", type, - "label", label, - "icon", icon, - "tooltip", tooltip, - "sensitive", sensitive, - "visible", visible, - "state", state, - "sub-props", props, - NULL); + g_assert (first_property_name); + + va_start (var_args, first_property_name); + prop = (IBusProperty *) g_object_new_valist (IBUS_TYPE_PROPERTY, + first_property_name, + var_args); + va_end (var_args); + + g_assert (prop->priv->key); + g_assert (prop->priv->type >= PROP_TYPE_NORMAL && + prop->priv->type <= PROP_TYPE_SEPARATOR); + return prop; } @@ -472,6 +530,7 @@ ibus_property_get_ ## field (IBusProperty *prop) \ IBUS_PROPERTY_GET_FIELD (key, const gchar *) IBUS_PROPERTY_GET_FIELD (icon, const gchar *) IBUS_PROPERTY_GET_FIELD (label, IBusText *) +IBUS_PROPERTY_GET_FIELD (symbol, IBusText *) IBUS_PROPERTY_GET_FIELD (tooltip, IBusText *) IBUS_PROPERTY_GET_FIELD (sensitive, gboolean) IBUS_PROPERTY_GET_FIELD (visible, gboolean) @@ -507,6 +566,25 @@ ibus_property_set_label (IBusProperty *prop, } void +ibus_property_set_symbol (IBusProperty *prop, + IBusText *symbol) +{ + g_assert (IBUS_IS_PROPERTY (prop)); + g_return_if_fail (symbol == NULL || IBUS_IS_TEXT (symbol)); + + if (prop->priv->symbol) { + g_object_unref (prop->priv->symbol); + } + + if (symbol == NULL) { + prop->priv->symbol = ibus_text_new_from_static_string (""); + } + else { + prop->priv->symbol = g_object_ref_sink (symbol); + } +} + +void ibus_property_set_icon (IBusProperty *prop, const gchar *icon) { @@ -609,6 +687,7 @@ ibus_property_update (IBusProperty *prop, ibus_property_set_icon (prop, ibus_property_get_icon (prop_update)); ibus_property_set_label (prop, ibus_property_get_label (prop_update)); + ibus_property_set_symbol (prop, ibus_property_get_symbol (prop_update)); ibus_property_set_tooltip (prop, ibus_property_get_tooltip (prop_update)); ibus_property_set_visible (prop, ibus_property_get_visible (prop_update)); ibus_property_set_state (prop, ibus_property_get_state (prop_update)); diff --git a/src/ibusproperty.h b/src/ibusproperty.h index 96b1a13..c826519 100644 --- a/src/ibusproperty.h +++ b/src/ibusproperty.h @@ -24,6 +24,12 @@ #error "Only can be included directly" #endif +#ifndef __IBUS_PROPERTY_H_ +#define __IBUS_PROPERTY_H_ + +#include "ibusserializable.h" +#include "ibustext.h" + /** * SECTION: ibusproperty * @short_description: UI component for input method engine property. @@ -37,14 +43,8 @@ * pressing ctrl-space or click on the Eng/Chi switch button. * And the IBusProperty shows the change correspondingly. * - * @see_also: #IBusPropList, #IBusEngine + * see_also: #IBusPropList, #IBusEngine */ -#ifndef __IBUS_PROPERTY_H_ -#define __IBUS_PROPERTY_H_ - -#include "ibusserializable.h" -#include "ibustext.h" - G_BEGIN_DECLS /* @@ -90,7 +90,7 @@ typedef enum { * @PROP_STATE_INCONSISTENT: The state is inconsistent with the associated IME * property. * - * State of IBusProperty. The actual effect depends on #IBusPropType of the + * State of #IBusProperty. The actual effect depends on #IBusPropType of the * IBusProperty. * * @@ -127,6 +127,7 @@ typedef struct _IBusPropListClass IBusPropListClass; * @key: Unique Identity for the IBusProperty. * @icon: Icon file for the IBusProperty. * @label: Text shown in UI. + * @symbol: A symbol char showned on a button or status icon for IBusProperty. * @tooltip: Message shown if mouse hovered the IBusProperty. * @sensitive: Whether the IBusProperty is sensitive to keyboard and mouse event. * @visible: Whether the IBusProperty is visible. @@ -153,18 +154,18 @@ GType ibus_property_get_type (); /** * ibus_property_new: - * @key: Unique Identity for the IBusProperty. - * @type: IBusPropType of IBusProperty. + * @key: Unique Identity for the #IBusProperty. + * @type: #IBusPropType of #IBusProperty. * @label: Text shown in UI. - * @icon: (allow-none): Icon file for the IBusProperty. - * @tooltip: Message shown if mouse hovered the IBusProperty. - * @sensitive: Whether the IBusProperty is sensitive to keyboard and mouse event. - * @visible: Whether the IBusProperty is visible. - * @state: IBusPropState of IBusProperty. - * @prop_list: (allow-none): IBusPropList that contains sub IBusProperties. - * @returns: A newly allocated IBusProperty. + * @icon: (allow-none): Icon file for the #IBusProperty. + * @tooltip: Message shown if mouse hovered the #IBusProperty. + * @sensitive: Whether the #IBusProperty is sensitive to keyboard and mouse event. + * @visible: Whether the #IBusProperty is visible. + * @state: IBusPropState of #IBusProperty. + * @prop_list: (allow-none): #IBusPropList that contains sub IBusProperties. + * @returns: A newly allocated #IBusProperty. * - * New a IBusProperty. + * New a #IBusProperty. */ IBusProperty *ibus_property_new (const gchar *key, IBusPropType type, @@ -177,151 +178,183 @@ IBusProperty *ibus_property_new (const gchar *key, IBusPropList *prop_list); /** + * ibus_property_new_varargs: + * @first_property_name: Name of the first property. + * @Varargs: the NULL-terminated arguments of the properties and values. + * + * New a #IBusProperty. + * ibus_property_new_varargs() supports the va_list format. + * name property is required. e.g. + * ibus_property_new_varargs("key", "TypingMode", "type", PROP_TYPE_MENU, NULL) + */ +IBusProperty *ibus_property_new_varargs (const gchar *first_property_name, + ...); + +/** * ibus_property_get_key: - * @prop: An IBusProperty. - * @returns: the key of IBusProperty. Should not be freed. + * @prop: An #IBusProperty. + * @returns: the key of #IBusProperty. Should not be freed. * - * Get the key of IBusProperty. + * Get the key of #IBusProperty. */ const gchar * ibus_property_get_key (IBusProperty *prop); /** * ibus_property_get_label: - * @prop: An IBusProperty. - * @returns: (transfer none): the label of IBusProperty. Should not be freed. + * @prop: An #IBusProperty. + * @returns: (transfer none): the label of #IBusProperty. Should not be freed. * - * Get the label of IBusProperty. + * Get the label of #IBusProperty. */ -IBusText * ibus_property_get_label (IBusProperty *prop); +IBusText * ibus_property_get_label (IBusProperty *prop); /** * ibus_property_set_label: - * @prop: An IBusProperty. + * @prop: An #IBusProperty. * @label: Text shown in UI. * - * Set the label of IBusProperty. + * Set the label of #IBusProperty. */ void ibus_property_set_label (IBusProperty *prop, IBusText *label); /** + * ibus_property_get_symbol: + * @prop: An #IBusProperty. + * @returns: (transfer none): the symbol of #IBusProperty. Should not be freed. + * + * Get the symbol of #IBusProperty. + */ +IBusText * ibus_property_get_symbol (IBusProperty *prop); + +/** + * ibus_property_set_symbol: + * @prop: An #IBusProperty. + * @symbol: Text shown in UI. + * + * Set the symbol of #IBusProperty. + */ +void ibus_property_set_symbol (IBusProperty *prop, + IBusText *symbol); + +/** * ibus_property_get_icon: - * @prop: An IBusProperty. - * @returns: the icon of IBusProperty. Should not be freed. + * @prop: An #IBusProperty. + * @returns: the icon of #IBusProperty. Should not be freed. * - * Get the icon of IBusProperty. + * Get the icon of #IBusProperty. */ const gchar * ibus_property_get_icon (IBusProperty *prop); /** * ibus_property_set_icon: - * @prop: An IBusProperty. + * @prop: An #IBusProperty. * @icon: Icon shown in UI. It could be a full path of an icon file or an icon name. * - * Set the icon of IBusProperty. + * Set the icon of #IBusProperty. */ void ibus_property_set_icon (IBusProperty *prop, const gchar *icon); /** * ibus_property_get_tooltip: - * @prop: An IBusProperty. - * @returns: (transfer none): the tooltip of IBusProperty. Should not be freed. + * @prop: An #IBusProperty. + * @returns: (transfer none): the tooltip of #IBusProperty. Should not be freed. * - * Get the tooltip of IBusProperty. + * Get the tooltip of #IBusProperty. */ -IBusText * ibus_property_get_tooltip (IBusProperty *prop); +IBusText * ibus_property_get_tooltip (IBusProperty *prop); /** * ibus_property_set_tooltip: - * @prop: An IBusProperty. + * @prop: An #IBusProperty. * @tooltip: Text of the tooltip. * - * Set the tooltip of IBusProperty. + * Set the tooltip of #IBusProperty. */ void ibus_property_set_tooltip (IBusProperty *prop, IBusText *tooltip); /** * ibus_property_get_sensitive: - * @prop: An IBusProperty. - * @returns: the sensitive of IBusProperty. + * @prop: An #IBusProperty. + * @returns: the sensitive of #IBusProperty. * - * Get the sensitive of IBusProperty. + * Get the sensitive of #IBusProperty. */ gboolean ibus_property_get_sensitive(IBusProperty *prop); /** * ibus_property_set_sensitive: - * @prop: An IBusProperty. - * @sensitive: Whether the IBusProperty is sensitive. + * @prop: An #IBusProperty. + * @sensitive: Whether the #IBusProperty is sensitive. * - * Set whether the IBusProperty is sensitive. + * Set whether the #IBusProperty is sensitive. */ void ibus_property_set_sensitive(IBusProperty *prop, gboolean sensitive); /** * ibus_property_get_visible: - * @prop: An IBusProperty. - * @returns: the visible of IBusProperty. + * @prop: An #IBusProperty. + * @returns: the visible of #IBusProperty. * - * Get the visible of IBusProperty. + * Get the visible of #IBusProperty. */ gboolean ibus_property_get_visible (IBusProperty *prop); /** * ibus_property_set_visible: - * @prop: An IBusProperty. - * @visible: Whether the IBusProperty is visible. + * @prop: An #IBusProperty. + * @visible: Whether the #IBusProperty is visible. * - * Set whether the IBusProperty is visible. + * Set whether the #IBusProperty is visible. */ void ibus_property_set_visible (IBusProperty *prop, gboolean visible); /** * ibus_property_get_property_type: - * @prop: An IBusProperty. - * @returns: the type of IBusProperty. + * @prop: An #IBusProperty. + * @returns: the type of #IBusProperty. * - * Get the type of IBusProperty. + * Get the type of #IBusProperty. */ IBusPropType ibus_property_get_prop_type(IBusProperty *prop); /** * ibus_property_get_state: - * @prop: An IBusProperty. - * @returns: the state of IBusProperty. + * @prop: An #IBusProperty. + * @returns: the state of #IBusProperty. * - * Get the state of IBusProperty. + * Get the state of #IBusProperty. */ IBusPropState ibus_property_get_state (IBusProperty *prop); /** * ibus_property_set_state: - * @prop: An IBusProperty. - * @state: The state of the IBusProperty. + * @prop: An #IBusProperty. + * @state: The state of the #IBusProperty. * - * Set the state of the IBusProperty. + * Set the state of the #IBusProperty. */ void ibus_property_set_state (IBusProperty *prop, IBusPropState state); /** * ibus_property_get_sub_props: - * @prop: An IBusProperty. - * @returns: (transfer none): the IBusPropList of IBusProperty. + * @prop: An #IBusProperty. + * @returns: (transfer none): the IBusPropList of #IBusProperty. * Should not be freed. * - * Get the IBusPropList of IBusProperty. + * Get the IBusPropList of #IBusProperty. */ IBusPropList * ibus_property_get_sub_props(IBusProperty *prop); /** * ibus_property_set_sub_props: - * @prop: An IBusProperty. - * @prop_list: IBusPropList that contains sub IBusProperties. + * @prop: An #IBusProperty. + * @prop_list: #IBusPropList that contains sub IBusProperties. * * Set the sub IBusProperties. */ @@ -330,12 +363,12 @@ void ibus_property_set_sub_props(IBusProperty *prop, /** * ibus_property_update: - * @prop: An IBusProperty. - * @prop_update: IBusPropList that contains sub IBusProperties. + * @prop: An #IBusProperty. + * @prop_update: #IBusPropList that contains sub IBusProperties. * @returns: TRUE for update suceeded; FALSE otherwise. * - * Update the content of an IBusProperty. - * IBusProperty @prop_update can either be sub-property of @prop, + * Update the content of an #IBusProperty. + * #IBusProperty @prop_update can either be sub-property of @prop, * or holds new values for @prop. */