Some attribute-related fixes
[platform/upstream/at-spi2-core.git] / atspi / atspi-document.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "atspi-private.h"
25
26 /**
27  * atspi_document_get_locale:
28  * @obj: a pointer to the #Accessible object on which to operate.
29  *
30  * Gets the locale associated with the document's content.
31  * e.g. the locale for LOCALE_TYPE_MESSAGES.
32  *
33  * Returns: a string compliant with the POSIX standard for locale description.
34  **/
35 gchar *
36 atspi_document_get_locale (AtspiDocument *obj, GError **error)
37 {
38   gchar *retval = NULL;
39
40   g_return_val_if_fail (obj != NULL, g_strdup ("C"));
41
42   _atspi_dbus_call (obj, atspi_interface_document, "GetLocale", error, "=>s", &retval);
43
44   return retval;
45 }
46
47 /**
48  * atspi_document_get_attribute_value:
49  * @obj: a pointer to the #Accessible object on which to operate.
50  * @attribute: a string indicating the name of a specific attribute 
51  *
52  * Gets the value of a single attribute, if specified for the document as a whole.
53  *
54  * (name-value pair) being queried.
55  * 
56  * Returns a string corresponding to the value of the specified attribute, or
57  * an empty string if the attribute is unspecified for the object.
58  **/
59 gchar *
60 atspi_document_get_attribute_value (AtspiDocument *obj,
61                                       gchar *attribute,
62                                       GError **error)
63 {
64   gchar *retval = NULL;
65
66   g_return_val_if_fail (obj != NULL, NULL);
67
68   _atspi_dbus_call (obj, atspi_interface_document, "GetAttributevaluee", error, "s=>s", attribute, &retval);
69
70   if (!retval)
71     retval = g_strdup ("");
72
73   return retval;
74 }
75                                       
76
77 /**
78  * atspi_document_get_attributes:
79  * @obj: a pointer to the #Accessible object on which to operate.
80  * 
81  * Gets all attributes specified for a document as a whole.  
82  *
83  * For attributes which change within 
84  * the document content, see atspi_text_get_attribute_run instead.
85  * 
86  * Returns: (element-type gchar* gchar*) (transfer full): an ::AttributeSet
87  *          containing the attributes of the document, as name-value pairs.
88  **/
89 GHashTable *
90 atspi_document_get_attributes (AtspiDocument *obj, GError **error)
91 {
92   DBusMessage *message;
93
94     g_return_val_if_fail (obj != NULL, NULL);
95
96   message = _atspi_dbus_call_partial (obj, atspi_interface_document, "GetAttributes", error, "");
97   return _atspi_dbus_return_hash_from_message (message);
98 }
99
100 static void
101 atspi_document_base_init (AtspiDocument *klass)
102 {
103 }
104
105 GType
106 atspi_document_get_type (void)
107 {
108   static GType type = 0;
109
110   if (!type) {
111     static const GTypeInfo tinfo =
112     {
113       sizeof (AtspiDocument),
114       (GBaseInitFunc) atspi_document_base_init,
115       (GBaseFinalizeFunc) NULL,
116     };
117
118     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiDocument", &tinfo, 0);
119
120   }
121   return type;
122 }