Skip to content

Implementation

loktacar edited this page Sep 22, 2012 · 28 revisions

TODO

  • 1.1.1 & 1.1.2: Add wallpaper_queue to the __init__ funciton in the base collage plugin class
  • 1.1.3: Remove the save and _get_wallpaper methods, implement a better way of saving the images
  • 2.2: Get resolution of all monitors, i.e. implement multi-monitor support, remember the collage plugins
  • 2.6.1: Don't know why self.initialized is here, INVESITGATE!
  • 2.6.2: In __init__ make app a required option
  • 2.6.2: GUI in wxpython UI plugin is not initalized correctly, see __init__
  • 2.6.2.1: pause_app_toggle and switch_collage_plugin should be depricated, investigate!
  • 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
    Example from simple_resize plugin
  • __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)

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
  • self.initialized:
  • self.logger: The logger currently in use

Methods (2.6.2)

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

App Control Methods (2.6.2.1)

  • start_app(self)
    • This method starts the application main thread, this is done to ensure that the ui is running on the main thread if any threading is to be done
  • pause_app_toggle(self)
    • Toggles the pause value of the app
  • switch_collage_plugin(self, collage)
    • Switches collage plugins
  • 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