Imported version 2.7.91
[platform/core/uifw/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 #AtspiDocument 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 #AtspiDocument 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  * Returns: a string corresponding to the value of the specified attribute, or
55  * an empty string if the attribute is unspecified for the object.
56  **/
57 gchar *
58 atspi_document_get_attribute_value (AtspiDocument *obj,
59                                       gchar *attribute,
60                                       GError **error)
61 {
62   gchar *retval = NULL;
63
64   g_return_val_if_fail (obj != NULL, NULL);
65
66   _atspi_dbus_call (obj, atspi_interface_document, "GetAttributeValue", error, "s=>s", attribute, &retval);
67
68   if (!retval)
69     retval = g_strdup ("");
70
71   return retval;
72 }
73                                       
74
75 /**
76  * atspi_document_get_attributes:
77  * @obj: a pointer to the #AtspiDocument object on which to operate.
78  * 
79  * Gets all constant attributes for the document as a whole. For attributes
80  * that change within the document content, see @atspi_text_get_attribute_run instead.
81  * 
82  * Returns: (element-type gchar* gchar*) (transfer full): a #GHashTable
83  *          containing the constant attributes of the document, as name-value pairs.
84  **/
85 GHashTable *
86 atspi_document_get_attributes (AtspiDocument *obj, GError **error)
87 {
88   DBusMessage *message;
89
90     g_return_val_if_fail (obj != NULL, NULL);
91
92   message = _atspi_dbus_call_partial (obj, atspi_interface_document, "GetAttributes", error, "");
93   return _atspi_dbus_return_hash_from_message (message);
94 }
95
96 static void
97 atspi_document_base_init (AtspiDocument *klass)
98 {
99 }
100
101 GType
102 atspi_document_get_type (void)
103 {
104   static GType type = 0;
105
106   if (!type) {
107     static const GTypeInfo tinfo =
108     {
109       sizeof (AtspiDocument),
110       (GBaseInitFunc) atspi_document_base_init,
111       (GBaseFinalizeFunc) NULL,
112     };
113
114     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiDocument", &tinfo, 0);
115
116   }
117   return type;
118 }