简体   繁体   中英

Linux GTK2/GTK3 recent files browser not showing recent shell created files

If a touch a new file or take a screenshot with scrot / escrotum , no "new files" are visible in GTK2/GTK3 file browser in the tab "Recent Files" (you can easily see an example of it in the CTRL+O window of browser like Firefox or Chrome.

What should I do to see my recently "hand" edited or created files to also be updated in the GTK Recent Files file browser?

Example:

$touch words.txt
$scrot image.jpg

Both generated files will not be visible in the Recent Files GTK tab.

Thank you

So based on my comment above, here's a small python script called recent that adds the files passed as arguments to the recent files. That could of course be improved to have better handling of URIs instead of assuming all files are local, clean the recent file list, remove specific entries, etc. It could also be rewritten in C to avoid running a full python interpreter just for that.

#! /usr/bin/env python

import os.path
import sys

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, GLib

def main():
    recent_mgr = Gtk.RecentManager.get_default()
    for filename in sys.argv[1:]:
        uri = GLib.filename_to_uri(os.path.abspath(filename))
        recent_mgr.add_item(uri)

    GObject.idle_add(Gtk.main_quit)
    Gtk.main()

if __name__ == '__main__':
    main()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM