gtk4::prelude

Trait RecentManagerExt

Source
pub trait RecentManagerExt: IsA<RecentManager> + 'static {
    // Provided methods
    fn add_full(&self, uri: &str, recent_data: &RecentData) -> bool { ... }
    fn add_item(&self, uri: &str) -> bool { ... }
    fn items(&self) -> Vec<RecentInfo> { ... }
    fn has_item(&self, uri: &str) -> bool { ... }
    fn lookup_item(&self, uri: &str) -> Result<Option<RecentInfo>, Error> { ... }
    fn move_item(&self, uri: &str, new_uri: Option<&str>) -> Result<(), Error> { ... }
    fn purge_items(&self) -> Result<i32, Error> { ... }
    fn remove_item(&self, uri: &str) -> Result<(), Error> { ... }
    fn filename(&self) -> Option<GString> { ... }
    fn size(&self) -> i32 { ... }
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
    fn connect_size_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all RecentManager methods.

§Implementors

RecentManager

Provided Methods§

Source

fn add_full(&self, uri: &str, recent_data: &RecentData) -> bool

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

§uri

a valid URI

§recent_data

metadata of the resource

§Returns

true if the new item was successfully added to the recently used resources list, false otherwise

Source

fn add_item(&self, uri: &str) -> bool

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 add_full().

See add_full() if you want to explicitly define the metadata for the resource pointed by @uri.

§uri

a valid URI

§Returns

true if the new item was successfully added to the recently used resources list

Source

fn items(&self) -> Vec<RecentInfo>

Gets the list of recently used resources.

§Returns

a list of newly allocated GtkRecentInfo objects. Use Gtk::RecentInfo::unref() on each item inside the list, and then free the list itself using g_list_free().

Source

fn has_item(&self, uri: &str) -> bool

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

§uri

a URI

§Returns

true if the resource was found, false otherwise

Source

fn lookup_item(&self, uri: &str) -> Result<Option<RecentInfo>, Error>

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

§uri

a URI

§Returns

a RecentInfo containing information about the resource pointed by @uri, or None if the URI was not registered in the recently used resources list. Free with Gtk::RecentInfo::unref().

Source

fn move_item(&self, uri: &str, new_uri: Option<&str>) -> Result<(), Error>

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.

§uri

the URI of a recently used resource

§new_uri

the new URI of the recently used resource, or None to remove the item pointed by @uri in the list

§Returns

true on success

Source

fn purge_items(&self) -> Result<i32, Error>

Purges every item from the recently used resources list.

§Returns

the number of items that have been removed from the recently used resources list

Source

fn remove_item(&self, uri: &str) -> Result<(), Error>

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

§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

Source

fn filename(&self) -> Option<GString>

The full path to the file to be used to store and read the recently used resources list

Source

fn size(&self) -> i32

The size of the recently used resources list.

Source

fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

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

This can happen either by calling add_item() or by another application.

Source

fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§