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