Add convenience function atk_object_notify_state_change() to generate
authorPadraig O'Briain <padraigo@src.gnome.org>
Fri, 19 Oct 2001 15:21:01 +0000 (15:21 +0000)
committerPadraig O'Briain <padraigo@src.gnome.org>
Fri, 19 Oct 2001 15:21:01 +0000 (15:21 +0000)
* atk/atkobject.[c|], docs/atk-sections.txt,
docs/tmpl/atkobject.sgml:
Add convenience function atk_object_notify_state_change()
to generate property notification of state change.

* atk/atktext.c, docs/tmpl/atk-unused.sgml:
Correct comments on functions atk_attribute_get_name() and
atk_attribute_get_value()

ChangeLog
atk/atkobject.c
atk/atkobject.h
atk/atktext.c
docs/atk-sections.txt
docs/tmpl/atkobject.sgml

index a5c6650..b921771 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2001-10-19  Padraig O'Briain  <padraig.obriain@sun.com>
+
+       * atk/atkobject.[c|], docs/atk-sections.txt,
+       docs/tmpl/atkobject.sgml:
+       Add convenience function atk_object_notify_state_change()
+       to generate property notification of state change.
+
+       * atk/atktext.c, docs/tmpl/atk-unused.sgml:
+       Correct comments on functions atk_attribute_get_name() and
+       atk_attribute_get_value()
+
 2001-10-17  Padraig O'Briain  <padraig.obriain@sun.com>
 
        * atk/atktext.c:
index 0f8bda1..9e1346c 100755 (executable)
@@ -629,10 +629,10 @@ atk_object_set_name (AtkObject    *accessible,
 
   klass = ATK_OBJECT_GET_CLASS (accessible);
   if (klass->set_name)
-  {
-    (klass->set_name) (accessible, name);
-    g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
-  }
+    {
+      (klass->set_name) (accessible, name);
+      g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
+    }
 }
 
 /**
@@ -653,10 +653,10 @@ atk_object_set_description (AtkObject   *accessible,
 
   klass = ATK_OBJECT_GET_CLASS (accessible);
   if (klass->set_description)
-  {
-    (klass->set_description) (accessible, description);
-    g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
-  }
+    {
+      (klass->set_description) (accessible, description);
+      g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
+    }
 }
 
 /**
@@ -746,6 +746,40 @@ atk_object_remove_property_change_handler  (AtkObject *accessible,
 }
 
 /**
+ * atk_object_notify_state_change:
+ * @accessible: an #AtkObject
+ * @state: an #AtkState whose state is changed
+ * @value : a gboolean which indicates whether the state is being set on or off
+ * 
+ * Emits a property_change signal for the specified state. 
+ * This signal is caught by an #AtkPropertyChangeHandler
+ **/
+void
+atk_object_notify_state_change (AtkObject *accessible,
+                                AtkState  state,
+                                gboolean  value)
+{
+  AtkPropertyValues  values;
+
+  memset (&values.old_value, 0, sizeof (GValue));
+  memset (&values.new_value, 0, sizeof (GValue));
+  values.property_name = atk_object_name_property_state;
+  if (value)
+    {
+       g_value_init (&values.new_value, G_TYPE_INT);
+       g_value_set_int (&values.new_value, state);
+    }
+    else
+    {
+       g_value_init (&values.old_value, G_TYPE_INT);
+       g_value_set_int (&values.old_value, state);
+    }
+  g_signal_emit (accessible, atk_object_signals[PROPERTY_CHANGE],
+                 g_quark_from_string (atk_object_name_property_state),
+                 &values, NULL);
+}
+
+/**
  * atk_implementor_ref_accessible:
  * @implementor: The #GObject instance which should implement #AtkImplementorIface
  * if a non-null return value is required.
@@ -793,7 +827,7 @@ atk_object_real_set_property (GObject      *object,
   accessible = ATK_OBJECT (object);
 
   switch (prop_id)
-  {
+    {
     case PROP_NAME:
       atk_object_set_name (accessible, g_value_get_string (value));
       break;
@@ -809,7 +843,7 @@ atk_object_real_set_property (GObject      *object,
       break;
     default:
       break;
-  }
+    }
 }
 
 static void
@@ -823,7 +857,7 @@ atk_object_real_get_property (GObject      *object,
   accessible = ATK_OBJECT (object);
 
   switch (prop_id)
-  {
+    {
     case PROP_NAME:
       g_value_set_string (value, atk_object_get_name (accessible));
       break;
@@ -836,7 +870,7 @@ atk_object_real_get_property (GObject      *object,
       break;
     default:
       break;
-  }
+    }
 }
 
 static void
@@ -897,23 +931,18 @@ atk_object_real_ref_state_set (AtkObject *accessible)
 
   ap = atk_object_get_parent (accessible);
   if (ap)
-  {
     if (ATK_IS_SELECTION (ap))
-    {
-      int i;
+      {
+        int i;
 
-      atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
+        atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
 
-      i = atk_object_get_index_in_parent (accessible);
-      if (i >= 0)
-      {
-        if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
-        {
-          atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
-        } 
+        i = atk_object_get_index_in_parent (accessible);
+        if (i >= 0)
+          if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
+            atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
       } 
-    } 
-  }
+
   return state_set; 
 }
 
@@ -995,4 +1024,3 @@ atk_object_notify (GObject     *obj,
                  g_quark_from_string (pspec->name),
                  &values, NULL);
 }
-
index 329767a..26f4628 100755 (executable)
@@ -25,6 +25,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 #include <glib-object.h>
+#include <atk/atkstate.h>
 
 /*
  * AtkObject represents the minimum information all accessible objects
@@ -399,9 +400,13 @@ void                    atk_object_set_role                       (AtkObject *ac
  */
 guint                atk_object_connect_property_change_handler  (AtkObject                      *accessible,
                                                                   AtkPropertyChangeHandler       *handler);
