X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk%2Fatktext.c;h=f18e8cb5267308c7b896ac562cd17cd6a34a51f8;hb=refs%2Ftags%2Faccepted%2Ftizen%2F3.0.m2%2Ftv%2F20170105.024221;hp=9cc63b66298454afe7475835495912982d82ffe2;hpb=0f1e31ad2451b1e00f631e217d9d29d306404f2d;p=platform%2Fupstream%2Fatk.git diff --git a/atk/atktext.c b/atk/atktext.c index 9cc63b6..f18e8cb 100755 --- a/atk/atktext.c +++ b/atk/atktext.c @@ -17,9 +17,10 @@ * Boston, MA 02111-1307, USA. */ -#include "atktext.h" +#include "config.h" + +#include "atk.h" #include "atkmarshal.h" -#include "atk-enum-types.h" #include @@ -59,7 +60,6 @@ enum { TEXT_ATTRIBUTES_CHANGED, TEXT_INSERT, TEXT_REMOVE, - TEXT_UPDATE, LAST_SIGNAL }; @@ -199,7 +199,10 @@ atk_text_base_init (AtkTextIface *class) * object which implements the AtkText interface changes, This * signal will have a detail which is either "insert" or * "delete" which identifies whether the text change was an - * insertion or a deletion + * insertion or a deletion. + * + * Deprecated: 2.9.4: Use #AtkObject::text-insert or + * #AtkObject::text-remove instead. */ atk_text_signals[TEXT_CHANGED] = g_signal_new ("text_changed", @@ -216,10 +219,12 @@ atk_text_base_init (AtkTextIface *class) * @atktext: the object which received the signal. * @arg1: The position (character offset) of the insertion. * @arg2: The length (in characters) of text inserted. - * @arg3: The text inserted + * @arg3: The new text inserted * * The "text-insert" signal is emitted when a new text is - * inserted. + * inserted. If the signal was not triggered by the user + * (e.g. typing or pasting text), the "system" detail should be + * included. */ atk_text_signals[TEXT_INSERT] = g_signal_new ("text_insert", @@ -236,10 +241,12 @@ atk_text_base_init (AtkTextIface *class) * @atktext: the object which received the signal. * @arg1: The position (character offset) of the removal. * @arg2: The length (in characters) of text removed. - * @arg3: The text inserted + * @arg3: The old text removed * * The "text-remove" signal is emitted when a new text is - * removed. + * removed. If the signal was not triggered by the user + * (e.g. typing or pasting text), the "system" detail should be + * included. */ atk_text_signals[TEXT_REMOVE] = g_signal_new ("text_remove", @@ -252,28 +259,6 @@ atk_text_base_init (AtkTextIface *class) 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); /** - * AtkText::text-update: - * @atktext: the object which received the signal. - * @arg1: unknown - * @arg2: unknown - * @arg3: unknown - * @arg4: unknown - * - * The "text-update" signal is emitted when a new text is - * updated. - */ - atk_text_signals[TEXT_UPDATE] = - g_signal_new ("text_update", - ATK_TYPE_TEXT, - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - (GSignalAccumulator) NULL, NULL, - atk_marshal_VOID__INT_INT_INT_STRING, - G_TYPE_NONE, - 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); - - - /** * AtkText::text-caret-moved: * @atktext: the object which received the signal. * @arg1: The new position of the text caret. @@ -397,8 +382,7 @@ atk_text_get_character_at_offset (AtkText *text, * * Gets the specified text. * - * Deprecated: This method is deprecated since ATK version - * 2.9.3. Please use atk_text_get_at_offset() instead. + * Deprecated: 2.9.3: Please use atk_text_get_string_at_offset() instead. * * Returns: a newly allocated string containing the text after @offset bounded * by the specified @boundary_type. Use g_free() to free the returned string. @@ -470,6 +454,9 @@ atk_text_get_text_after_offset (AtkText *text, * string is from the line start at or before the offset to the line * start after the offset. * + * Deprecated: This method is deprecated since ATK version + * 2.9.4. Please use atk_text_get_string_at_offset() instead. + * * Returns: a newly allocated string containing the text at @offset bounded by * the specified @boundary_type. Use g_free() to free the returned string. **/ @@ -514,8 +501,7 @@ atk_text_get_text_at_offset (AtkText *text, * * Gets the specified text. * - * Deprecated: This method is deprecated since ATK version - * 2.9.3. Please use atk_text_get_at_offset() instead. + * Deprecated: 2.9.3: Please use atk_text_get_string_at_offset() instead. * * Returns: a newly allocated string containing the text before @offset bounded * by the specified @boundary_type. Use g_free() to free the returned string. @@ -554,6 +540,93 @@ atk_text_get_text_before_offset (AtkText *text, } /** + * atk_text_get_string_at_offset: + * @text: an #AtkText + * @offset: position + * @granularity: An #AtkTextGranularity + * @start_offset: (out): the start offset of the returned string, or -1 + * if an error has occurred (e.g. invalid offset, not implemented) + * @end_offset: (out): the offset of the first character after the returned string, + * or -1 if an error has occurred (e.g. invalid offset, not implemented) + * + * Gets a portion of the text exposed through an #AtkText according to a given @offset + * and a specific @granularity, along with the start and end offsets defining the + * boundaries of such a portion of text. + * + * If @granularity is ATK_TEXT_GRANULARITY_CHAR the character at the + * offset is returned. + * + * If @granularity is ATK_TEXT_GRANULARITY_WORD the returned string + * is from the word start at or before the offset to the word start after + * the offset. + * + * The returned string will contain the word at the offset if the offset + * is inside a word and will contain the word before the offset if the + * offset is not inside a word. + * + * If @granularity is ATK_TEXT_GRANULARITY_SENTENCE the returned string + * is from the sentence start at or before the offset to the sentence + * start after the offset. + * + * The returned string will contain the sentence at the offset if the offset + * is inside a sentence and will contain the sentence before the offset + * if the offset is not inside a sentence. + * + * If @granularity is ATK_TEXT_GRANULARITY_LINE the returned string + * is from the line start at or before the offset to the line + * start after the offset. + * + * If @granularity is ATK_TEXT_GRANULARITY_PARAGRAPH the returned string + * is from the start of the paragraph at or before the offset to the start + * of the following paragraph after the offset. + * + * Since: 2.10 + * + * Returns: (nullable): a newly allocated string containing the text + * at the @offset bounded by the specified @granularity. Use + * g_free() to free the returned string. Returns %NULL if the + * offset is invalid or no implementation is available. + **/ +gchar* atk_text_get_string_at_offset (AtkText *text, + gint offset, + AtkTextGranularity granularity, + gint *start_offset, + gint *end_offset) +{ + AtkTextIface *iface; + gint local_start_offset, local_end_offset; + gint *real_start_offset, *real_end_offset; + + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + if (start_offset) + { + *start_offset = -1; + real_start_offset = start_offset; + } + else + real_start_offset = &local_start_offset; + + if (end_offset) + { + *end_offset = -1; + real_end_offset = end_offset; + } + else + real_end_offset = &local_end_offset; + + if (offset < 0) + return NULL; + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_string_at_offset) + return (*(iface->get_string_at_offset)) (text, offset, granularity, real_start_offset, real_end_offset); + else + return NULL; +} + +/** * atk_text_get_caret_offset: * @text: an #AtkText * @@ -997,10 +1070,8 @@ atk_text_get_range_extents (AtkText *text, g_return_if_fail (ATK_IS_TEXT (text)); g_return_if_fail (rect); + g_return_if_fail (start_offset >= 0 && start_offset < end_offset); - if (start_offset < 0 || start_offset >= end_offset) - return; - iface = ATK_TEXT_GET_IFACE (text); if (iface->get_range_extents) @@ -1021,7 +1092,6 @@ atk_text_get_range_extents (AtkText *text, * * Returns: (array zero-terminated=1): Array of AtkTextRange. The last * element of the array returned by this function will be NULL. - * Virtual: get_bounded_ranges **/ AtkTextRange** atk_text_get_bounded_ranges (AtkText *text, @@ -1192,8 +1262,9 @@ atk_text_attribute_for_name (const gchar *name) * * Gets the value for the index of the #AtkTextAttribute * - * Returns: a string containing the value; this string should not be freed; - * NULL is returned if there are no values maintained for the attr value. + * Returns: (nullable): a string containing the value; this string + * should not be freed; %NULL is returned if there are no values + * maintained for the attr value. **/ const gchar* atk_text_attribute_get_value (AtkTextAttribute attr,