]> code.delx.au - bg-scripts/commitdiff
Implemented the start of a favourite's list
authorGreg Darke <greg@tsukasa.net.au>
Wed, 23 Jul 2008 13:38:17 +0000 (23:38 +1000)
committerGreg Darke <greg@tsukasa.net.au>
Wed, 23 Jul 2008 13:38:17 +0000 (23:38 +1000)
randombg.py

index bb2936b29bee4c72ab1436eb29c75a81b17e6854..a6fb4f079e35d5a72f13b8d234927869c87a0187 100755 (executable)
@@ -40,6 +40,7 @@ class BaseFileList(object):
        """Base file list implementation"""
        def __init__(self):
                self.paths = []
        """Base file list implementation"""
        def __init__(self):
                self.paths = []
+               self.favourites = []
 
        def add_path(self, path):
                self.paths.append(path)
 
        def add_path(self, path):
                self.paths.append(path)
@@ -77,6 +78,10 @@ class BaseFileList(object):
                        logging.warning("Loading cache: %s" % e)
                        return False
 
                        logging.warning("Loading cache: %s" % e)
                        return False
 
+       def add_to_favourites(self):
+               '''Adds the current image to the list of favourites'''
+               self.favourites.append(self.get_current_image())
+
        def scan_paths(self):
                raise NotImplementedError()
 
        def scan_paths(self):
                raise NotImplementedError()
 
@@ -166,7 +171,7 @@ class AllRandomFileList(BaseFileList):
                        if self.paths == tmp.paths:
                                logging.debug("Path lists match, copying properties")
                                # Overwrite this object with the other
                        if self.paths == tmp.paths:
                                logging.debug("Path lists match, copying properties")
                                # Overwrite this object with the other
-                               for attr in ('list', 'imagePointer'):
+                               for attr in ('list', 'imagePointer', 'favourites'):
                                        setattr(self, attr, getattr(tmp, attr))
                        else:
                                logging.debug("Ignoring cache, path lists do not match")
                                        setattr(self, attr, getattr(tmp, attr))
                        else:
                                logging.debug("Ignoring cache, path lists do not match")
@@ -315,6 +320,9 @@ class Cycler(object):
        def cmd_exit(self):
                asyncsched.exit()
 
        def cmd_exit(self):
                asyncsched.exit()
 
+       def cmd_favourite(self):
+               self.filelist.add_to_favourites()
+
 class Server(asynchat.async_chat):
        def __init__(self, cycler, conn, addr):
                asynchat.async_chat.__init__(self, conn=conn)
 class Server(asynchat.async_chat):
        def __init__(self, cycler, conn, addr):
                asynchat.async_chat.__init__(self, conn=conn)