-void                 atk_object_remove_property_change_handler  (AtkObject                      *accessible,
-                                                                  guint                         handler_id);
+void                 atk_object_remove_property_change_handler   (AtkObject                      *accessible,
+                                                                  guint                          handler_id);
 
+void                 atk_object_notify_state_change              (AtkObject                      *accessible,
+                                                                  AtkState                       state,
+                                                                  gboolean                       value);
+                                    
 /*
  * Note: the properties which are registered with the GType
  *   property registry, for type ATK_TYPE_OBJECT, are as follows:
index 4c00a8e..ea954ab 100755 (executable)
@@ -891,7 +891,9 @@ atk_attribute_set_free(AtkAttributeSet *attrib_set)
  * atk_attribute_get_name:
  * @attr: The #AtkTextAttribute whose name is required
  *
- * Returns the name corresponding to the attr value.
+ * Gets the name corresponding to the #AtkTextAttribute
+ *
+ * Returns: a string containing the name; this string should not be freed
  **/
 G_CONST_RETURN gchar*
 atk_attribute_get_name (AtkTextAttribute attr)
@@ -905,7 +907,9 @@ atk_attribute_get_name (AtkTextAttribute attr)
  * @attr: The #AtkTextAttribute for which a value is required
  * @index: The index of the required value
  *
- * Returns the value corresponding to the attr value and index.
+ * 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. 
  **/
 G_CONST_RETURN gchar*
index 2ade06b..4bc486d 100644 (file)
@@ -164,6 +164,7 @@ atk_object_set_parent
 atk_object_set_role
 atk_object_connect_property_change_handler
 atk_object_remove_property_change_handler
+atk_object_notify_state_change
 <SUBSECTION Standard>
 ATK_OBJECT
 ATK_IS_OBJECT
index 9b1cb09..be3cc3a 100644 (file)
@@ -288,3 +288,13 @@ of the other ATK interfaces:
 @handler_id: 
 
 
+<!-- ##### FUNCTION atk_object_notify_state_change ##### -->
+<para>
+
+</para>
+
+@accessible: 
+@state: 
+@value: 
+
+