__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
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)
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)
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 \
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)
props = struct.pop(0)
self.__sub_props = deserialize_object(props)
+ self.__symbol = deserialize_object(struct.pop(0))
class PropList(Serializable):
__gtype_name__ = "PYIBusPropList"
PROP_KEY,
PROP_ICON,
PROP_LABEL,
+ PROP_SYMBOL,
PROP_TOOLTIP,
PROP_SENSITIVE,
PROP_VISIBLE,
gchar *key;
gchar *icon;
IBusText *label;
+ IBusText *symbol;
IBusText *tooltip;
gboolean sensitive;
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
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);
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;
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;
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;
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;
}
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;
}
}
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);
}
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;
}
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)
}
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)
{
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));
#error "Only <ibus.h> 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.
* 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
/*
* @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.
*
* <variablelist>
* @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.
/**
* 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,
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.
*/
/**
* 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.
*/