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