RecentManagerProtocol

public protocol RecentManagerProtocol : ObjectProtocol

GtkRecentManager manages and looks 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.

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:

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 [methodGtk.RecentManager.lookup_item]:

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 [methodGtk.RecentManager.get_items], which returns a list of [structGtk.RecentInfo].

Note that the maximum age of the recently used files list is controllable through the [propertyGtk.Settings:gtk-recent-files-max-age] property.

The RecentManagerProtocol protocol exposes the methods and properties of an underlying GtkRecentManager instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see RecentManager. Alternatively, use RecentManagerRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkRecentManager instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • recent_manager_ptr Default implementation

    Typed pointer to the underlying GtkRecentManager instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkRecentManager instance.

    Declaration

    Swift

    var recent_manager_ptr: UnsafeMutablePointer<GtkRecentManager>! { get }
  • Required Initialiser for types conforming to RecentManagerProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

RecentManager Class

  • Bind a RecentManagerPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: RecentManagerPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a RecentManager property

    Declaration

    Swift

    @inlinable
    func get(property: RecentManagerPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a RecentManager property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: RecentManagerPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

RecentManager signals

  • Connect a Swift signal handler to the given, typed RecentManagerSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: RecentManagerSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed RecentManagerSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: RecentManagerSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • onChanged(flags:handler:) Extension method

    Emitted when the current recently used resources manager changes its contents.

    This can happen either by calling [methodGtk.RecentManager.add_item] or by another application.

    Note

    This represents the underlying changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: RecentManagerRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

    The signal handler to call Run the given callback whenever the changed signal is emitted

  • changedSignal Extension method

    Typed changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var changedSignal: RecentManagerSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::filename signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyFilename(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: RecentManagerRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyFilename signal is emitted

  • notifyFilenameSignal Extension method

    Typed notify::filename signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyFilenameSignal: RecentManagerSignalName { get }
  • onNotifySize(flags:handler:) Extension method

    The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::size signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifySize(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: RecentManagerRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifySize signal is emitted

  • notifySizeSignal Extension method

    Typed notify::size signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifySizeSignal: RecentManagerSignalName { get }

RecentManager Class: RecentManagerProtocol extension (methods and fields)

  • addFull(uri:recentData:) Extension method

    Adds a new resource, pointed by uri, into the recently used resources list, using the metadata specified inside the GtkRecentData 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, 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 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.

    Declaration

    Swift

    @inlinable
    func addFull<RecentDataT>(uri: UnsafePointer<CChar>!, recentData: RecentDataT) -> Bool where RecentDataT : RecentDataProtocol
  • addItem(uri:) Extension method

    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 [methodGtk.RecentManager.add_full].

    See [methodGtk.RecentManager.add_full] if you want to explicitly define the metadata for the resource pointed by uri.

    Declaration

    Swift

    @inlinable
    func addItem(uri: UnsafePointer<CChar>!) -> Bool
  • getItems() Extension method

    Gets the list of recently used resources.

    Declaration

    Swift

    @inlinable
    func getItems() -> GLib.ListRef!
  • hasItem(uri:) Extension method

    Checks whether there is a recently used resource registered with uri inside the recent manager.

    Declaration

    Swift

    @inlinable
    func hasItem(uri: UnsafePointer<CChar>!) -> Bool
  • lookupItem(uri:) Extension method

    Searches for a URI inside the recently used resources list, and returns a GtkRecentInfo containing information about the resource like its MIME type, or its display name.

    Declaration

    Swift

    @inlinable
    func lookupItem(uri: UnsafePointer<CChar>!) throws -> RecentInfoRef!
  • moveItem(uri:newUri:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func moveItem(uri: UnsafePointer<CChar>!, newUri: UnsafePointer<CChar>? = nil) throws -> Bool
  • purgeItems() Extension method

    Purges every item from the recently used resources list.

    Declaration

    Swift

    @inlinable
    func purgeItems() throws -> Int
  • removeItem(uri:) Extension method

    Removes a resource pointed by uri from the recently used resources list handled by a recent manager.

    Declaration

    Swift

    @inlinable
    func removeItem(uri: UnsafePointer<CChar>!) throws -> Bool
  • items Extension method

    Gets the list of recently used resources.

    Declaration

    Swift

    @inlinable
    var items: GLib.ListRef! { get }