Skip to content

Instantly share code, notes, and snippets.

@wolfv wolfv/why.py
Created Aug 26, 2012

Embed
What would you like to do?
Gtk Recent Chooser Menu Fail's
#!/usr/bin/env python
from gi.repository import Gtk
class RecentChooserMenu:
def __init__(self):
window = Gtk.Window()
manager = Gtk.RecentManager.get_default()
self.recentchooser = Gtk.RecentChooserMenu.new_for_manager(manager)
menubar = Gtk.MenuBar()
file_menuitem = Gtk.MenuItem("Recent Items")
menubar.append(file_menuitem)
file_menuitem.set_submenu(self.recentchooser)
window.connect("destroy", lambda w: Gtk.main_quit())
self.recentchooser.connect("item-activated", self.display_info)
window.add(menubar)
window.show_all()
def display_info(self, widget):
selected = self.recentchooser.get_current_item()
print "Display name:", selected.get_display_name()
print "File URI:", selected.get_uri()
print "Last application:", selected.last_application()
RecentChooserMenu()
Gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.