RecentChooserWidget

A RecentChooserWidget allows the selection of documents and files which have previously been opened. The widget-variant can be placed inside a Window or Dialog container.

Constructor

The RecentChooserWidget can be constructed using the following:

recentchooserwidget = Gtk.RecentChooserWidget(manager)

Setting the manager parameter to a RecentManager object allows for increase control over the content of the RecentChooserWidget.

Note

A RecentManager is not required to be added if only basic functions of the RecentChooserWidget are required. The RecentManager simply provides more options on working with files.

Methods

Example

Below is an example of a RecentChooserWidget:

#!/usr/bin/env python3

from gi.repository import Gtk

class RecentChooserWidget(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title('RecentChooserWidget')
        self.set_default_size(300, 250)
        self.set_border_width(5)
        self.connect('destroy', Gtk.main_quit)

        recentchooserwidget = Gtk.RecentChooserWidget()
        recentchooserwidget.connect('item-activated', self.on_item_activated)
        self.add(recentchooserwidget)

    def on_item_activated(self, recentchooserwidget):
        item = recentchooserwidget.get_current_item()

        if item:
            print('Item selected:')
            print('Name:\t %s' % (item.get_display_name()))
            print('URI:\t %s' % (item.get_uri()))

window = RecentChooserWidget()
window.show_all()

Gtk.main()

Download: RecentChooserWidget