Package ch.bailu.gtk.gtk
Class RecentManager
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.RecentManager
- All Implemented Interfaces:
PointerInterface
`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:
```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 [method@Gtk.RecentManager.lookup_item]:
```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
[method@Gtk.RecentManager.get_items], which returns a list of
[struct@Gtk.RecentInfo].
Note that the maximum age of the recently used files list is
controllable through the [property@Gtk.Settings:gtk-recent-files-max-age]
property.
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:
```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 [method@Gtk.RecentManager.lookup_item]:
```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
[method@Gtk.RecentManager.get_items], which returns a list of
[struct@Gtk.RecentInfo].
Note that the maximum age of the recently used files list is
controllable through the [property@Gtk.Settings:gtk-recent-files-max-age]
property.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionCreates a new recent manager object.RecentManager
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addFull
(Str uri, RecentData recent_data) Adds a new resource, pointed by @uri, into the recently used
resources list, using the metadata specified inside the
`GtkRecentData` passed in @recent_data.boolean
addFull
(String uri, RecentData recent_data) Adds a new resource, pointed by @uri, into the recently used
resources list, using the metadata specified inside the
`GtkRecentData` passed in @recent_data.boolean
Adds a new resource, pointed by @uri, into the recently used
resources list.boolean
Adds a new resource, pointed by @uri, into the recently used
resources list.static ClassHandler
static RecentManager
Gets a unique instance of `GtkRecentManager` that you can share
in your application without caring about memory management.static int
getItems()
Gets the list of recently used resources.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
boolean
Checks whether there is a recently used resource registered
with @uri inside the recent manager.boolean
Checks whether there is a recently used resource registered
with @uri inside the recent manager.lookupItem
(Str uri) 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.lookupItem
(String uri) 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.boolean
Changes the location of a recently used resource from @uri to @new_uri.boolean
Changes the location of a recently used resource from @uri to @new_uri.onChanged
(RecentManager.OnChanged signal) Connect to signal "changed".int
Purges every item from the recently used resources list.boolean
removeItem
(Str uri) Removes a resource pointed by @uri from the recently used resources
list handled by a recent manager.boolean
removeItem
(String uri) Removes a resource pointed by @uri from the recently used resources
list handled by a recent manager.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CHANGED
- See Also:
-
-
Constructor Details
-
RecentManager
-
RecentManager
public RecentManager()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 [signal@Gtk.RecentManager::changed]
signal each time something inside the list changes.
`GtkRecentManager` objects are expensive: be sure to create them
only when needed. You should use [func@Gtk.RecentManager.get_default]
instead.
-
-
Method Details
-
getClassHandler
-
addFull
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.- Parameters:
uri
- a valid URIrecent_data
- metadata of the resource- Returns:
- %TRUE if the new item was successfully added to the recently used resources list, %FALSE otherwise
-
addFull
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.- Parameters:
uri
- a valid URIrecent_data
- metadata of the resource- Returns:
- %TRUE if the new item was successfully added to the recently used resources list, %FALSE otherwise
-
addItem
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 [method@Gtk.RecentManager.add_full].
See [method@Gtk.RecentManager.add_full] if you want to explicitly
define the metadata for the resource pointed by @uri.- Parameters:
uri
- a valid URI- Returns:
- %TRUE if the new item was successfully added to the recently used resources list
-
addItem
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 [method@Gtk.RecentManager.add_full].
See [method@Gtk.RecentManager.add_full] if you want to explicitly
define the metadata for the resource pointed by @uri.- Parameters:
uri
- a valid URI- Returns:
- %TRUE if the new item was successfully added to the recently used resources list
-
getItems
Gets the list of recently used resources.- Returns:
- a list of newly allocated `GtkRecentInfo objects`. Use [method@Gtk.RecentInfo.unref] on each item inside the list, and then free the list itself using g_list_free().
-
hasItem
Checks whether there is a recently used resource registered
with @uri inside the recent manager.- Parameters:
uri
- a URI- Returns:
- %TRUE if the resource was found, %FALSE otherwise
-
hasItem
Checks whether there is a recently used resource registered
with @uri inside the recent manager.- Parameters:
uri
- a URI- Returns:
- %TRUE if the resource was found, %FALSE otherwise
-
lookupItem
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.- Parameters:
uri
- a URI- Returns:
- a `GtkRecentInfo` containing information about the resource pointed by @uri, or %NULL if the URI was not registered in the recently used resources list. Free with [method@Gtk.RecentInfo.unref].
- Throws:
AllocationError
-
lookupItem
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.- Parameters:
uri
- a URI- Returns:
- a `GtkRecentInfo` containing information about the resource pointed by @uri, or %NULL if the URI was not registered in the recently used resources list. Free with [method@Gtk.RecentInfo.unref].
- Throws:
AllocationError
-
moveItem
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.- Parameters:
uri
- the URI of a recently used resourcenew_uri
- the new URI of the recently used resource, or %NULL to remove the item pointed by @uri in the list- Returns:
- %TRUE on success
- Throws:
AllocationError
-
moveItem
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.- Parameters:
uri
- the URI of a recently used resourcenew_uri
- the new URI of the recently used resource, or %NULL to remove the item pointed by @uri in the list- Returns:
- %TRUE on success
- Throws:
AllocationError
-
purgeItems
Purges every item from the recently used resources list.- Returns:
- the number of items that have been removed from the recently used resources list
- Throws:
AllocationError
-
removeItem
Removes a resource pointed by @uri from the recently used resources
list handled by a recent manager.- Parameters:
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
- Throws:
AllocationError
-
removeItem
Removes a resource pointed by @uri from the recently used resources
list handled by a recent manager.- Parameters:
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
- Throws:
AllocationError
-
onChanged
Connect to signal "changed".
SeeRecentManager.OnChanged.onChanged()
for signal description.
FieldSIGNAL_ON_CHANGED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getDefault
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.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-