JFLib

plat/recent.rs#

Source: lib/plat/recent.rs

recent -- the system's list of recently used files

  recent_add(path) -> bool        a file the user opened or saved.  Windows:
                                  SHAddToRecentDocs (Explorer's recent files; the app's jump
                                  list shows it under "Recent" when the app is a registered
                                  handler of the type: the setup, assoc_register, MSIX; with
                                  the process's explicit AppUserModelID, taskbar.rs, the
                                  item is given to that id: SHARD_APPIDINFO).
                                  Linux: a bookmark in $XDG_DATA_HOME/recently-used.xbel (the
                                  freedesktop format GTK and KDE read: href, added / modified /
                                  visited, the MIME type, this app's entry with exec and count).
                                  macOS: the app's recent documents (NSDocumentController, the
                                  Dock's menu of the app; apple_recent.rs)
  recent_list(max) -> [path]      this app's files, newest first (Windows: the jump list's
                                  recent items, IApplicationDocumentLists; Linux: the
                                  bookmarks with an entry of this app; macOS: recentDocumentURLs)
  recent_remove(path) -> bool     the file out of the app's list (Windows: the jump list,
                                  IApplicationDestinations -- Explorer's recent files keep it;
                                  Linux: this app's entry, the bookmark when no other app is
                                  left in it)
  recent_clear() -> bool          every file of the app (RemoveAllDestinations; every entry of
                                  this app)
  recent_os(on)                   (ui::main!) off in headless runs (--script, --shot, the
                                  agent protocols): add / remove / clear leave the system's
                                  list alone and return false
  recent_list_of(id, max) / recent_remove_of(id, path)   (Windows, tests) the jump list of
                                  another AppUserModelID (Explorer's own recent files:
                                  Microsoft.Windows.Explorer)

The path must be readable under the app's permissions (fs.read / fs.user, policy.rs; else
"PERMDENY fs.read" and false) and be an OS file (a folder mount's file counts as its OS path;
mem:// and app:// do not).  jfgui_RECENT=off: nothing is read or written; jfgui_RECENT=
/path/x.xbel: that file instead of the system's list, on every OS (tests).  The xbel file is
changed under a lock (a sidecar file in $XDG_RUNTIME_DIR, else beside it) and replaced
atomically; other programs' bookmarks stay byte for byte.  GLib does not lock: a write of a
GTK program between our read and our rename can be lost (as between two GTK programs).  The
MIME type of a bookmark comes from the app's PACKAGE filetypes, else a short table, else
application/octet-stream.  In a Flatpak $XDG_DATA_HOME is the app's own folder: the host's
list needs --filesystem=xdg-data/recently-used.xbel (PACKAGE flatpak_args=) and is used
then.  Web and Android: false / empty.
  • fn recent_os(on: bool) (ui::main!) false: add / remove / clear leave the system's list alone (headless runs)

  • fn recent_add(path: &str) -> bool put a file the user opened or saved into the system's list of recent files

  • fn recent_list(max: usize) -> Vec<String> this app's recent files, newest first (at most max)

  • fn recent_remove(path: &str) -> bool take a file out of this app's recent files

  • fn recent_clear() -> bool forget every recent file of this app

  • fn recent_list_of(id: &str, max: usize) -> Vec<String> (Windows) (Windows, tests) the recent files of the jump list of AppUserModelID id

  • fn recent_remove_of(id: &str, path: &str) -> bool (Windows) (Windows, tests) a file out of the jump list of AppUserModelID id (Explorer's own: Microsoft.Windows.Explorer)

Source: docs/API.md in the JFLib repository.