#!/usr/bin/env python3
from gi.repository import Gtk, GObject
import os.path

manager = Gtk.RecentManager.get_default()
fileslist = manager.get_items()
def update():
	global fileslist
	print("updating")
	fileslist = []
	fileslist = manager.get_items()
	where_test()

def check_update(a):
	update()

def where_test():
	for i in range(len(fileslist)):
		if fileslist[i].exists():
			file=fileslist[i].get_uri_display()
			if (os.path.basename(file)=="test"):
				print("the recently accessed file \"test\" is located at: "+os.path.dirname(file))
			

update()
manager.connect("changed",check_update)

loop = GObject.MainLoop()

loop.run()
