def _query_tooltip_cb(self, widget, x, y, keyboard_tip, tooltip): context = widget.get_tooltip_context(x, y, keyboard_tip) if not context: return False thumbman = ThumbnailManager() model, path, iter = context.model, context.path, context.iter if not (model and iter): return name = model[iter][BASENAME_COL] file = self.folder.file(name) mtime = file.mtime() if mtime: mdate = datetime.datetime.fromtimestamp( file.mtime()).strftime('%c') # TODO: fix datetime format else: mdate = _( 'Unknown') # T: unspecified value for file modification time size = format_file_size(file.size()) thumbfile, pixbuf = thumbman.get_thumbnail(file, THUMB_SIZE_LARGE) if not pixbuf: pixbuf = get_mime_icon(file, 64) or render_file_icon(self, 64) mtype = file.mimetype() mtype_desc = get_mime_description(mtype) if mtype_desc: mtype_desc = mtype_desc + " (%s)" % mtype # E.g. "PDF document (application/pdf)" f_label = _('Name') # T: label for file name t_label = _('Type') # T: label for file type s_label = _('Size') # T: label for file size m_label = _('Modified') # T: label for file modification date tooltip.set_markup( "%s\n\n<b>%s:</b> %s\n<b>%s:</b> %s\n<b>%s:</b>\n%s" % ( name, t_label, mtype_desc or mtype, s_label, size, m_label, mdate, )) tooltip.set_icon(pixbuf) widget.set_tooltip_item(tooltip, path) return True
def _query_tooltip_cb(self, widget, x, y, keyboard_tip, tooltip): context = widget.get_tooltip_context(x, y, keyboard_tip) if not context: return False thumbman = ThumbnailManager() model, path, iter = context name = model[iter][BASENAME_COL] file = self.folder.file(name) mtime = file.mtime() if mtime: mdate = datetime.datetime.fromtimestamp(file.mtime()).strftime('%c') # TODO: fix datetime format else: mdate = _('Unknown') # T: unspecified value for file modification time size = format_file_size(file.size()) thumbfile, pixbuf = thumbman.get_thumbnail(file, THUMB_SIZE_LARGE) if not pixbuf: pixbuf = get_mime_icon(file, 64) or render_file_icon(self, 64) mtype = file.get_mimetype() mtype_desc = get_mime_description(mtype) if mtype_desc: mtype_desc = mtype_desc + " (%s)" % mtype # E.g. "PDF document (application/pdf)" f_label = _('Name') # T: label for file name t_label = _('Type') # T: label for file type s_label = _('Size') # T: label for file size m_label = _('Modified') # T: label for file modification date tooltip.set_markup( "%s\n\n<b>%s:</b> %s\n<b>%s:</b> %s\n<b>%s:</b>\n%s" % ( name, t_label, mtype_desc or mtype, s_label, size, m_label, mdate, )) tooltip.set_icon(pixbuf) widget.set_tooltip_item(tooltip, path) return True
def my_get_mime_icon(file): mt = file.mimetype() if not mt in mime_cache: mime_cache[mt] = get_mime_icon(file, min_icon_size) or file_icon return mime_cache[mt]
def my_get_mime_icon(file): mt = file.get_mimetype() if not mt in mime_cache: mime_cache[mt] = get_mime_icon(file, min_icon_size) or file_icon return mime_cache[mt]