Add missing accessibility states
[platform/upstream/atk.git] / atk / atkeditabletext.c
index 2d65cc6..d44f8bf 100755 (executable)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "atkeditabletext.h"
-
-enum {
-  TEXT_CHANGED,
-  CARET_MOVED,
-  LAST_SIGNAL
-};
-
-struct _AtkEditableTextIfaceClass
-{
-  GObjectClass parent;
-};
-
-typedef struct _AtkEditableTextIfaceClass AtkEditableTextIfaceClass;
+#include "config.h"
 
-#if 0
-static void atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass);
-
-static gpointer parent_class = NULL;
-#endif
+#include "atkeditabletext.h"
 
+/**
+ * SECTION:atkeditabletext
+ * @Short_description: The ATK interface implemented by components
+ *  containing user-editable text content.
+ * @Title:AtkEditableText
+ *
+ * #AtkEditableText should be implemented by UI components which
+ * contain text which the user can edit, via the #AtkObject
+ * corresponding to that component (see #AtkObject).
+ *
+ * #AtkEditableText is a subclass of #AtkText, and as such, an object
+ * which implements #AtkEditableText is by definition an #AtkText
+ * implementor as well.
+ *
+ * See also: #AtkText
+ */
 
 GType
-atk_editable_text_get_type ()
+atk_editable_text_get_type (void)
 {
   static GType type = 0;
 
@@ -48,8 +47,8 @@ atk_editable_text_get_type ()
     static const GTypeInfo tinfo =
     {
       sizeof (AtkEditableTextIface),
-      NULL,
-      NULL,
+      (GBaseInitFunc) NULL,
+      (GBaseFinalizeFunc) NULL,
 
     };
 
@@ -59,83 +58,57 @@ atk_editable_text_get_type ()
   return type;
 }
 
-/*
- * Additional GObject properties exported by AtkText:
- *    "accessible_text" (accessible text has changed)
- *    "accessible_caret" (accessible text cursor position changed:
- *                         editable text only)
- */
-
-#if 0
-static void
-atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass)
-{
-  parent_class = g_type_class_ref (ATK_TYPE_EDITABLE_TEXT);
-
-  /* Note that text_changed signal supports details "insert", "delete", possibly "replace". */
-
-  atk_signals[TEXT_CHANGED] =
-    g_signal_newc ("text_changed",
-                   G_TYPE_FROM_CLASS (klass),
-                   G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                   G_STRUCT_OFFSET (AtkEditableTextClass, text_changed), /* still need to declare and define this func */
-                   NULL,
-                   g_cclosure_marshal_VOID__UINT_POINTER,
-                   G_TYPE_NONE,
-                   2, G_TYPE_UINT, ATK_TYPE_OBJECT);
-
-  atk_signals[CARET_MOVED] =
-    g_signal_newc ("text_caret_moved",
-                   G_TYPE_FROM_CLASS (klass),
-                   G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (AtkTextClass, caret_changed), /* still need to declare and define this func */
-                   NULL,
-                   g_cclosure_marshal_VOID__UINT_POINTER,
-                   G_TYPE_NONE,
-                   2, G_TYPE_UINT, ATK_TYPE_OBJECT);
-}
-#endif
-
-void 
-atk_editable_text_select_text (AtkEditableText  *text,
-                               gint             start_pos,
-                               gint             end_pos)
+/**
+ *atk_editable_text_set_run_attributes:
+ *@text: an #AtkEditableText
+ *@attrib_set: an #AtkAttributeSet
+ *@start_offset: start of range in which to set attributes
+ *@end_offset: end of range in which to set attributes
+ *
+ *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
+ *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes 
+ *that can be set. Note that other attributes that do not have corresponding
+ *ATK_ATTRIBUTE macros may also be set for certain text widgets.
+ *
+ *Returns: %TRUE if attributes successfully set for the specified
+ *range, otherwise %FALSE
+ **/
+gboolean
+atk_editable_text_set_run_attributes (AtkEditableText *text,
+                                      AtkAttributeSet *attrib_set,
+                                     gint start_offset,
+                                      gint end_offset)
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
-  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
 
-  if (iface->select_text)
-    (*(iface->select_text)) (text, start_pos, end_pos);
+  if (iface->set_run_attributes)
+    {
+      return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
+    }
+  else
+    {
+      return FALSE;
+    }
 }
 
-void 
-atk_editable_text_set_attributes (AtkEditableText  *text,
-                                  gint             start_pos,
-                                  gint             end_pos,
-                                  PangoAttrList    *attributes)
-{
-  AtkEditableTextIface *iface;
-
-  g_return_if_fail (text != NULL);
-  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
-
-  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
-
-  if (iface->set_attributes)
-    (*(iface->set_attributes)) (text, start_pos, end_pos, attributes);
-}
 
+/**
+ * atk_editable_text_set_text_contents:
+ * @text: an #AtkEditableText
+ * @string: string to set for text contents of @text
+ *
+ * Set text contents of @text.
+ **/
 void 
 atk_editable_text_set_text_contents (AtkEditableText  *text,
                                      const gchar      *string)
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
@@ -144,6 +117,17 @@ atk_editable_text_set_text_contents (AtkEditableText  *text,
     (*(iface->set_text_contents)) (text, string);
 }
 
+/**
+ * atk_editable_text_insert_text:
+ * @text: an #AtkEditableText
+ * @string: the text to insert
+ * @length: the length of text to insert, in bytes
+ * @position: The caller initializes this to 
+ * the position at which to insert the text. After the call it
+ * points at the position after the newly inserted text.
+ *
+ * Insert text at a given position.
+ **/
 void 
 atk_editable_text_insert_text (AtkEditableText  *text,
                                const gchar      *string,
@@ -152,7 +136,6 @@ atk_editable_text_insert_text (AtkEditableText  *text,
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
@@ -161,6 +144,15 @@ atk_editable_text_insert_text (AtkEditableText  *text,
     (*(iface->insert_text)) (text, string, length, position);
 }
 
+/**
+ * atk_editable_text_copy_text:
+ * @text: an #AtkEditableText
+ * @start_pos: start position
+ * @end_pos: end position
+ *
+ * Copy text from @start_pos up to, but not including @end_pos 
+ * to the clipboard.
+ **/
 void 
 atk_editable_text_copy_text (AtkEditableText  *text,
                              gint             start_pos,
@@ -168,7 +160,6 @@ atk_editable_text_copy_text (AtkEditableText  *text,
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
@@ -177,6 +168,15 @@ atk_editable_text_copy_text (AtkEditableText  *text,
     (*(iface->copy_text)) (text, start_pos, end_pos);
 }
 
+/**
+ * atk_editable_text_cut_text:
+ * @text: an #AtkEditableText
+ * @start_pos: start position
+ * @end_pos: end position
+ *
+ * Copy text from @start_pos up to, but not including @end_pos
+ * to the clipboard and then delete from the widget.
+ **/
 void 
 atk_editable_text_cut_text  (AtkEditableText  *text,
                              gint             start_pos,
@@ -184,7 +184,6 @@ atk_editable_text_cut_text  (AtkEditableText  *text,
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
@@ -193,6 +192,14 @@ atk_editable_text_cut_text  (AtkEditableText  *text,
     (*(iface->cut_text)) (text, start_pos, end_pos);
 }
 
+/**
+ * atk_editable_text_delete_text:
+ * @text: an #AtkEditableText
+ * @start_pos: start position
+ * @end_pos: end position
+ *
+ * Delete text @start_pos up to, but not including @end_pos.
+ **/
 void 
 atk_editable_text_delete_text (AtkEditableText  *text,
                                gint             start_pos,
@@ -200,7 +207,6 @@ atk_editable_text_delete_text (AtkEditableText  *text,
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
@@ -209,13 +215,19 @@ atk_editable_text_delete_text (AtkEditableText  *text,
     (*(iface->delete_text)) (text, start_pos, end_pos);
 }
 
+/**
+ * atk_editable_text_paste_text:
+ * @text: an #AtkEditableText
+ * @position: position to paste
+ *
+ * Paste text from clipboard to specified @position.
+ **/
 void 
 atk_editable_text_paste_text (AtkEditableText  *text,
                               gint             position)
 {
   AtkEditableTextIface *iface;
 
-  g_return_if_fail (text != NULL);
   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
 
   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);