1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.StreamableContentT;
26 
27 public  import atk.c.functions;
28 public  import atk.c.types;
29 public  import glib.IOChannel;
30 public  import glib.Str;
31 public  import gtkc.atktypes;
32 
33 
34 /**
35  * An interface whereby an object allows its backing content to be
36  * streamed to clients.  Typical implementors would be images or
37  * icons, HTML content, or multimedia display/rendering widgets.
38  * 
39  * Negotiation of content type is allowed. Clients may examine the
40  * backing data and transform, convert, or parse the content in order
41  * to present it in an alternate form to end-users.
42  * 
43  * The AtkStreamableContent interface is particularly useful for
44  * saving, printing, or post-processing entire documents, or for
45  * persisting alternate views of a document. If document content
46  * itself is being serialized, stored, or converted, then use of the
47  * AtkStreamableContent interface can help address performance
48  * issues. Unlike most ATK interfaces, this interface is not strongly
49  * tied to the current user-agent view of the a particular document,
50  * but may in some cases give access to the underlying model data.
51  */
52 public template StreamableContentT(TStruct)
53 {
54 	/** Get the main Gtk struct */
55 	public AtkStreamableContent* getStreamableContentStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return cast(AtkStreamableContent*)getStruct();
60 	}
61 
62 
63 	/**
64 	 * Gets the character string of the specified mime type. The first mime
65 	 * type is at position 0, the second at position 1, and so on.
66 	 *
67 	 * Params:
68 	 *     i = a gint representing the position of the mime type starting from 0
69 	 *
70 	 * Returns: a gchar* representing the specified mime type; the caller
71 	 *     should not free the character string.
72 	 */
73 	public string getMimeType(int i)
74 	{
75 		return Str.toString(atk_streamable_content_get_mime_type(getStreamableContentStruct(), i));
76 	}
77 
78 	/**
79 	 * Gets the number of mime types supported by this object.
80 	 *
81 	 * Returns: a gint which is the number of mime types supported by the object.
82 	 */
83 	public int getNMimeTypes()
84 	{
85 		return atk_streamable_content_get_n_mime_types(getStreamableContentStruct());
86 	}
87 
88 	/**
89 	 * Gets the content in the specified mime type.
90 	 *
91 	 * Params:
92 	 *     mimeType = a gchar* representing the mime type
93 	 *
94 	 * Returns: A #GIOChannel which contains the content in the
95 	 *     specified mime type.
96 	 */
97 	public IOChannel getStream(string mimeType)
98 	{
99 		auto p = atk_streamable_content_get_stream(getStreamableContentStruct(), Str.toStringz(mimeType));
100 
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 
106 		return new IOChannel(cast(GIOChannel*) p, true);
107 	}
108 
109 	/**
110 	 * Get a string representing a URI in IETF standard format
111 	 * (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
112 	 * may be streamed in the specified mime-type, if one is available.
113 	 * If mime_type is NULL, the URI for the default (and possibly only) mime-type is
114 	 * returned.
115 	 *
116 	 * Note that it is possible for get_uri to return NULL but for
117 	 * get_stream to work nonetheless, since not all GIOChannels connect to URIs.
118 	 *
119 	 * Params:
120 	 *     mimeType = a gchar* representing the mime type, or NULL to request a URI
121 	 *         for the default mime type.
122 	 *
123 	 * Returns: Returns a string representing a URI, or %NULL
124 	 *     if no corresponding URI can be constructed.
125 	 *
126 	 * Since: 1.12
127 	 */
128 	public string getUri(string mimeType)
129 	{
130 		return Str.toString(atk_streamable_content_get_uri(getStreamableContentStruct(), Str.toStringz(mimeType)));
131 	}
132 }