def handle_drag_data_received(self, selection, target_type): for uri in selection.get_uris(): item = FileItem(uri) if item.get_mimetype() == "application/x-desktop": bookmarks.add_bookmark(uri, item.get_mimetype()) else: launcher.launch_uri(uri)
def get_item_for_uri(self, launch_uri): item = FileItem(launch_uri) if item.get_mimetype() in ("application/x-desktop", "purple/buddy", "gaim/buddy", "purple/log", "gaim/log", None): # Avoid showing launchers or conversations as running documents return None return item
def get_comment_markup(self): '''Return the comment if it exists, otherwise use the command in small monospace.''' if self.get_comment(): return FileItem.get_comment_markup(self) else: return "<span size='small' font_family='monospace'>%s</span>" % \ saxutils.escape(self.get_command())
def get_bookmark_items(self): items = [] # Make FileItem for all document bookmarks for uri, mime in bookmarks.get_bookmarks(): if mime not in ("application/x-desktop", "purple/buddy", "gaim/buddy"): try: items.append(FileItem(uri)) except ValueError: pass return items
def _add_templates(self, menu): # Get all the templates template_dir = os.path.expanduser("~/Templates") try: templates = os.listdir(template_dir) except: templates = [] for template in templates: item = FileItem(os.path.join(template_dir, template)) menu.append( self._add_template_item( menu, item.get_name(), item.get_uri(), item.get_icon(gtk.ICON_SIZE_LARGE_TOOLBAR))) if len(templates) == 0: empty_item = gtk.MenuItem(_("No templates available")) empty_item.set_sensitive(False) empty_item.show() menu.append(empty_item) sep = gtk.SeparatorMenuItem() sep.show() menu.append(sep) menu.append( self._add_template_item(menu, _("Empty File"), None, "stock_new")) sep = gtk.SeparatorMenuItem() sep.show() menu.append(sep) # Add a link to the templates directory mi = gtk.ImageMenuItem(_("Templates")) mi.set_image( icon_factory.load_image("gnome-fs-directory", gtk.ICON_SIZE_LARGE_TOOLBAR)) mi.show() mi.connect("activate", lambda mi, uri: launcher.launch_uri(uri), template_dir) menu.append(mi)
def get_items_uncached(self): if not self.download_rdf_monitors: self._monitor_download_rdf_paths() for download_rdf in self.download_rdf_monitors: try: # Read previous download locations download_doc = parse(download_rdf) li_list = download_doc.getElementsByTagName("RDF:li") for li_elem in li_list: uri = str(li_elem.getAttribute("RDF:resource")) # Sometimes contains absolute paths instead of URLs if os.path.isabs(uri): uri = "file://" + uri yield FileItem(uri) except (IOError, ExpatError), err: print " !!! Error parsing Mozilla download file '%s': %s" % ( download_rdf, err)
def get_items_uncached(self): paths = [] os.path.walk(self.path, self._add_name, paths) for path in paths: yield FileItem(path)
def get_items_uncached(self): for item in RecentlyUsedOfMimeType.get_items_uncached(self): yield FileItem(uri=item.get_uri(), timestamp=item.get_timestamp())
def matches_text(self, text): command = self.get_command() return FileItem.matches_text(self, text) or \ (command and command.lower().find(text) > -1)
def __init__(self, uri): FileItem.__init__(self, uri=uri)
def get_items_uncached(self): for uri, name, mime, icon in places.get_places(): yield FileItem(uri=uri, icon=icon) # Add a trashcan so people can toggle it's pinned setting on the gimmie bar. yield TrashItem()