简体   繁体   English

Linux GTK2 / GTK3最新文件浏览器未显示最新的Shell创建文件

[英]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. 如果触摸新文件或使用scrot / escrotum截屏, GTK2 / GTK3文件浏览器中“最近的文件”选项卡中看不到“新文件”(您可以在CTRL + O窗口中轻松查看其示例)浏览器,例如Firefox或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? 我应该怎么做才能查看我最近“手工”编辑或创建的文件,以便它们也可以在GTK最近文件浏览器中更新?

Example: 例:

$touch words.txt
$scrot image.jpg

Both generated files will not be visible in the Recent Files GTK tab. 这两个生成的文件在“最近的文件” GTK选项卡中均不可见。

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. 因此,根据我上面的评论,这是一个名为“ recent的小型python脚本,它将作为参数传递的文件添加到最近的文件中。 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. 当然,可以改进它以更好地处理URI,而不是假设所有文件都是本地文件,清理最近的文件列表,删除特定条目等。也可以用C重写它,以避免为此仅运行完整的python解释器。

#! /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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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