Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
RecentManager
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 RecentManager
acts like a database of all the recently
used files. You can create new RecentManager
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 code
GtkRecentManager *manager; manager = gtk_recent_manager_get_default (); gtk_recent_manager_add_item (manager, file_uri);
The RecentManager
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 recentManagerLookupItem
:
C code
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
recentManagerGetItems
, which returns a list of RecentInfo
-structs.
A RecentManager
is the model used to populate the contents of
one, or more RecentChooser
implementations.
Note that the maximum age of the recently used files list is
controllable through the Settings
:gtk-recent-files-max-age
property.
Recently used files are supported since GTK+ 2.10.
- newtype RecentManager = RecentManager (ManagedPtr RecentManager)
- class GObject o => IsRecentManager o
- toRecentManager :: IsRecentManager o => o -> IO RecentManager
- noRecentManager :: Maybe RecentManager
- data RecentManagerAddFullMethodInfo
- recentManagerAddFull :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> RecentData -> m Bool
- data RecentManagerAddItemMethodInfo
- recentManagerAddItem :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> m Bool
- recentManagerGetDefault :: (HasCallStack, MonadIO m) => m RecentManager
- data RecentManagerGetItemsMethodInfo
- recentManagerGetItems :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> m [RecentInfo]
- data RecentManagerHasItemMethodInfo
- recentManagerHasItem :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> m Bool
- data RecentManagerLookupItemMethodInfo
- recentManagerLookupItem :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> m (Maybe RecentInfo)
- data RecentManagerMoveItemMethodInfo
- recentManagerMoveItem :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> Maybe Text -> m ()
- recentManagerNew :: (HasCallStack, MonadIO m) => m RecentManager
- data RecentManagerPurgeItemsMethodInfo
- recentManagerPurgeItems :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> m Int32
- data RecentManagerRemoveItemMethodInfo
- recentManagerRemoveItem :: (HasCallStack, MonadIO m, IsRecentManager a) => a -> Text -> m ()
- data RecentManagerFilenamePropertyInfo
- constructRecentManagerFilename :: IsRecentManager o => Text -> IO (GValueConstruct o)
- getRecentManagerFilename :: (MonadIO m, IsRecentManager o) => o -> m (Maybe Text)
- recentManagerFilename :: AttrLabelProxy "filename"
- data RecentManagerSizePropertyInfo
- getRecentManagerSize :: (MonadIO m, IsRecentManager o) => o -> m Int32
- recentManagerSize :: AttrLabelProxy "size"
- type C_RecentManagerChangedCallback = Ptr () -> Ptr () -> IO ()
- type RecentManagerChangedCallback = IO ()
- data RecentManagerChangedSignalInfo
- afterRecentManagerChanged :: (GObject a, MonadIO m) => a -> RecentManagerChangedCallback -> m SignalHandlerId
- genClosure_RecentManagerChanged :: RecentManagerChangedCallback -> IO Closure
- mk_RecentManagerChangedCallback :: C_RecentManagerChangedCallback -> IO (FunPtr C_RecentManagerChangedCallback)
- noRecentManagerChangedCallback :: Maybe RecentManagerChangedCallback
- onRecentManagerChanged :: (GObject a, MonadIO m) => a -> RecentManagerChangedCallback -> m SignalHandlerId
- wrap_RecentManagerChangedCallback :: RecentManagerChangedCallback -> Ptr () -> Ptr () -> IO ()
Exported types
newtype RecentManager Source #
GObject RecentManager Source # | |
IsObject RecentManager Source # | |
IsRecentManager RecentManager Source # | |
((~) * info (ResolveRecentManagerMethod t RecentManager), MethodInfo * info RecentManager p) => IsLabel t (RecentManager -> p) Source # | |
((~) * info (ResolveRecentManagerMethod t RecentManager), MethodInfo * info RecentManager p) => IsLabelProxy t (RecentManager -> p) Source # | |
HasAttributeList * RecentManager Source # | |
type AttributeList RecentManager Source # | |
type SignalList RecentManager Source # | |
class GObject o => IsRecentManager o Source #
toRecentManager :: IsRecentManager o => o -> IO RecentManager Source #
Methods
addFull
data RecentManagerAddFullMethodInfo Source #
((~) * signature (Text -> RecentData -> m Bool), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerAddFullMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> RecentData |
|
-> m Bool | Returns: |
Adds a new resource, pointed by uri
, into the recently used
resources list, using the metadata specified inside the
RecentData
-struct passed in recentData
.
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
-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 RecentData
-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.
Since: 2.10
addItem
data RecentManagerAddItemMethodInfo Source #
((~) * signature (Text -> m Bool), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerAddItemMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: |
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 recentManagerAddFull
.
See recentManagerAddFull
if you want to explicitly
define the metadata for the resource pointed by uri
.
Since: 2.10
getDefault
recentManagerGetDefault Source #
:: (HasCallStack, MonadIO m) | |
=> m RecentManager | Returns: A unique |
Gets a unique instance of RecentManager
, that you can share
in your application without caring about memory management.
Since: 2.10
getItems
data RecentManagerGetItemsMethodInfo Source #
((~) * signature (m [RecentInfo]), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerGetItemsMethodInfo a signature Source # | |
recentManagerGetItems Source #
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> m [RecentInfo] | Returns: a list of
newly allocated |
Gets the list of recently used resources.
Since: 2.10
hasItem
data RecentManagerHasItemMethodInfo Source #
((~) * signature (Text -> m Bool), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerHasItemMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> m Bool |
Checks whether there is a recently used resource registered
with uri
inside the recent manager.
Since: 2.10
lookupItem
data RecentManagerLookupItemMethodInfo Source #
((~) * signature (Text -> m (Maybe RecentInfo)), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerLookupItemMethodInfo a signature Source # | |
recentManagerLookupItem Source #
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> m (Maybe RecentInfo) | Returns: a |
Searches for a URI inside the recently used resources list, and
returns a RecentInfo
-struct containing informations about the resource
like its MIME type, or its display name.
Since: 2.10
moveItem
data RecentManagerMoveItemMethodInfo Source #
((~) * signature (Text -> Maybe Text -> m ()), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerMoveItemMethodInfo a signature Source # | |
recentManagerMoveItem Source #
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> Maybe Text |
|
-> m () | (Can throw |
Changes the location of a recently used resource from uri
to newUri
.
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.
Since: 2.10
new
:: (HasCallStack, MonadIO m) | |
=> m RecentManager | Returns: A newly created |
Creates a new recent manager object. Recent manager objects are used to
handle the list of recently used resources. A RecentManager
object
monitors the recently used resources list, and emits the “changed” signal
each time something inside the list changes.
RecentManager
objects are expensive: be sure to create them only when
needed. You should use recentManagerGetDefault
instead.
Since: 2.10
purgeItems
data RecentManagerPurgeItemsMethodInfo Source #
((~) * signature (m Int32), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerPurgeItemsMethodInfo a signature Source # | |
recentManagerPurgeItems Source #
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> m Int32 | Returns: the number of items that have been removed from the
recently used resources list (Can throw |
Purges every item from the recently used resources list.
Since: 2.10
removeItem
data RecentManagerRemoveItemMethodInfo Source #
((~) * signature (Text -> m ()), MonadIO m, IsRecentManager a) => MethodInfo * RecentManagerRemoveItemMethodInfo a signature Source # | |
recentManagerRemoveItem Source #
:: (HasCallStack, MonadIO m, IsRecentManager a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
Removes a resource pointed by uri
from the recently used resources
list handled by a recent manager.
Since: 2.10
Properties
filename
data RecentManagerFilenamePropertyInfo Source #
constructRecentManagerFilename :: IsRecentManager o => Text -> IO (GValueConstruct o) Source #
getRecentManagerFilename :: (MonadIO m, IsRecentManager o) => o -> m (Maybe Text) Source #
recentManagerFilename :: AttrLabelProxy "filename" Source #
size
data RecentManagerSizePropertyInfo Source #
getRecentManagerSize :: (MonadIO m, IsRecentManager o) => o -> m Int32 Source #
recentManagerSize :: AttrLabelProxy "size" Source #
Signals
changed
type RecentManagerChangedCallback = IO () Source #
afterRecentManagerChanged :: (GObject a, MonadIO m) => a -> RecentManagerChangedCallback -> m SignalHandlerId Source #
mk_RecentManagerChangedCallback :: C_RecentManagerChangedCallback -> IO (FunPtr C_RecentManagerChangedCallback) Source #
onRecentManagerChanged :: (GObject a, MonadIO m) => a -> RecentManagerChangedCallback -> m SignalHandlerId Source #
wrap_RecentManagerChangedCallback :: RecentManagerChangedCallback -> Ptr () -> Ptr () -> IO () Source #