-
Notifications
You must be signed in to change notification settings - Fork 3
Implementation
loktacar edited this page Sep 23, 2012
·
28 revisions
- 2.2: Get resolution of all monitors, i.e. implement multi-monitor support, remember the collage plugins
- 2.5: None of this has been implemented
Creates a wallpaper collage, taking one or more instances of pygame.Surface
from the wallpaper_queue
and returning a new instance of pygame.Surface
.
-
self.config
: The configuration dictionary. -
self.wallpaper_queue
: The wallpaper queue currently in use -
self.logger
: The logger currently in use.
-
generate(self, size)
-
size
: tuple of length 2, dimensions of the generated wallpaper - Requires implementation
-
wallpapers = self._get_wallpapers(wallpaper_queues)
self.logger.debug('Generating...')
collage = pygame.Surface(size)
wp_offset, wp = self._resize_wallpaper(wallpapers[0], size)
for x1, x2 in enumerate(range(size[0]), wp_offset[0]):
for y1, y2 in enumerate(range(size[1]), wp_offset[1]):
collage.set_at((x2, y2), wp.get_at((x1, y1)))
self.logger.debug('Generation complete')
return collage
-
__init__(self, config, wallpaper_queue)
-
config
: configuration dictionary -
wallpaper_queue
: an instance of the wallpaper_queue class - Requires implementation, Ex.
-
def __init__(self, config, wallpaper_queue):
super(CollagePluginName, self).__init__(config, wallpaper_queue)
-
_resize_wallpaper(self, wallpaper, size)
-
wallpaper
:pygame.Surface
which needs to be resized -
size
: the new size the wallpaper should take
-
Gets the resolution of all monitors
-
platform_check()
- Checks if this plugin is viable on the current platform
@staticmethod
- Requires implementation
-
get()
- Gets the resolution, returns a tuple of size 2 with the dimensions of the monitor resolution
@staticmethod
- Requires implementation
Adds arguments to the command line and options to the configuration file
-
self.default
: Default value of the opion, None means it's required -
self.option
: The name of the option (used in config file and as the long form command line option -
self.cmd_short
: Used as the short form command line option -
self.cmd_argument
: The name of the argument in the command line -
self.description
: The description written in the command line when -h or --help is used -
self.conf_description
: The description written in the sample configuration -
self.conf_default
: The default value in written in the sample configuration
-
parse(self, value)
- Returns an appropriate object instead of the string value
- ex.
'4'
is turned intoint(4)
- ex.
-
value
: the value to be parsed
- Returns an appropriate object instead of the string value
Sets the config['wallpaper']
file as the current desktop wallpaper
-
platform_check(config)
- Checks if this plugin is viable on the current platform
@staticmethod
- Requires implementation
-
set(config)
- Sets the wallpaper
@staticmethod
- Requires implementation
Searches for new wallpapers, sources could be file system, flickr, instagram, reddit, etc. The wallpaper queue in the app handles calls to these plugins. Should keep a list of the images, and the wallpaper queue should pop equal amounts of images from each active instance of these plugins.
-
self.config
: The configuration dict -
self.logger
: The logger currently in use
-
find_wallpapers(self)
- Searches for wallpapers and fills it's own list of images
-
pop(self, count)
- Returns a list of
pygame.Surface
instances
- Returns a list of
Creates a user interface for the application
-
self.app
: The application instance, set by the Application__init__
function. -
self.logger
: The logger currently in use
-
__init__(self)
- Initializes the ui plugin, the ui itself should be initalized when
start_app
is called - base class sets the neccessary instance variables
- Initializes the ui plugin, the ui itself should be initalized when
-
start_app(self)
- This method starts both the application loop thread and the main thread (the UI thread).
-
exit_app(self)
- Stops the necessary threads to stop the application running.
-
start_generating(self)
- Tries to start generating a new collage as soon as possible.
Plugin events, these hooks are called when certain events happen in the application
-
app_initialized(self)
- Called after app has been initialized
- UI can be initialized now
-
app_started(self)
- Called when main loop is first called
-
app_quitting(self)
- Called when the main loop is stopped completely
-
generate_finished(self)
- Called when generation of collage is complete
-
generate_started(self)
- Called when generation of a collage is starting
-
wallpaper_search_finished(self)
- Called after wallpaper search plugin(s) has finished searching
-
wallpaper_search_started(self)
- Called when wallpaper search plugin(s) is started