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 gstreamer.PresetT;
26 
27 public  import glib.Str;
28 public  import gstreamerc.gstreamer;
29 public  import gstreamerc.gstreamertypes;
30 
31 
32 /**
33  * This interface offers methods to query and manipulate parameter preset sets.
34  * A preset is a bunch of property settings, together with meta data and a name.
35  * The name of a preset serves as key for subsequent method calls to manipulate
36  * single presets.
37  * All instances of one type will share the list of presets. The list is created
38  * on demand, if presets are not used, the list is not created.
39  * 
40  * The interface comes with a default implementation that serves most plugins.
41  * Wrapper plugins will override most methods to implement support for the
42  * native preset format of those wrapped plugins.
43  * One method that is useful to be overridden is gst_preset_get_property_names().
44  * With that one can control which properties are saved and in which order.
45  * When implementing support for read-only presets, one should set the vmethods
46  * for gst_preset_save_preset() and gst_preset_delete_preset() to %NULL.
47  * Applications can use gst_preset_is_editable() to check for that.
48  * 
49  * The default implementation supports presets located in a system directory,
50  * application specific directory and in the users home directory. When getting
51  * a list of presets individual presets are read and overlaid in 1) system,
52  * 2) application and 3) user order. Whenever an earlier entry is newer, the
53  * later entries will be updated. Since 1.8 you can also provide extra paths
54  * where to find presets through the GST_PRESET_PATH environment variable.
55  * Presets found in those paths will be concidered as "app presets".
56  */
57 public template PresetT(TStruct)
58 {
59 	/** Get the main Gtk struct */
60 	public GstPreset* getPresetStruct()
61 	{
62 		return cast(GstPreset*)getStruct();
63 	}
64 
65 
66 	/**
67 	 * Gets the directory for application specific presets if set by the
68 	 * application.
69 	 *
70 	 * Return: the directory or %NULL, don't free or modify
71 	 *     the string
72 	 */
73 	public static string getAppDir()
74 	{
75 		return Str.toString(gst_preset_get_app_dir());
76 	}
77 
78 	/**
79 	 * Sets an extra directory as an absolute path that should be considered when
80 	 * looking for presets. Any presets in the application dir will shadow the
81 	 * system presets.
82 	 *
83 	 * Params:
84 	 *     appDir = the application specific preset dir
85 	 *
86 	 * Return: %TRUE for success, %FALSE if the dir already has been set
87 	 */
88 	public static bool setAppDir(string appDir)
89 	{
90 		return gst_preset_set_app_dir(Str.toStringz(appDir)) != 0;
91 	}
92 
93 	/**
94 	 * Delete the given preset.
95 	 *
96 	 * Params:
97 	 *     name = preset name to remove
98 	 *
99 	 * Return: %TRUE for success, %FALSE if e.g. there is no preset with that @name
100 	 */
101 	public bool deletePreset(string name)
102 	{
103 		return gst_preset_delete_preset(getPresetStruct(), Str.toStringz(name)) != 0;
104 	}
105 
106 	/**
107 	 * Gets the @value for an existing meta data @tag. Meta data @tag names can be
108 	 * something like e.g. "comment". Returned values need to be released when done.
109 	 *
110 	 * Params:
111 	 *     name = preset name
112 	 *     tag = meta data item name
113 	 *     value = value
114 	 *
115 	 * Return: %TRUE for success, %FALSE if e.g. there is no preset with that @name
116 	 *     or no value for the given @tag
117 	 */
118 	public bool getMeta(string name, string tag, out string value)
119 	{
120 		char* outvalue = null;
121 		
122 		auto p = gst_preset_get_meta(getPresetStruct(), Str.toStringz(name), Str.toStringz(tag), &outvalue) != 0;
123 		
124 		value = Str.toString(outvalue);
125 		
126 		return p;
127 	}
128 
129 	/**
130 	 * Get a copy of preset names as a %NULL terminated string array.
131 	 *
132 	 * Return: list with names, use g_strfreev() after usage.
133 	 */
134 	public string[] getPresetNames()
135 	{
136 		auto retStr = gst_preset_get_preset_names(getPresetStruct());
137 		
138 		scope(exit) Str.freeStringArray(retStr);
139 		return Str.toStringArray(retStr);
140 	}
141 
142 	/**
143 	 * Get a the names of the GObject properties that can be used for presets.
144 	 *
145 	 * Return: an
146 	 *     array of property names which should be freed with g_strfreev() after use.
147 	 */
148 	public string[] getPropertyNames()
149 	{
150 		auto retStr = gst_preset_get_property_names(getPresetStruct());
151 		
152 		scope(exit) Str.freeStringArray(retStr);
153 		return Str.toStringArray(retStr);
154 	}
155 
156 	/**
157 	 * Check if one can add new presets, change existing ones and remove presets.
158 	 *
159 	 * Return: %TRUE if presets are editable or %FALSE if they are static
160 	 *
161 	 * Since: 1.6
162 	 */
163 	public bool isEditable()
164 	{
165 		return gst_preset_is_editable(getPresetStruct()) != 0;
166 	}
167 
168 	/**
169 	 * Load the given preset.
170 	 *
171 	 * Params:
172 	 *     name = preset name to load
173 	 *
174 	 * Return: %TRUE for success, %FALSE if e.g. there is no preset with that @name
175 	 */
176 	public bool loadPreset(string name)
177 	{
178 		return gst_preset_load_preset(getPresetStruct(), Str.toStringz(name)) != 0;
179 	}
180 
181 	/**
182 	 * Renames a preset. If there is already a preset by the @new_name it will be
183 	 * overwritten.
184 	 *
185 	 * Params:
186 	 *     oldName = current preset name
187 	 *     newName = new preset name
188 	 *
189 	 * Return: %TRUE for success, %FALSE if e.g. there is no preset with @old_name
190 	 */
191 	public bool renamePreset(string oldName, string newName)
192 	{
193 		return gst_preset_rename_preset(getPresetStruct(), Str.toStringz(oldName), Str.toStringz(newName)) != 0;
194 	}
195 
196 	/**
197 	 * Save the current object settings as a preset under the given name. If there
198 	 * is already a preset by this @name it will be overwritten.
199 	 *
200 	 * Params:
201 	 *     name = preset name to save
202 	 *
203 	 * Return: %TRUE for success, %FALSE
204 	 */
205 	public bool savePreset(string name)
206 	{
207 		return gst_preset_save_preset(getPresetStruct(), Str.toStringz(name)) != 0;
208 	}
209 
210 	/**
211 	 * Sets a new @value for an existing meta data item or adds a new item. Meta
212 	 * data @tag names can be something like e.g. "comment". Supplying %NULL for the
213 	 * @value will unset an existing value.
214 	 *
215 	 * Params:
216 	 *     name = preset name
217 	 *     tag = meta data item name
218 	 *     value = new value
219 	 *
220 	 * Return: %TRUE for success, %FALSE if e.g. there is no preset with that @name
221 	 */
222 	public bool setMeta(string name, string tag, string value)
223 	{
224 		return gst_preset_set_meta(getPresetStruct(), Str.toStringz(name), Str.toStringz(tag), Str.toStringz(value)) != 0;
225 	}
226 }