RecentManagerProtocol
public protocol RecentManagerProtocol : ObjectProtocol
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:
(C Language Example):
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()
:
(C Language Example):
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.
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.
-
Untyped pointer to the underlying
GtkRecentManager
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
recent_manager_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
Extension methodvalue: ) 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
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
RecentManagerSignalName
signalDeclaration
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 byuserData
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(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
RecentManagerSignalName
signalDeclaration
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 byuserData
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:
Extension methodhandler: ) Emitted when the current recently used resources manager changes its contents, either by calling
gtk_recent_manager_add_item()
or by another application.Note
This represents the underlyingchanged
signalDeclaration
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 methodTyped
changed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var changedSignal: RecentManagerSignalName { get }
-
onNotifyFilename(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::filename
signalDeclaration
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 methodTyped
notify::filename
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyFilenameSignal: RecentManagerSignalName { get }
-
onNotifySize(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::size
signalDeclaration
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 methodTyped
notify::size
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifySizeSignal: RecentManagerSignalName { get }
-
addFull(uri:
Extension methodrecentData: ) Adds a new resource, pointed by
uri
, into the recently used resources list, using the metadata specified inside theGtkRecentData-struct
passed inrecent_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.Declaration
Swift
@inlinable func addFull<RecentDataT>(uri: UnsafePointer<gchar>!, 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
gtk_recent_manager_add_full()
.See
gtk_recent_manager_add_full()
if you want to explicitly define the metadata for the resource pointed byuri
.Declaration
Swift
@inlinable func addItem(uri: UnsafePointer<gchar>!) -> Bool
-
getItems()
Extension methodGets 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<gchar>!) -> Bool
-
lookupItem(uri:
Extension method) 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.Declaration
Swift
@inlinable func lookupItem(uri: UnsafePointer<gchar>!) throws -> RecentInfoRef!
-
moveItem(uri:
Extension methodnewURI: ) Changes the location of a recently used resource from
uri
tonew_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<gchar>!, newURI: UnsafePointer<gchar>? = nil) throws -> Bool
-
purgeItems()
Extension methodPurges 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<gchar>!) throws -> Bool
-
items
Extension methodGets the list of recently used resources.
Declaration
Swift
@inlinable var items: GLib.ListRef! { get }