Modified:
trunk/imbus/TODO
trunk/imbus/src/im_event_roles.h
trunk/imbus/src/im_hotkeys.c
trunk/imbus/src/im_hotkeys.h
trunk/imbus/src/im_key_codes.h
trunk/imbus/src/im_lookup_table.c
trunk/imbus/src/im_lookup_table.h
trunk/imbus/src/im_properties.c
trunk/imbus/src/im_properties.h
trunk/imbus/tests/test_byte_stream.c
trunk/imbus/tests/test_text_stream.c
Log:
Get rid off the usage of bitmasks from IMProperty code.
Modified: trunk/imbus/TODO
==============================================================================
--- trunk/imbus/TODO (original)
+++ trunk/imbus/TODO Thu Nov 22 00:54:34 2007
@@ -34,3 +34,12 @@
* Thread safe
* !!! Documentation !!!
+
+
+==============================
+TODO for hotkey profile:
+Add an event to check if a hotkey is conflict with currently registered
+hotkey profiles.
+Add events to add/remove hotkeys from a registered hotkey profile
+
+Reimplement key code as object.
Modified: trunk/imbus/src/im_event_roles.h
==============================================================================
--- trunk/imbus/src/im_event_roles.h (original)
+++ trunk/imbus/src/im_event_roles.h Thu Nov 22 00:54:34 2007
@@ -98,8 +98,8 @@
/**
* @brief Create a new IMEventRoles object.
*
- * Create a new IMEventRoles object, would could the this event role
when you register
- * the component to handle the event into the imbus daemon. In case of
the failure to
+ * Create a new IMEventRoles object, would could the this event role
when you register
+ * the component to handle the event into the imbus daemon. In case of
the failure to
* allocate new memory, it abort.
*
* @return void.
@@ -109,7 +109,9 @@
/**
* @brief Clear a specified IMEventRoles object.
*
- * Clear a IMEventRoles object that it initialize all information in
the object
+ * This function removes all event roles information stored in a
specified IMEventRoles
+ * object.
+ *
* @param event_roles Event role to clear. If the event_roles is not
valid, it aborts.
* @return void.
*/
@@ -119,14 +121,14 @@
* @brief Set the roles of a specified event type in a IMEventRoles object.
*
* Old roles information for that event type will be replaced by the
new one.
- *
+ *
* @param event_roles Event role to set with event type and roles
* If event role is not the valid value, it would just return.
- * @param event_type Type id of the event.
+ * @param event_type Type id of the event.
* @param roles Roles, bitmask of one or more of IM_EVENT_ROLE_PRODUCER,
* IM_EVENT_ROLE_CONSUMER or IM_EVENT_ROLE_OBSERVER.
* If roles is 0, it removes the role belong to the event.
- *
+ *
* @return void.
*/
void im_event_roles_set (IMEventRoles
*event_roles,
@@ -153,7 +155,7 @@
* @brief Remove role information of a event type.
*
* All role information of specified event type will be removed.
- *
+ *
* @param event_roles the role to modify
* If event_roles is not the valid value, it would just return.
* @param event_type event type to remove, then the event_type became
unkown to the event role
@@ -166,7 +168,7 @@
* @brief Get roles for a specified event type.
*
* Get the role information for the specified event type. The role
information would be bitmask of producer, consumer and observer.
- *
+ *
* @param event_roles The role to get the information from
* If event_roles is not the valid value, it would just
return 0.
* @param event_type Type id of the event.
@@ -177,10 +179,10 @@
/**
* @brief Check whether a role is set to a specified event type.
- *
+ *
* Check if the role is associated with the specified event type.
*
- * @param event_roles The role to check
+ * @param event_roles The role to check
* If event_roles is not the valid value, it would just
return 0.
* @param event_type Type id of the event.
* @param role Type of the role to be checked.
Modified: trunk/imbus/src/im_hotkeys.c
==============================================================================
--- trunk/imbus/src/im_hotkeys.c (original)
+++ trunk/imbus/src/im_hotkeys.c Thu Nov 22 00:54:34 2007
@@ -49,7 +49,7 @@
IMObject object;
/* private */
- IMUInt32 uid;
+ IMUInt32 id;
IMHotkeyProfileScope scope;
IMHashTable *hotkeys;
};
@@ -202,7 +202,7 @@
static void
__im_hotkey_profile_initialize (IMPointer profile)
{
- ((IMHotkeyProfile *) profile)->uid = 0;
+ ((IMHotkeyProfile *) profile)->id = 0;
((IMHotkeyProfile *) profile)->scope = IM_HOTKEY_PROFILE_GLOBAL;
((IMHotkeyProfile *) profile)->hotkeys = 0;
}
@@ -237,7 +237,7 @@
__im_hotkey_profile_finalize (dest);
- dp->uid = sp->uid;
+ dp->id = sp->id;
dp->scope = sp->scope;
if (sp->hotkeys) {
@@ -273,7 +273,7 @@
if (!__im_hotkey_profile_parent_class->serialize (obj, stream))
return FALSE;
- if (!im_stream_put_uint32 (sp, pp->uid))
+ if (!im_stream_put_uint32 (sp, pp->id))
return FALSE;
if (!im_stream_put_uint32 (sp, pp->scope))
return FALSE;
@@ -291,7 +291,7 @@
{
IMHotkeyProfile *pp = IM_HOTKEY_PROFILE (obj);
IMStream *sp = IM_STREAM (stream);
- IMUInt32 uid;
+ IMUInt32 id;
IMUInt32 scope;
IMUInt32 num;
IMSize i;
@@ -301,7 +301,7 @@
if (!__im_hotkey_profile_parent_class->deserialize (obj, stream))
return FALSE;
- if (!im_stream_get_uint32 (sp, &uid) ||
+ if (!im_stream_get_uint32 (sp, &id) ||
!im_stream_get_uint32 (sp, &scope) ||
!im_stream_get_uint32 (sp, &num))
return FALSE;
@@ -309,7 +309,7 @@
/* clear this property list */
__im_hotkey_profile_finalize (pp);
- pp->uid = uid;
+ pp->id = id;
pp->scope = (IMHotkeyProfileScope) scope;
if (num) {
@@ -472,29 +472,29 @@
}
IMHotkeyProfile *
-im_hotkey_profile_new (IMUInt32 uid, IMHotkeyProfileScope scope)
+im_hotkey_profile_new (IMUInt32 id, IMHotkeyProfileScope scope)
{
IMHotkeyProfile *profile = (IMHotkeyProfile *) im_object_new (IM_TYPE_HOTKEY_PROFILE);
_im_assert (profile != 0);
- profile->uid = uid;
+ profile->id = id;
profile->scope = scope;
return profile;
}
void
-im_hotkey_profile_set_uid (IMHotkeyProfile *profile, IMUInt32 uid)
+im_hotkey_profile_set_id (IMHotkeyProfile *profile, IMUInt32 id)
{
_im_return_if_fail (IM_IS_HOTKEY_PROFILE (profile));
- profile->uid = uid;
+ profile->id = id;
}
IMUInt32
-im_hotkey_profile_get_uid (const IMHotkeyProfile *profile)
+im_hotkey_profile_get_id (const IMHotkeyProfile *profile)
{
_im_return_val_if_fail (IM_IS_HOTKEY_PROFILE (profile), 0);
- return profile->uid;
+ return profile->id;
}
void
Modified: trunk/imbus/src/im_hotkeys.h
==============================================================================
--- trunk/imbus/src/im_hotkeys.h (original)
+++ trunk/imbus/src/im_hotkeys.h Thu Nov 22 00:54:34 2007
@@ -85,7 +85,7 @@
*
* Create a new object with the type of hotkey and set given keycode.
*
- * @param keycode Keycode to be set as a hotkey
+ * @param keycode Keycode to be set as a hotkey
*
* @return Created IMHotkey object
*/
@@ -94,11 +94,11 @@
/**
* @brief Set key code of a hotkey
*
- * Set keycode to a hotkey object.
+ * Set keycode to a hotkey object.
* Fail if the given keycode is invalid.
*
- * @param hotkey IMHotkey object to set keycode
- * @param keycode Keycode to be set as a hotkey
+ * @param hotkey IMHotkey object to set keycode
+ * @param keycode Keycode to be set as a hotkey
*
* @return This function returns no value
*/
@@ -107,7 +107,7 @@
/**
* @brief Get key code of a specified hotkey
*
- * Get keycode of a IMHotkey object.
+ * Get keycode of a IMHotkey object.
* Fail if the given hotkey is invalid.
*
* @param hotkey IMHotkey object to get keycode
@@ -119,13 +119,13 @@
/**
* @brief Get how many events stored in a hotkey.
*
- * Get the size of the events array of given IMHotkey object.
- * Fail if the given hotkey is invalid.
+ * Get the size of the events array of given IMHotkey object.
+ * Fail if the given hotkey is invalid.
*
* @param hotkey IMHotkey object to get the number of events
- *
- * @return Number of the events.
- * Return 0 if the events array of the given hotkey object is NULL
+ *
+ * @return Number of the events.
+ * Return 0 if the events array of the given hotkey object is NULL
* or operation is failed.
*/
IMSize im_hotkey_get_n_events (const IMHotkey
*hotkey);
@@ -145,13 +145,13 @@
/**
* @brief Append an event to a specified IMHotkey object.
*
- * Increase the reference count of the given event
+ * Increase the reference count of the given event
* and append the event to the events array of the given hotkey object.
* If the events array is NULL, create a new array.
- * Fail if the given hotkey or event is invalid.
+ * Fail if the given hotkey or event is invalid.
*
- * @param hotkey IMHotkey object
- * @param event IMEvent to be appended to the IMHotkey object
+ * @param hotkey IMHotkey object
+ * @param event IMEvent to be appended to the IMHotkey object
*
* @return This function returns no value
*/
@@ -160,12 +160,12 @@
/**
* @brief Get an event stored in a IMHotkey object at sepcified index.
*
- * Get an IMEvent object at the given index of the
+ * Get an IMEvent object at the given index of the
* events array of the given hotkey object.
* Return NULL if the given hotkey or the index is invalid.
*
- * @param hotkey IMHotkey object
- * @param index Index which user want to get from the event array
+ * @param hotkey IMHotkey object
+ * @param index Index which user want to get from the event array
*
* @ return IMEvent object if it exists at the given index, else
return NULL
*/
@@ -177,9 +177,9 @@
*
* Call the given function for each IMEvent object in the given
IMHotkey object.
*
- * @param hotkey IMHotkey object
- * @param func The iterator function
- * @param user_data Data to pass to the function
+ * @param hotkey IMHotkey object
+ * @param func The iterator function
+ * @param user_data Data to pass to the function
*
* @return This function returns no value
*/
@@ -192,37 +192,37 @@
*
* Create a new IMHotkeyProfile object and set a Uid and scope.
*
- * @param uid Unique id of the profile to identify the profile among all
- * profiles owned by a IMBUS component
+ * @param id Id of the profile to identify the profile among all
+ * profiles owned by a IMBUS component
* @param scope Scope of the hotkey profile
*/
-IMHotkeyProfile* im_hotkey_profile_new (IMUInt32
uid,
+IMHotkeyProfile* im_hotkey_profile_new (IMUInt32
id,
IMHotkeyProfileScope scope);
/**
- * @brief Set uid of a specified hotkey profile
+ * @brief Set id of a specified hotkey profile
*
- * Set uid of the given IMHotkeyProfile object.
- * Existing uid will be replaced with the new uid.
+ * Set id of the given IMHotkeyProfile object.
+ * Existing id will be replaced with the new id.
* Fail if the given hotkey profile is invalid.
*
- * @param profile Hotkey profile which uid is set to
- * @param uid Unique id to be set to the hotkey profile
+ * @param profile Hotkey profile which id is set to
+ * @param id Unique id to be set to the hotkey profile
*
* @return This function returns no value
*/
-void im_hotkey_profile_set_uid (IMHotkeyProfile
*profile,
- IMUInt32
uid);
+void im_hotkey_profile_set_id (IMHotkeyProfile
*profile,
+ IMUInt32
id);
/**
- * @brief Get uid of a specified hotkey profile
+ * @brief Get id of a specified hotkey profile
*
- * Get uid of the given IMHotkeyProfile object.
+ * Get id of the given IMHotkeyProfile object.
* Return 0 if the given hotkey profile is invalid.
*
- * @param profile Hotkey profile which user wants to get the uid
+ * @param profile Hotkey profile which user wants to get the id
*
* @return Uid of the hotkey profile
*/
-IMUInt32 im_hotkey_profile_get_uid (const
IMHotkeyProfile *profile);
+IMUInt32 im_hotkey_profile_get_id (const
IMHotkeyProfile *profile);
/**
* @brief Set scope of a specified hotkey profile
*
@@ -230,8 +230,8 @@
* Existing scope will be replaced with the new scope.
* Fail if the given hotkey profile is invalid.
*
- * @param profile Hotkey profile which user wants to set the scope to
- * @param scope Scope of the hotkey profile
+ * @param profile Hotkey profile which user wants to set the scope to
+ * @param scope Scope of the hotkey profile
*
* @return This function returns no value
*/
@@ -280,8 +280,8 @@
* the old hotkey will be replaced by the new one.
* Fail if the given profile or hotkey is invalid.
*
- * @param profile Hotkey profile which user wants to add a hotkey to
- * @param kotkey Hotkey to be added
+ * @param profile Hotkey profile which user wants to add a hotkey to
+ * @param kotkey Hotkey to be added
*
* @return This function returns no value
*/
@@ -293,7 +293,7 @@
* Lookup the given keycode in hotkeys hash table
* and remove the hotkey if it is found in the table.
* Fail if the given profile is invalid.
- *
+ *
* @param profile Hotkey profile which user wants to remove a hotkey from
* @param keycode Keycode of the hotkey to be removed
*
@@ -320,9 +320,9 @@
*
* Call the given function for each IMHotkeyProfile object in the
hotkeys hash table
*
- * @param profile Hotkey profile
- * @param func The iterator function
- * @param user_data Data to pass to the function
+ * @param profile Hotkey profile
+ * @param func The iterator function
+ * @param user_data Data to pass to the function
*
* @return This function returns no value
*/
Modified: trunk/imbus/src/im_key_codes.h
==============================================================================
--- trunk/imbus/src/im_key_codes.h (original)
+++ trunk/imbus/src/im_key_codes.h Thu Nov 22 00:54:34 2007
@@ -1721,11 +1721,11 @@
/**
* @brief Get the name of a key value.
*
- * The im_key_get_name() function
+ * The im_key_get_name() function
*
* If the specified keyval is not defined, im_key_get_name() returns NULL.
*
- * @return The im_key_get_name() function returns
+ * @return The im_key_get_name() function returns
* @return A newly created IMString object,
* must be released by caller.
*/
Modified: trunk/imbus/src/im_lookup_table.c
==============================================================================
--- trunk/imbus/src/im_lookup_table.c (original)
+++ trunk/imbus/src/im_lookup_table.c Thu Nov 22 00:54:34 2007
@@ -398,7 +398,7 @@
return FALSE;
/* Check whether page size is valid */
- if (!buf[2] || !buf[3])
+ if (!buf[1] || !buf[2])
return FALSE;
/* Check whether following data is a IMText or a VOID.
Modified: trunk/imbus/src/im_lookup_table.h
==============================================================================
--- trunk/imbus/src/im_lookup_table.h (original)
+++ trunk/imbus/src/im_lookup_table.h Thu Nov 22 00:54:34 2007
@@ -161,21 +161,21 @@
* @enum IMLookupTableFlag
* @brief Flags to control various behaviour of a lookup table.
*
- * - IM_LOOKUP_TABLE_SHOW_TITLE \n
+ * - IM_LOOKUP_TABLE_SHOW_TITLE
* Whether to show title text or not, default not show.
- * - IM_LOOKUP_TABLE_SHOW_CURSOR \n
+ * - IM_LOOKUP_TABLE_SHOW_CURSOR
* Whether to show cursor or not, default show.
- * - IM_LOOKUP_TABLE_SHOW_SCROLL_BAR \n
+ * - IM_LOOKUP_TABLE_SHOW_SCROLL_BAR
* Whether to show scroll bar or not, default not show.
- * - IM_LOOKUP_TABLE_SHOW_PAGE_FLIP_BUTTONS \n
+ * - IM_LOOKUP_TABLE_SHOW_PAGE_FLIP_BUTTONS
* Whether to show page flip buttons (page up and page down) or not,
* default show.
- * - IM_LOOKUP_TABLE_HORIZONTAL_SHRINKABLE \n
+ * - IM_LOOKUP_TABLE_HORIZONTAL_SHRINKABLE
* Whether the page size can be shrunk by GUI component in
* horizontal orientation or not, default not shrinkable.
* If it's shrinkable and the size is shrunk by GUI component,
* an event will be sent back to IMEngine to indicate it.
- * - IM_LOOKUP_TABLE_VERTICAL_SHRINKABLE \n
+ * - IM_LOOKUP_TABLE_VERTICAL_SHRINKABLE
* Whether the page size can be shrunk by GUI component in
* vertical orientation or not, default not shrinkable.
* If it's shrinkable and the size is shrunk by GUI component,
Modified: trunk/imbus/src/im_properties.c
==============================================================================
--- trunk/imbus/src/im_properties.c (original)
+++ trunk/imbus/src/im_properties.c Thu Nov 22 00:54:34 2007
@@ -9,12 +9,21 @@
#include "im_string.h"
#include "im_properties.h"
-#define IM_PROPERTY_FLAGS_MASK 0xFF
-#define IM_PROPERTY_HAS_KEY 0x0100
-#define IM_PROPERTY_HAS_ICON 0x0200
-#define IM_PROPERTY_HAS_LABEL 0x0400
-#define IM_PROPERTY_HAS_TIP 0x0800
-#define IM_PROPERTY_HAS_SUB_PROPS 0x1000
+#define IM_PROP_TYPE_SHIFT 0
+#define IM_PROP_CHECK_STATE_SHIFT 4
+#define IM_PROP_SENSITIVE_SHIFT 6
+#define IM_PROP_VISIBLE_SHIFT 7
+
+#define IM_PROP_TYPE_MASK 0x000F
+#define IM_PROP_CHECK_STATE_MASK 0x0003
+#define IM_PROP_SENSITIVE_MASK 0x0001
+#define IM_PROP_VISIBLE_MASK 0x0001
+
+#define IM_PROP_HAS_KEY 0x0100
+#define IM_PROP_HAS_ICON 0x0200
+#define IM_PROP_HAS_LABEL 0x0400
+#define IM_PROP_HAS_TIP 0x0800
+#define IM_PROP_HAS_SUB_PROPS 0x1000
/************************** Declaration of internal functions ***************/
static void __im_property_initialize (IMPointer prop);
@@ -43,13 +52,16 @@
IMObject object;
/* private */
- IMUInt16 type;
- IMUInt16 flags;
IMString *key;
IMString *icon;
IMText *label;
IMText *tip;
IMPropList *sub_props;
+
+ IMUInt type : 4;
+ IMUInt check_state : 2;
+ IMUInt sensitive : 1;
+ IMUInt visible : 1;
};
struct _IMPropertyClass
@@ -88,13 +100,16 @@
{
_im_assert (IM_IS_PROPERTY (prop));
- ((IMProperty*)prop)->type = IM_PROPERTY_NORMAL;
- ((IMProperty*)prop)->flags = IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE;
- ((IMProperty*)prop)->key = 0;
- ((IMProperty*)prop)->icon = 0;
- ((IMProperty*)prop)->label = 0;
- ((IMProperty*)prop)->tip = 0;
- ((IMProperty*)prop)->sub_props = 0;
+ ((IMProperty*)prop)->key = 0;
+ ((IMProperty*)prop)->icon = 0;
+ ((IMProperty*)prop)->label = 0;
+ ((IMProperty*)prop)->tip = 0;
+ ((IMProperty*)prop)->sub_props = 0;
+
+ ((IMProperty*)prop)->type = IM_PROPERTY_NORMAL;
+ ((IMProperty*)prop)->check_state = IM_PROPERTY_UNCHECKED;
+ ((IMProperty*)prop)->sensitive = 1;
+ ((IMProperty*)prop)->visible = 1;
}
static void
@@ -127,7 +142,10 @@
__im_property_finalize (dest);
dp->type = sp->type;
- dp->flags = sp->flags;
+ dp->check_state = sp->check_state;
+ dp->sensitive = sp->sensitive;
+ dp->visible = sp->visible;
+
dp->key = (sp->key ? im_object_ref (im_object_clone
(sp->key)) : 0);
dp->icon = (sp->icon ? im_object_ref (im_object_clone
(sp->icon)) : 0);
dp->label = (sp->label ? im_object_ref (im_object_clone
(sp->label)) : 0);
@@ -143,7 +161,7 @@
{
const IMProperty *pp = IM_CONST_PROPERTY (obj);
IMStream *sp = IM_STREAM (stream);
- IMUInt32 flags;
+ IMUInt16 flags;
_im_assert (pp && sp);
@@ -151,31 +169,35 @@
if (!__im_property_parent_class->serialize (obj, stream))
return FALSE;
- flags = (pp->flags & IM_PROPERTY_FLAGS_MASK);
+ flags = 0;
+ flags |= (pp->type << IM_PROP_TYPE_SHIFT);
+ flags |= (pp->check_state << IM_PROP_CHECK_STATE_SHIFT);
+ flags |= (pp->sensitive << IM_PROP_SENSITIVE_SHIFT);
+ flags |= (pp->visible << IM_PROP_VISIBLE_SHIFT);
if (pp->key && im_string_length (pp->key))
- flags |= IM_PROPERTY_HAS_KEY;
+ flags |= IM_PROP_HAS_KEY;
if (pp->icon && im_string_length (pp->icon))
- flags |= IM_PROPERTY_HAS_ICON;
+ flags |= IM_PROP_HAS_ICON;
if (pp->label && im_text_length (pp->label))
- flags |= IM_PROPERTY_HAS_LABEL;
+ flags |= IM_PROP_HAS_LABEL;
if (pp->tip && im_text_length (pp->tip))
- flags |= IM_PROPERTY_HAS_TIP;
+ flags |= IM_PROP_HAS_TIP;
if (pp->sub_props && !im_prop_list_empty (pp->sub_props))
- flags |= IM_PROPERTY_HAS_SUB_PROPS;
+ flags |= IM_PROP_HAS_SUB_PROPS;
- if (!im_stream_put_uint32 (sp, ((flags << 16) | (pp->type & 0xFFFF))))
+ if (!im_stream_put_uint16 (sp, flags))
return FALSE;
- if (flags & IM_PROPERTY_HAS_KEY)
+ if (flags & IM_PROP_HAS_KEY)
if (!im_stream_put_object (sp, pp->key)) return FALSE;
- if (flags & IM_PROPERTY_HAS_ICON)
+ if (flags & IM_PROP_HAS_ICON)
if (!im_stream_put_object (sp, pp->icon)) return FALSE;
- if (flags & IM_PROPERTY_HAS_LABEL)
+ if (flags & IM_PROP_HAS_LABEL)
if (!im_stream_put_object (sp, pp->label)) return FALSE;
- if (flags & IM_PROPERTY_HAS_TIP)
+ if (flags & IM_PROP_HAS_TIP)
if (!im_stream_put_object (sp, pp->tip)) return FALSE;
- if (flags & IM_PROPERTY_HAS_SUB_PROPS)
+ if (flags & IM_PROP_HAS_SUB_PROPS)
if (!im_stream_put_object (sp, pp->sub_props)) return FALSE;
return TRUE;
@@ -186,7 +208,7 @@
{
IMProperty *pp = IM_PROPERTY (obj);
IMStream *sp = IM_STREAM (stream);
- IMUInt32 flags;
+ IMUInt16 flags;
_im_assert (pp && sp);
@@ -194,21 +216,23 @@
if (!__im_property_parent_class->deserialize (obj, stream))
return FALSE;
- if (im_stream_get_data_type (sp) != IM_TYPE_UINT32 ||
!im_stream_get_uint32 (sp, &flags))
+ if (im_stream_get_data_type (sp) != IM_TYPE_UINT16 ||
!im_stream_get_uint16 (sp, &flags))
return FALSE;
__im_property_finalize (obj);
- pp->type = (flags & 0xFFFF);
- flags >>= 16;
- pp->flags = (flags & IM_PROPERTY_FLAGS_MASK);
- pp->key = 0;
- pp->icon = 0;
- pp->label = 0;
- pp->tip = 0;
- pp->sub_props = 0;
+ pp->type = ((flags >> IM_PROP_TYPE_SHIFT) & IM_PROP_TYPE_MASK);
+ pp->check_state = ((flags >> IM_PROP_CHECK_STATE_SHIFT) & IM_PROP_CHECK_STATE_MASK);
+ pp->sensitive = ((flags >> IM_PROP_SENSITIVE_SHIFT) & IM_PROP_SENSITIVE_MASK);
+ pp->visible = ((flags >> IM_PROP_VISIBLE_SHIFT) & IM_PROP_VISIBLE_MASK);
+
+ pp->key = 0;
+ pp->icon = 0;
+ pp->label = 0;
+ pp->tip = 0;
+ pp->sub_props = 0;
- if (flags & IM_PROPERTY_HAS_KEY) {
+ if (flags & IM_PROP_HAS_KEY) {
if (im_stream_get_data_type (sp) != IM_TYPE_STRING)
return FALSE;
@@ -224,7 +248,7 @@
}
}
- if (flags & IM_PROPERTY_HAS_ICON) {
+ if (flags & IM_PROP_HAS_ICON) {
if (im_stream_get_data_type (sp) != IM_TYPE_STRING)
return FALSE;
@@ -240,7 +264,7 @@
}
}
- if (flags & IM_PROPERTY_HAS_LABEL) {
+ if (flags & IM_PROP_HAS_LABEL) {
if (im_stream_get_data_type (sp) != IM_TYPE_TEXT)
return FALSE;
@@ -256,7 +280,7 @@
}
}
- if (flags & IM_PROPERTY_HAS_TIP) {
+ if (flags & IM_PROP_HAS_TIP) {
if (im_stream_get_data_type (sp) != IM_TYPE_TEXT)
return FALSE;
@@ -272,7 +296,7 @@
}
}
- if (flags & IM_PROPERTY_HAS_SUB_PROPS) {
+ if (flags & IM_PROP_HAS_SUB_PROPS) {
if (im_stream_get_data_type (sp) != IM_TYPE_PROP_LIST)
return FALSE;
@@ -459,13 +483,14 @@
IMProperty*
im_property_new (IMString *key)
{
- return im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE|IM_PROPERTY_VISIBLE,
- key, 0, 0, 0);
+ return im_property_new_full (IM_PROPERTY_NORMAL, key, 0, 0, 0,
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED);
}
IMProperty*
-im_property_new_full (IMPropertyType type, IMUInt flags, IMString
*key, IMString *icon, IMText *label, IMText *tip)
+im_property_new_full (IMPropertyType type, IMString *key, IMString *icon,
+ IMText *label, IMText *tip, IMBool sensitive,
+ IMBool visible, IMPropertyCheckState check_state)
{
IMProperty *p;
@@ -479,12 +504,13 @@
_im_assert (p != 0);
p->type = type;
- p->flags = flags & IM_PROPERTY_FLAGS_MASK;
-
p->key = key;
p->icon = icon;
p->label = label;
p->tip = tip;
+ p->sensitive = (sensitive ? 1 : 0);
+ p->visible = (visible ? 1 : 0);
+ p->check_state = check_state;
if (key) im_object_ref (key);
if (icon) im_object_ref (icon);
@@ -509,27 +535,49 @@
return prop->type;
}
+
void
-im_property_enable_flags (IMProperty *prop, IMUInt flags)
+im_property_set_sensitive (IMProperty *prop, IMBool sensitive)
{
_im_return_if_fail (IM_IS_PROPERTY(prop));
+ prop->sensitive = (sensitive ? 1 : 0);
+}
- prop->flags |= (flags & IM_PROPERTY_FLAGS_MASK);
+IMBool
+im_property_is_sensitive (const IMProperty *prop)
+{
+ _im_return_val_if_fail (IM_IS_PROPERTY(prop), FALSE);
+ return prop->sensitive != 0;
}
+
void
-im_property_disable_flags (IMProperty *prop, IMUInt flags)
+im_property_set_visible (IMProperty *prop, IMBool visible)
{
_im_return_if_fail (IM_IS_PROPERTY(prop));
-
- prop->flags &= ~(flags & IM_PROPERTY_FLAGS_MASK);
+ prop->visible = (visible ? 1 : 0);
}
+
IMBool
-im_property_check_flags (const IMProperty *prop, IMUInt flags)
+im_property_is_visible (const IMProperty *prop)
{
_im_return_val_if_fail (IM_IS_PROPERTY(prop), FALSE);
+ return prop->visible != 0;
+}
- return (prop->flags & flags) == flags;
+void
+im_property_set_check_state (IMProperty *prop, IMPropertyCheckState state)
+{
+ _im_return_if_fail (IM_IS_PROPERTY(prop));
+ prop->check_state = state;
}
+
+IMPropertyCheckState
+im_property_get_check_state (IMProperty *prop)
+{
+ _im_return_val_if_fail (IM_IS_PROPERTY(prop), IM_PROPERTY_CHECKED);
+ return (IMPropertyCheckState) prop->check_state;
+}
+
void
im_property_set_key (IMProperty *prop, IMString *key)
{
Modified: trunk/imbus/src/im_properties.h
==============================================================================
--- trunk/imbus/src/im_properties.h (original)
+++ trunk/imbus/src/im_properties.h Thu Nov 22 00:54:34 2007
@@ -12,7 +12,7 @@
* @{
*/
-/**
+/**
* @struct IMProperty
* @brief An object holds a property of an IMBUS component.
*
@@ -32,42 +32,38 @@
* There are four @copydoc IMPropertyType
*
* A property contains the following elements:
- * - Key \n
- * type: const char* \n
+ * - Key
+ * type: const char*
* An unique string key to identify the property.
* A separator property should have an unique string key as well,
* so that it can be manipulated by IMPropList object.
- * - Label \n
- * type: IMText* \n
+ * - Label
+ * type: IMText*
* A human readable text label which will be displayed on
* the screen.
* It doesn't apply to separator property.
- * - Icon \n
- * type: const char* \n
+ * - Icon
+ * type: const char*
* An icon file which will be displayed on the screen along
- * with label.
+ * with label. A URI shall be used here, and file URI shall be
supported by
+ * default. Other kind of URIs are optional.
* It doesn't apply to separator property.
- * - Tip \n
- * type: IMText* \n
+ * - Tip
+ * type: IMText*
* A human readable text to describe the meaning of the property,
* which may be displayed on the screen.
* It doesn't apply to separator property.
- * - Flags
- * type: IMUInt32 \n
- * Flags to indicate various states of the property, such as
- * whether it's active or not.
- * It doesn't apply to separator property.
- * - Sub Properties \n
- * type: IMPropList * \n
+ * - Sub Properties
+ * type: IMPropList *
* Optionally a IMPropList object contains one or more sub-properties.
* With sub-properties list, we can organize multiple properties
* in hierarchy style.
* It doesn't apply to separator property.
*
- * Multiple properties can be organized in hierarchy style
+ * Multiple properties may be organized in hierarchy style
* by attaching a IMPropList object, which contains sub-properties,
* to a property. A property with sub-properties attached becomes
- * root property. Normally user may not trigger a root property.
+ * root property.
*
* A reasonable screen display form of a multi-level properties
* hierarchy can look like a menu:
@@ -82,13 +78,12 @@
* +-------+ +-------+ | prop9 |
* +-------+
* @endcode
- *
+ *
* In such case, prop2 is root property of prop5,prop6 and prop7.
- * While prop6 is root property of prop8 and prop9. So user may
- * not trigger prop2 and prop6.
+ * While prop6 is root property of prop8 and prop9.
*/
-/**
+/**
* @struct IMPropList
* @brief An object to hold multiple properties.
*
@@ -98,7 +93,7 @@
* component.
*/
-/**
+/**
* @struct IMPropIterator
* @brief Iterator of IMPropList to iterate all properties
* stored in a IMPropList object.
@@ -140,27 +135,27 @@
typedef struct _IMPropIterator IMPropIterator;
-/**
+/**
* @enum IMPropertyType
* @brief types of an IMProperty.
*
- * - IM_PROPERTY_NORMAL \n
+ * - IM_PROPERTY_NORMAL
* Normal property that represents a state of IMBUS component.
* It can be triggerred by user.
* Normal property may be displayed as a normal button or menu
* item by GUI component.
- * - IM_PROPERTY_SWITCH \n
- * Like normal property, a switch property can represent a state
+ * - IM_PROPERTY_TOGGLE
+ * Like normal property, a toggle property can represent a state
* of IMBUS component and can be triggerred by user.
- * But GUI component may display a switch property with different
+ * But GUI component may display a toggle property with different
* appearance which indicates that it can be turned on or off
- * (selected or deselected).
- * - IM_PROPERTY_RADIO \n
- * Similar than switch property, but it may have a different
+ * (checked or unchecked).
+ * - IM_PROPERTY_RADIO
+ * Similar than toggle property, but it may have a different
* appearance which indicates that it's one of an items group,
* in which only one item can be selected at one time. Just
* like radio buttons widget used in GUI interface.
- * - IM_PROPERTY_SEPARATOR \n
+ * - IM_PROPERTY_SEPARATOR
* A separator property doesn't carry any state information of IMBUS
* component. It will just be displayed as a separator to split
* other properties into different groups.
@@ -169,41 +164,31 @@
typedef enum
{
IM_PROPERTY_NORMAL = 0,
- IM_PROPERTY_SWITCH,
+ IM_PROPERTY_TOGGLE,
IM_PROPERTY_RADIO,
IM_PROPERTY_SEPARATOR
} IMPropertyType;
-/**
- * @enum IMPropertyFlag
- * @brief Flags to control various behaviours of an IMProperty.
- *
- * - IM_PROPERTY_SENSITIVE \n
- * Whether it's sensitive or not. Only sensitive property can
- * be triggered/selected by user.
- * - IM_PROPERTY_VISIBLE \n
- * Whether it's visible or not. If a property is invisible,
- * all properties belongs to it and itself won't be displayed.
- * - IM_PROPERTY_CHECKED \n
- * Whether it's checked or not.
- * It only applies to switch and radio properties.
- * - IM_PROPERTY_UNCHECKED \n
- * Whether it's unchecked or not. IM_PROPERTY_CHECKED and
- * IM_PROPERTY_UNCHECKED are opposite flags. If both are
- * set then becomes IM_PROPERTY_INCONSISTENT.
- * It only applies to switch and radio properties.
- * - IM_PROPERTY_INCONSISTENT \n
- * Whether it's in inconsistent state or not.
- * It only applies to switch and radio properties.
+/**
+ * @enum IMPropertyCheckState
+ * @brief Value to Indicate the different states of a checkable property..
+ *
+ * Only radio and toggle property are checkable.
+ *
+ * - IM_PROPERTY_UNCHECKED
+ * Indicates that this property is currently not checked.
+ * - IM_PROPERTY_INCONSISTENT
+ * Indicates that this property is currently in inconsitent state, neither
+ * checked nor unchecked. It's a state beteen unchecked and checked.
+ * - IM_PROPERTY_CHECKED
+ * Indicates that this property is currently checked.
*/
typedef enum
{
- IM_PROPERTY_SENSITIVE = 0x01,
- IM_PROPERTY_VISIBLE = 0x02,
- IM_PROPERTY_CHECKED = 0x04,
- IM_PROPERTY_UNCHECKED = 0x08,
- IM_PROPERTY_INCONSISTENT = IM_PROPERTY_CHECKED|IM_PROPERTY_UNCHECKED,
-} IMPropertyFlag;
+ IM_PROPERTY_UNCHECKED = 0,
+ IM_PROPERTY_INCONSISTENT = 1,
+ IM_PROPERTY_CHECKED = 2,
+} IMPropertyCheckState;
/**
* @brief Create a new property with a specified key string.
@@ -214,32 +199,34 @@
*
* The key IMString object will only be referenced rather than cloned.
*
- * The default type is IM_PROPERTY_NORMAL, default flag is
- * IM_PROPERTY_SENSITIVE|IM_PROPERTY_VISIBLE
+ * The default type is IM_PROPERTY_NORMAL. Sensitive and visible flags
will be
+ * set to TRUE by default. Check state will be set to
IM_PROPERTY_UNCHECKED by
+ * default.
*/
IMProperty* im_property_new (IMString
*key);
/**
* @brief Create a new property with specified parameters.
- *
+ *
* @param type the IMPropertyType
- * @param flags bitmask of IMPropertyFlag(s)
* @param key the string id of this property
* @param icon the icon id of this property
* @param label the label (IMText*) of this property
* @param tip the tip (IMText*) of this property
*
- * The objects (not primitive types) in parameter list will only be referenced
+ * The objects (not primitive types) in parameter list will only be referenced
* rather than cloned.
- *
+ *
* @return the newly created IMProperty object.
*/
IMProperty* im_property_new_full (IMPropertyType
type,
- IMUInt
flags,
IMString
*key,
IMString
*icon,
IMText
*label,
- IMText
*tip);
+ IMText
*tip,
+ IMBool
sensitive,
+ IMBool
visible,
+
IMPropertyCheckState check_state);
/**
* @brief Set the type of specified property.
*
@@ -253,36 +240,69 @@
IMPropertyType
type);
/**
* @brief Get the type of specified property.
- *
+ *
* @param prop an IMProperty
- *
+ *
* @return the property type
*/
IMPropertyType im_property_get_type (const IMProperty
*prop);
+
/**
- * @brief Enable various flags for a property to adjust its behaviour.
- *
- * @param prop an IMProperty
- * @param flags the bitmask of IMPropertyFlag(s)
+ * @brief Set the sensitive state of a specified property.
+ *
+ * Only sensitive property can be triggered/selected by user.
+ *
+ * @param prop Pointer to an IMProperty object.
+ * @param sensitive Indicates if the specified IMProperty object will be
+ * sensitive or not.
*/
-void im_property_enable_flags (IMProperty
*prop,
- IMUInt
flags);
+void im_property_set_sensitive (IMProperty
*prop,
+ IMBool
sensitive);
/**
- * @brief Disable various flags for a property to adjust its behaviour.
+ * @brief Check if a specified IMProperty object is sensitive.
*
- * @param prop an IMProperty
- * @param flags the bitmask of IMPropertyFlag(s)
+ * @param prop Pointer to an IMProperty object.
+ * @return TRUE if the specified property is currently sensitive.
*/
-void im_property_disable_flags (IMProperty
*prop,
- IMUInt
flags);
+IMBool im_property_is_sensitive (const IMProperty
*prop);
+
/**
- * @brief Check whether one or more flags is enabled or not.
+ * @brief Set the visible state of a specified property.
*
- * @param prop an IMProperty
- * @param flags the bitmask of IMPropertyFlag(s)
+ * If a property is invisible, all properties belongs to it and itself won't
+ * be displayed.
+
+ * @param prop Pointer to an IMProperty object.
+ * @param visible Indicates if the specified IMProperty object will be
+ * visible or not.
*/
-IMBool im_property_check_flags (const IMProperty
*prop,
- IMUInt
flags);
+void im_property_set_visible (IMProperty
*prop,
+ IMBool
visible);
+
+/**
+ * @brief Check if a specified IMProperty object is visible.
+ *
+ * @param prop Pointer to an IMProperty object.
+ * @return TRUE if the specified property is currently visible.
+ */
+IMBool im_property_is_visible (const IMProperty
*prop);
+
+/**
+ * @brief Set the check state of a specified IMProperty object.
+ *
+ * @param prop Pointer to an IMProperty object.
+ * @param state The check state to be set, @sa IMPropertyCheckState.
+ */
+void im_property_set_check_state (IMProperty
*prop,
+
IMPropertyCheckState state);
+/**
+ * @brief Get the check state of a specified IMProperty object.
+ *
+ * @param prop Pointer to an IMProperty object.
+ * @return The current check state of the specified IMProperty object.
+ */
+IMPropertyCheckState im_property_get_check_state (IMProperty
*prop);
+
/**
* @brief Set key string of a property.
*
@@ -295,28 +315,29 @@
IMString
*key);
/**
* @brief Get key string of a specified IMProperty object.
- *
+ *
* @param prop an IMProperty
- *
+ *
* @return the string id
*/
IMString* im_property_get_key (const IMProperty
*prop);
/**
* @brief Set icon file of a property.
- *
+ *
* @param prop an IMProperty
- * @param icon the icon path
+ * @param icon URI to the icon, file URI shall be supported by
default, others
+ * are optional.
*
* The icon IMString object will only be referenced rather than cloned.
*/
void im_property_set_icon (IMProperty
*prop,
IMString
*icon);
/**
- * @brief Get icon file path of a specified IMProperty object.
- *
+ * @brief Get icon uri of a specified IMProperty object.
+ *
* @param prop an IMProperty
- *
- * @return the icon path
+ *
+ * @return URI to the icon.
*/
IMString* im_property_get_icon (const IMProperty
*prop);
/**
@@ -331,9 +352,9 @@
IMText
*label);
/**
* @brief Get tje label of a specified IMProperty object.
- *
+ *
* @param prop an IMProperty
- *
+ *
* @return the label object
*/
IMText* im_property_get_label (const IMProperty
*prop);
@@ -441,9 +462,9 @@
IMPointer
user_data);
/**
* @brief Create an iterator for a specified IMPropList object.
- *
+ *
* @param list an IMPropList
- *
+ *
* @return an iterator
*/
IMPropIterator* im_prop_list_get_iterator (IMPropList
*list);
Modified: trunk/imbus/tests/test_byte_stream.c
==============================================================================
--- trunk/imbus/tests/test_byte_stream.c (original)
+++ trunk/imbus/tests/test_byte_stream.c Thu Nov 22 00:54:34 2007
@@ -196,57 +196,57 @@
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node1"),
im_string_new_static ("Icon1"),
im_text_new_from_utf8_string ("第一
个Node", -1),
- 0));
+ im_text_new_from_utf8_string ("A
tip", -1),
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node2"),
im_string_new_static ("Icon2"),
im_text_new_from_utf8_string ("第二
个Node", -1),
- 0));
+ 0,
+ TRUE, FALSE, IM_PROPERTY_CHECKED));
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3"),
im_string_new_static ("Icon3"),
im_text_new_from_utf8_string ("第三
个Node", -1),
- 0));
+ im_text_new_from_utf8_string ("A
tip", -1),
+ FALSE, TRUE, IM_PROPERTY_INCONSISTENT));
im_prop_list_append (proplist,
- im_property_new_full (IM_PROPERTY_SWITCH,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
+ im_property_new_full (IM_PROPERTY_TOGGLE,
im_string_new_static ("/Root/Node4"),
im_string_new_static ("Icon4"),
im_text_new_from_utf8_string ("第四
个Node", -1),
- 0));
+ 0,
+ FALSE, FALSE, IM_PROPERTY_UNCHECKED));
prop = im_prop_list_get (proplist, "/Root/Node3");
subproplist = im_prop_list_new ();
im_prop_list_append (subproplist,
im_property_new_full (IM_PROPERTY_RADIO,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3/SubNode1"),
im_string_new_static ("Icon5"),
im_text_new_from_utf8_string ("第三
个Node第一个子Node", -1),
- 0));
+ 0,
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_prop_list_append (subproplist,
im_property_new_full (IM_PROPERTY_RADIO,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3/SubNode2"),
im_string_new_static ("Icon6"),
im_text_new_from_utf8_string ("第三
个Node第二个子Node", -1),
- 0));
+ 0,
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_property_set_sub_props (prop, subproplist);
im_stream_put_object (stream, proplist);
-
+
im_stream_write (stream, channel_out, 0, 0);
im_object_unref (array);
Modified: trunk/imbus/tests/test_text_stream.c
==============================================================================
--- trunk/imbus/tests/test_text_stream.c (original)
+++ trunk/imbus/tests/test_text_stream.c Thu Nov 22 00:54:34 2007
@@ -195,52 +195,52 @@
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node1"),
im_string_new_static ("Icon1"),
im_text_new_from_utf8_string ("第一
个Node", -1),
- 0));
+ im_text_new_from_utf8_string ("A
tip", -1),
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node2"),
im_string_new_static ("Icon2"),
im_text_new_from_utf8_string ("第二
个Node", -1),
- 0));
+ 0,
+ TRUE, FALSE, IM_PROPERTY_CHECKED));
im_prop_list_append (proplist,
im_property_new_full (IM_PROPERTY_NORMAL,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3"),
im_string_new_static ("Icon3"),
im_text_new_from_utf8_string ("第三
个Node", -1),
- 0));
+ im_text_new_from_utf8_string ("A
tip", -1),
+ FALSE, TRUE, IM_PROPERTY_INCONSISTENT));
im_prop_list_append (proplist,
- im_property_new_full (IM_PROPERTY_SWITCH,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
+ im_property_new_full (IM_PROPERTY_TOGGLE,
im_string_new_static ("/Root/Node4"),
im_string_new_static ("Icon4"),
im_text_new_from_utf8_string ("第四
个Node", -1),
- 0));
+ 0,
+ FALSE, FALSE, IM_PROPERTY_UNCHECKED));
prop = im_prop_list_get (proplist, "/Root/Node3");
subproplist = im_prop_list_new ();
im_prop_list_append (subproplist,
im_property_new_full (IM_PROPERTY_RADIO,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3/SubNode1"),
im_string_new_static ("Icon5"),
im_text_new_from_utf8_string ("第三
个Node第一个子Node", -1),
- 0));
+ 0,
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_prop_list_append (subproplist,
im_property_new_full (IM_PROPERTY_RADIO,
- IM_PROPERTY_SENSITIVE | IM_PROPERTY_VISIBLE,
im_string_new_static ("/Root/Node3/SubNode2"),
im_string_new_static ("Icon6"),
im_text_new_from_utf8_string ("第三
个Node第二个子Node", -1),
- 0));
+ 0,
+ TRUE, TRUE, IM_PROPERTY_UNCHECKED));
im_property_set_sub_props (prop, subproplist);