1 | /* ATK - Accessibility Toolkit |
---|
2 | * Copyright 2001 Sun Microsystems Inc. |
---|
3 | * |
---|
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. |
---|
8 | * |
---|
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. |
---|
13 | * |
---|
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. |
---|
18 | */ |
---|
19 | |
---|
20 | #include "atkstreamablecontent.h" |
---|
21 | |
---|
22 | GType |
---|
23 | atk_streamable_content_get_type (void) |
---|
24 | { |
---|
25 | static GType type = 0; |
---|
26 | |
---|
27 | if (!type) { |
---|
28 | GTypeInfo tinfo = |
---|
29 | { |
---|
30 | sizeof (AtkStreamableContentIface), |
---|
31 | (GBaseInitFunc) NULL, |
---|
32 | (GBaseFinalizeFunc) NULL, |
---|
33 | |
---|
34 | }; |
---|
35 | |
---|
36 | type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0); |
---|
37 | } |
---|
38 | |
---|
39 | return type; |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * atk_streamable_content_get_n_mime_types: |
---|
44 | * @streamable: a GObject instance that implements AtkStreamableContentIface |
---|
45 | * |
---|
46 | * Gets the number of mime types supported by this object. |
---|
47 | * |
---|
48 | * Returns: a gint which is the number of mime types supported by the object. |
---|
49 | **/ |
---|
50 | gint |
---|
51 | atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable) |
---|
52 | { |
---|
53 | AtkStreamableContentIface *iface; |
---|
54 | |
---|
55 | g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0); |
---|
56 | |
---|
57 | iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable); |
---|
58 | |
---|
59 | if (iface->get_n_mime_types) |
---|
60 | return (iface->get_n_mime_types) (streamable); |
---|
61 | else |
---|
62 | return 0; |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * atk_streamable_content_get_mime_type: |
---|
67 | * @streamable: a GObject instance that implements AtkStreamableContent |
---|
68 | * @i: a gint representing the position of the mime type starting from 0 |
---|
69 | * |
---|
70 | * Gets the character string of the specified mime type. The first mime |
---|
71 | * type is at position 0, the second at position 1, and so on. |
---|
72 | * |
---|
73 | * Returns : a gchar* representing the specified mime type; the caller |
---|
74 | * should not free the character string. |
---|
75 | **/ |
---|
76 | G_CONST_RETURN gchar* |
---|
77 | atk_streamable_content_get_mime_type (AtkStreamableContent *streamable, |
---|
78 | gint i) |
---|
79 | { |
---|
80 | AtkStreamableContentIface *iface; |
---|
81 | |
---|
82 | g_return_val_if_fail (i >= 0, NULL); |
---|
83 | g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL); |
---|
84 | |
---|
85 | iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable); |
---|
86 | |
---|
87 | if (iface->get_mime_type) |
---|
88 | return (iface->get_mime_type) (streamable, i); |
---|
89 | else |
---|
90 | return NULL; |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * atk_streamable_content_get_stream: |
---|
95 | * @streamable: a GObject instance that implements AtkStreamableContentIface |
---|
96 | * @mime_type: a gchar* representing the mime type |
---|
97 | * |
---|
98 | * Gets the content in the specified mime type. |
---|
99 | * |
---|
100 | * Returns: A #GIOChannel which contains the content in the specified mime |
---|
101 | * type. |
---|
102 | **/ |
---|
103 | GIOChannel* |
---|
104 | atk_streamable_content_get_stream (AtkStreamableContent *streamable, |
---|
105 | const gchar *mime_type) |
---|
106 | { |
---|
107 | AtkStreamableContentIface *iface; |
---|
108 | |
---|
109 | g_return_val_if_fail (mime_type != NULL, NULL); |
---|
110 | g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL); |
---|
111 | |
---|
112 | iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable); |
---|
113 | |
---|
114 | if (iface->get_stream) |
---|
115 | return (iface->get_stream) (streamable, mime_type); |
---|
116 | else |
---|
117 | return NULL; |
---|
118 | } |
---|