X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk%2Fatkobject.c;h=b1ecf78bf9550f884724d87f08693689313e54a9;hb=c2e2f1b65b4e7a1a921434a4f34f63cce09684ff;hp=ab8f53e8318bf0d604431a9b71185cfdd07a959b;hpb=e4fe9a9b7bb4e314667d4c67f583f6e17232d04e;p=platform%2Fupstream%2Fatk.git diff --git a/atk/atkobject.c b/atk/atkobject.c old mode 100755 new mode 100644 index ab8f53e..b1ecf78 --- a/atk/atkobject.c +++ b/atk/atkobject.c @@ -17,23 +17,17 @@ * Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include - -#ifdef G_OS_WIN32 -#define STRICT -#include -#undef STRICT -#undef FOCUS_EVENT /* pollutes the namespace - * like a six hundred pound gorilla */ -#endif +#include #include "atk.h" #include "atkmarshal.h" -#include "atk-enum-types.h" -#include "atkintl.h" +#include "atkprivate.h" /** * SECTION:atkobject @@ -202,6 +196,22 @@ enum { N_("image map") N_("notification") N_("info bar") + N_("level bar") + N_("title bar") + N_("block quote") + N_("audio") + N_("video") + N_("definition") + N_("article") + N_("landmark") + N_("log") + N_("marquee") + N_("math") + N_("rating") + N_("timer") + N_("description list") + N_("description term") + N_("description value") #endif /* 0 */ static void atk_object_class_init (AtkObjectClass *klass); @@ -237,13 +247,6 @@ static void atk_object_real_set_parent (AtkObject *object, AtkObject *parent); static void atk_object_real_set_role (AtkObject *object, AtkRole role); -static guint atk_object_real_connect_property_change_handler - (AtkObject *obj, - AtkPropertyChangeHandler - *handler); -static void atk_object_real_remove_property_change_handler - (AtkObject *obj, - guint handler_id); static void atk_object_notify (GObject *obj, GParamSpec *pspec); static const gchar* atk_object_real_get_object_locale @@ -269,98 +272,6 @@ static const gchar* const atk_object_name_property_table_summary = "accessible-t static const gchar* const atk_object_name_property_table_caption_object = "accessible-table-caption-object"; static const gchar* const atk_object_name_property_hypertext_num_links = "accessible-hypertext-nlinks"; -#ifdef G_OS_WIN32 - -static HMODULE atk_dll; - -BOOL WINAPI -DllMain (HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - atk_dll = (HMODULE) hinstDLL; - break; - } - - return TRUE; -} - -static const char * -get_atk_locale_dir (void) -{ - static gchar *atk_localedir = NULL; - - if (!atk_localedir) - { - const gchar *p; - gchar *root, *temp; - - /* ATK_LOCALEDIR might end in either /lib/locale or - * /share/locale. Scan for that slash. - */ - p = ATK_LOCALEDIR + strlen (ATK_LOCALEDIR); - while (*--p != '/') - ; - while (*--p != '/') - ; - - root = g_win32_get_package_installation_directory_of_module (atk_dll); - temp = g_build_filename (root, p, NULL); - g_free (root); - - /* atk_localedir is passed to bindtextdomain() which isn't - * UTF-8-aware. - */ - atk_localedir = g_win32_locale_filename_from_utf8 (temp); - g_free (temp); - } - return atk_localedir; -} - -#undef ATK_LOCALEDIR - -#define ATK_LOCALEDIR get_atk_locale_dir() - -#endif - -static void -gettext_initialization (void) -{ -#ifdef ENABLE_NLS - static gboolean gettext_initialized = FALSE; - - if (!gettext_initialized) - { - const char *dir = g_getenv ("ATK_ALT_LOCALEDIR"); - - gettext_initialized = TRUE; - if (dir == NULL) - dir = ATK_LOCALEDIR; - - bindtextdomain (GETTEXT_PACKAGE, dir); -#ifdef HAVE_BIND_TEXTDOMAIN_CODESET - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); -#endif - } -#endif -} - -static void -compact_role_name (gchar *role_name) -{ - gchar *p = role_name; - - while (*p) - { - if (*p == '-') - *p = ' '; - p++; - } -} - static void initialize_role_names () { @@ -382,7 +293,7 @@ initialize_role_names () enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class), i); role_name = g_strdup (enum_value->value_nick); // We want the role names to be in the format "check button" and not "check-button" - compact_role_name (role_name); + _compact_name (role_name); g_ptr_array_add (role_names, role_name); } @@ -442,10 +353,6 @@ atk_object_class_init (AtkObjectClass *klass) klass->set_description = atk_object_real_set_description; klass->set_parent = atk_object_real_set_parent; klass->set_role = atk_object_real_set_role; - klass->connect_property_change_handler = - atk_object_real_connect_property_change_handler; - klass->remove_property_change_handler = - atk_object_real_remove_property_change_handler; klass->get_object_locale = atk_object_real_get_object_locale; /* @@ -457,13 +364,13 @@ atk_object_class_init (AtkObjectClass *klass) klass->visible_data_changed = NULL; klass->active_descendant_changed = NULL; - gettext_initialization (); + _gettext_initialization (); g_object_class_install_property (gobject_class, PROP_NAME, g_param_spec_string (atk_object_name_property_name, _("Accessible Name"), - _("Object instance\'s name formatted for assistive technology access"), + _("Object instance’s name formatted for assistive technology access"), NULL, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, @@ -477,9 +384,19 @@ atk_object_class_init (AtkObjectClass *klass) PROP_PARENT, g_param_spec_object (atk_object_name_property_parent, _("Accessible Parent"), - _("Is used to notify that the parent has changed"), + _("Parent of the current accessible as returned by atk_object_get_parent()"), ATK_TYPE_OBJECT, G_PARAM_READWRITE)); + + /** + * AtkObject:accessible-value: + * + * Numeric value of this object, in case being and AtkValue. + * + * Deprecated: Since 2.12. Use atk_value_get_value_and_text() to get + * the value, and value-changed signal to be notified on their value + * changes. + */ g_object_class_install_property (gobject_class, PROP_VALUE, g_param_spec_double (atk_object_name_property_value, @@ -516,6 +433,14 @@ atk_object_class_init (AtkObjectClass *klass) G_MAXINT, G_MININT, G_PARAM_READABLE)); + + /** + * AtkObject:accessible-table-caption: + * + * Table caption. + * + * Deprecated: Since 1.3. Use table-caption-object instead. + */ g_object_class_install_property (gobject_class, PROP_TABLE_CAPTION, g_param_spec_string (atk_object_name_property_table_caption, @@ -523,6 +448,14 @@ atk_object_class_init (AtkObjectClass *klass) _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"), NULL, G_PARAM_READWRITE)); + /** + * AtkObject:accessible-table-column-header: + * + * Accessible table column header. + * + * Deprecated: Since 2.12. Use atk_table_get_column_header() and + * atk_table_set_column_header() instead. + */ g_object_class_install_property (gobject_class, PROP_TABLE_COLUMN_HEADER, g_param_spec_object (atk_object_name_property_table_column_header, @@ -530,6 +463,15 @@ atk_object_class_init (AtkObjectClass *klass) _("Is used to notify that the table column header has changed"), ATK_TYPE_OBJECT, G_PARAM_READWRITE)); + + /** + * AtkObject:accessible-table-column-description: + * + * Accessible table column description. + * + * Deprecated: Since 2.12. Use atk_table_get_column_description() + * and atk_table_set_column_description() instead. + */ g_object_class_install_property (gobject_class, PROP_TABLE_COLUMN_DESCRIPTION, g_param_spec_string (atk_object_name_property_table_column_description, @@ -537,6 +479,15 @@ atk_object_class_init (AtkObjectClass *klass) _("Is used to notify that the table column description has changed"), NULL, G_PARAM_READWRITE)); + + /** + * AtkObject:accessible-table-row-header: + * + * Accessible table row header. + * + * Deprecated: Since 2.12. Use atk_table_get_row_header() and + * atk_table_set_row_header() instead. + */ g_object_class_install_property (gobject_class, PROP_TABLE_ROW_HEADER, g_param_spec_object (atk_object_name_property_table_row_header, @@ -544,6 +495,14 @@ atk_object_class_init (AtkObjectClass *klass) _("Is used to notify that the table row header has changed"), ATK_TYPE_OBJECT, G_PARAM_READWRITE)); + /** + * AtkObject:accessible-table-row-description: + * + * Accessible table row description. + * + * Deprecated: Since 2.12. Use atk_table_get_row_description() and + * atk_table_set_row_description() instead. + */ g_object_class_install_property (gobject_class, PROP_TABLE_ROW_DESCRIPTION, g_param_spec_string (atk_object_name_property_table_row_description, @@ -580,8 +539,11 @@ atk_object_class_init (AtkObjectClass *klass) * @atkobject: the object which received the signal. * @arg1: The index of the added or removed child. The value can be * -1. This is used if the value is not known by the implementor - * when the child is added or irrelevant. - * @arg2: A gpointer to the child AtkObject which was added or removed + * when the child is added/removed or irrelevant. + * @arg2: A gpointer to the child AtkObject which was added or + * removed. If the child was removed, it is possible that it is not + * available for the implementor. In that case this pointer can be + * NULL. * * The signal "children-changed" is emitted when a child is added or * removed form an object. It supports two details: "add" and @@ -606,7 +568,7 @@ atk_object_class_init (AtkObjectClass *klass) * The signal "focus-event" is emitted when an object gained or lost * focus. * - * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead. + * Deprecated: 2.9.4: Use the #AtkObject::state-change signal instead. */ atk_object_signals[FOCUS_EVENT] = g_signal_new ("focus_event", @@ -620,11 +582,22 @@ atk_object_class_init (AtkObjectClass *klass) /** * AtkObject::property-change: * @atkobject: the object which received the signal. - * @arg1: The new value of the property which changed. + * @arg1: an #AtkPropertyValues containing the new value of the + * property which changed. * * The signal "property-change" is emitted when an object's property - * value changes. The detail identifies the name of the property - * whose value has changed. + * value changes. @arg1 contains an #AtkPropertyValues with the name + * and the new value of the property whose value has changed. Note + * that, as with GObject notify, getting this signal does not + * guarantee that the value of the property has actually changed; it + * may also be emitted when the setter of the property is called to + * reinstate the previous value. + * + * Toolkit implementor note: ATK implementors should use + * g_object_notify() to emit property-changed + * notifications. #AtkObject::property-changed is needed by the + * implementation of atk_add_global_event_listener() because GObject + * notify doesn't support emission hooks. */ atk_object_signals[PROPERTY_CHANGE] = g_signal_new ("property_change", @@ -775,10 +748,17 @@ atk_object_get_description (AtkObject *accessible) * atk_object_get_parent: * @accessible: an #AtkObject * - * Gets the accessible parent of the accessible. + * Gets the accessible parent of the accessible. By default this is + * the one assigned with atk_object_set_parent(), but it is assumed + * that ATK implementors have ways to get the parent of the object + * without the need of assigning it manually with + * atk_object_set_parent(), and will return it with this method. + * + * If you are only interested on the parent assigned with + * atk_object_set_parent(), use atk_object_peek_parent(). * - * Returns: (transfer none): a #AtkObject representing the accessible parent - * of the accessible + * Returns: (transfer none): an #AtkObject representing the accessible + * parent of the accessible **/ AtkObject* atk_object_get_parent (AtkObject *accessible) @@ -795,6 +775,27 @@ atk_object_get_parent (AtkObject *accessible) } /** + * atk_object_peek_parent: + * @accessible: an #AtkObject + * + * Gets the accessible parent of the accessible, if it has been + * manually assigned with atk_object_set_parent. Otherwise, this + * function returns %NULL. + * + * This method is intended as an utility for ATK implementors, and not + * to be exposed to accessible tools. See atk_object_get_parent() for + * further reference. + * + * Returns: (transfer none): an #AtkObject representing the accessible + * parent of the accessible if assigned + **/ +AtkObject* +atk_object_peek_parent (AtkObject *accessible) +{ + return accessible->accessible_parent; +} + +/** * atk_object_get_n_accessible_children: * @accessible: an #AtkObject * @@ -871,13 +872,33 @@ atk_object_ref_relation_set (AtkObject *accessible) * atk_role_register: * @name: a character string describing the new role. * - * Registers the role specified by @name. + * Registers the role specified by @name. @name must be a meaningful + * name. So it should not be empty, or consisting on whitespaces. * - * Returns: an #AtkRole for the new role. + * Deprecated: Since 2.12. If your application/toolkit doesn't find a + * suitable role for a specific object defined at #AtkRole, please + * submit a bug in order to add a new role to the specification. + * + * Returns: an #AtkRole for the new role if added + * properly. ATK_ROLE_INVALID in case of error. **/ AtkRole atk_role_register (const gchar *name) { + gboolean valid = FALSE; + gint i = 0; + glong length = g_utf8_strlen (name, -1); + + for (i=0; i < length; i++) { + if (name[i]!=' ') { + valid = TRUE; + break; + } + } + + if (!valid) + return ATK_ROLE_INVALID; + if (!role_names) initialize_role_names (); @@ -1076,7 +1097,7 @@ atk_object_set_description (AtkObject *accessible, * @accessible: an #AtkObject * @parent: an #AtkObject to be set as the accessible parent * - * Sets the accessible parent of the accessible. + * Sets the accessible parent of the accessible. @parent can be NULL. **/ void atk_object_set_parent (AtkObject *accessible, @@ -1129,7 +1150,8 @@ atk_object_set_role (AtkObject *accessible, * @accessible: an #AtkObject * @handler: a function to be called when a property changes its value * - * Specifies a function to be called when a property changes value. + * Deprecated: Since 2.12. Connect directly to property-change or + * notify signals. * * Returns: a #guint which is the handler id used in * atk_object_remove_property_change_handler() @@ -1154,7 +1176,9 @@ atk_object_connect_property_change_handler (AtkObject *accessible, * atk_object_remove_property_change_handler: * @accessible: an #AtkObject * @handler_id: a guint which identifies the handler to be removed. - * + * + * Deprecated: Since 2.12. + * * Removes a property change handler. **/ void @@ -1176,7 +1200,10 @@ atk_object_remove_property_change_handler (AtkObject *accessible, * @state: an #AtkState whose state is changed * @value: a gboolean which indicates whether the state is being set on or off * - * Emits a state-change signal for the specified state. + * Emits a state-change signal for the specified state. + * + * Note that as a general rule when the state of an existing object changes, + * emitting a notification is expected. **/ void atk_object_notify_state_change (AtkObject *accessible, @@ -1398,7 +1425,7 @@ atk_object_real_get_description (AtkObject *object) static AtkObject* atk_object_real_get_parent (AtkObject *object) { - return object->accessible_parent; + return atk_object_peek_parent (object); } static AtkRole @@ -1463,26 +1490,6 @@ atk_object_real_set_role (AtkObject *object, object->role = role; } -static guint -atk_object_real_connect_property_change_handler (AtkObject *obj, - AtkPropertyChangeHandler *handler) -{ - return g_signal_connect_closure_by_id (obj, - atk_object_signals[PROPERTY_CHANGE], - 0, - g_cclosure_new ( - G_CALLBACK (handler), NULL, - (GClosureNotify) NULL), - FALSE); -} - -static void -atk_object_real_remove_property_change_handler (AtkObject *obj, - guint handler_id) -{ - g_signal_handler_disconnect (obj, handler_id); -} - /** * atk_object_initialize: * @accessible: a #AtkObject @@ -1562,7 +1569,7 @@ atk_role_get_name (AtkRole role) const gchar* atk_role_get_localized_name (AtkRole role) { - gettext_initialization (); + _gettext_initialization (); return dgettext (GETTEXT_PACKAGE, atk_role_get_name (role)); } @@ -1580,7 +1587,7 @@ atk_object_real_get_object_locale (AtkObject *object) * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale * of @accessible. * - * Since: 2.7.90 + * Since: 2.8 * * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES * locale of @accessible.