Class RecentManager
- All Implemented Interfaces:
Proxy
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 lookupItem(java.lang.String)
:
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
getItems()
, which returns a list of
Gtk.RecentInfo
.
Note that the maximum age of the recently used files list is
controllable through the Gtk.Settings:gtk-recent-files-max-age
property.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
RecentManager.Builder<B extends RecentManager.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangedCallback
callback.static class
GtkRecentManagerClass
contains only private data.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a new recent manager object.RecentManager
(MemorySegment address) Create a RecentManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addFull
(String uri, RecentData recentData) Adds a new resource, pointed byuri
, into the recently used resources list, using the metadata specified inside theGtkRecentData
passed inrecentData
.boolean
Adds a new resource, pointed byuri
, into the recently used resources list.protected RecentManager
asParent()
Returns this instance as if it were its parent type.static RecentManager.Builder
<? extends RecentManager.Builder> builder()
ARecentManager.Builder
object constructs aRecentManager
with the specified properties.protected void
changed()
void
Emits the "changed" signal.static RecentManager
Gets a unique instance ofGtkRecentManager
that you can share in your application without caring about memory management.getItems()
Gets the list of recently used resources.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the RecentManager classboolean
Checks whether there is a recently used resource registered withuri
inside the recent manager.lookupItem
(String uri) Searches for a URI inside the recently used resources list, and returns aGtkRecentInfo
containing information about the resource like its MIME type, or its display name.boolean
Changes the location of a recently used resource fromuri
tonewUri
.onChanged
(RecentManager.ChangedCallback handler) Emitted when the current recently used resources manager changes its contents.int
Purges every item from the recently used resources list.boolean
removeItem
(String uri) Removes a resource pointed byuri
from the recently used resources list handled by a recent manager.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
RecentManager
Create a RecentManager proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
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 theGtk.RecentManager::changed
signal each time something inside the list changes.GtkRecentManager
objects are expensive: be sure to create them only when needed. You should usegetDefault()
instead.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDefault
Gets a unique instance ofGtkRecentManager
that you can share in your application without caring about memory management.- Returns:
- A unique
GtkRecentManager
. Do not ref or unref it.
-
addFull
Adds a new resource, pointed byuri
, into the recently used resources list, using the metadata specified inside theGtkRecentData
passed inrecentData
.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 URIrecentData
- 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 byuri
, 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
addFull(java.lang.String, org.gnome.gtk.RecentData)
.See
addFull(java.lang.String, org.gnome.gtk.RecentData)
if you want to explicitly define the metadata for the resource pointed byuri
.- 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
. UseRecentInfo.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 withuri
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 aGtkRecentInfo
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 byuri
, ornull
if the URI was not registered in the recently used resources list. Free withRecentInfo.unref()
. - Throws:
GErrorException
- seeGError
-
moveItem
Changes the location of a recently used resource fromuri
tonewUri
.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 resourcenewUri
- the new URI of the recently used resource, ornull
to remove the item pointed byuri
in the list- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
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:
GErrorException
- seeGError
-
removeItem
Removes a resource pointed byuri
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 byuri
has been successfully removed by the recently used resources list, andfalse
otherwise- Throws:
GErrorException
- seeGError
-
changed
protected void changed() -
onChanged
public SignalConnection<RecentManager.ChangedCallback> onChanged(RecentManager.ChangedCallback handler) Emitted when the current recently used resources manager changes its contents.This can happen either by calling
addItem(java.lang.String)
or by another application.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChanged
public void emitChanged()Emits the "changed" signal. SeeonChanged(org.gnome.gtk.RecentManager.ChangedCallback)
. -
builder
ARecentManager.Builder
object constructs aRecentManager
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withRecentManager.Builder.build()
.
-