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, see <http://www.gnu.org/licenses/>.
18 #include "atkstreamablecontent.h"
21 * SECTION:atkstreamablecontent
22 * @Short_description: The ATK interface which provides access to
24 * @Title:AtkStreamableContent
26 * An interface whereby an object allows its backing content to be
27 * streamed to clients. Typical implementors would be images or
28 * icons, HTML content, or multimedia display/rendering widgets.
30 * Negotiation of content type is allowed. Clients may examine the
31 * backing data and transform, convert, or parse the content in order
32 * to present it in an alternate form to end-users.
34 * The AtkStreamableContent interface is particularly useful for
35 * saving, printing, or post-processing entire documents, or for
36 * persisting alternate views of a document. If document content
37 * itself is being serialized, stored, or converted, then use of the
38 * AtkStreamableContent interface can help address performance
39 * issues. Unlike most ATK interfaces, this interface is not strongly
40 * tied to the current user-agent view of the a particular document,
41 * but may in some cases give access to the underlying model data.
45 atk_streamable_content_get_type (void)
47 static GType type = 0;
52 sizeof (AtkStreamableContentIface),
54 (GBaseFinalizeFunc) NULL,
58 type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0);
65 * atk_streamable_content_get_n_mime_types:
66 * @streamable: a GObject instance that implements AtkStreamableContentIface
68 * Gets the number of mime types supported by this object.
70 * Returns: a gint which is the number of mime types supported by the object.
73 atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable)
75 AtkStreamableContentIface *iface;
77 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0);
79 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
81 if (iface->get_n_mime_types)
82 return (iface->get_n_mime_types) (streamable);
88 * atk_streamable_content_get_mime_type:
89 * @streamable: a GObject instance that implements AtkStreamableContent
90 * @i: a gint representing the position of the mime type starting from 0
92 * Gets the character string of the specified mime type. The first mime
93 * type is at position 0, the second at position 1, and so on.
95 * Returns: a gchar* representing the specified mime type; the caller
96 * should not free the character string.
99 atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
102 AtkStreamableContentIface *iface;
104 g_return_val_if_fail (i >= 0, NULL);
105 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
107 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
109 if (iface->get_mime_type)
110 return (iface->get_mime_type) (streamable, i);
116 * atk_streamable_content_get_stream:
117 * @streamable: a GObject instance that implements AtkStreamableContentIface
118 * @mime_type: a gchar* representing the mime type
120 * Gets the content in the specified mime type.
122 * Returns: (transfer full): A #GIOChannel which contains the content in the
123 * specified mime type.
126 atk_streamable_content_get_stream (AtkStreamableContent *streamable,
127 const gchar *mime_type)
129 AtkStreamableContentIface *iface;
131 g_return_val_if_fail (mime_type != NULL, NULL);
132 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
134 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
136 if (iface->get_stream)
137 return (iface->get_stream) (streamable, mime_type);
143 * atk_streamable_content_get_uri:
144 * @streamable: a GObject instance that implements AtkStreamableContentIface
145 * @mime_type: a gchar* representing the mime type, or NULL to request a URI
146 * for the default mime type.
148 * Get a string representing a URI in IETF standard format
149 * (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
150 * may be streamed in the specified mime-type, if one is available.
151 * If mime_type is NULL, the URI for the default (and possibly only) mime-type is
154 * Note that it is possible for get_uri to return NULL but for
155 * get_stream to work nonetheless, since not all GIOChannels connect to URIs.
157 * Returns: Returns a string representing a URI, or NULL if no corresponding URI
158 * can be constructed.
163 atk_streamable_content_get_uri (AtkStreamableContent *streamable,
164 const gchar *mime_type)
166 AtkStreamableContentIface *iface;
168 g_return_val_if_fail (mime_type != NULL, NULL);
169 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
171 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
174 return (iface->get_uri) (streamable, mime_type);