# 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 RecentReader import RecentReader from utils import FileWatcher from config.GConfBackend import GConfBackend import os _GCONF_PATH = "/desktop/gnome/interface" class RfileSet: __RECENTPATH = os.path.expanduser("~/.recently-used") __ICON_THEME = "icon_theme" def __init__(self): # the recent files self.__rfiles = [] # the visualizer for icons self.__visualizer = None # gconf watcher for icon theme changes self.__gwatcher = GConfBackend(_GCONF_PATH) self.__gwatcher.add_observer(self.__on_observe_recent) watcher = FileWatcher(self.__RECENTPATH) watcher.add_observer(self.__on_observe_recent) # # Call for other methods to force load # def load_files(self): self.__on_observe_recent(None, None) # # File Watcher # def __on_observe_recent(self, src, cmd, *args): theme = self.__gwatcher.get(self.__ICON_THEME) rr = RecentReader(self.__RECENTPATH, theme) self.__rfiles = rr.get_recent_files() if (self.__visualizer): self.__visualizer(self) # # Returns the icon at the given position index. # def get_rfile(self, index): return self.__rfiles[index] # # Returns the length of the icon set, i.e. the number of the icons in it. # def get_length(self): return len(self.__rfiles) # # Sets the visualizer function for the icon set. The visualizer is called # whenever the icon set changes. # def set_visualizer(self, handler): self.__visualizer = handler