PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/generated/gtkd/gtk/RecentInfo.d

http://github.com/gtkd-developers/GtkD
D | 521 lines | 182 code | 57 blank | 282 comment | 15 complexity | bfa880a4516fcd1006e5635cf9e6013e MD5 | raw file
Possible License(s): LGPL-3.0
  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. // generated automatically - do not change
  20. // find conversion definition on APILookup.txt
  21. // implement new conversion functionalities on the wrap.utils pakage
  22. module gtk.RecentInfo;
  23. private import gdkpixbuf.Pixbuf;
  24. private import gio.AppInfoIF;
  25. private import gio.IconIF;
  26. private import glib.ErrorG;
  27. private import glib.GException;
  28. private import glib.Str;
  29. private import gobject.ObjectG;
  30. private import gtk.c.functions;
  31. public import gtk.c.types;
  32. public import gtkc.gtktypes;
  33. private import gtkd.Loader;
  34. /**
  35. * #GtkRecentInfo-struct contains private data only, and should
  36. * be accessed using the provided API.
  37. *
  38. * #GtkRecentInfo constains all the meta-data
  39. * associated with an entry in the recently used files list.
  40. *
  41. * Since: 2.10
  42. */
  43. public class RecentInfo
  44. {
  45. /** the main Gtk struct */
  46. protected GtkRecentInfo* gtkRecentInfo;
  47. protected bool ownedRef;
  48. /** Get the main Gtk struct */
  49. public GtkRecentInfo* getRecentInfoStruct(bool transferOwnership = false)
  50. {
  51. if (transferOwnership)
  52. ownedRef = false;
  53. return gtkRecentInfo;
  54. }
  55. /** the main Gtk struct as a void* */
  56. protected void* getStruct()
  57. {
  58. return cast(void*)gtkRecentInfo;
  59. }
  60. /**
  61. * Sets our main struct and passes it to the parent class.
  62. */
  63. public this (GtkRecentInfo* gtkRecentInfo, bool ownedRef = false)
  64. {
  65. this.gtkRecentInfo = gtkRecentInfo;
  66. this.ownedRef = ownedRef;
  67. }
  68. ~this ()
  69. {
  70. if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef )
  71. gtk_recent_info_unref(gtkRecentInfo);
  72. }
  73. /** */
  74. public static GType getType()
  75. {
  76. return gtk_recent_info_get_type();
  77. }
  78. /**
  79. * Creates a #GAppInfo for the specified #GtkRecentInfo
  80. *
  81. * Params:
  82. * appName = the name of the application that should
  83. * be mapped to a #GAppInfo; if %NULL is used then the default
  84. * application for the MIME type is used
  85. *
  86. * Returns: the newly created #GAppInfo, or %NULL.
  87. * In case of error, @error will be set either with a
  88. * %GTK_RECENT_MANAGER_ERROR or a %G_IO_ERROR
  89. *
  90. * Throws: GException on failure.
  91. */
  92. public AppInfoIF createAppInfo(string appName)
  93. {
  94. GError* err = null;
  95. auto p = gtk_recent_info_create_app_info(gtkRecentInfo, Str.toStringz(appName), &err);
  96. if (err !is null)
  97. {
  98. throw new GException( new ErrorG(err) );
  99. }
  100. if(p is null)
  101. {
  102. return null;
  103. }
  104. return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) p, true);
  105. }
  106. /**
  107. * Checks whether the resource pointed by @info still exists.
  108. * At the moment this check is done only on resources pointing
  109. * to local files.
  110. *
  111. * Returns: %TRUE if the resource exists
  112. *
  113. * Since: 2.10
  114. */
  115. public bool exists()
  116. {
  117. return gtk_recent_info_exists(gtkRecentInfo) != 0;
  118. }
  119. /**
  120. * Gets the timestamp (seconds from system’s Epoch) when the resource
  121. * was added to the recently used resources list.
  122. *
  123. * Returns: the number of seconds elapsed from system’s Epoch when
  124. * the resource was added to the list, or -1 on failure.
  125. *
  126. * Since: 2.10
  127. */
  128. public uint getAdded()
  129. {
  130. return gtk_recent_info_get_added(gtkRecentInfo);
  131. }
  132. /**
  133. * Gets the number of days elapsed since the last update
  134. * of the resource pointed by @info.
  135. *
  136. * Returns: a positive integer containing the number of days
  137. * elapsed since the time this resource was last modified
  138. *
  139. * Since: 2.10
  140. */
  141. public int getAge()
  142. {
  143. return gtk_recent_info_get_age(gtkRecentInfo);
  144. }
  145. /**
  146. * Gets the data regarding the application that has registered the resource
  147. * pointed by @info.
  148. *
  149. * If the command line contains any escape characters defined inside the
  150. * storage specification, they will be expanded.
  151. *
  152. * Params:
  153. * appName = the name of the application that has registered this item
  154. * appExec = return location for the string containing
  155. * the command line
  156. * count = return location for the number of times this item was registered
  157. * time = return location for the timestamp this item was last registered
  158. * for this application
  159. *
  160. * Returns: %TRUE if an application with @app_name has registered this
  161. * resource inside the recently used list, or %FALSE otherwise. The
  162. * @app_exec string is owned by the #GtkRecentInfo and should not be
  163. * modified or freed
  164. *
  165. * Since: 2.10
  166. */
  167. public bool getApplicationInfo(string appName, out string appExec, out uint count, out uint time)
  168. {
  169. char* outappExec = null;
  170. auto p = gtk_recent_info_get_application_info(gtkRecentInfo, Str.toStringz(appName), &outappExec, &count, &time) != 0;
  171. appExec = Str.toString(outappExec);
  172. return p;
  173. }
  174. /**
  175. * Retrieves the list of applications that have registered this resource.
  176. *
  177. * Returns: a newly allocated %NULL-terminated array of strings.
  178. * Use g_strfreev() to free it.
  179. *
  180. * Since: 2.10
  181. */
  182. public string[] getApplications()
  183. {
  184. size_t length;
  185. auto retStr = gtk_recent_info_get_applications(gtkRecentInfo, &length);
  186. scope(exit) Str.freeStringArray(retStr);
  187. return Str.toStringArray(retStr, length);
  188. }
  189. /**
  190. * Gets the (short) description of the resource.
  191. *
  192. * Returns: the description of the resource. The returned string
  193. * is owned by the recent manager, and should not be freed.
  194. *
  195. * Since: 2.10
  196. */
  197. public string getDescription()
  198. {
  199. return Str.toString(gtk_recent_info_get_description(gtkRecentInfo));
  200. }
  201. /**
  202. * Gets the name of the resource. If none has been defined, the basename
  203. * of the resource is obtained.
  204. *
  205. * Returns: the display name of the resource. The returned string
  206. * is owned by the recent manager, and should not be freed.
  207. *
  208. * Since: 2.10
  209. */
  210. public string getDisplayName()
  211. {
  212. return Str.toString(gtk_recent_info_get_display_name(gtkRecentInfo));
  213. }
  214. /**
  215. * Retrieves the icon associated to the resource MIME type.
  216. *
  217. * Returns: a #GIcon containing the icon, or %NULL.
  218. * Use g_object_unref() when finished using the icon
  219. *
  220. * Since: 2.22
  221. */
  222. public IconIF getGicon()
  223. {
  224. auto p = gtk_recent_info_get_gicon(gtkRecentInfo);
  225. if(p is null)
  226. {
  227. return null;
  228. }
  229. return ObjectG.getDObject!(IconIF)(cast(GIcon*) p, true);
  230. }
  231. /**
  232. * Returns all groups registered for the recently used item @info.
  233. * The array of returned group names will be %NULL terminated, so
  234. * length might optionally be %NULL.
  235. *
  236. * Returns: a newly allocated %NULL terminated array of strings.
  237. * Use g_strfreev() to free it.
  238. *
  239. * Since: 2.10
  240. */
  241. public string[] getGroups()
  242. {
  243. size_t length;
  244. auto retStr = gtk_recent_info_get_groups(gtkRecentInfo, &length);
  245. scope(exit) Str.freeStringArray(retStr);
  246. return Str.toStringArray(retStr, length);
  247. }
  248. /**
  249. * Retrieves the icon of size @size associated to the resource MIME type.
  250. *
  251. * Params:
  252. * size = the size of the icon in pixels
  253. *
  254. * Returns: a #GdkPixbuf containing the icon,
  255. * or %NULL. Use g_object_unref() when finished using the icon.
  256. *
  257. * Since: 2.10
  258. */
  259. public Pixbuf getIcon(int size)
  260. {
  261. auto p = gtk_recent_info_get_icon(gtkRecentInfo, size);
  262. if(p is null)
  263. {
  264. return null;
  265. }
  266. return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
  267. }
  268. /**
  269. * Gets the MIME type of the resource.
  270. *
  271. * Returns: the MIME type of the resource. The returned string
  272. * is owned by the recent manager, and should not be freed.
  273. *
  274. * Since: 2.10
  275. */
  276. public string getMimeType()
  277. {
  278. return Str.toString(gtk_recent_info_get_mime_type(gtkRecentInfo));
  279. }
  280. /**
  281. * Gets the timestamp (seconds from system’s Epoch) when the meta-data
  282. * for the resource was last modified.
  283. *
  284. * Returns: the number of seconds elapsed from system’s Epoch when
  285. * the resource was last modified, or -1 on failure.
  286. *
  287. * Since: 2.10
  288. */
  289. public uint getModified()
  290. {
  291. return gtk_recent_info_get_modified(gtkRecentInfo);
  292. }
  293. /**
  294. * Gets the value of the “private” flag. Resources in the recently used
  295. * list that have this flag set to %TRUE should only be displayed by the
  296. * applications that have registered them.
  297. *
  298. * Returns: %TRUE if the private flag was found, %FALSE otherwise
  299. *
  300. * Since: 2.10
  301. */
  302. public bool getPrivateHint()
  303. {
  304. return gtk_recent_info_get_private_hint(gtkRecentInfo) != 0;
  305. }
  306. /**
  307. * Computes a valid UTF-8 string that can be used as the
  308. * name of the item in a menu or list. For example, calling
  309. * this function on an item that refers to
  310. * “file:///foo/bar.txt” will yield “bar.txt”.
  311. *
  312. * Returns: A newly-allocated string in UTF-8 encoding
  313. * free it with g_free()
  314. *
  315. * Since: 2.10
  316. */
  317. public string getShortName()
  318. {
  319. auto retStr = gtk_recent_info_get_short_name(gtkRecentInfo);
  320. scope(exit) Str.freeString(retStr);
  321. return Str.toString(retStr);
  322. }
  323. /**
  324. * Gets the URI of the resource.
  325. *
  326. * Returns: the URI of the resource. The returned string is
  327. * owned by the recent manager, and should not be freed.
  328. *
  329. * Since: 2.10
  330. */
  331. public string getUri()
  332. {
  333. return Str.toString(gtk_recent_info_get_uri(gtkRecentInfo));
  334. }
  335. /**
  336. * Gets a displayable version of the resource’s URI. If the resource
  337. * is local, it returns a local path; if the resource is not local,
  338. * it returns the UTF-8 encoded content of gtk_recent_info_get_uri().
  339. *
  340. * Returns: a newly allocated UTF-8 string containing the
  341. * resource’s URI or %NULL. Use g_free() when done using it.
  342. *
  343. * Since: 2.10
  344. */
  345. public string getUriDisplay()
  346. {
  347. auto retStr = gtk_recent_info_get_uri_display(gtkRecentInfo);
  348. scope(exit) Str.freeString(retStr);
  349. return Str.toString(retStr);
  350. }
  351. /**
  352. * Gets the timestamp (seconds from system’s Epoch) when the meta-data
  353. * for the resource was last visited.
  354. *
  355. * Returns: the number of seconds elapsed from system’s Epoch when
  356. * the resource was last visited, or -1 on failure.
  357. *
  358. * Since: 2.10
  359. */
  360. public uint getVisited()
  361. {
  362. return gtk_recent_info_get_visited(gtkRecentInfo);
  363. }
  364. /**
  365. * Checks whether an application registered this resource using @app_name.
  366. *
  367. * Params:
  368. * appName = a string containing an application name
  369. *
  370. * Returns: %TRUE if an application with name @app_name was found,
  371. * %FALSE otherwise
  372. *
  373. * Since: 2.10
  374. */
  375. public bool hasApplication(string appName)
  376. {
  377. return gtk_recent_info_has_application(gtkRecentInfo, Str.toStringz(appName)) != 0;
  378. }
  379. /**
  380. * Checks whether @group_name appears inside the groups
  381. * registered for the recently used item @info.
  382. *
  383. * Params:
  384. * groupName = name of a group
  385. *
  386. * Returns: %TRUE if the group was found
  387. *
  388. * Since: 2.10
  389. */
  390. public bool hasGroup(string groupName)
  391. {
  392. return gtk_recent_info_has_group(gtkRecentInfo, Str.toStringz(groupName)) != 0;
  393. }
  394. /**
  395. * Checks whether the resource is local or not by looking at the
  396. * scheme of its URI.
  397. *
  398. * Returns: %TRUE if the resource is local
  399. *
  400. * Since: 2.10
  401. */
  402. public bool isLocal()
  403. {
  404. return gtk_recent_info_is_local(gtkRecentInfo) != 0;
  405. }
  406. /**
  407. * Gets the name of the last application that have registered the
  408. * recently used resource represented by @info.
  409. *
  410. * Returns: an application name. Use g_free() to free it.
  411. *
  412. * Since: 2.10
  413. */
  414. public string lastApplication()
  415. {
  416. auto retStr = gtk_recent_info_last_application(gtkRecentInfo);
  417. scope(exit) Str.freeString(retStr);
  418. return Str.toString(retStr);
  419. }
  420. /**
  421. * Checks whether two #GtkRecentInfo-struct point to the same
  422. * resource.
  423. *
  424. * Params:
  425. * infoB = a #GtkRecentInfo
  426. *
  427. * Returns: %TRUE if both #GtkRecentInfo-struct point to the same
  428. * resource, %FALSE otherwise
  429. *
  430. * Since: 2.10
  431. */
  432. public bool match(RecentInfo infoB)
  433. {
  434. return gtk_recent_info_match(gtkRecentInfo, (infoB is null) ? null : infoB.getRecentInfoStruct()) != 0;
  435. }
  436. alias doref = ref_;
  437. /**
  438. * Increases the reference count of @recent_info by one.
  439. *
  440. * Returns: the recent info object with its reference count
  441. * increased by one
  442. *
  443. * Since: 2.10
  444. */
  445. public RecentInfo ref_()
  446. {
  447. auto p = gtk_recent_info_ref(gtkRecentInfo);
  448. if(p is null)
  449. {
  450. return null;
  451. }
  452. return ObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p, true);
  453. }
  454. /**
  455. * Decreases the reference count of @info by one. If the reference
  456. * count reaches zero, @info is deallocated, and the memory freed.
  457. *
  458. * Since: 2.10
  459. */
  460. public void unref()
  461. {
  462. gtk_recent_info_unref(gtkRecentInfo);
  463. }
  464. }