# This file is part of Recently Used Desklet # # Recently Used Desklet is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # Recently Used Desklet is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with Recently Used Desklet; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA from MimeIcon import MimeIcon from Icon import Icon import string import md5 import os import urllib class RecentFile: __THUMBNAIL = "~/.thumbnails/normal" __THUMBNAILPATH = os.path.expanduser(__THUMBNAIL) def __init__(self, theme): self.__file_name = "" self.__local_file_path = "" self.__uri = "" self.__md5 = "" self.__mime_type = "" self.__timestamp = 0 self.__group_name = "" self.__icon = None self.__theme = theme def get_file_name(self): return self.__file_name def get_local_file_path(self): return self.__local_file_path def get_uri(self): return self.__uri def get_md5(self): return self.__md5 def get_mime_type(self): return self.__mime_type def get_timestamp(self): return self.__timestamp def get_group_name(self): return self.__group_name def get_icon(self): if ( self.__icon == None ): self.__make_icon() return self.__icon def set_uri(self, uri = ""): self.__uri = uri self.__local_file_path = urllib.unquote(uri.replace("file://","")) local_split = self.__local_file_path.split("/") self.__file_name = local_split[len(local_split) - 1] self.__md5 = md5.new(uri).hexdigest() def set_mime_type(self, mime_type = ""): self.__mime_type = mime_type def set_timestamp(self, timestamp = 0): self.__timestamp = timestamp def set_group_name(self, group_name = ""): self.__group_name = group_name def __make_icon(self): path = os.path.join(self.__THUMBNAILPATH, self.get_md5() + ".png" ) if ( os.path.exists(path) ): # icon = Icon("file://" + path) icon = Icon(path) icon.set_uri("file://" + path) self.__icon = icon else: mimeicon = MimeIcon(self.get_mime_type(),self.__theme) # icon = Icon("file://" + mimeicon.get_path()) icon = Icon(mimeicon.get_path()) icon.set_uri("file://" + mimeicon.get_path()) self.__icon = icon