def append_item(self, parent, path):
'''
Append a folder or a file to a menu.
'''
name = os.path.basename(path)
items = []
if name == ".":
# the item is a '.' element: add a menu entry to open the folder
# in the default file explorer, and a menu entry to open a shell
# with that folder as working directory
item_dot = gtk.MenuItem(".", False)
item_dot.connect("activate", self.onclick, path)
item_shell = gtk.MenuItem(">_", False)
item_shell.connect("activate", self.onshell, path)
items.append(item_dot)
items.append(item_shell)
elif os.path.isdir(path):
item = gtk.MenuItem(name, False)
submenu = self.append_dummy(item)
item.connect("activate", self.onhover, path, submenu)
items.append(item)
else:
item = gtk.MenuItem(name, False)
item.connect("activate", self.onclick, path)
items.append(item)
for i in items:
i.show()
parent.append(i)
bookmarks-indicator.py 文件源码
python
阅读 14
收藏 0
点赞 0
评论 0
评论列表
文章目录