atktext: Fixing some typos on atk_text_get_text_at_offset deprecation
[atk.git] / atk / atkstreamablecontent.c
blob4e8399a96b1b9973d622d532d9c3c210bd31dcdd
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "atkstreamablecontent.h"
22 /**
23 * SECTION:atkstreamablecontent
24 * @Short_description: The ATK interface which provides access to
25 * streamable content.
26 * @Title:AtkStreamableContent
28 * An interface whereby an object allows its backing content to be
29 * streamed to clients. Typical implementors would be images or
30 * icons, HTML content, or multimedia display/rendering widgets.
32 * Negotiation of content type is allowed. Clients may examine the
33 * backing data and transform, convert, or parse the content in order
34 * to present it in an alternate form to end-users.
36 * The AtkStreamableContent interface is particularly useful for
37 * saving, printing, or post-processing entire documents, or for
38 * persisting alternate views of a document. If document content
39 * itself is being serialized, stored, or converted, then use of the
40 * AtkStreamableContent interface can help address performance
41 * issues. Unlike most ATK interfaces, this interface is not strongly
42 * tied to the current user-agent view of the a particular document,
43 * but may in some cases give access to the underlying model data.
46 GType
47 atk_streamable_content_get_type (void)
49 static GType type = 0;
51 if (!type) {
52 GTypeInfo tinfo =
54 sizeof (AtkStreamableContentIface),
55 (GBaseInitFunc) NULL,
56 (GBaseFinalizeFunc) NULL,
60 type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0);
63 return type;
66 /**
67 * atk_streamable_content_get_n_mime_types:
68 * @streamable: a GObject instance that implements AtkStreamableContentIface
70 * Gets the number of mime types supported by this object.
72 * Returns: a gint which is the number of mime types supported by the object.
73 **/
74 gint
75 atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable)
77 AtkStreamableContentIface *iface;
79 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0);
81 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
83 if (iface->get_n_mime_types)
84 return (iface->get_n_mime_types) (streamable);
85 else
86 return 0;
89 /**
90 * atk_streamable_content_get_mime_type:
91 * @streamable: a GObject instance that implements AtkStreamableContent
92 * @i: a gint representing the position of the mime type starting from 0
94 * Gets the character string of the specified mime type. The first mime
95 * type is at position 0, the second at position 1, and so on.
97 * Returns: a gchar* representing the specified mime type; the caller
98 * should not free the character string.
99 **/
100 const gchar*
101 atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
102 gint i)
104 AtkStreamableContentIface *iface;
106 g_return_val_if_fail (i >= 0, NULL);
107 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
109 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
111 if (iface->get_mime_type)
112 return (iface->get_mime_type) (streamable, i);
113 else
114 return NULL;
118 * atk_streamable_content_get_stream:
119 * @streamable: a GObject instance that implements AtkStreamableContentIface
120 * @mime_type: a gchar* representing the mime type
122 * Gets the content in the specified mime type.
124 * Returns: (transfer full): A #GIOChannel which contains the content in the
125 * specified mime type.
127 GIOChannel*
128 atk_streamable_content_get_stream (AtkStreamableContent *streamable,
129 const gchar *mime_type)
131 AtkStreamableContentIface *iface;
133 g_return_val_if_fail (mime_type != NULL, NULL);
134 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
136 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
138 if (iface->get_stream)
139 return (iface->get_stream) (streamable, mime_type);
140 else
141 return NULL;
145 * atk_streamable_content_get_uri:
146 * @streamable: a GObject instance that implements AtkStreamableContentIface
147 * @mime_type: a gchar* representing the mime type, or NULL to request a URI
148 * for the default mime type.
150 * Get a string representing a URI in IETF standard format
151 * (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
152 * may be streamed in the specified mime-type, if one is available.
153 * If mime_type is NULL, the URI for the default (and possibly only) mime-type is
154 * returned.
156 * Note that it is possible for get_uri to return NULL but for
157 * get_stream to work nonetheless, since not all GIOChannels connect to URIs.
159 * Returns: Returns a string representing a URI, or NULL if no corresponding URI
160 * can be constructed.
162 * Since: 1.12
164 const gchar*
165 atk_streamable_content_get_uri (AtkStreamableContent *streamable,
166 const gchar *mime_type)
168 AtkStreamableContentIface *iface;
170 g_return_val_if_fail (mime_type != NULL, NULL);
171 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
173 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
175 if (iface->get_uri)
176 return (iface->get_uri) (streamable, mime_type);
177 else
178 return NULL;