/usr/include/d/gtkd-3/gtk/RecentManager.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gtk.RecentManager;
private import glib.ConstructionException;
private import glib.ErrorG;
private import glib.GException;
private import glib.ListG;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
private import gtk.RecentInfo;
private import gtk.c.functions;
public import gtk.c.types;
public import gtkc.gtktypes;
private import std.algorithm;
/**
* #GtkRecentManager provides a facility for adding, removing and
* looking up recently used files. Each recently used file is
* identified by its URI, and has meta-data associated to it, like
* the names and command lines of the applications that have
* registered it, the number of time each application has registered
* the same file, the mime type of the file and whether the file
* should be displayed only by the applications that have
* registered it.
*
* The recently used files list is per user.
*
* The #GtkRecentManager acts like a database of all the recently
* used files. You can create new #GtkRecentManager objects, but
* it is more efficient to use the default manager created by GTK+.
*
* Adding a new recently used file is as simple as:
*
* |[<!-- language="C" -->
* GtkRecentManager *manager;
*
* manager = gtk_recent_manager_get_default ();
* gtk_recent_manager_add_item (manager, file_uri);
* ]|
*
* The #GtkRecentManager will try to gather all the needed information
* from the file itself through GIO.
*
* Looking up the meta-data associated with a recently used file
* given its URI requires calling gtk_recent_manager_lookup_item():
*
* |[<!-- language="C" -->
* GtkRecentManager *manager;
* GtkRecentInfo *info;
* GError *error = NULL;
*
* manager = gtk_recent_manager_get_default ();
* info = gtk_recent_manager_lookup_item (manager, file_uri, &error);
* if (error)
* {
* g_warning ("Could not find the file: %s", error->message);
* g_error_free (error);
* }
* else
* {
* // Use the info object
* gtk_recent_info_unref (info);
* }
* ]|
*
* In order to retrieve the list of recently used files, you can use
* gtk_recent_manager_get_items(), which returns a list of #GtkRecentInfo-structs.
*
* A #GtkRecentManager is the model used to populate the contents of
* one, or more #GtkRecentChooser implementations.
*
* Note that the maximum age of the recently used files list is
* controllable through the #GtkSettings:gtk-recent-files-max-age
* property.
*
* Recently used files are supported since GTK+ 2.10.
*
* Since: 2.10
*/
public class RecentManager : ObjectG
{
/** the main Gtk struct */
protected GtkRecentManager* gtkRecentManager;
/** Get the main Gtk struct */
public GtkRecentManager* getRecentManagerStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gtkRecentManager;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gtkRecentManager;
}
protected override void setStruct(GObject* obj)
{
gtkRecentManager = cast(GtkRecentManager*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GtkRecentManager* gtkRecentManager, bool ownedRef = false)
{
this.gtkRecentManager = gtkRecentManager;
super(cast(GObject*)gtkRecentManager, ownedRef);
}
/** */
public static GType getType()
{
return gtk_recent_manager_get_type();
}
/**
* Creates a new recent manager object. Recent manager objects are used to
* handle the list of recently used resources. A #GtkRecentManager object
* monitors the recently used resources list, and emits the “changed” signal
* each time something inside the list changes.
*
* #GtkRecentManager objects are expensive: be sure to create them only when
* needed. You should use gtk_recent_manager_get_default() instead.
*
* Returns: A newly created #GtkRecentManager object
*
* Since: 2.10
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this()
{
auto p = gtk_recent_manager_new();
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GtkRecentManager*) p, true);
}
/**
* Gets a unique instance of #GtkRecentManager, that you can share
* in your application without caring about memory management.
*
* Returns: A unique #GtkRecentManager. Do not ref or
* unref it.
*
* Since: 2.10
*/
public static RecentManager getDefault()
{
auto p = gtk_recent_manager_get_default();
if(p is null)
{
return null;
}
return ObjectG.getDObject!(RecentManager)(cast(GtkRecentManager*) p);
}
/**
* Adds a new resource, pointed by @uri, into the recently used
* resources list, using the metadata specified inside the
* #GtkRecentData-struct passed in @recent_data.
*
* The passed URI will be used to identify this resource inside the
* list.
*
* In order to register the new recently used resource, metadata about
* the resource must be passed as well as the URI; the metadata is
* stored in a #GtkRecentData-struct, which must contain the MIME
* type of the resource pointed by the URI; the name of the application
* that is registering the item, and a command line to be used when
* launching the item.
*
* Optionally, a #GtkRecentData-struct might contain a UTF-8 string
* to be used when viewing the item instead of the last component of
* the URI; a short description of the item; whether the item should
* be considered private - that is, should be displayed only by the
* applications that have registered it.
*
* Params:
* uri = a valid URI
* recentData = metadata of the resource
*
* Returns: %TRUE if the new item was successfully added to the
* recently used resources list, %FALSE otherwise
*
* Since: 2.10
*/
public bool addFull(string uri, GtkRecentData* recentData)
{
return gtk_recent_manager_add_full(gtkRecentManager, Str.toStringz(uri), recentData) != 0;
}
/**
* Adds a new resource, pointed by @uri, into the recently used
* resources list.
*
* This function automatically retrieves some of the needed
* metadata and setting other metadata to common default values;
* it then feeds the data to gtk_recent_manager_add_full().
*
* See gtk_recent_manager_add_full() if you want to explicitly
* define the metadata for the resource pointed by @uri.
*
* Params:
* uri = a valid URI
*
* Returns: %TRUE if the new item was successfully added
* to the recently used resources list
*
* Since: 2.10
*/
public bool addItem(string uri)
{
return gtk_recent_manager_add_item(gtkRecentManager, Str.toStringz(uri)) != 0;
}
/**
* Gets the list of recently used resources.
*
* Returns: a list of
* newly allocated #GtkRecentInfo objects. Use
* gtk_recent_info_unref() on each item inside the list, and then
* free the list itself using g_list_free().
*
* Since: 2.10
*/
public ListG getItems()
{
auto p = gtk_recent_manager_get_items(gtkRecentManager);
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Checks whether there is a recently used resource registered
* with @uri inside the recent manager.
*
* Params:
* uri = a URI
*
* Returns: %TRUE if the resource was found, %FALSE otherwise
*
* Since: 2.10
*/
public bool hasItem(string uri)
{
return gtk_recent_manager_has_item(gtkRecentManager, Str.toStringz(uri)) != 0;
}
/**
* Searches for a URI inside the recently used resources list, and
* returns a #GtkRecentInfo-struct containing informations about the resource
* like its MIME type, or its display name.
*
* Params:
* uri = a URI
*
* Returns: a #GtkRecentInfo-struct containing information
* about the resource pointed by @uri, or %NULL if the URI was
* not registered in the recently used resources list. Free with
* gtk_recent_info_unref().
*
* Since: 2.10
*
* Throws: GException on failure.
*/
public RecentInfo lookupItem(string uri)
{
GError* err = null;
auto p = gtk_recent_manager_lookup_item(gtkRecentManager, Str.toStringz(uri), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return ObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p, true);
}
/**
* Changes the location of a recently used resource from @uri to @new_uri.
*
* Please note that this function will not affect the resource pointed
* by the URIs, but only the URI used in the recently used resources list.
*
* Params:
* uri = the URI of a recently used resource
* newUri = the new URI of the recently used resource, or
* %NULL to remove the item pointed by @uri in the list
*
* Returns: %TRUE on success
*
* Since: 2.10
*
* Throws: GException on failure.
*/
public bool moveItem(string uri, string newUri)
{
GError* err = null;
auto p = gtk_recent_manager_move_item(gtkRecentManager, Str.toStringz(uri), Str.toStringz(newUri), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Purges every item from the recently used resources list.
*
* Returns: the number of items that have been removed from the
* recently used resources list
*
* Since: 2.10
*
* Throws: GException on failure.
*/
public int purgeItems()
{
GError* err = null;
auto p = gtk_recent_manager_purge_items(gtkRecentManager, &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Removes a resource pointed by @uri from the recently used resources
* list handled by a recent manager.
*
* Params:
* uri = the URI of the item you wish to remove
*
* Returns: %TRUE if the item pointed by @uri has been successfully
* removed by the recently used resources list, and %FALSE otherwise
*
* Since: 2.10
*
* Throws: GException on failure.
*/
public bool removeItem(string uri)
{
GError* err = null;
auto p = gtk_recent_manager_remove_item(gtkRecentManager, Str.toStringz(uri), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
protected class OnChangedDelegateWrapper
{
void delegate(RecentManager) dlg;
gulong handlerId;
this(void delegate(RecentManager) dlg)
{
this.dlg = dlg;
onChangedListeners ~= this;
}
void remove(OnChangedDelegateWrapper source)
{
foreach(index, wrapper; onChangedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onChangedListeners[index] = null;
onChangedListeners = std.algorithm.remove(onChangedListeners, index);
break;
}
}
}
}
OnChangedDelegateWrapper[] onChangedListeners;
/**
* Emitted when the current recently used resources manager changes
* its contents, either by calling gtk_recent_manager_add_item() or
* by another application.
*
* Since: 2.10
*/
gulong addOnChanged(void delegate(RecentManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnChangedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"changed",
cast(GCallback)&callBackChanged,
cast(void*)wrapper,
cast(GClosureNotify)&callBackChangedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackChanged(GtkRecentManager* recentmanagerStruct, OnChangedDelegateWrapper wrapper)
{
wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|