Re: How does one add an item to the “recently used” file list (from Python)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Op 10/07/2016 om 11:55 PM schreef Laurence Gonsalves:
> However, when I tried adding an item like this...
>
>     # /home/laurence/foo/bar.txt is an existing text file
>     recent_mgr.add_item('file:///home/laurence/foo/bar.txt')
>
> ...the file does not show up in the Recent section of Nautilus or in
> file dialogs. It doesn't even show up in the results returned by
> recent_mgr.get_items(). The call to add_item returned True.


That is how you do it, however you _require_ a main-loop running for
this to work. Working example below.

~infirit


from gi.repository import Gtk, GLib

def on_timeout(manager):
    res = manager.add_item('file:///home/user/example.txt')
    print(res)

recent_manager = Gtk.RecentManager.get_default()

GLib.timeout_add(5000, on_timeout, recent_manager)

Gtk.main()

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux