Class RecentManager
- All Implemented Interfaces:
Proxy
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
Nested ClassesModifier and TypeClassDescriptionstatic classRecentManager.Builder<B extends RecentManager.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theChangedCallbackcallback.static classGtkRecentManagerClasscontains only private data.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RecentManager.RecentManager(MemorySegment address) Create a RecentManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddFull(String uri, RecentData recentData) Adds a new resource, pointed byuri,into the recently used resources list, using the metadata specified inside theGtkRecentDatapassed inrecentData.booleanAdds a new resource, pointed byuri,into the recently used resources list.protected RecentManagerasParent()Returns this instance as if it were its parent type.static RecentManager.Builder<? extends RecentManager.Builder> builder()ARecentManager.Builderobject constructs aRecentManagerwith the specified properties.protected voidchanged()voidEmits the "changed" signal.static RecentManagerGets a unique instance ofGtkRecentManagerthat you can share in your application without caring about memory management.getItems()Gets the list of recently used resources.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the RecentManager classbooleanChecks whether there is a recently used resource registered withuriinside the recent manager.@Nullable RecentInfolookupItem(String uri) Searches for a URI inside the recently used resources list, and returns aGtkRecentInfocontaining information about the resource like its MIME type, or its display name.booleanChanges the location of a recently used resource fromuritonewUri.onChanged(RecentManager.ChangedCallback handler) Emitted when the current recently used resources manager changes its contents.intPurges every item from the recently used resources list.booleanremoveItem(String uri) Removes a resource pointed byurifrom 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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 RecentManager.
-
-
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 Javasuperkeyword, 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 ofGtkRecentManagerthat 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 theGtkRecentDatapassed 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
GtkRecentDatamight 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:
trueif the new item was successfully added to the recently used resources list,falseotherwise
-
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:
trueif 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 withuriinside the recent manager.- Parameters:
uri- a URI- Returns:
trueif the resource was found,falseotherwise
-
lookupItem
Searches for a URI inside the recently used resources list, and returns aGtkRecentInfocontaining information about the resource like its MIME type, or its display name.- Parameters:
uri- a URI- Returns:
- a
GtkRecentInfocontaining information about the resource pointed byuri,ornullif 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 fromuritonewUri.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, ornullto remove the item pointed byuriin the list- Returns:
trueon 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 byurifrom the recently used resources list handled by a recent manager.- Parameters:
uri- the URI of the item you wish to remove- Returns:
trueif the item pointed byurihas been successfully removed by the recently used resources list, andfalseotherwise- 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.Builderobject constructs aRecentManagerwith the specified properties. Use the variousset...()methods to set properties, and finish construction withRecentManager.Builder.build().- Returns:
- the builder object
-