openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00446
[Merge] lp:~j-corwin/openlp/presentations into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/presentations into lp:openlp.
Requested reviews:
openlp.org Core (openlp-core)
The three presentation controllers now inherit from common presentationcontroller.
Add PowerPoint support
PowerPointViewer now outputs to correct screen
--
https://code.launchpad.net/~j-corwin/openlp/presentations/+merge/12472
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/__init__.py'
--- openlp/plugins/presentations/lib/__init__.py 2009-09-25 16:23:44 +0000
+++ openlp/plugins/presentations/lib/__init__.py 2009-09-26 21:10:22 +0000
@@ -22,12 +22,10 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-import os
-
+from presentationcontroller import PresentationController
from impresscontroller import ImpressController
-if os.name == u'nt':
- #from powerpointcontroller import PowerpointController
- from pptviewcontroller import PptviewController
+from powerpointcontroller import PowerpointController
+from pptviewcontroller import PptviewController
from messagelistener import MessageListener
from mediaitem import PresentationMediaItem
from presentationtab import PresentationTab
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2009-09-25 23:06:54 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-09-26 21:10:22 +0000
@@ -36,7 +36,10 @@
from PyQt4 import QtCore
-class ImpressController(object):
+from presentationcontroller import PresentationController
+
+
+class ImpressController(PresentationController):
"""
Class to control interactions with Impress presentations.
It creates the runtime environment, loads and closes the presentation as
@@ -45,14 +48,29 @@
global log
log = logging.getLogger(u'ImpressController')
- def __init__(self):
+ def __init__(self, plugin):
+ """
+ Initialise the class
+ """
log.debug(u'Initialising')
+ PresentationController.__init__(self, plugin, u'Impress')
self.process = None
self.document = None
self.presentation = None
- self.startOpenoffice()
+ self.controller = None
- def startOpenoffice(self):
+ def is_available(self):
+ """
+ PPT Viewer is able to run on this machine
+ """
+ log.debug(u'is_available')
+ try:
+ self.start_process()
+ return True
+ except:
+ return False
+
+ def start_process(self):
"""
Loads a running version of OpenOffice in the background.
It is not displayed to the user but is available to the UNO interface
@@ -71,9 +89,9 @@
Called at system exit to clean up any running presentations
"""
log.debug(u'Kill')
- self.closePresentation()
+ self.close_presentation()
- def loadPresentation(self, presentation):
+ def load_presentation(self, presentation):
"""
Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background
@@ -86,10 +104,10 @@
"""
log.debug(u'LoadPresentation')
if os.name == u'nt':
- desktop = self.getCOMDesktop()
+ desktop = self.get_com_desktop()
url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
else:
- desktop = self.getUNODesktop()
+ desktop = self.get_uno_desktop()
url = uno.systemPathToFileUrl(presentation)
if desktop is None:
return
@@ -100,12 +118,12 @@
url, "_blank", 0, properties)
self.presentation = self.document.getPresentation()
self.presentation.start()
- self.xSlideShowController = \
+ self.controller = \
desktop.getCurrentComponent().Presentation.getController()
except:
log.exception(u'Failed to load presentation')
- def getUNODesktop(self):
+ def get_uno_desktop(self):
log.debug(u'getUNODesktop')
ctx = None
loop = 0
@@ -127,7 +145,7 @@
log.exception(u'Failed to get UNO desktop')
return None
- def getCOMDesktop(self):
+ def get_com_desktop(self):
log.debug(u'getCOMDesktop')
try:
smgr = Dispatch("com.sun.star.ServiceManager")
@@ -137,7 +155,7 @@
log.exception(u'Failed to get COM desktop')
return None
- def closePresentation(self):
+ def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
@@ -150,43 +168,45 @@
self.document.dispose()
self.document = None
- def isActive(self):
+ def is_loaded(self):
+ return self.presentation is not None and self.document is not None
+
+ def is_active(self):
+ if not self.is_loaded():
+ return False
return self.presentation.isRunning() and self.presentation.isActive()
- def resume(self):
+ def unblank_screen(self):
return self.presentation.resume()
- def pause(self):
- return self.presentation.pause()
-
- def blankScreen(self):
+ def blank_screen(self):
self.presentation.blankScreen(0)
- def stop(self):
+ def stop_presentation(self):
self.presentation.deactivate()
# self.presdoc.end()
- def go(self):
+ def start_presentation(self):
self.presentation.activate()
# self.presdoc.start()
- def getSlideNumber(self):
+ def get_slide_number(self):
return self.presentation.getCurrentSlideIndex
- def setSlideNumber(self, slideno):
+ def goto_slide(self, slideno):
self.presentation.gotoSlideIndex(slideno)
- slideNumber = property(getSlideNumber, setSlideNumber)
-
- def nextStep(self):
+ def next_step(self):
"""
Triggers the next effect of slide on the running presentation
"""
- self.xSlideShowController.gotoNextEffect()
+ self.controller.gotoNextEffect()
- def previousStep(self):
+ def previous_step(self):
"""
Triggers the previous slide on the running presentation
"""
- self.xSlideShowController.gotoPreviousSlide()
+ self.controller.gotoPreviousSlide()
+
+ # def get_slide_preview_file(self, slide_no):
=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py 2009-09-25 00:43:42 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py 2009-09-26 21:10:22 +0000
@@ -56,25 +56,25 @@
Save the handler as any new presentations start here
"""
self.handler, file = self.decodeMessage(message)
- self.controllers[self.handler].loadPresentation(file)
+ self.controllers[self.handler].load_presentation(file)
def next(self, message):
"""
Based on the handler passed at startup triggers the next slide event
"""
- self.controllers[self.handler].nextStep()
+ self.controllers[self.handler].next_step()
def previous(self, message):
"""
Based on the handler passed at startup triggers the previous slide event
"""
- self.controllers[self.handler].previousStep()
+ self.controllers[self.handler].previous_step()
def shutDown(self, message):
"""
Based on the handler passed at startup triggers slide show to shut down
"""
- self.controllers[self.handler].closePresentation()
+ self.controllers[self.handler].close_presentation()
def decodeMessage(self, message):
"""
=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py 2009-09-25 23:06:54 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py 2009-09-26 21:10:22 +0000
@@ -21,26 +21,48 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-try:
+
+import os
+import logging
+
+if os.name == u'nt':
from win32com.client import Dispatch
-except:
- pass
+
+from presentationcontroller import PresentationController
# PPT API documentation:
# http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx
-class PowerPointApp(object):
- def __init__(self):
+class PowerpointController(PresentationController):
+ """
+ Class to control interactions with PowerPoint Presentations
+ It creates the runtime Environment , Loads the and Closes the Presentation
+ As well as triggering the correct activities based on the users input
+ """
+ global log
+ log = logging.getLogger(u'PowerpointController')
+
+ def __init__(self, plugin):
+ """
+ Initialise the class
+ """
log.debug(u'Initialising')
+ PresentationController.__init__(self, plugin, u'Powerpoint')
self.process = None
- self.document = None
self.presentation = None
- self.startPowerpoint()
- def startPowerpoint(self):
+ def is_available(self):
+ """
+ PowerPoint is able to run on this machine
+ """
+ log.debug(u'is_available')
+ if os.name != u'nt':
+ return False
try:
- self._app = Dispatch(u'PowerPoint.Application')
+ self.start_process()
+ return True
except:
+<<<<<<< TREE
self._app = None
return
self._app.Visible = True
@@ -165,3 +187,122 @@
# self.preview = w.GetClipboardData.GetData(win32con.CF_BITMAP)
# w.CloseClipboard()
return self.preview
+=======
+ return False
+
+ if os.name == u'nt':
+ def start_process(self):
+ """
+ Loads PowerPoint process
+ """
+ self.process = Dispatch(u'PowerPoint.Application')
+ self.process.Visible = True
+ self.process.WindowState = 2
+
+ def is_loaded(self):
+ """
+ Returns true if a presentation is loaded
+ """
+ if self.process is None:
+ return False
+ if self.process.Windows.Count == 0:
+ return False
+
+ def kill(self):
+ self.process.Quit()
+ self.process = None
+
+ def load_presentation(self, presentation):
+ """
+ Called when a presentation is added to the SlideController.
+ It builds the environment, starts communcations with the background
+ OpenOffice task started earlier. If OpenOffice is not present is is
+ started. Once the environment is available the presentation is loaded
+ and started.
+
+ ``presentation``
+ The file name of the presentations to run.
+ """
+ self.filename = presentation
+ self.process.Presentations.Open(presentation, False, False, True)
+ self.presentation = self.process.Presentations(self.process.Presentations.Count)
+ self.start_presentation()
+
+ def close_presentation(self):
+ """
+ Close presentation and clean up objects
+ Triggerent by new object being added to SlideController orOpenLP
+ being shut down
+ """
+ self.presentation.Close()
+ self.presentation = None
+
+ def is_active(self):
+ """
+ Returns true if a presentation is currently active
+ """
+ if not self.is_loaded():
+ return False
+ if self.presentation.SlideShowWindow == None:
+ return False
+ if self.presentation.SlideShowWindow.View == None:
+ return False
+ return True
+
+ def unblank_screen(self):
+ """
+ Unblanks (restores) the presentationn
+ """
+ self.presentation.SlideShowSettings.Run()
+ self.presentation.SlideShowWindow.View.State = 1
+ self.presentation.SlideShowWindow.Activate()
+
+ def blank_screen(self):
+ """
+ Blanks the screen
+ """
+ self.presentation.SlideShowWindow.View.State = 3
+
+ def stop_presentation(self):
+ """
+ Stops the current presentation and hides the output
+ """
+ self.presentation.SlideShowWindow.View.Exit()
+
+ def start_presentation(self):
+ """
+ Starts a presentation from the beginning
+ """
+ self.presentation.SlideShowSettings.Run()
+ rendermanager = self.plugin.render_manager
+ rect = rendermanager.screen_list[rendermanager.current_display][u'size']
+ self.presentation.SlideShowWindow.Top = rect.y() / 20
+ self.presentation.SlideShowWindow.Height = rect.height() / 20
+ self.presentation.SlideShowWindow.Left = rect.x() / 20
+ self.presentation.SlideShowWindow.Width = rect.width() / 20
+
+ def get_slide_number(self):
+ """
+ Returns the current slide number
+ """
+ return self.presentation.SlideShowWindow.View.CurrentShowPosition
+
+ def get_slide_count(self):
+ """
+ Returns total number of slides
+ """
+ return self.presentation.Slides.Count
+
+ def goto_slide(self, slideno):
+ self.presentation.SlideShowWindow.View.GotoSlide(slideno)
+
+ def next_step(self):
+ self.presentation.SlideShowWindow.View.Next()
+
+ def previous_step(self):
+ self.presentation.SlideShowWindow.View.Previous()
+
+ #def get_slide_preview_file(self, slide_no):
+
+
+>>>>>>> MERGE-SOURCE
=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
--- openlp/plugins/presentations/lib/pptviewcontroller.py 2009-09-25 14:36:35 +0000
+++ openlp/plugins/presentations/lib/pptviewcontroller.py 2009-09-26 21:10:22 +0000
@@ -22,160 +22,170 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
+import os
import logging
-from ctypes import *
-from ctypes.wintypes import RECT
-
-class PptviewController(object):
+if os.name == u'nt':
+ from ctypes import *
+ from ctypes.wintypes import RECT
+
+from presentationcontroller import PresentationController
+
+class PptviewController(PresentationController):
"""
Class to control interactions with PowerPOint Viewer Presentations
It creates the runtime Environment , Loads the and Closes the Presentation
- As well as trigggering the correct activities based on the users input
+ As well as triggering the correct activities based on the users input
"""
global log
log = logging.getLogger(u'PptviewController')
- def __init__(self):
+ def __init__(self, plugin):
+ """
+ Initialise the class
+ """
log.debug(u'Initialising')
+ PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
self.process = None
- self.document = None
- self.presentation = None
self.pptid = None
- self.startPPTView()
-
- def startPPTView(self):
- """
- Loads the PPTVIEWLIB library
- """
- log.debug(u'start PPTView')
- self.presentation = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
-
- def kill(self):
- """
- Called at system exit to clean up any running presentations
- """
- log.debug(u'Kill')
- self.closePresentation()
-
- def loadPresentation(self, presentation):
- """
- Called when a presentation is added to the SlideController.
- It builds the environment, starts communcations with the background
- OpenOffice task started earlier. If OpenOffice is not present is is
- started. Once the environment is available the presentation is loaded
- and started.
-
- ``presentation``
- The file name of the presentations to run.
- """
- log.debug(u'LoadPresentation')
- if self.pptid >= 0:
- self.closePresentation()
- rect = RECT(0, 0, 800, 600) # until such time I can get screen info
- filename = str(presentation.replace(u'/', u'\\'));
+ self.thumbnailpath = os.path.join(plugin.config.get_data_path(),
+ u'pptview', u'thumbnails')
+ self.thumbprefix = u'slide'
+
+ def is_available(self):
+ """
+ PPT Viewer is able to run on this machine
+ """
+ log.debug(u'is_available')
+ if os.name != u'nt':
+ return False
try:
- tempfolder = None #r'c:\temp\pptviewlib\' + filename.split('u\\')[-1]
- self.pptid = self.presentation.OpenPPT(filename, None, rect, tempfolder)
+ self.start_process()
+ return True
except:
- log.exception(u'Failed to load presentation')
- #self.slidecount = pptdll.GetSlideCount(self.pptid)
-
- def closePresentation(self):
- """
- Close presentation and clean up objects
- Triggerent by new object being added to SlideController orOpenLP
- being shut down
- """
- if self.pptid < 0:
- return
- self.presentation.ClosePPT(self.pptid)
- self.pptid = -1
-
- def nextStep(self):
- """
- Triggers the next effect of slide on the running presentation
- """
- if self.pptid < 0:
- return
- self.presentation.NextStep(self.pptid)
-
- def previousStep(self):
- """
- Triggers the previous slide on the running presentation
- """
- if self.pptid < 0:
- return
- self.presentation.PrevStep(self.pptid)
-
- def isActive(self):
- """
- Returns true if a presentation is currently active
- """
- return self.pptid >= 0
-
- def resume(self):
- """
- Resumes a previously paused presentation
- """
- if self.pptid < 0:
- return
- self.presentation.Resume(self.pptid)
-
- def pause(self):
- """
- Not implemented (pauses a presentation)
- """
- return
-
- def blankScreen(self):
- """
- Blanks the screen
- """
- if self.pptid < 0:
- return
- self.presentation.Blank(self.pptid)
-
- def unblankScreen(self):
- """
- Unblanks (restores) the presentationn
- """
- if self.pptid < 0:
- return
- self.presentation.Unblank(self.pptid)
-
- def stop(self):
- """
- Stops the current presentation and hides the output
- """
- if self.pptid < 0:
- return
- self.presentation.Stop(self.pptid)
-
- def go(self):
- """
- Starts a presentation from the beginning
- """
- if self.pptid < 0:
- return
- self.presentation.RestartShow(self.pptid)
-
- def getSlideNumber(self):
- """
- Returns the current slide number
- """
- if self.pptid < 0:
- return -1
- return self.presentation.GetCurrentSlide(self.pptid)
-
- def setSlideNumber(self, slideno):
- """
- Moves to a specific slide in the presentation
- """
- if self.pptid < 0:
- return
- self.presentation.GotoSlide(self.pptid, slideno)
-
- slideNumber = property(getSlideNumber, setSlideNumber)
-
+ return False
+
+ if os.name == u'nt':
+ def start_process(self):
+ """
+ Loads the PPTVIEWLIB library
+ """
+ log.debug(u'start PPTView')
+ self.process = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
+
+ def kill(self):
+ """
+ Called at system exit to clean up any running presentations
+ """
+ log.debug(u'Kill')
+ self.close_presentation()
+
+ def load_presentation(self, presentation):
+ """
+ Called when a presentation is added to the SlideController.
+ It builds the environment, starts communcations with the background
+ OpenOffice task started earlier. If OpenOffice is not present is is
+ started. Once the environment is available the presentation is loaded
+ and started.
+
+ ``presentation``
+ The file name of the presentations to run.
+ """
+ log.debug(u'LoadPresentation')
+ if self.pptid >= 0:
+ self.close_presentation()
+ rendermanager = self.plugin.render_manager
+ rect = rendermanager.screen_list[rendermanager.current_display][u'size']
+ rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
+ filename = str(presentation.replace(u'/', u'\\'));
+ try:
+ self.pptid = self.process.OpenPPT(filename, None, rect,
+ str(self.thumbnailpath))
+ except:
+ log.exception(u'Failed to load presentation')
+
+ def close_presentation(self):
+ """
+ Close presentation and clean up objects
+ Triggerent by new object being added to SlideController orOpenLP
+ being shut down
+ """
+ self.process.ClosePPT(self.pptid)
+ self.pptid = -1
+
+ def is_loaded(self):
+ """
+ Returns true if a presentation is loaded
+ """
+ return self.pptid >= 0
+
+ def is_active(self):
+ """
+ Returns true if a presentation is currently active
+ """
+ return self.pptid >= 0
+
+ def blank_screen(self):
+ """
+ Blanks the screen
+ """
+ self.process.Blank(self.pptid)
+
+ def unblank_screen(self):
+ """
+ Unblanks (restores) the presentationn
+ """
+ self.process.Unblank(self.pptid)
+
+ def stop_presentation(self):
+ """
+ Stops the current presentation and hides the output
+ """
+ self.process.Stop(self.pptid)
+
+ def start_presentation(self):
+ """
+ Starts a presentation from the beginning
+ """
+ self.process.RestartShow(self.pptid)
+
+ def get_slide_number(self):
+ """
+ Returns the current slide number
+ """
+ return self.process.GetCurrentSlide(self.pptid)
+
+ def get_slide_count(self):
+ """
+ Returns total number of slides
+ """
+ return self.process.GetSlideCount(self.pptid)
+
+ def goto_slide(self, slideno):
+ """
+ Moves to a specific slide in the presentation
+ """
+ self.process.GotoSlide(self.pptid, slideno)
+
+ def next_step(self):
+ """
+ Triggers the next effect of slide on the running presentation
+ """
+ self.process.NextStep(self.pptid)
+
+ def previous_step(self):
+ """
+ Triggers the previous slide on the running presentation
+ """
+ self.process.PrevStep(self.pptid)
+
+ def get_slide_preview_file(self, slide_no):
+ """
+ Returns an image path containing a preview for the requested slide
+
+ ``slide_no``
+ The slide an image is required for, starting at 1
+ """
+ return os.path.join(self.thumbnailpath,
+ self.thumbprefix + slide_no + u'.bmp')
=== added file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2009-09-26 21:10:22 +0000
@@ -0,0 +1,227 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+"""
+OpenLP - Open Source Lyrics Projection
+Copyright (c) 2008 Raoul Snyman
+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
+
+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
+"""
+
+import logging
+
+class PresentationController(object):
+ """
+ Base class for presentation controllers to inherit from
+ Class to control interactions with presentations.
+ It creates the runtime environment, loads and closes the presentation as
+ well as triggering the correct activities based on the users input
+
+ **Basic Attributes**
+
+ ``name``
+ The name that appears in the options and the media manager
+
+ ``plugin``
+ The presentationplugin object
+
+ **Hook Functions**
+
+ ``kill()``
+ Called at system exit to clean up any running presentations
+
+ ``is_available()``
+ Returns True if presentation application is installed/can run on this machine
+
+ ``load_presentation(presentation)``
+ Load a presentation file
+
+ ``close_presentation()``
+ Close presentation and clean up objects
+
+ ``presentation_loaded()``
+ Returns True if presentation is currently loaded
+
+ ``is_active()``
+ Returns True if a presentation is currently running
+
+ ``blank_screen()``
+ Blanks the screen, making it black.
+
+ ``unblank_screen()``
+ Unblanks the screen, restoring the output
+
+ ``stop_presentation()``
+ Stops the presentation, removing it from the output display
+
+ ``start_presentation()``
+ Starts the presentation from the beginning
+
+ ``get_slide_number()``
+ Returns the current slide number, from 1
+
+ ``get_slide_count()``
+ Returns total number of slides
+
+ ``goto_slide(slide_no)``
+ Jumps directly to the requested slide.
+
+ ``next_step()``
+ Triggers the next effect of slide on the running presentation
+
+ ``previous_step()``
+ Triggers the previous slide on the running presentation
+
+ ``get_slide_preview_file(slide_no)``
+ Returns a path to an image containing a preview for the requested slide
+
+ """
+ global log
+ log = logging.getLogger(u'PresentationController')
+ log.info(u'loaded')
+
+ def __init__(self, plugin=None, name=u'PresentationController'):
+ """
+ This is the constructor for the presentationcontroller object.
+ This provides an easy way for descendent plugins to populate common data.
+ This method *must* be overridden, like so::
+
+ class MyPresentationController(PresentationController):
+ def __init__(self, plugin):
+ PresentationController.__init(self, plugin, u'My Presenter App')
+
+ ``plugin``
+ Defaults to *None*. The presentationplugin object
+
+ ``name``
+ Name of the application, to appear in the application
+ """
+ self.plugin = plugin
+ self.name = name
+ self.start_process()
+
+ def is_available(self):
+ """
+ Presentation app is able to run on this machine
+ """
+ return False
+
+ def start_process(self):
+ """
+ Loads a running version of the presentation application in the background.
+ """
+ pass
+
+ def kill(self):
+ """
+ Called at system exit to clean up any running presentations and
+ close the application
+ """
+ log.debug(u'Kill')
+ self.close_presentation()
+
+ def load_presentation(self, presentation):
+ """
+ Called when a presentation is added to the SlideController.
+ Loads the presentation and starts it
+
+ ``presentation``
+ The file name of the presentatios to the run.
+ """
+ pass
+
+ def close_presentation(self):
+ """
+ Close presentation and clean up objects
+ Triggered by new object being added to SlideController
+ """
+ pass
+
+ def is_active(self):
+ """
+ Returns True if a presentation is currently running
+ """
+ return False
+
+ def is_loaded(self):
+ """
+ Returns true if a presentation is loaded
+ """
+ return False
+
+ def blank_screen(self):
+ """
+ Blanks the screen, making it black.
+ """
+ pass
+
+ def unblank_screen(self):
+ """
+ Unblanks (restores) the presentationn
+ """
+ pass
+
+ def stop_presentation(self):
+ """
+ Stops the presentation, removing it from the output display
+ """
+ pass
+
+ def start_presentation(self):
+ """
+ Starts the presentation from the beginning
+ """
+ pass
+
+ def get_slide_number(self):
+ """
+ Returns the current slide number, from 1
+ """
+ return 0
+
+ def get_slide_count(self):
+ """
+ Returns total number of slides
+ """
+ return 0
+
+ def goto_slide(self, slide_no):
+ """
+ Jumps directly to the requested slide.
+
+ ``slide_no``
+ The slide to jump to, starting at 1
+ """
+ pass
+
+ def next_step(self):
+ """
+ Triggers the next effect of slide on the running presentation
+ This might be the next animation on the current slide, or the next slide
+ """
+ pass
+
+ def previous_step(self):
+ """
+ Triggers the previous slide on the running presentation
+ """
+ pass
+
+ def get_slide_preview_file(self, slide_no):
+ """
+ Returns an image path containing a preview for the requested slide
+
+ ``slide_no``
+ The slide an image is required for, starting at 1
+ """
+ return None
=== modified file 'openlp/plugins/presentations/lib/presentationtab.py'
--- openlp/plugins/presentations/lib/presentationtab.py 2009-09-25 16:23:44 +0000
+++ openlp/plugins/presentations/lib/presentationtab.py 2009-09-26 21:10:22 +0000
@@ -31,7 +31,8 @@
"""
PresentationsTab is the Presentations settings tab in the settings dialog.
"""
- def __init__(self):
+ def __init__(self, controllers):
+ self.controllers = controllers
SettingsTab.__init__(self,
translate(u'PresentationTab', u'Presentation'), u'Presentations')
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2009-09-25 00:43:42 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2009-09-26 21:10:22 +0000
@@ -28,14 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin
-from openlp.plugins.presentations.lib import PresentationMediaItem, \
- PresentationTab, ImpressController
-if os.name == u'nt':
- try:
- from openlp.plugins.presentations.lib import PowerpointController
- except:
- pass
- from openlp.plugins.presentations.lib import PptviewController
+from openlp.plugins.presentations.lib import *
class PresentationPlugin(Plugin):
@@ -57,7 +50,7 @@
"""
Create the settings Tab
"""
- self.presentation_tab = PresentationTab()
+ self.presentation_tab = PresentationTab(self.controllers)
return self.presentation_tab
def get_media_manager_item(self):
@@ -68,8 +61,8 @@
self, self.icon, u'Presentations', self.controllers)
return self.media_item
- def registerControllers(self, handle, controller):
- self.controllers[handle] = controller
+ def registerControllers(self, controller):
+ self.controllers[controller.name] = controller
def check_pre_conditions(self):
"""
@@ -77,39 +70,24 @@
If Not do not install the plugin.
"""
log.debug('check_pre_conditions')
+ #Lets see if Powerpoint is required (Default is Not wanted)
+ controller = PowerpointController(self)
+ if int(self.config.get_config(
+ controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
+ if controller.is_available():
+ self.registerControllers(controller)
#Lets see if Impress is required (Default is Not wanted)
- if int(self.config.get_config(
- u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
- try:
- if os.name == u'nt':
- #Check to see if we are Win32
- from win32com.client import Dispatch
- else:
- #Check to see if we have uno installed
- import uno
- openoffice = ImpressController()
- self.registerControllers(u'Impress', openoffice)
- except:
- log.exception(u'Failed to set up plugin for Impress')
- if os.name == u'nt':
- #Lets see if Powerpoint is required (Default is Not wanted)
- if int(self.config.get_config(
- u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
- try:
- #Check to see if we are Win32
- from win32com.client import Dispatch
- powerpoint = PowerpointController()
- self.registerControllers(u'Powerpoint', powerpoint)
- except:
- log.exception(u'Failed to set up plugin for Powerpoint')
- #Lets see if Powerpoint Viewer is required (Default is Not wanted)
- if int(self.config.get_config(
- u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
- try:
- pptview = PptviewController()
- self.registerControllers(u'Powerpoint Viewer', pptview)
- except:
- log.exception(u'Failed to set up plugin for Powerpoint Viewer')
+ controller = ImpressController(self)
+ if int(self.config.get_config(
+ controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
+ if controller.is_available():
+ self.registerControllers(controller)
+ #Lets see if Powerpoint Viewer is required (Default is Not wanted)
+ controller = PptviewController(self)
+ if int(self.config.get_config(
+ controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
+ if controller.is_available():
+ self.registerControllers(controller)
#If we have no available controllers disable plugin
if len(self.controllers) > 0:
return True
Follow ups