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