}
/**
- * @brief Adds attribute to attribute set
- *
- * Creates an AtkAttribute from attr and value, and adds it
- * to attrib_set.
- *
- * @param attrib_set AtkAttributeSet instance to add the attribute to
- * @param attr AtkTextAttrribute instance which identifies the attribute to be added
- * @param value attribute value
- *
- * @returns: AtkAttributeSet representing the new attribute set
- **/
-AtkAttributeSet*
-eail_entry_add_attribute(AtkAttributeSet *attrib_set,
- AtkTextAttribute attr,
- gchar *value)
-{
- AtkAttributeSet *return_set;
- AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
- at->name = g_strdup (atk_text_attribute_get_name (attr));
- at->value = value;
- return_set = g_slist_prepend(attrib_set, at);
- return return_set;
-}
-
-/**
* @brief Creates an AtkAttributeSet which consists of the default values of
* attributes for the text
*
* @returns AtkAttributeSet which contains the default values of attributes
* at offset
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_entry_get_default_attributes(AtkText *text)
{
AtkAttributeSet *at_set = NULL;
- at_set = eail_entry_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0)));
+ atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0));
- at_set = eail_entry_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, TRUE)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, TRUE));
return at_set;
}
* @returns AtkAttributeSet which contains the attributes explicitly set at
* offset
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_entry_get_run_attributes(AtkText *text,
gint offset,
gint *start_offset,
/* NOTE: Elm_Wrap_Type value is in 100% compatible with ATK wrap modes, so
* no additional conversion is needed*/
Elm_Wrap_Type wrap_type = elm_entry_line_wrap_get(widget);
- at_set = eail_entry_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_WRAP_MODE, wrap_type)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_WRAP_MODE, wrap_type));
Eina_Bool editable = elm_entry_editable_get(widget);
- at_set = eail_entry_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, editable)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, editable));
return at_set;
}
}
/**
- * @brief Adds attribute to attribute set
- *
- * @param attrib_set AtkAttributeSet to add the attribute to
- * @param attr AtkTextAttrribute to be added
- * @param value attribute value
- *
- * Creates an AtkAttribute from attr and value, and adds it
- * to attrib_set.
- *
- * @returns AtkAttributeSet containing set with added attribute
- **/
-AtkAttributeSet*
-_eail_label_add_attribute(AtkAttributeSet *attrib_set,
- AtkTextAttribute attr,
- gchar *value)
-{
- AtkAttributeSet *return_set;
- AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
- at->name = g_strdup (atk_text_attribute_get_name (attr));
- at->value = value;
- return_set = g_slist_prepend(attrib_set, at);
- return return_set;
-}
-
-/**
* @brief Creates an AtkAttributeSet which consists of the default values of
* attributes for the text.
*
* @returns AtkAttributeSet containing default values of attributes
* at offset.
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_label_get_default_attributes(AtkText *text)
{
AtkAttributeSet *at_set = NULL;
- at_set = _eail_label_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0)));
+ atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0));
- at_set = _eail_label_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, FALSE)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
return at_set;
}
* @returns an AtkAttributeSet which contains the attributes explicitly set at
* offset.
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_label_get_run_attributes(AtkText *text,
gint offset,
gint *start_offset,
/* NOTE: Elm_Wrap_Type value is in 100% compatible with ATK wrap modes, so
* no additional conversion is needed*/
Elm_Wrap_Type wrap_type = elm_label_line_wrap_get(widget);
- at_set = _eail_label_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_WRAP_MODE, wrap_type)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_WRAP_MODE, wrap_type));
- at_set = _eail_label_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, FALSE)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
return at_set;
}
#include "eail_factory.h"
#include "eail_utils.h"
#include "eail_priv.h"
+#include "eail_text.h"
static void atk_text_interface_init(AtkTextIface *iface);
}
}
+/*
+ * @brief Creates an AtkAttributeSet which consists of the attributes
+ * explicitly set at the position offset in the text.
+ *
+ * start_offset and end_offset are set to the start and end of the range around offset
+ * where the attributes are invariant.
+ *
+ * Note that end_offset is the offset of the first character after the range.
+ *
+ * This AtkAttributeSet should be freed by a call to
+ * atk_attribute_set_free()
+ *
+ * @param text AtkText instance
+ * @param offset the offset at which to get the attributes
+ * @param [out] start_offset start offset of the range
+ * @param [out] end_offset end offset of the range
+ *
+ * @returns an AtkAttributeSet which contains the attributes explicitly set at
+ * offset.
+ */
+static AtkAttributeSet *
+eail_popup_get_run_attributes(AtkText *text,
+ gint offset,
+ gint *start_offset,
+ gint *end_offset)
+{
+ AtkAttributeSet *at_set = NULL;
+ Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
+ gint len = eail_popup_get_character_count(ATK_TEXT(text));
+
+ if (!widget || offset >= len)
+ {
+ *start_offset = -1;
+ *end_offset = -1;
+
+ return NULL;
+ }
+
+ *start_offset = 0;
+ *end_offset = len;
+
+ /* NOTE: Elm_Wrap_Type value is in 100% compatible with ATK wrap modes, so
+ * no additional conversion is needed*/
+ Elm_Wrap_Type wrap_type = elm_popup_content_text_wrap_type_get(widget);
+ at_set = eail_utils_text_add_attribute
+ (at_set, ATK_TEXT_ATTR_WRAP_MODE,
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_WRAP_MODE, wrap_type));
+
+ at_set = eail_utils_text_add_attribute
+ (at_set, ATK_TEXT_ATTR_EDITABLE,
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
+
+ return at_set;
+}
+
+/**
+ * @brief Creates an AtkAttributeSet which consists of the default values of
+ * attributes for the text.
+ *
+ * This AtkAttributeSet should be freed by a call to
+ * atk_attribute_set_free()
+ *
+ * @param text AtkText instance
+ *
+ * @returns AtkAttributeSet containing default values of attributes
+ * at offset.
+ */
+static AtkAttributeSet *
+eail_popup_get_default_attributes(AtkText *text)
+{
+ AtkAttributeSet *at_set = NULL;
+
+ at_set = eail_utils_text_add_attribute
+ (at_set, ATK_TEXT_ATTR_WRAP_MODE,
+ atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0));
+
+ at_set = eail_utils_text_add_attribute
+ (at_set, ATK_TEXT_ATTR_EDITABLE,
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
+
+ return at_set;
+}
+
/**
* @brief Initializer for AtkTextIface interface class
*
iface->get_character_at_offset = eail_popup_get_character_at_offset;
iface->get_character_count = eail_popup_get_character_count;
iface->get_character_extents = eail_popup_get_character_extents;
+ iface->get_run_attributes = eail_popup_get_run_attributes;
+ iface->get_default_attributes = eail_popup_get_default_attributes;
}
}
/**
- * @brief Adds attribute to attribute set
- *
- * @param attrib_set AtkAttributeSet to add the attribute to
- * @param attr AtkTextAttrribute to be added
- * @param value attribute value
- *
- * Creates an AtkAttribute from attr and value, and adds it
- * to attrib_set.
- *
- * @returns AtkAttributeSet containing set with added attribute
- **/
-AtkAttributeSet*
-_eail_text_add_attribute(AtkAttributeSet *attrib_set,
- AtkTextAttribute attr,
- gchar *value)
-{
- AtkAttributeSet *return_set;
- AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
- at->name = g_strdup (atk_text_attribute_get_name (attr));
- at->value = value;
- return_set = g_slist_prepend(attrib_set, at);
- return return_set;
-}
-
-/**
* @brief Creates an AtkAttributeSet which consists of the default values of
* attributes for the text.
*
* @returns AtkAttributeSet containing default values of attributes
* at offset.
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_text_get_default_attributes(AtkText *text)
{
AtkAttributeSet *at_set = NULL;
- at_set = _eail_text_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0)));
+ atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0));
- at_set = _eail_text_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, FALSE)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
return at_set;
}
* @returns an AtkAttributeSet which contains the attributes explicitly set at
* offset.
*/
-AtkAttributeSet *
+static AtkAttributeSet *
eail_text_get_run_attributes(AtkText *text,
gint offset,
gint *start_offset,
/* NOTE: Elm_Wrap_Type value is in 100% compatible with ATK wrap modes, so
* no additional conversion is needed*/
Elm_Wrap_Type wrap_type = ELM_WRAP_NONE;
- at_set = _eail_text_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_WRAP_MODE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_WRAP_MODE, wrap_type)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_WRAP_MODE, wrap_type));
- at_set = _eail_text_add_attribute
+ at_set = eail_utils_text_add_attribute
(at_set, ATK_TEXT_ATTR_EDITABLE,
- g_strdup
- (atk_text_attribute_get_value
- (ATK_TEXT_ATTR_EDITABLE, FALSE)));
+ atk_text_attribute_get_value
+ (ATK_TEXT_ATTR_EDITABLE, FALSE));
return at_set;
}
return g_utf8_substring(text, start, end);
}
+
+/*
+ * @brief Adds attribute to attribute set
+ *
+ * @param attrib_set AtkAttributeSet to add the attribute to
+ * @param attr AtkTextAttrribute to be added
+ * @param value attribute value
+ *
+ * Creates an AtkAttribute from attr and value, and adds it
+ * to attrib_set.
+ *
+ * @returns AtkAttributeSet containing set with added attribute
+ **/
+AtkAttributeSet*
+eail_utils_text_add_attribute(AtkAttributeSet *attrib_set,
+ AtkTextAttribute attr,
+ const gchar *value)
+{
+ AtkAttributeSet *return_set;
+ AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
+ at->name = g_strdup (atk_text_attribute_get_name (attr));
+ at->value = g_strdup(value);
+ return_set = g_slist_prepend(attrib_set, at);
+ return return_set;
+}
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
+/*
+ * @brief Helper function to add attribute to attribute set
+ *
+ * @param attrib_set AtkAttributeSet to add the attribute to
+ * @param attr AtkTextAttrribute to be added
+ * @param value attribute value
+ *
+ * Creates an AtkAttribute from attr and value, and adds it
+ * to attrib_set.
+ *
+ * @returns AtkAttributeSet containing set with added attribute
+ **/
+AtkAttributeSet*
+eail_utils_text_add_attribute(AtkAttributeSet *attrib_set,
+ AtkTextAttribute attr,
+ const gchar *value);
#ifdef __cplusplus
}
#endif