Skip to content

Instantly share code, notes, and snippets.

@wolfv
Created August 26, 2012 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfv/3483363 to your computer and use it in GitHub Desktop.
Save wolfv/3483363 to your computer and use it in GitHub Desktop.
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