Skip to content

Implementation

loktacar edited this page Sep 23, 2012 · 28 revisions

TODO

  • 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

Application (1)

Plugins (2)

Collage Plugins (2.1)

Creates a wallpaper collage, taking one or more instances of pygame.Surface from the wallpaper_queue and returning a new instance of pygame.Surface.

Instance Variables (2.1.1)

  • self.config: The configuration dictionary.
  • self.wallpaper_queue: The wallpaper queue currently in use
  • self.logger: The logger currently in use.

Methods (2.1.2)

  • generate(self, size)
    • size: tuple of length 2, dimensions of the generated wallpaper
    • Requires implementation, Ex.
    wallpapers = self._get_wallpapers()

    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, wallpaper_queue, config)
    • wallpaper_queue: an instance of the wallpaper_queue class
    • config: configuration dictionary
    • Requires implementation, Ex.
    def __init__(self, wallpaper_queue, config):
        super(CollagePluginName, self).__init__(wallpaper_queue, config)

Base methods (2.1.3) (implemented in the base collage plugin class)

  • _resize_wallpaper(self, wallpaper, size)
    • wallpaper: pygame.Surface which needs to be resized
    • size: the new size the wallpaper should take

Get Resolution Plugins (2.2)

Gets the resolution of all monitors

Methods (2.2.1)

  • 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

Option Plugins (2.3)

Adds arguments to the command line and options to the configuration file

Instance variables (2.3.1)

  • 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

Methods (2.3.2)

  • parse(self, value)
    • Returns an appropriate object instead of the string value
      • ex. '4' is turned into int(4)
    • value: the value to be parsed

Set Wallpaper Plugins (2.4)

Sets the config['wallpaper'] file as the current desktop wallpaper

Methods (2.4.1)

  • platform_check(config)
    • Checks if this plugin is viable on the current platform
    • @staticmethod
    • Requires implementation
  • set(config)
    • Sets the wallpaper
    • @staticmethod
    • Requires implementation

Search for Wallpaper Plugins (2.5)

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.

Instance Variables (2.5.1)

  • self.config: The configuration dict
  • self.logger: The logger currently in use

Methods (2.5.2)

  • find_wallpapers(self)
    • Searches for wallpapers and fills it's own list of images
  • pop(self, count)
    • Returns a list of pygame.Surface instances

UI Plugins (2.6)

Creates a user interface for the application

Instance Variables (2.6.1)

  • self.app: The application instance, set by the Application __init__ function.
  • self.logger: The logger currently in use

Methods (2.6.2)

  • __init__(self)
    • Initializes the ui plugin, the ui itself should be initalized when start_app is called
    • base class sets the neccessary instance variables

App Control Methods (2.6.2.1)

  • 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.

UI Hooks (2.6.2.2)

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
Clone this wiki locally