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  * Conversion parameters:
26  * inFile  = 
27  * outPack = gtk
28  * outFile = RecentInfo
29  * strct   = GtkRecentInfo
30  * realStrct=
31  * ctorStrct=
32  * clss    = RecentInfo
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_recent_info_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- changed
46  * imports:
47  * 	- glib.Str
48  * 	- gdk.Pixbuf
49  * structWrap:
50  * 	- GdkPixbuf* -> Pixbuf
51  * 	- GtkRecentInfo* -> RecentInfo
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.RecentInfo;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import gobject.Signals;
66 public  import gtkc.gdktypes;
67 
68 private import glib.Str;
69 private import gdk.Pixbuf;
70 
71 
72 
73 
74 /**
75  * Description
76  * GtkRecentManager provides a facility for adding, removing and
77  * looking up recently used files. Each recently used file is
78  * identified by its URI, and has meta-data associated to it, like
79  * the names and command lines of the applications that have
80  * registered it, the number of time each application has registered
81  * the same file, the mime type of the file and whether the file
82  * should be displayed only by the applications that have
83  * registered it.
84  * The GtkRecentManager acts like a database of all the recently
85  * used files. You can create new GtkRecentManager objects, but
86  * it is more efficient to use the standard recent manager for
87  * the GdkScreen so that informations about the recently used
88  * files is shared with other people using them. In case the
89  * default screen is being used, adding a new recently used
90  * file is as simple as:
91  * $(DDOC_COMMENT example)
92  * While looking up a recently used file is as simple as:
93  * $(DDOC_COMMENT example)
94  * Recently used files are supported since GTK+ 2.10.
95  */
96 public class RecentInfo
97 {
98 	
99 	/** the main Gtk struct */
100 	protected GtkRecentInfo* gtkRecentInfo;
101 	
102 	
103 	public GtkRecentInfo* getRecentInfoStruct()
104 	{
105 		return gtkRecentInfo;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected void* getStruct()
111 	{
112 		return cast(void*)gtkRecentInfo;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (GtkRecentInfo* gtkRecentInfo)
119 	{
120 		this.gtkRecentInfo = gtkRecentInfo;
121 	}
122 	
123 	/**
124 	 */
125 	
126 	/**
127 	 * Increases the reference count of recent_info by one.
128 	 * Since 2.10
129 	 * Returns: the recent info object with its reference count increased by one.
130 	 */
131 	public RecentInfo doref()
132 	{
133 		// GtkRecentInfo * gtk_recent_info_ref (GtkRecentInfo *info);
134 		auto p = gtk_recent_info_ref(gtkRecentInfo);
135 		
136 		if(p is null)
137 		{
138 			return null;
139 		}
140 		
141 		return ObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p);
142 	}
143 	
144 	/**
145 	 * Decreases the reference count of info by one. If the reference
146 	 * count reaches zero, info is deallocated, and the memory freed.
147 	 * Since 2.10
148 	 */
149 	public void unref()
150 	{
151 		// void gtk_recent_info_unref (GtkRecentInfo *info);
152 		gtk_recent_info_unref(gtkRecentInfo);
153 	}
154 	
155 	/**
156 	 * Gets the URI of the resource.
157 	 * Since 2.10
158 	 * Returns: the URI of the resource. The returned string is owned by the recent manager, and should not be freed.
159 	 */
160 	public string getUri()
161 	{
162 		// const gchar * gtk_recent_info_get_uri (GtkRecentInfo *info);
163 		return Str.toString(gtk_recent_info_get_uri(gtkRecentInfo));
164 	}
165 	
166 	/**
167 	 * Gets the name of the resource. If none has been defined, the basename
168 	 * of the resource is obtained.
169 	 * Since 2.10
170 	 * Returns: the display name of the resource. The returned string is owned by the recent manager, and should not be freed.
171 	 */
172 	public string getDisplayName()
173 	{
174 		// const gchar * gtk_recent_info_get_display_name (GtkRecentInfo *info);
175 		return Str.toString(gtk_recent_info_get_display_name(gtkRecentInfo));
176 	}
177 	
178 	/**
179 	 * Gets the (short) description of the resource.
180 	 * Since 2.10
181 	 * Returns: the description of the resource. The returned string is owned by the recent manager, and should not be freed.
182 	 */
183 	public string getDescription()
184 	{
185 		// const gchar * gtk_recent_info_get_description (GtkRecentInfo *info);
186 		return Str.toString(gtk_recent_info_get_description(gtkRecentInfo));
187 	}
188 	
189 	/**
190 	 * Gets the MIME type of the resource.
191 	 * Since 2.10
192 	 * Returns: the MIME type of the resource. The returned string is owned by the recent manager, and should not be freed.
193 	 */
194 	public string getMimeType()
195 	{
196 		// const gchar * gtk_recent_info_get_mime_type (GtkRecentInfo *info);
197 		return Str.toString(gtk_recent_info_get_mime_type(gtkRecentInfo));
198 	}
199 	
200 	/**
201 	 * Gets the timestamp (seconds from system's Epoch) when the resource
202 	 * was added to the recently used resources list.
203 	 * Since 2.10
204 	 * Returns: the number of seconds elapsed from system's Epoch when the resource was added to the list, or -1 on failure.
205 	 */
206 	public uint getAdded()
207 	{
208 		// time_t gtk_recent_info_get_added (GtkRecentInfo *info);
209 		return gtk_recent_info_get_added(gtkRecentInfo);
210 	}
211 	
212 	/**
213 	 * Gets the timestamp (seconds from system's Epoch) when the resource
214 	 * was last modified.
215 	 * Since 2.10
216 	 * Returns: the number of seconds elapsed from system's Epoch when the resource was last modified, or -1 on failure.
217 	 */
218 	public uint getModified()
219 	{
220 		// time_t gtk_recent_info_get_modified (GtkRecentInfo *info);
221 		return gtk_recent_info_get_modified(gtkRecentInfo);
222 	}
223 	
224 	/**
225 	 * Gets the timestamp (seconds from system's Epoch) when the resource
226 	 * was last visited.
227 	 * Since 2.10
228 	 * Returns: the number of seconds elapsed from system's Epoch when the resource was last visited, or -1 on failure.
229 	 */
230 	public uint getVisited()
231 	{
232 		// time_t gtk_recent_info_get_visited (GtkRecentInfo *info);
233 		return gtk_recent_info_get_visited(gtkRecentInfo);
234 	}
235 	
236 	/**
237 	 * Gets the value of the "private" flag. Resources in the recently used
238 	 * list that have this flag set to TRUE should only be displayed by the
239 	 * applications that have registered them.
240 	 * Since 2.10
241 	 * Returns: TRUE if the private flag was found, FALSE otherwise.
242 	 */
243 	public int getPrivateHint()
244 	{
245 		// gboolean gtk_recent_info_get_private_hint (GtkRecentInfo *info);
246 		return gtk_recent_info_get_private_hint(gtkRecentInfo);
247 	}
248 	
249 	/**
250 	 * Gets the data regarding the application that has registered the resource
251 	 * pointed by info.
252 	 * If the command line contains any escape characters defined inside the
253 	 * storage specification, they will be expanded.
254 	 * Since 2.10
255 	 * Params:
256 	 * appName = the name of the application that has registered this item
257 	 * appExec = return location for the string containing the command line. [transfer none][out]
258 	 * count = return location for the number of times this item was registered. [out]
259 	 * time = return location for the timestamp this item was last registered
260 	 * for this application. [out]
261 	 * Returns: TRUE if an application with app_name has registered this resource inside the recently used list, or FALSE otherwise. The app_exec string is owned by the GtkRecentInfo and should not be modified or freed
262 	 */
263 	public int getApplicationInfo(string appName, out string appExec, out uint count, out uint time)
264 	{
265 		// gboolean gtk_recent_info_get_application_info  (GtkRecentInfo *info,  const gchar *app_name,  const gchar **app_exec,  guint *count,  time_t *time_);
266 		char* outappExec = null;
267 		
268 		auto p = gtk_recent_info_get_application_info(gtkRecentInfo, Str.toStringz(appName), &outappExec, &count, &time);
269 		
270 		appExec = Str.toString(outappExec);
271 		return p;
272 	}
273 	
274 	/**
275 	 * Retrieves the list of applications that have registered this resource.
276 	 * Since 2.10
277 	 * Returns: a newly allocated NULL-terminated array of strings. Use g_strfreev() to free it. [array length=length zero-terminated=1][transfer full]
278 	 */
279 	public string[] getApplications()
280 	{
281 		// gchar ** gtk_recent_info_get_applications (GtkRecentInfo *info,  gsize *length);
282 		gsize length;
283 		auto p = gtk_recent_info_get_applications(gtkRecentInfo, &length);
284 		
285 		string[] strArray = null;
286 		foreach ( cstr; p[0 .. length] )
287 		{
288 			strArray ~= Str.toString(cstr);
289 		}
290 		
291 		return strArray;
292 	}
293 	
294 	/**
295 	 * Gets the name of the last application that have registered the
296 	 * recently used resource represented by info.
297 	 * Since 2.10
298 	 * Returns: an application name. Use g_free() to free it.
299 	 */
300 	public string lastApplication()
301 	{
302 		// gchar * gtk_recent_info_last_application (GtkRecentInfo *info);
303 		return Str.toString(gtk_recent_info_last_application(gtkRecentInfo));
304 	}
305 	
306 	/**
307 	 * Returns all groups registered for the recently used item info. The
308 	 * array of returned group names will be NULL terminated, so length might
309 	 * optionally be NULL.
310 	 * Since 2.10
311 	 * Returns: a newly allocated NULL terminated array of strings. Use g_strfreev() to free it. [array length=length zero-terminated=1][transfer full]
312 	 */
313 	public string[] getGroups()
314 	{
315 		// gchar ** gtk_recent_info_get_groups (GtkRecentInfo *info,  gsize *length);
316 		gsize length;
317 		auto p = gtk_recent_info_get_groups(gtkRecentInfo, &length);
318 		
319 		string[] strArray = null;
320 		foreach ( cstr; p[0 .. length] )
321 		{
322 			strArray ~= Str.toString(cstr);
323 		}
324 		
325 		return strArray;
326 	}
327 	
328 	/**
329 	 * Checks whether group_name appears inside the groups registered for the
330 	 * recently used item info.
331 	 * Since 2.10
332 	 * Params:
333 	 * groupName = name of a group
334 	 * Returns: TRUE if the group was found.
335 	 */
336 	public int hasGroup(string groupName)
337 	{
338 		// gboolean gtk_recent_info_has_group (GtkRecentInfo *info,  const gchar *group_name);
339 		return gtk_recent_info_has_group(gtkRecentInfo, Str.toStringz(groupName));
340 	}
341 	
342 	/**
343 	 * Checks whether an application registered this resource using app_name.
344 	 * Since 2.10
345 	 * Params:
346 	 * appName = a string containing an application name
347 	 * Returns: TRUE if an application with name app_name was found, FALSE otherwise.
348 	 */
349 	public int hasApplication(string appName)
350 	{
351 		// gboolean gtk_recent_info_has_application (GtkRecentInfo *info,  const gchar *app_name);
352 		return gtk_recent_info_has_application(gtkRecentInfo, Str.toStringz(appName));
353 	}
354 	
355 	/**
356 	 * Retrieves the icon of size size associated to the resource MIME type.
357 	 * Since 2.10
358 	 * Params:
359 	 * size = the size of the icon in pixels
360 	 * Returns: a GdkPixbuf containing the icon, or NULL. Use g_object_unref() when finished using the icon. [transfer full]
361 	 */
362 	public Pixbuf getIcon(int size)
363 	{
364 		// GdkPixbuf * gtk_recent_info_get_icon (GtkRecentInfo *info,  gint size);
365 		auto p = gtk_recent_info_get_icon(gtkRecentInfo, size);
366 		
367 		if(p is null)
368 		{
369 			return null;
370 		}
371 		
372 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
373 	}
374 	
375 	/**
376 	 * Computes a valid UTF-8 string that can be used as the name of the item in a
377 	 * menu or list. For example, calling this function on an item that refers to
378 	 * "file:///foo/bar.txt" will yield "bar.txt".
379 	 * Since 2.10
380 	 * Returns: A newly-allocated string in UTF-8 encoding; free it with g_free().
381 	 */
382 	public string getShortName()
383 	{
384 		// gchar * gtk_recent_info_get_short_name (GtkRecentInfo *info);
385 		return Str.toString(gtk_recent_info_get_short_name(gtkRecentInfo));
386 	}
387 	
388 	/**
389 	 * Gets a displayable version of the resource's URI. If the resource
390 	 * is local, it returns a local path; if the resource is not local,
391 	 * it returns the UTF-8 encoded content of gtk_recent_info_get_uri().
392 	 * Since 2.10
393 	 * Returns: a newly allocated UTF-8 string containing the resource's URI or NULL. Use g_free() when done using it.
394 	 */
395 	public string getUriDisplay()
396 	{
397 		// gchar * gtk_recent_info_get_uri_display (GtkRecentInfo *info);
398 		return Str.toString(gtk_recent_info_get_uri_display(gtkRecentInfo));
399 	}
400 	
401 	/**
402 	 * Gets the number of days elapsed since the last update of the resource
403 	 * pointed by info.
404 	 * Since 2.10
405 	 * Returns: a positive integer containing the number of days elapsed since the time this resource was last modified.
406 	 */
407 	public int getAge()
408 	{
409 		// gint gtk_recent_info_get_age (GtkRecentInfo *info);
410 		return gtk_recent_info_get_age(gtkRecentInfo);
411 	}
412 	
413 	/**
414 	 * Checks whether the resource is local or not by looking at the
415 	 * scheme of its URI.
416 	 * Since 2.10
417 	 * Returns: TRUE if the resource is local.
418 	 */
419 	public int isLocal()
420 	{
421 		// gboolean gtk_recent_info_is_local (GtkRecentInfo *info);
422 		return gtk_recent_info_is_local(gtkRecentInfo);
423 	}
424 	
425 	/**
426 	 * Checks whether the resource pointed by info still exists. At
427 	 * the moment this check is done only on resources pointing to local files.
428 	 * Since 2.10
429 	 * Returns: TRUE if the resource exists
430 	 */
431 	public int exists()
432 	{
433 		// gboolean gtk_recent_info_exists (GtkRecentInfo *info);
434 		return gtk_recent_info_exists(gtkRecentInfo);
435 	}
436 	
437 	/**
438 	 * Checks whether two GtkRecentInfo structures point to the same
439 	 * resource.
440 	 * Since 2.10
441 	 * Params:
442 	 * infoB = a GtkRecentInfo
443 	 * Returns: TRUE if both GtkRecentInfo structures point to se same resource, FALSE otherwise.
444 	 */
445 	public int match(RecentInfo infoB)
446 	{
447 		// gboolean gtk_recent_info_match (GtkRecentInfo *info_a,  GtkRecentInfo *info_b);
448 		return gtk_recent_info_match(gtkRecentInfo, (infoB is null) ? null : infoB.getRecentInfoStruct());
449 	}
450 }