forked from openlp/openlp
Added the Event class and added some more hooks into the Plugin class.
bzr-revno: 132
This commit is contained in:
parent
5c41b9e8b7
commit
0a6ce5e3f7
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
|
||||
<!-- eric4 user project file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2008-11-26, 21:51:46 -->
|
||||
<!-- Saved: 2008-11-27, 22:05:12 -->
|
||||
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||
<UserProject version="4.0">
|
||||
</UserProject>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
|
||||
<!-- eric4 tasks file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2008-11-26, 21:51:46 -->
|
||||
<!-- Saved: 2008-11-27, 22:05:12 -->
|
||||
<Tasks version="4.2">
|
||||
<Task priority="1" completed="False" bugfix="False">
|
||||
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
|
||||
<!-- eric4 project file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2008-11-26, 21:51:46 -->
|
||||
<!-- Saved: 2008-11-27, 22:05:01 -->
|
||||
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||
<Project version="4.4">
|
||||
<ProgLanguage mixed="0">Python</ProgLanguage>
|
||||
@ -12,47 +12,30 @@
|
||||
<Email>raoulsnyman@openlp.org</Email>
|
||||
<Sources>
|
||||
<Source>openlp.pyw</Source>
|
||||
<Source>openlp/theme/test/test_theme.py</Source>
|
||||
<Source>openlp/theme/__init__.py</Source>
|
||||
<Source>openlp/theme/theme.py</Source>
|
||||
<Source>openlp/controls/__init__.py</Source>
|
||||
<Source>openlp/core/test/test_render_theme.py</Source>
|
||||
<Source>openlp/core/test/test_render.py</Source>
|
||||
<Source>openlp/core/interpolate.py</Source>
|
||||
<Source>openlp/core/__init__.py</Source>
|
||||
<Source>openlp/core/render.py</Source>
|
||||
<Source>openlp/ui/__init__.py</Source>
|
||||
<Source>openlp/ui/forms/__init__.py</Source>
|
||||
<Source>openlp/__init__.py</Source>
|
||||
<Source>openlp/utils/ConfigHelper.py</Source>
|
||||
<Source>openlp/utils/__init__.py</Source>
|
||||
<Source>demo.py</Source>
|
||||
<Source>openlp/core/settingsmanager.py</Source>
|
||||
<Source>openlp/resources/openlp_rc.py</Source>
|
||||
<Source>openlp/resources/__init__.py</Source>
|
||||
<Source>openlp/core/plugin.py</Source>
|
||||
<Source>openlp/core/xmlrootclass.py</Source>
|
||||
<Source>openlp/song/__init__.py</Source>
|
||||
<Source>openlp/song/test/test_song_opensong.py</Source>
|
||||
<Source>openlp/song/test/test_song_basic.py</Source>
|
||||
<Source>openlp/song/test/test_song_text.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/__init__.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/BibleDBImpl.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/BibleManager.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/BibleHTTPImpl.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/test/__init__.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/test/test_bibleManager.py</Source>
|
||||
<Source>openlp/song/test/test_song_verse.py</Source>
|
||||
<Source>openlp/plugins/__init__.py</Source>
|
||||
<Source>openlp/plugins/testplugin1.py</Source>
|
||||
<Source>openlp/plugins/testplugin2/__init__.py</Source>
|
||||
<Source>openlp/plugins/testplugin2/testplugin2.py</Source>
|
||||
<Source>openlp/plugins/test/test_plugin_manager.py</Source>
|
||||
<Source>openlp/ui/forms/editsongform.py</Source>
|
||||
<Source>openlp/ui/forms/openlpexportform.py</Source>
|
||||
<Source>openlp/ui/forms/openlpimportform.py</Source>
|
||||
<Source>openlp/ui/forms/opensongexportform.py</Source>
|
||||
<Source>openlp/ui/forms/opensongimportform.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/BibleCommon.py</Source>
|
||||
<Source>openlp/libraries/pptviewlib/ppttest.py</Source>
|
||||
<Source>openlp/plugins/biblemanager/BibleCSVImpl.py</Source>
|
||||
@ -71,10 +54,25 @@
|
||||
<Source>openlp/core/ui/settings.py</Source>
|
||||
<Source>openlp/core/ui/alertform.py</Source>
|
||||
<Source>openlp/core/ui/about.py</Source>
|
||||
<Source>openlp/song/songxml.py</Source>
|
||||
<Source>openlp/plugins/songs/songsplugin.py</Source>
|
||||
<Source>openlp/plugins/songs/__init__.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/__init__.py</Source>
|
||||
<Source>openlp/plugins/songs/songxml.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/openlpimportform.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/editsongform.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/opensongexportform.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/openlpexportform.py</Source>
|
||||
<Source>openlp/plugins/songs/forms/opensongimportform.py</Source>
|
||||
<Source>openlp/core/utils/__init__.py</Source>
|
||||
<Source>openlp/core/utils/ConfigHelper.py</Source>
|
||||
<Source>openlp/core/theme/__init__.py</Source>
|
||||
<Source>openlp/core/theme/theme.py</Source>
|
||||
<Source>openlp/plugins/songs/test/test_song_opensong.py</Source>
|
||||
<Source>openlp/plugins/songs/test/test_song_basic.py</Source>
|
||||
<Source>openlp/plugins/songs/test/test_song_verse.py</Source>
|
||||
<Source>openlp/plugins/songs/test/test_song_text.py</Source>
|
||||
<Source>openlp/core/theme/test/test_theme.py</Source>
|
||||
<Source>openlp/core/event.py</Source>
|
||||
</Sources>
|
||||
<Forms>
|
||||
<Form>openlp/resources/forms/mainwindow.ui</Form>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env pythonw
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80
|
||||
"""
|
||||
|
51
openlp/core/event.py
Normal file
51
openlp/core/event.py
Normal file
@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Scott Guerreri,
|
||||
Carsten Tingaard, Jonathan Corwin
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
class EventType(object):
|
||||
"""
|
||||
Types of events are stored in this class.
|
||||
"""
|
||||
# "Default" event - a non-event
|
||||
Default = 0
|
||||
# General application events
|
||||
InitApplication = -1
|
||||
ShowApplication = -2
|
||||
BeforeAppClose = -3
|
||||
ApplicationClose = -4
|
||||
# Service events
|
||||
BeforeLoadService = 1
|
||||
AfterLoadService = 2
|
||||
BeforeSaveService = 3
|
||||
AfterSaveService = 4
|
||||
# Preview events
|
||||
PreviewBeforeLoad = 11
|
||||
PreviewAfterLoad = 12
|
||||
PreviewBeforeShow = 13
|
||||
PreviewAfterShow = 14
|
||||
|
||||
|
||||
class Event(object):
|
||||
"""
|
||||
Provides an Event class to encapsulate events within openlp.org.
|
||||
"""
|
||||
|
||||
def __init__(self, event_type=EventType.Default):
|
||||
self.type = event_type
|
@ -23,15 +23,46 @@ class Plugin(object):
|
||||
Base class for openlp plugins to inherit from.
|
||||
|
||||
Basic attributes are:
|
||||
name: the name that should appear in the plugins list
|
||||
version: The version number of this iteration of the plugin (just an incrementing integer!)
|
||||
paint_context: A list of paint contexts?
|
||||
* Name
|
||||
The name that should appear in the plugins list.
|
||||
* Version
|
||||
The version number of this iteration of the plugin.
|
||||
* MediaManagerItem
|
||||
An instance of the MediaManagerItem class, used in the Media Manager.
|
||||
* SettingsTab
|
||||
An instance of the SettingsTab class, used in the Settings dialog.
|
||||
* ImportMenuItem
|
||||
A menu item to be placed in the Import menu.
|
||||
* ExportMenuItem
|
||||
A menu item to be placed in the Export menu.
|
||||
|
||||
Hook functions:
|
||||
* about()
|
||||
Used in the plugin manager, when a person clicks on the 'About' button.
|
||||
* save(data)
|
||||
A method to convert the plugin's data to a string to be stored in the
|
||||
Service file.
|
||||
* load(string)
|
||||
A method to convert the string from a Service file into the plugin's
|
||||
own data format.
|
||||
* render(theme, screen_number)
|
||||
A method used to render something to the screen, given the current theme
|
||||
and screen number.
|
||||
* addToMenu(menubar)
|
||||
A method to add a menu item to anywhere in the menu, given the menu bar.
|
||||
* handleEvent(event)
|
||||
A method use to handle events, given an Event object.
|
||||
"""
|
||||
|
||||
def __init__(self, name=None, version=None):
|
||||
"""
|
||||
This is the constructor for the plugin object. This provides an easy
|
||||
way for descendent plugins to populate common data.
|
||||
way for descendent plugins to populate common data. This method *must*
|
||||
be overridden, like so:
|
||||
class MyPlugin(Plugin):
|
||||
def __init__(self):
|
||||
Plugin.__init('MyPlugin', '0.1')
|
||||
...
|
||||
"""
|
||||
if name is not None:
|
||||
self.Name = name
|
||||
@ -39,33 +70,46 @@ class Plugin(object):
|
||||
self.Name = 'Plugin'
|
||||
if version is not None:
|
||||
self.__version__ = version
|
||||
# this will be a MediaManagerItem if it needs one
|
||||
self.MediaManagerItem = None
|
||||
# this will be a PrefsPage object if it needs one
|
||||
self.SettingsTab = None
|
||||
#self.paint_context = None
|
||||
self.ImportMenuItem = None
|
||||
self.ExportMenuItem = None
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
Show a dialog when the user clicks on the 'About' button in the plugin
|
||||
manager.
|
||||
"""
|
||||
pass
|
||||
|
||||
def save(self, data):
|
||||
"""
|
||||
Service item data is passed to this function, which should return a
|
||||
string which can be written to the service file
|
||||
string which can be written to the service file.
|
||||
"""
|
||||
pass
|
||||
|
||||
def load(self, str):
|
||||
def load(self, string):
|
||||
"""
|
||||
A string from the service file is passed in. This function parses and
|
||||
sets up the internals of the plugin
|
||||
sets up the internals of the plugin.
|
||||
"""
|
||||
pass
|
||||
|
||||
def render(self, screen=None):
|
||||
def render(self, theme, screen=None):
|
||||
"""
|
||||
Render the screenth screenful of data to self.paint_conext
|
||||
Render the screenth screenful of data using theme settings in theme.
|
||||
"""
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return '<Plugin %s>' % self.__class__.__name__
|
||||
|
||||
def addToMenu(self, menubar):
|
||||
"""
|
||||
Add menu items to the menu, given the menubar.
|
||||
"""
|
||||
pass
|
||||
|
||||
def handleEvent(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user