diff --git a/copyright.txt b/copyright.txt index df5563844..b8385cc89 100644 --- a/copyright.txt +++ b/copyright.txt @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp.pyw b/openlp.pyw index 64ffb3321..cc58c6a21 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -5,8 +5,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/__init__.py b/openlp/__init__.py index 5f7608770..c0e8a73dc 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 82a30b19f..b6efd5595 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index a687ded64..4403ac8ec 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -32,7 +32,7 @@ import logging import os.path import types -from PyQt4 import QtCore, QtGui +from PyQt4 import QtCore, QtGui, Qt log = logging.getLogger(__name__) @@ -43,6 +43,26 @@ class MediaType(object): Audio = 1 Video = 2 + +class SlideLimits(object): + """ + Provides an enumeration for behaviour of OpenLP at the end limits of each + service item when pressing the up/down arrow keys + """ + End = 1 + Wrap = 2 + Next = 3 + + +class ServiceItemAction(object): + """ + Provides an enumeration for the required action moving between service + items by left/right arrow keys + """ + Previous = 1 + PreviousLastSlide = 2 + Next = 3 + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): @@ -298,6 +318,34 @@ def check_directory_exists(dir): except IOError: pass +def create_separated_list(stringlist): + """ + Returns a string that represents a join of a list of strings with a + localized separator. This function corresponds to + QLocale::createSeparatedList which was introduced in Qt 4.8 and implements + the algorithm from http://www.unicode.org/reports/tr35/#ListPatterns + + ``stringlist`` + List of unicode strings + """ + if Qt.PYQT_VERSION_STR >= u'4.9' and Qt.qVersion() >= u'4.8': + return unicode(QtCore.QLocale().createSeparatedList(stringlist)) + if not stringlist: + return u'' + elif len(stringlist) == 1: + return stringlist[0] + elif len(stringlist) == 2: + return unicode(translate('OpenLP.core.lib', '%1 and %2', + 'Locale list separator: 2 items').arg(stringlist[0], stringlist[1])) + else: + merged = unicode(translate('OpenLP.core.lib', '%1, and %2', + u'Locale list separator: end').arg(stringlist[-2], stringlist[-1])) + for index in reversed(range(1, len(stringlist) - 2)): + merged = unicode(translate('OpenLP.core.lib', '%1, %2', + u'Locale list separator: middle').arg(stringlist[index], merged)) + return unicode(translate('OpenLP.core.lib', '%1, %2', + u'Locale list separator: start').arg(stringlist[0], merged)) + from eventreceiver import Receiver from listwidgetwithdnd import ListWidgetWithDnD from formattingtags import FormattingTags diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index b6f12d180..436ea82de 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -199,6 +199,10 @@ class Manager(object): urlquote(unicode(settings.value(u'db password').toString())), urlquote(unicode(settings.value(u'db hostname').toString())), urlquote(unicode(settings.value(u'db database').toString()))) + if db_type == u'mysql': + db_encoding = unicode( + settings.value(u'db encoding', u'utf8').toString()) + self.db_url += u'?charset=%s' % urlquote(db_encoding) settings.endGroup() if upgrade_mod: db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod) @@ -239,6 +243,17 @@ class Manager(object): self.session.commit() self.is_dirty = True return True + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue - "MySQL has gone away"') + self.session.rollback() + self.session.add(object_instance) + if commit: + self.session.commit() + self.is_dirty = True + return True except InvalidRequestError: self.session.rollback() log.exception(u'Object save failed') @@ -260,6 +275,17 @@ class Manager(object): self.session.commit() self.is_dirty = True return True + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + self.session.add_all(object_list) + if commit: + self.session.commit() + self.is_dirty = True + return True except InvalidRequestError: self.session.rollback() log.exception(u'Object list save failed') @@ -278,7 +304,15 @@ class Manager(object): if not key: return object_class() else: - return self.session.query(object_class).get(key) + try: + return self.session.query(object_class).get(key) + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + return self.session.query(object_class).get(key) def get_object_filtered(self, object_class, filter_clause): """ @@ -290,7 +324,15 @@ class Manager(object): ``filter_clause`` The criteria to select the object by """ - return self.session.query(object_class).filter(filter_clause).first() + try: + return self.session.query(object_class).filter(filter_clause).first() + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + return self.session.query(object_class).filter(filter_clause).first() def get_all_objects(self, object_class, filter_clause=None, order_by_ref=None): @@ -311,10 +353,18 @@ class Manager(object): if filter_clause is not None: query = query.filter(filter_clause) if isinstance(order_by_ref, list): - return query.order_by(*order_by_ref).all() + query = query.order_by(*order_by_ref) elif order_by_ref is not None: - return query.order_by(order_by_ref).all() - return query.all() + query = query.order_by(order_by_ref) + try: + return query.all() + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + return query.all() def get_object_count(self, object_class, filter_clause=None): """ @@ -330,7 +380,15 @@ class Manager(object): query = self.session.query(object_class) if filter_clause is not None: query = query.filter(filter_clause) - return query.count() + try: + return query.count() + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + return query.count() def delete_object(self, object_class, key): """ @@ -349,6 +407,16 @@ class Manager(object): self.session.commit() self.is_dirty = True return True + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + self.session.delete(object_instance) + self.session.commit() + self.is_dirty = True + return True except InvalidRequestError: self.session.rollback() log.exception(u'Failed to delete object') @@ -378,6 +446,19 @@ class Manager(object): self.session.commit() self.is_dirty = True return True + except OperationalError: + # This exception clause is for users running MySQL which likes + # to terminate connections on its own without telling anyone. + # See bug #927473 + log.exception(u'Probably a MySQL issue, "MySQL has gone away"') + self.session.rollback() + query = self.session.query(object_class) + if filter_clause is not None: + query = query.filter(filter_clause) + query.delete(synchronize_session=False) + self.session.commit() + self.is_dirty = True + return True except InvalidRequestError: self.session.rollback() log.exception(u'Failed to delete %s records', object_class.__name__) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 8c942171c..4f74784ad 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 40cac8e35..35459e9dd 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -111,6 +111,9 @@ class EventReceiver(QtCore.QObject): ``slidecontroller_live_spin_delay`` Pushes out the loop delay. + + ``slidecontroller_update_slide_limits`` + Updates the slide_limits variable from the saved settings. ``slidecontroller_live_stop_loop`` Stop the loop on the main display. diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index bc0055325..bb5f1e716 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index e4cdecd72..b90b895b4 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -45,6 +45,7 @@ HTMLSRC = u""" padding: 0; border: 0; overflow: hidden; + -webkit-user-select: none; } body { %s; @@ -129,10 +130,10 @@ sup { var match = /-webkit-text-fill-color:[^;\"]+/gi; if(timer != null) clearTimeout(timer); - /* - QtWebkit bug with outlines and justify causing outline alignment - problems. (Bug 859950) Surround each word with a to workaround, - but only in this scenario. + /* + QtWebkit bug with outlines and justify causing outline alignment + problems. (Bug 859950) Surround each word with a to workaround, + but only in this scenario. */ var txt = document.getElementById('lyricsmain'); if(window.getComputedStyle(txt).textAlign == 'justify'){ @@ -141,7 +142,7 @@ sup { txt = outline; if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){ newtext = newtext.replace(/(\s| )+(?![^<]*>)/g, - function(match) { + function(match) { return '' + match + ''; }); newtext = '' + newtext + ''; @@ -288,6 +289,9 @@ def build_background_css(item, width, height): background = u'background-color: black' if theme: if theme.background_type == \ + BackgroundType.to_string(BackgroundType.Transparent): + background = u'' + elif theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): background = u'background-color: %s' % theme.background_color else: diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 0dcc2246b..8fa2127ad 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 31be1f5be..67fa45f74 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 1bddb2d93..d7b15a0cb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ StringContent, build_icon, translate, Receiver, ListWidgetWithDnD +from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, context_menu_action, \ context_menu_separator, critical_error_message_box @@ -301,6 +302,40 @@ class MediaManagerItem(QtGui.QWidget): QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.contextMenu) + def addSearchToToolBar(self): + """ + Creates a search field with button and related signal handling. + """ + self.searchWidget = QtGui.QWidget(self) + self.searchWidget.setObjectName(u'searchWidget') + self.searchLayout = QtGui.QVBoxLayout(self.searchWidget) + self.searchLayout.setObjectName(u'searchLayout') + self.searchTextLayout = QtGui.QFormLayout() + self.searchTextLayout.setObjectName(u'searchTextLayout') + self.searchTextLabel = QtGui.QLabel(self.searchWidget) + self.searchTextLabel.setObjectName(u'searchTextLabel') + self.searchTextEdit = SearchEdit(self.searchWidget) + self.searchTextEdit.setObjectName(u'searchTextEdit') + self.searchTextLabel.setBuddy(self.searchTextEdit) + self.searchTextLayout.addRow(self.searchTextLabel, self.searchTextEdit) + self.searchLayout.addLayout(self.searchTextLayout) + self.searchButtonLayout = QtGui.QHBoxLayout() + self.searchButtonLayout.setObjectName(u'searchButtonLayout') + self.searchButtonLayout.addStretch() + self.searchTextButton = QtGui.QPushButton(self.searchWidget) + self.searchTextButton.setObjectName(u'searchTextButton') + self.searchButtonLayout.addWidget(self.searchTextButton) + self.searchLayout.addLayout(self.searchButtonLayout) + self.pageLayout.addWidget(self.searchWidget) + # Signals and slots + QtCore.QObject.connect(self.searchTextEdit, + QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClick) + QtCore.QObject.connect(self.searchTextButton, + QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick) + QtCore.QObject.connect(self.searchTextEdit, + QtCore.SIGNAL(u'textChanged(const QString&)'), + self.onSearchTextEditChanged) + def addCustomContextActions(self): """ Implement this method in your descendent media manager item to diff --git a/openlp/core/lib/mediaplayer.py b/openlp/core/lib/mediaplayer.py index 9a86f708b..e4c8dc88f 100644 --- a/openlp/core/lib/mediaplayer.py +++ b/openlp/core/lib/mediaplayer.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 624ce2083..f3bfb68c6 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index d63a37dde..80160911d 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 503c60b04..135bb9078 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index c172ba21d..c212dcc24 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 62418f49e..9878e1f24 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 9bcbf2f07..c21b58a45 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index f36f9f561..aaa1e5af4 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 25e4e24ae..38077a590 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 34a3b9d98..486f89b18 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -100,6 +100,7 @@ class BackgroundType(object): Solid = 0 Gradient = 1 Image = 2 + Transparent = 3 @staticmethod def to_string(background_type): @@ -112,6 +113,8 @@ class BackgroundType(object): return u'gradient' elif background_type == BackgroundType.Image: return u'image' + elif background_type == BackgroundType.Transparent: + return u'transparent' @staticmethod def from_string(type_string): @@ -124,6 +127,8 @@ class BackgroundType(object): return BackgroundType.Gradient elif type_string == u'image': return BackgroundType.Image + elif type_string == u'transparent': + return BackgroundType.Transparent class BackgroundGradientType(object): @@ -246,7 +251,7 @@ class ThemeXML(object): Add a transparent background. """ background = self.theme_xml.createElement(u'background') - background.setAttribute(u'mode', u'transparent') + background.setAttribute(u'type', u'transparent') self.theme.appendChild(background) def add_background_solid(self, bkcolor): @@ -487,25 +492,25 @@ class ThemeXML(object): return xml_iter = theme_xml.getiterator() for element in xml_iter: - parent = element.getparent() master = u'' + if element.tag == u'background': + if element.attrib: + for attr in element.attrib: + self._create_attr(element.tag, attr, \ + element.attrib[attr]) + parent = element.getparent() if parent is not None: - if element.getparent().tag == u'font': - master = element.getparent().tag + u'_' + \ - element.getparent().attrib[u'type'] + if parent.tag == u'font': + master = parent.tag + u'_' + parent.attrib[u'type'] # set up Outline and Shadow Tags and move to font_main - if element.getparent().tag == u'display': + if parent.tag == u'display': if element.tag.startswith(u'shadow') or \ element.tag.startswith(u'outline'): self._create_attr(u'font_main', element.tag, element.text) - master = element.getparent().tag - if element.getparent().tag == u'background': - master = element.getparent().tag - if element.getparent().attrib: - for attr in element.getparent().attrib: - self._create_attr(master, attr, \ - element.getparent().attrib[attr]) + master = parent.tag + if parent.tag == u'background': + master = parent.tag if master: self._create_attr(master, element.tag, element.text) if element.attrib: @@ -599,9 +604,13 @@ class ThemeXML(object): self.background_start_color, self.background_end_color, self.background_direction) - else: + elif self.background_type == \ + BackgroundType.to_string(BackgroundType.Image): filename = os.path.split(self.background_filename)[1] self.add_background_image(filename, self.background_border_color) + elif self.background_type == \ + BackgroundType.to_string(BackgroundType.Transparent): + self.add_background_transparent() self.add_font(self.font_main_name, self.font_main_color, self.font_main_size, diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index cf550d875..1418b501a 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 756df36c3..2922200e3 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -93,6 +93,7 @@ class UiStrings(object): self.New = translate('OpenLP.Ui', 'New') self.NewService = translate('OpenLP.Ui', 'New Service') self.NewTheme = translate('OpenLP.Ui', 'New Theme') + self.NextTrack = translate('OpenLP.Ui', 'Next Track') self.NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular') self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') diff --git a/openlp/core/theme/__init__.py b/openlp/core/theme/__init__.py index 44a937608..76223d78a 100644 --- a/openlp/core/theme/__init__.py +++ b/openlp/core/theme/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 48e364dbd..90ca6cf6c 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index a24d357f0..e9c593337 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 8216d3e7a..5032f0d40 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -126,7 +126,8 @@ class Ui_AboutDialog(object): u'Tim "TRB143" Bentley (Fedora and Android)', u'Matthias "matthub" Hub (Mac OS X)', u'Stevan "ElderP" Pettit (Windows)', - u'Raoul "superfly" Snyman (Ubuntu)'] + u'Raoul "superfly" Snyman (Ubuntu)', + u'Garrett "floft" Wilson (Arch Linux)'] translators = { u'af': [u'Johan "nuvolari" Mynhardt'], u'de': [u'Patrick "madmuffin" Br\xfcckner', @@ -226,8 +227,8 @@ class Ui_AboutDialog(object): self.aboutNotebook.indexOf(self.creditsTab), translate('OpenLP.AboutForm', 'Credits')) copyright = unicode(translate('OpenLP.AboutForm', - 'Copyright \xa9 2004-2011 %s\n' - 'Portions copyright \xa9 2004-2011 %s')) % (u'Raoul Snyman', + 'Copyright \xa9 2004-2012 %s\n' + 'Portions copyright \xa9 2004-2012 %s')) % (u'Raoul Snyman', u'Tim Bentley, Jonathan Corwin, Michael Gorven, Gerald Britton, ' u'Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin K\xf6hler, ' u'Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias ' diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 4e031656c..e2ccbc3c3 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 43e2a9915..210dabdd2 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -27,10 +27,13 @@ """ The :mod:`advancedtab` provides an advanced settings facility. """ +from datetime import datetime, timedelta + from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, build_icon +from openlp.core.lib import SettingsTab, translate, build_icon, Receiver from openlp.core.lib.ui import UiStrings +from openlp.core.lib import SlideLimits from openlp.core.utils import get_images_filter class AdvancedTab(SettingsTab): @@ -42,11 +45,26 @@ class AdvancedTab(SettingsTab): """ Initialise the settings tab """ - advancedTranslated = translate('OpenLP.AdvancedTab', 'Advanced') - self.default_image = u':/graphics/openlp-splash-screen.png' - self.default_color = u'#ffffff' + self.displayChanged = False + # 7 stands for now, 0 to 6 is Monday to Sunday. + self.defaultServiceDay = 7 + # 11 o'clock is the most popular time for morning service. + self.defaultServiceHour = 11 + self.defaultServiceMinute = 0 + self.defaultServiceName = unicode(translate('OpenLP.AdvancedTab', + 'Service %Y-%m-%d %H-%M', + 'This is the default default service name template, which can be ' + 'found under Advanced in Settings, Configure OpenLP. Please do not ' + 'include any of the following characters: /\\?*|<>\[\]":+\n' + 'You can use any of the directives as shown on page ' + 'http://docs.python.org/library/datetime.html' + '#strftime-strptime-behavior , but if possible, please keep ' + 'the resulting string sortable by name.')) + self.defaultImage = u':/graphics/openlp-splash-screen.png' + self.defaultColor = u'#ffffff' self.icon_path = u':/system/system_settings.png' - SettingsTab.__init__(self, parent, u'Advanced', advancedTranslated) + advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') + SettingsTab.__init__(self, parent, u'Advanced', advanced_translated) def setupUi(self): """ @@ -83,7 +101,61 @@ class AdvancedTab(SettingsTab): u'enableAutoCloseCheckBox') self.uiLayout.addRow(self.enableAutoCloseCheckBox) self.leftLayout.addWidget(self.uiGroupBox) + # Default service name + self.serviceNameGroupBox = QtGui.QGroupBox(self.leftColumn) + self.serviceNameGroupBox.setObjectName(u'serviceNameGroupBox') + self.serviceNameLayout = QtGui.QFormLayout( + self.serviceNameGroupBox) + self.serviceNameCheckBox = QtGui.QCheckBox( + self.serviceNameGroupBox) + self.serviceNameCheckBox.setObjectName(u'serviceNameCheckBox') + self.serviceNameLayout.setObjectName(u'serviceNameLayout') + self.serviceNameLayout.addRow(self.serviceNameCheckBox) + self.serviceNameTimeLabel = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameTimeLabel.setObjectName(u'serviceNameTimeLabel') + self.serviceNameDay = QtGui.QComboBox( + self.serviceNameGroupBox) + self.serviceNameDay.addItems( + [u'', u'', u'', u'', u'', u'', u'', u'']) + self.serviceNameDay.setObjectName( + u'serviceNameDay') + self.serviceNameTime = QtGui.QTimeEdit(self.serviceNameGroupBox) + self.serviceNameTime.setObjectName(u'serviceNameTime') + self.serviceNameTimeHBox = QtGui.QHBoxLayout() + self.serviceNameTimeHBox.setObjectName(u'serviceNameTimeHBox') + self.serviceNameTimeHBox.addWidget(self.serviceNameDay) + self.serviceNameTimeHBox.addWidget(self.serviceNameTime) + self.serviceNameLayout.addRow(self.serviceNameTimeLabel, + self.serviceNameTimeHBox) + self.serviceNameLabel = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameLabel.setObjectName(u'serviceNameLabel') + self.serviceNameEdit = QtGui.QLineEdit(self.serviceNameGroupBox) + self.serviceNameEdit.setObjectName(u'serviceNameEdit') + self.serviceNameEdit.setValidator(QtGui.QRegExpValidator( + QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) + self.serviceNameRevertButton = QtGui.QToolButton( + self.serviceNameGroupBox) + self.serviceNameRevertButton.setObjectName( + u'serviceNameRevertButton') + self.serviceNameRevertButton.setIcon( + build_icon(u':/general/general_revert.png')) + self.serviceNameHBox = QtGui.QHBoxLayout() + self.serviceNameHBox.setObjectName(u'serviceNameHBox') + self.serviceNameHBox.addWidget(self.serviceNameEdit) + self.serviceNameHBox.addWidget(self.serviceNameRevertButton) + self.serviceNameLayout.addRow(self.serviceNameLabel, + self.serviceNameHBox) + self.serviceNameExampleLabel = QtGui.QLabel( + self.serviceNameGroupBox) + self.serviceNameExampleLabel.setObjectName( + u'serviceNameExampleLabel') + self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameExample.setObjectName(u'serviceNameExample') + self.serviceNameLayout.addRow(self.serviceNameExampleLabel, + self.serviceNameExample) + self.leftLayout.addWidget(self.serviceNameGroupBox) self.leftLayout.addStretch() + # Default Image self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn) self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox') self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox) @@ -114,7 +186,8 @@ class AdvancedTab(SettingsTab): self.defaultImageLayout.addRow(self.defaultFileLabel, self.defaultFileLayout) self.rightLayout.addWidget(self.defaultImageGroupBox) - self.hideMouseGroupBox = QtGui.QGroupBox(self.leftColumn) + # Hide mouse + self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn) self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox') self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox) self.hideMouseLayout.setObjectName(u'hideMouseLayout') @@ -122,14 +195,76 @@ class AdvancedTab(SettingsTab): self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') self.hideMouseLayout.addWidget(self.hideMouseCheckBox) self.rightLayout.addWidget(self.hideMouseGroupBox) + # Service Item Slide Limits + self.slideGroupBox = QtGui.QGroupBox(self.rightColumn) + self.slideGroupBox.setObjectName(u'slideGroupBox') + self.slideLayout = QtGui.QFormLayout(self.slideGroupBox) + self.slideLayout.setLabelAlignment( + QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) + self.slideLayout.setFormAlignment( + QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) + self.slideLayout.setObjectName(u'slideLayout') + self.endSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.endSlideRadioButton.setObjectName(u'endSlideRadioButton') + self.endSlideLabel = QtGui.QLabel(self.slideGroupBox) + self.endSlideLabel.setWordWrap(True) + self.endSlideLabel.setObjectName(u'endSlideLabel') + self.slideLayout.addRow(self.endSlideRadioButton, self.endSlideLabel) + self.wrapSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.wrapSlideRadioButton.setObjectName(u'wrapSlideRadioButton') + self.wrapSlideLabel = QtGui.QLabel(self.slideGroupBox) + self.wrapSlideLabel.setWordWrap(True) + self.wrapSlideLabel.setObjectName(u'wrapSlideLabel') + self.slideLayout.addRow(self.wrapSlideRadioButton, + self.wrapSlideLabel) + self.nextItemRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.nextItemRadioButton.setChecked(True) + self.nextItemRadioButton.setObjectName(u'nextItemRadioButton') + self.nextItemLabel = QtGui.QLabel(self.slideGroupBox) + self.nextItemLabel.setWordWrap(True) + self.nextItemLabel.setObjectName(u'nextItemLabel') + self.slideLayout.addRow(self.nextItemRadioButton, + self.nextItemLabel) + self.rightLayout.addWidget(self.slideGroupBox) + self.x11GroupBox = QtGui.QGroupBox(self.leftColumn) + self.x11GroupBox.setObjectName(u'x11GroupBox') + self.x11Layout = QtGui.QVBoxLayout(self.x11GroupBox) + self.x11Layout.setObjectName(u'x11Layout') + self.x11BypassCheckBox = QtGui.QCheckBox(self.x11GroupBox) + self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') + self.x11Layout.addWidget(self.x11BypassCheckBox) + self.rightLayout.addWidget(self.x11GroupBox) self.rightLayout.addStretch() + self.shouldUpdateServiceNameExample = False + QtCore.QObject.connect(self.serviceNameCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.serviceNameCheckBoxToggled) + QtCore.QObject.connect(self.serviceNameDay, + QtCore.SIGNAL(u'currentIndexChanged(int)'), + self.onServiceNameDayChanged) + QtCore.QObject.connect(self.serviceNameTime, + QtCore.SIGNAL(u'timeChanged(QTime)'), + self.updateServiceNameExample) + QtCore.QObject.connect(self.serviceNameEdit, + QtCore.SIGNAL(u'textChanged(QString)'), + self.updateServiceNameExample) + QtCore.QObject.connect(self.serviceNameRevertButton, + QtCore.SIGNAL(u'pressed()'), + self.onServiceNameRevertButtonPressed) QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'pressed()'), self.onDefaultColorButtonPressed) QtCore.QObject.connect(self.defaultBrowseButton, QtCore.SIGNAL(u'pressed()'), self.onDefaultBrowseButtonPressed) QtCore.QObject.connect(self.defaultRevertButton, QtCore.SIGNAL(u'pressed()'), self.onDefaultRevertButtonPressed) + QtCore.QObject.connect(self.x11BypassCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) + QtCore.QObject.connect(self.endSlideRadioButton, + QtCore.SIGNAL(u'pressed()'), self.onEndSlideButtonPressed) + QtCore.QObject.connect(self.wrapSlideRadioButton, + QtCore.SIGNAL(u'pressed()'), self.onWrapSlideButtonPressed) + QtCore.QObject.connect(self.nextItemRadioButton, + QtCore.SIGNAL(u'pressed()'), self.onnextItemButtonPressed) def retranslateUi(self): """ @@ -151,6 +286,40 @@ class AdvancedTab(SettingsTab): 'Expand new service items on creation')) self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable application exit confirmation')) + self.serviceNameGroupBox.setTitle( + translate('OpenLP.AdvancedTab', 'Default Service Name')) + self.serviceNameCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Enable default service name')) + self.serviceNameTimeLabel.setText( + translate('OpenLP.AdvancedTab', 'Date and Time:')) + self.serviceNameDay.setItemText(0, + translate('OpenLP.AdvancedTab', 'Monday')) + self.serviceNameDay.setItemText(1, + translate('OpenLP.AdvancedTab', 'Tuesday')) + self.serviceNameDay.setItemText(2, + translate('OpenLP.AdvancedTab', 'Wednesday')) + self.serviceNameDay.setItemText(3, + translate('OpenLP.AdvancedTab', 'Thurdsday')) + self.serviceNameDay.setItemText(4, + translate('OpenLP.AdvancedTab', 'Friday')) + self.serviceNameDay.setItemText(5, + translate('OpenLP.AdvancedTab', 'Saturday')) + self.serviceNameDay.setItemText(6, + translate('OpenLP.AdvancedTab', 'Sunday')) + self.serviceNameDay.setItemText(7, + translate('OpenLP.AdvancedTab', 'Now')) + self.serviceNameTime.setToolTip(translate('OpenLP.AdvancedTab', + 'Time when usual service starts.')) + self.serviceNameLabel.setText( + translate('OpenLP.AdvancedTab', 'Name:')) + self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', + 'Consult the OpenLP manual for usage.')) + self.serviceNameRevertButton.setToolTip(unicode( + translate('OpenLP.AdvancedTab', + 'Revert to the default service name "%s".')) % + self.defaultServiceName) + self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', + 'Example:')) self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', @@ -167,6 +336,29 @@ class AdvancedTab(SettingsTab): 'Browse for an image file to display.')) self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) + self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', + 'X11')) + self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Bypass X11 Window Manager')) + # Slide Limits + self.slideGroupBox.setTitle( + translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) + self.endSlideRadioButton.setText( + translate('OpenLP.GeneralTab', '&End Slide')) + self.endSlideLabel.setText( + translate('OpenLP.GeneralTab', 'Up and down arrow keys ' + 'stop at the top and bottom slides of each Service Item.')) + self.wrapSlideRadioButton.setText( + translate('OpenLP.GeneralTab', '&Wrap Slide')) + self.wrapSlideLabel.setText( + translate('OpenLP.GeneralTab', 'Up and down arrow keys ' + 'wrap around at the top and bottom slides of each Service Item.')) + self.nextItemRadioButton.setText( + translate('OpenLP.GeneralTab', '&Next Item')) + self.nextItemLabel.setText( + translate('OpenLP.GeneralTab', 'Up and down arrow keys ' + 'advance to the the next or previous Service Item from the ' + 'top and bottom slides of each Service Item.')) def load(self): """ @@ -198,14 +390,39 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) - self.default_color = settings.value(u'default color', + self.serviceNameDay.setCurrentIndex( + settings.value(u'default service day', + QtCore.QVariant(self.defaultServiceDay)).toInt()[0]) + self.serviceNameTime.setTime(QtCore.QTime( + settings.value(u'default service hour', + self.defaultServiceHour).toInt()[0], + settings.value(u'default service minute', + self.defaultServiceMinute).toInt()[0])) + self.shouldUpdateServiceNameExample = True + self.serviceNameEdit.setText(settings.value(u'default service name', + self.defaultServiceName).toString()) + default_service_enabled = settings.value(u'default service enabled', + QtCore.QVariant(True)).toBool() + self.serviceNameCheckBox.setChecked(default_service_enabled) + self.serviceNameCheckBoxToggled(default_service_enabled) + self.x11BypassCheckBox.setChecked( + settings.value(u'x11 bypass wm', QtCore.QVariant(True)).toBool()) + self.defaultColor = settings.value(u'default color', QtCore.QVariant(u'#ffffff')).toString() self.defaultFileEdit.setText(settings.value(u'default image', QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ .toString()) + self.slide_limits = settings.value( + u'slide limits', QtCore.QVariant(SlideLimits.End)).toInt()[0] + if self.slide_limits == SlideLimits.End: + self.endSlideRadioButton.setChecked(True) + elif self.slide_limits == SlideLimits.Wrap: + self.wrapSlideRadioButton.setChecked(True) + else: + self.nextItemRadioButton.setChecked(True) settings.endGroup() self.defaultColorButton.setStyleSheet( - u'background-color: %s' % self.default_color) + u'background-color: %s' % self.defaultColor) def save(self): """ @@ -213,6 +430,21 @@ class AdvancedTab(SettingsTab): """ settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) + settings.setValue(u'default service enabled', + self.serviceNameCheckBox.isChecked()) + service_name = unicode(self.serviceNameEdit.text()) + preset_is_valid = self.generateServiceNameExample()[0] + if service_name == self.defaultServiceName or not preset_is_valid: + settings.remove(u'default service name') + self.serviceNameEdit.setText(service_name) + else: + settings.setValue(u'default service name', service_name) + settings.setValue(u'default service day', + self.serviceNameDay.currentIndex()) + settings.setValue(u'default service hour', + self.serviceNameTime.time().hour()) + settings.setValue(u'default service minute', + self.serviceNameTime.time().minute()) settings.setValue(u'recent file count', QtCore.QVariant(self.recentSpinBox.value())) settings.setValue(u'save current plugin', @@ -227,17 +459,67 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'default color', self.default_color) + settings.setValue(u'x11 bypass wm', + QtCore.QVariant(self.x11BypassCheckBox.isChecked())) + settings.setValue(u'default color', self.defaultColor) settings.setValue(u'default image', self.defaultFileEdit.text()) + settings.setValue(u'slide limits', QtCore.QVariant(self.slide_limits)) settings.endGroup() + if self.displayChanged: + Receiver.send_message(u'config_screen_changed') + self.displayChanged = False + Receiver.send_message(u'slidecontroller_update_slide_limits') + + def serviceNameCheckBoxToggled(self, default_service_enabled): + self.serviceNameDay.setEnabled(default_service_enabled) + time_enabled = default_service_enabled and \ + self.serviceNameDay.currentIndex() is not 7 + self.serviceNameTime.setEnabled(time_enabled) + self.serviceNameEdit.setEnabled(default_service_enabled) + self.serviceNameRevertButton.setEnabled(default_service_enabled) + + def generateServiceNameExample(self): + preset_is_valid = True + if self.serviceNameDay.currentIndex() == 7: + time = datetime.now() + else: + now = datetime.now() + day_delta = self.serviceNameDay.currentIndex() - now.weekday() + if day_delta < 0: + day_delta += 7 + time = now + timedelta(days=day_delta) + time = time.replace(hour = self.serviceNameTime.time().hour(), + minute = self.serviceNameTime.time().minute()) + try: + service_name_example = time.strftime(unicode( + self.serviceNameEdit.text())) + except ValueError: + preset_is_valid = False + service_name_example = translate('OpenLP.AdvancedTab', + 'Syntax error.') + return preset_is_valid, service_name_example + + def updateServiceNameExample(self, returned_value): + if not self.shouldUpdateServiceNameExample: + return + name_example = self.generateServiceNameExample()[1] + self.serviceNameExample.setText(name_example) + + def onServiceNameDayChanged(self, service_day): + self.serviceNameTime.setEnabled(service_day is not 7) + self.updateServiceNameExample(None) + + def onServiceNameRevertButtonPressed(self): + self.serviceNameEdit.setText(self.defaultServiceName) + self.serviceNameEdit.setFocus() def onDefaultColorButtonPressed(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.default_color), self) + QtGui.QColor(self.defaultColor), self) if new_color.isValid(): - self.default_color = new_color.name() + self.defaultColor = new_color.name() self.defaultColorButton.setStyleSheet( - u'background-color: %s' % self.default_color) + u'background-color: %s' % self.defaultColor) def onDefaultBrowseButtonPressed(self): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), @@ -252,3 +534,21 @@ class AdvancedTab(SettingsTab): def onDefaultRevertButtonPressed(self): self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png') self.defaultFileEdit.setFocus() + + def onX11BypassCheckBoxToggled(self, checked): + """ + Toggle X11 bypass flag on maindisplay depending on check box state. + + ``checked`` + The state of the check box (boolean). + """ + self.displayChanged = True + + def onEndSlideButtonPressed(self): + self.slide_limits = SlideLimits.End + + def onWrapSlideButtonPressed(self): + self.slide_limits = SlideLimits.Wrap + + def onnextItemButtonPressed(self): + self.slide_limits = SlideLimits.Next diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 6ed45c5d8..26f90e11f 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 0cda4bd60..d2469c092 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -32,7 +32,7 @@ import platform import sqlalchemy import BeautifulSoup from lxml import etree -from PyQt4 import Qt, QtCore, QtGui +from PyQt4 import Qt, QtCore, QtGui, QtWebKit try: from PyQt4.phonon import Phonon @@ -77,6 +77,11 @@ try: UNO_VERSION = node.getByName(u'ooSetupVersion') except ImportError: UNO_VERSION = u'-' +try: + WEBKIT_VERSION = QtWebKit.qWebKitVersion() +except AttributeError: + WEBKIT_VERSION = u'-' + from openlp.core.lib import translate, SettingsManager from openlp.core.lib.ui import UiStrings @@ -111,6 +116,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): u'Qt4: %s\n' % Qt.qVersion() + \ u'Phonon: %s\n' % PHONON_VERSION + \ u'PyQt4: %s\n' % Qt.PYQT_VERSION_STR + \ + u'QtWebkit: %s\n' % WEBKIT_VERSION + \ u'SQLAlchemy: %s\n' % sqlalchemy.__version__ + \ u'SQLAlchemy Migrate: %s\n' % MIGRATE_VERSION + \ u'BeautifulSoup: %s\n' % BeautifulSoup.__version__ + \ diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 6611a9df7..4822d4751 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -41,7 +41,7 @@ class Ui_FileRenameDialog(object): self.dialogLayout.addWidget(self.fileNameLabel, 0, 0) self.fileNameEdit = QtGui.QLineEdit(fileRenameDialog) self.fileNameEdit.setValidator(QtGui.QRegExpValidator( - QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self)) + QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self)) self.fileNameEdit.setObjectName(u'fileNameEdit') self.dialogLayout.addWidget(self.fileNameEdit, 0, 1) self.buttonBox = create_accept_reject_button_box(fileRenameDialog, True) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 0bdbdf892..3396d68cb 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 9a5a2ea9d..abee968f9 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -29,6 +29,7 @@ import io import logging import os import sys +import time import urllib import urllib2 from tempfile import gettempdir @@ -43,6 +44,29 @@ from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) +class ThemeScreenshotThread(QtCore.QThread): + """ + This thread downloads the theme screenshots. + """ + def __init__(self, parent): + QtCore.QThread.__init__(self, parent) + + def run(self): + themes = self.parent().config.get(u'themes', u'files') + themes = themes.split(u',') + config = self.parent().config + for theme in themes: + title = config.get(u'theme_%s' % theme, u'title') + filename = config.get(u'theme_%s' % theme, u'filename') + screenshot = config.get(u'theme_%s' % theme, u'screenshot') + urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot), + os.path.join(gettempdir(), u'openlp', screenshot)) + item = QtGui.QListWidgetItem(title, self.parent().themesListWidget) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename)) + item.setCheckState(QtCore.Qt.Unchecked) + item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) + + class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ This is the Theme Import Wizard, which allows easy creation and editing of @@ -125,21 +149,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item.setCheckState(0, QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) self.biblesTreeWidget.expandAll() - themes = self.config.get(u'themes', u'files') - themes = themes.split(u',') - for theme in themes: - title = self.config.get(u'theme_%s' % theme, u'title') - filename = self.config.get(u'theme_%s' % theme, u'filename') - screenshot = self.config.get(u'theme_%s' % theme, u'screenshot') - urllib.urlretrieve(u'%s%s' % (self.web, screenshot), - os.path.join(gettempdir(), u'openlp', screenshot)) - item = QtGui.QListWidgetItem(title, self.themesListWidget) - item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(filename)) - item.setIcon(build_icon( - os.path.join(gettempdir(), u'openlp', screenshot))) - item.setCheckState(QtCore.Qt.Unchecked) - item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) + # Download the theme screenshots. + self.themeScreenshotThread = ThemeScreenshotThread(self) + self.themeScreenshotThread.start() Receiver.send_message(u'cursor_normal') def nextId(self): @@ -156,6 +168,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): return -1 elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress + elif self.currentId() == FirstTimePage.Themes: + Receiver.send_message(u'cursor_busy') + while not self.themeScreenshotThread.isFinished(): + time.sleep(0.1) + # Build the screenshot icons, as this can not be done in the thread. + self._buildThemeScreenshots() + Receiver.send_message(u'cursor_normal') + return FirstTimePage.Defaults else: return self.currentId() + 1 @@ -172,7 +192,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.hasRunWizard: self.noInternetLabel.setText(self.noInternetText) else: - self.noInternetLabel.setText(self.noInternetText + + self.noInternetLabel.setText(self.noInternetText + self.cancelWizardText) elif pageId == FirstTimePage.Defaults: self.themeComboBox.clear() @@ -264,6 +284,23 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.downloadCanceled: os.remove(fpath) + def _buildThemeScreenshots(self): + """ + This method builds the theme screenshots' icons for all items in the + ``self.themesListWidget``. + """ + themes = self.config.get(u'themes', u'files') + themes = themes.split(u',') + for theme in themes: + filename = self.config.get(u'theme_%s' % theme, u'filename') + screenshot = self.config.get(u'theme_%s' % theme, u'screenshot') + for index in xrange(self.themesListWidget.count()): + item = self.themesListWidget.item(index) + if item.data(QtCore.Qt.UserRole) == QtCore.QVariant(filename): + break + item.setIcon(build_icon( + os.path.join(gettempdir(), u'openlp', screenshot))) + def _getFileSize(self, url): site = urllib.urlopen(url) meta = site.info() @@ -273,7 +310,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): increment = (count * block_size) - self.previous_size self._incrementProgressBar(None, increment) self.previous_size = count * block_size - + def _incrementProgressBar(self, status_text, increment=1): """ Update the wizard progress page. @@ -421,6 +458,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.displayComboBox.currentIndex() != -1: QtCore.QSettings().setValue(u'General/monitor', QtCore.QVariant(self.displayComboBox.currentIndex())) + self.screens.set_current_display( + self.displayComboBox.currentIndex()) # Set Global Theme if self.themeComboBox.currentIndex() != -1: QtCore.QSettings().setValue(u'themes/global theme', diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index 172fd3e0f..b021c9d8e 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index dcde212eb..3ffbc1b00 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 0f152a396..e402134c6 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index 186f4739b..b73816635 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index e7435e5b7..d99758476 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index be02b3caa..b1d44b3dd 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -97,9 +97,6 @@ class GeneralTab(SettingsTab): self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox) self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox') self.settingsLayout.addRow(self.autoPreviewCheckBox) - self.enableLoopCheckBox = QtGui.QCheckBox(self.settingsGroupBox) - self.enableLoopCheckBox.setObjectName(u'enableLoopCheckBox') - self.settingsLayout.addRow(self.enableLoopCheckBox) # Moved here from image tab self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox) self.timeoutLabel.setObjectName(u'timeoutLabel') @@ -178,6 +175,9 @@ class GeneralTab(SettingsTab): self.startPausedCheckBox = QtGui.QCheckBox(self.audioGroupBox) self.startPausedCheckBox.setObjectName(u'startPausedCheckBox') self.audioLayout.addWidget(self.startPausedCheckBox) + self.repeatListCheckBox = QtGui.QCheckBox(self.audioGroupBox) + self.repeatListCheckBox.setObjectName(u'repeatListCheckBox') + self.audioLayout.addWidget(self.repeatListCheckBox) self.rightLayout.addWidget(self.audioGroupBox) self.rightLayout.addStretch() # Signals and slots @@ -231,8 +231,6 @@ class GeneralTab(SettingsTab): 'Unblank display when adding new live item')) self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) - self.enableLoopCheckBox.setText(translate('OpenLP.GeneralTab', - 'Enable slide wrap-around')) self.timeoutLabel.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec')) @@ -256,6 +254,8 @@ class GeneralTab(SettingsTab): translate('OpenLP.GeneralTab', 'Background Audio')) self.startPausedCheckBox.setText( translate('OpenLP.GeneralTab', 'Start background audio paused')) + self.repeatListCheckBox.setText( + translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ @@ -289,8 +289,6 @@ class GeneralTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', QtCore.QVariant(False)).toBool()) - self.enableLoopCheckBox.setChecked(settings.value(u'enable slide loop', - QtCore.QVariant(True)).toBool()) self.timeoutSpinBox.setValue(settings.value(u'loop delay', QtCore.QVariant(5)).toInt()[0]) self.overrideCheckBox.setChecked(settings.value(u'override position', @@ -305,12 +303,15 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0]) self.startPausedCheckBox.setChecked(settings.value( u'audio start paused', QtCore.QVariant(True)).toBool()) + self.repeatListCheckBox.setChecked(settings.value( + u'audio repeat list', QtCore.QVariant(False)).toBool()) settings.endGroup() self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customHeightValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customWidthValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.display_changed = False + settings.beginGroup(self.settingsSection) def save(self): """ @@ -336,8 +337,6 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.autoUnblankCheckBox.isChecked())) settings.setValue(u'auto preview', QtCore.QVariant(self.autoPreviewCheckBox.isChecked())) - settings.setValue(u'enable slide loop', - QtCore.QVariant(self.enableLoopCheckBox.isChecked())) settings.setValue(u'loop delay', QtCore.QVariant(self.timeoutSpinBox.value())) settings.setValue(u'ccli number', @@ -358,6 +357,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.overrideCheckBox.isChecked())) settings.setValue(u'audio start paused', QtCore.QVariant(self.startPausedCheckBox.isChecked())) + settings.setValue(u'audio repeat list', + QtCore.QVariant(self.repeatListCheckBox.isChecked())) settings.endGroup() # On save update the screens as well self.postSetUp(True) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 328970d45..ef6ded3fa 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -28,13 +28,16 @@ The :mod:`maindisplay` module provides the functionality to display screens and play multimedia within OpenLP. """ +import cgi import logging +import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ - translate, PluginManager + translate, PluginManager, expand_tags +from openlp.core.lib.theme import BackgroundType from openlp.core.ui import HideMode, ScreenList, AlertLocation @@ -60,7 +63,12 @@ class Display(QtGui.QGraphicsView): self.controller = controller self.screen = {} self.plugins = PluginManager.get_instance().plugins - self.setViewport(QtOpenGL.QGLWidget()) + # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with + # OpenGL. Only white blank screen is shown on the 2nd monitor all the + # time. We need to investigate more how to use OpenGL properly on Mac OS + # X. + if sys.platform != 'darwin': + self.setViewport(QtOpenGL.QGLWidget()) def setup(self): """ @@ -74,6 +82,10 @@ class Display(QtGui.QGraphicsView): self.screen[u'size'].width(), self.screen[u'size'].height()) self.webView.settings().setAttribute( QtWebKit.QWebSettings.PluginsEnabled, True) + palette = self.webView.palette() + palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent) + self.webView.page().setPalette(palette) + self.webView.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False) self.page = self.webView.page() self.frame = self.page.mainFrame() if self.isLive and log.getEffectiveLevel() == logging.DEBUG: @@ -120,10 +132,19 @@ class MainDisplay(Display): self.audioPlayer = None self.firstTime = True self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') - self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | - QtCore.Qt.WindowStaysOnTopHint | - QtCore.Qt.X11BypassWindowManagerHint) + windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \ + QtCore.Qt.WindowStaysOnTopHint + if QtCore.QSettings().value(u'advanced/x11 bypass wm', + QtCore.QVariant(True)).toBool(): + windowFlags |= QtCore.Qt.X11BypassWindowManagerHint + # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen + # stay always on top on Mac OS X. For details see bug 906926. + # It needs more investigation to fix it properly. + if sys.platform == 'darwin': + windowFlags |= QtCore.Qt.SplashScreen + self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) + self.setTransparency(False) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) @@ -134,6 +155,14 @@ class MainDisplay(Display): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) + def setTransparency(self, enabled): + if enabled: + self.setAutoFillBackground(False) + else: + self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) + self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) + self.repaint() + def cssChanged(self): """ We may need to rebuild the CSS on the live display. @@ -222,16 +251,17 @@ class MainDisplay(Display): The text to be displayed. """ log.debug(u'alert to display') + # First we convert <>& marks to html variants, then apply + # formattingtags, finally we double all backslashes for JavaScript. + text_prepared = expand_tags(cgi.escape(text)) \ + .replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') if self.height() != self.screen[u'size'].height() or \ not self.isVisible(): shrink = True - js = u'show_alert("%s", "%s")' % ( - text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'), - u'top') + js = u'show_alert("%s", "%s")' % (text_prepared, u'top') else: shrink = False - js = u'show_alert("%s", "")' % ( - text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) + js = u'show_alert("%s", "")' % text_prepared height = self.frame.evaluateJavaScript(js) if shrink: if text: @@ -332,13 +362,7 @@ class MainDisplay(Display): self.setVisible(True) else: self.setVisible(True) - preview = QtGui.QPixmap(self.screen[u'size'].width(), - self.screen[u'size'].height()) - painter = QtGui.QPainter(preview) - painter.setRenderHint(QtGui.QPainter.Antialiasing) - self.frame.render(painter) - painter.end() - return preview + return QtGui.QPixmap.grabWidget(self) def buildHtml(self, serviceItem, image=None): """ @@ -364,6 +388,8 @@ class MainDisplay(Display): # replace the background background = self.imageManager. \ get_image_bytes(self.override[u'image']) + self.setTransparency(self.serviceItem.themedata.background_type == + BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) @@ -402,6 +428,11 @@ class MainDisplay(Display): Store the images so they can be replaced when required """ log.debug(u'hideDisplay mode = %d', mode) + if self.screens.display_count == 1: + # Only make visible if setting enabled + if not QtCore.QSettings().value(u'general/display on monitor', + QtCore.QVariant(True)).toBool(): + return if mode == HideMode.Screen: self.frame.evaluateJavaScript(u'show_blank("desktop");') self.setVisible(False) @@ -422,6 +453,11 @@ class MainDisplay(Display): Make the stored images None to release memory. """ log.debug(u'showDisplay') + if self.screens.display_count == 1: + # Only make visible if setting enabled + if not QtCore.QSettings().value(u'general/display on monitor', + QtCore.QVariant(True)).toBool(): + return self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): self.setVisible(True) @@ -459,11 +495,15 @@ class AudioPlayer(QtCore.QObject): QtCore.QObject.__init__(self, parent) self.currentIndex = -1 self.playlist = [] + self.repeat = False self.mediaObject = Phonon.MediaObject() + self.mediaObject.setTickInterval(100) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self.audioObject) QtCore.QObject.connect(self.mediaObject, QtCore.SIGNAL(u'aboutToFinish()'), self.onAboutToFinish) + QtCore.QObject.connect(self.mediaObject, + QtCore.SIGNAL(u'finished()'), self.onFinished) def __del__(self): """ @@ -482,6 +522,14 @@ class AudioPlayer(QtCore.QObject): if len(self.playlist) > self.currentIndex: self.mediaObject.enqueue(self.playlist[self.currentIndex]) + def onFinished(self): + if self.repeat: + log.debug(u'Repeat is enabled... here we go again!') + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex = -1 + self.play() + def connectVolumeSlider(self, slider): slider.setAudioOutput(self.audioObject) @@ -529,3 +577,27 @@ class AudioPlayer(QtCore.QObject): for filename in filenames: self.playlist.append(Phonon.MediaSource(filename)) + def next(self): + if not self.repeat and self.currentIndex + 1 == len(self.playlist): + return + isPlaying = self.mediaObject.state() == Phonon.PlayingState + self.currentIndex += 1 + if self.repeat and self.currentIndex == len(self.playlist): + self.currentIndex = 0 + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + if isPlaying: + self.mediaObject.play() + + def goTo(self, index): + isPlaying = self.mediaObject.state() == Phonon.PlayingState + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex = index + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + if isPlaying: + self.mediaObject.play() + + def connectSlot(self, signal, slot): + QtCore.QObject.connect(self.mediaObject, signal, slot) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 07c90e62f..947c1318d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -38,6 +38,7 @@ from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \ PluginManager, Receiver, translate, ImageManager, PluginStatus from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ icon_action, shortcut_action +from openlp.core.lib import SlideLimits from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm, FormattingTagForm @@ -1059,7 +1060,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): export_settings.endGroup() # Write all the sections and keys. for section_key in keys: - section, key = section_key.split(u'/') key_value = settings.value(section_key) export_settings.setValue(section_key, key_value) export_settings.sync() @@ -1307,6 +1307,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Load the main window settings. """ log.debug(u'Loading QSettings') + # Migrate Wrap Settings to Slide Limits Settings + if QtCore.QSettings().contains(self.generalSettingsSection + + u'/enable slide loop'): + if QtCore.QSettings().value(self.generalSettingsSection + + u'/enable slide loop', QtCore.QVariant(True)).toBool(): + QtCore.QSettings().setValue(self.advancedlSettingsSection + + u'/slide limits', QtCore.QVariant(SlideLimits.Wrap)) + else: + QtCore.QSettings().setValue(self.advancedlSettingsSection + + u'/slide limits', QtCore.QVariant(SlideLimits.End)) + QtCore.QSettings().remove(self.generalSettingsSection + + u'/enable slide loop') + Receiver.send_message(u'slidecontroller_update_slide_limits') settings = QtCore.QSettings() # Remove obsolete entries. settings.remove(u'custom slide') diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b58afeb1e..8a1a8e260 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -100,8 +100,7 @@ class MediaController(object): Register each media Player controller (Webkit, Phonon, etc) and store for later use """ - if controller.check_available(): - self.mediaPlayers[controller.name] = controller + self.mediaPlayers[controller.name] = controller def check_available_media_players(self): """ @@ -134,7 +133,8 @@ class MediaController(object): QtCore.QVariant(u'webkit')).toString()) savedPlayers = playerSettings.split(u',') invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ - if not mediaPlayer in self.mediaPlayers] + if not mediaPlayer in self.mediaPlayers or \ + not self.mediaPlayers[mediaPlayer].check_available()] if len(invalidMediaPlayers) > 0: for invalidPlayer in invalidMediaPlayers: savedPlayers.remove(invalidPlayer) @@ -219,6 +219,7 @@ class MediaController(object): # Build the seekSlider. controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) controller.seekSlider.setMaximum(1000) + controller.seekSlider.setTracking(False) controller.seekSlider.setToolTip(translate( 'OpenLP.SlideController', 'Video position.')) controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) @@ -231,6 +232,7 @@ class MediaController(object): controller.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove) controller.volumeSlider.setMinimum(0) controller.volumeSlider.setMaximum(100) + controller.volumeSlider.setTracking(True) controller.volumeSlider.setToolTip(translate( 'OpenLP.SlideController', 'Audio Volume.')) controller.volumeSlider.setValue(controller.media_info.volume) @@ -242,9 +244,9 @@ class MediaController(object): controller.mediabar.setVisible(False) # Signals QtCore.QObject.connect(controller.seekSlider, - QtCore.SIGNAL(u'sliderMoved(int)'), controller.sendToPlugins) + QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) QtCore.QObject.connect(controller.volumeSlider, - QtCore.SIGNAL(u'sliderMoved(int)'), controller.sendToPlugins) + QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) def setup_special_controls(self, controller, control_panel): """ @@ -276,6 +278,10 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) + if controller.isLive and controller.display: + if self.curDisplayMediaPlayer and value: + if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: + controller.display.setTransparency(False) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO @@ -316,7 +322,8 @@ class MediaController(object): controller.media_info.start_time = 0 controller.media_info.end_time = 0 else: - controller.media_info.start_time = display.serviceItem.start_time + controller.media_info.start_time = \ + display.serviceItem.start_time controller.media_info.end_time = display.serviceItem.end_time elif controller.previewDisplay: display = controller.previewDisplay @@ -478,6 +485,7 @@ class MediaController(object): Responds to the request to reset a loaded video """ log.debug(u'video_reset') + self.set_controls_visible(controller, False) for display in self.curDisplayMediaPlayer.keys(): if display.controller == controller: display.override = {} @@ -486,7 +494,6 @@ class MediaController(object): display.frame.evaluateJavaScript(u'show_video( \ "setBackBoard", null, null, null,"hidden");') del self.curDisplayMediaPlayer[display] - self.set_controls_visible(controller, False) def video_hide(self, msg): """ diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5203c5960..5a9a5f67d 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -51,6 +51,7 @@ ADDITIONAL_EXT = { u'video/x-matroska': [u'.mpv', u'.mkv'], u'video/x-wmv': [u'.wmv'], u'video/x-mpg': [u'.mpg'], + u'video/mpeg' : [u'.mp4', u'.mts'], u'video/x-ms-wmv': [u'.wmv']} @@ -153,7 +154,7 @@ class PhononPlayer(MediaPlayer): int(display.mediaObject.totalTime()/1000) controller.seekSlider.setMaximum(controller.media_info.length*1000) self.state = MediaState.Playing - display.phononWidget.raise_() + display.phononWidget.raise_() return True else: return False diff --git a/openlp/core/ui/media/vlc.py b/openlp/core/ui/media/vlc.py new file mode 100644 index 000000000..720e27826 --- /dev/null +++ b/openlp/core/ui/media/vlc.py @@ -0,0 +1,6274 @@ +#! /usr/bin/python + +# Python ctypes bindings for VLC +# +# Copyright (C) 2009-2010 the VideoLAN team +# $Id: $ +# +# Authors: Olivier Aubert +# Jean Brouwers +# +# 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; either version 2 of the License, or +# (at your option) any later version. +# +# 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + +"""This module provides bindings for the LibVLC public API, see +U{http://wiki.videolan.org/LibVLC}. + +You can find the documentation and a README file with some examples +at U{http://www.advene.org/download/python-ctypes/}. + +Basically, the most important class is L{Instance}, which is used +to create a libvlc instance. From this instance, you then create +L{MediaPlayer} and L{MediaListPlayer} instances. + +Alternatively, you may create instances of the L{MediaPlayer} and +L{MediaListPlayer} class directly and an instance of L{Instance} +will be implicitly created. The latter can be obtained using the +C{get_instance} method of L{MediaPlayer} and L{MediaListPlayer}. +""" + +import ctypes +from ctypes.util import find_library +import os +import sys + +# Used by EventManager in override.py +from inspect import getargspec + +__version__ = "N/A" +build_date = "Tue Sep 13 17:50:18 2011" + +# Internal guard to prevent internal classes to be directly +# instanciated. +_internal_guard = object() + +def find_lib(): + dll = None + plugin_path = None + if sys.platform.startswith('linux') or sys.platform.startswith('freeBSD'): + p = find_library('vlc') + try: + dll = ctypes.CDLL(p) + except OSError: # may fail + dll = ctypes.CDLL('libvlc.so.5') + elif sys.platform.startswith('win'): + p = find_library('libvlc.dll') + if p is None: + try: # some registry settings + import _winreg as w # leaner than win32api, win32con + for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: + try: + r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') + plugin_path, _ = w.QueryValueEx(r, 'InstallDir') + w.CloseKey(r) + break + except w.error: + pass + except ImportError: # no PyWin32 + pass + if plugin_path is None: + # try some standard locations. + for p in ('Program Files\\VideoLan\\', 'VideoLan\\', + 'Program Files\\', ''): + p = 'C:\\' + p + 'VLC\\libvlc.dll' + if os.path.exists(p): + plugin_path = os.path.dirname(p) + break + if plugin_path is not None: # try loading + p = os.getcwd() + os.chdir(plugin_path) + # if chdir failed, this will raise an exception + dll = ctypes.CDLL('libvlc.dll') + # restore cwd after dll has been loaded + os.chdir(p) + else: # may fail + dll = ctypes.CDLL('libvlc.dll') + else: + plugin_path = os.path.dirname(p) + dll = ctypes.CDLL(p) + + elif sys.platform.startswith('darwin'): + # FIXME: should find a means to configure path + d = '/Applications/VLC.app/Contents/MacOS/' + p = d + 'lib/libvlc.dylib' + if os.path.exists(p): + dll = ctypes.CDLL(p) + d += 'modules' + if os.path.isdir(d): + plugin_path = d + else: # hope, some PATH is set... + dll = ctypes.CDLL('libvlc.dylib') + + else: + raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform)) + + return (dll, plugin_path) + +# plugin_path used on win32 and MacOS in override.py +dll, plugin_path = find_lib() + +class VLCException(Exception): + """Exception raised by libvlc methods. + """ + pass + +try: + _Ints = (int, long) +except NameError: # no long in Python 3+ + _Ints = int + +# Default instance. It is used to instanciate classes directly in the +# OO-wrapper. +_default_instance = None + +def get_default_instance(): + """Return the default VLC.Instance. + """ + global _default_instance + if _default_instance is None: + _default_instance = Instance() + return _default_instance + +_Seqs = (list, tuple) + +_Cfunctions = {} # from LibVLC __version__ + +def _Cfunction(name, flags, errcheck, *types): + """(INTERNAL) New ctypes function binding. + """ + if hasattr(dll, name): + p = ctypes.CFUNCTYPE(*types) + f = p((name, dll), flags) + if errcheck is not None: + f.errcheck = errcheck + _Cfunctions[name] = f + return f + raise NameError('no function %r' % (name,)) + +def _Cobject(cls, ctype): + """(INTERNAL) New instance from ctypes. + """ + o = object.__new__(cls) + o._as_parameter_ = ctype + return o + +def _Constructor(cls, ptr=_internal_guard): + """(INTERNAL) New wrapper from ctypes. + """ + if ptr == _internal_guard: + raise VLCException("(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.") + if ptr is None or ptr == 0: + return None + return _Cobject(cls, ctypes.c_void_p(ptr)) + +class _Ctype(object): + """(INTERNAL) Base class for ctypes. + """ + @staticmethod + def from_param(this): # not self + """(INTERNAL) ctypes parameter conversion method. + """ + if this is None: + return None + return this._as_parameter_ + +class ListPOINTER(object): + """Just like a POINTER but accept a list of ctype as an argument. + """ + def __init__(self, etype): + self.etype = etype + + def from_param(self, param): + if isinstance(param, _Seqs): + return (self.etype * len(param))(*param) + +# errcheck functions for some native functions. +def string_result(result, func, arguments): + """Errcheck function. Returns a string and frees the original pointer. + + It assumes the result is a char *. + """ + if result: + # make a python string copy + s = ctypes.string_at(result) + # free original string ptr + libvlc_free(result) + return s + return None + +def class_result(classname): + """Errcheck function. Returns a function that creates the specified class. + """ + def wrap_errcheck(result, func, arguments): + if result is None: + return None + return classname(result) + return wrap_errcheck + + # Generated enum types # + +class _Enum(ctypes.c_uint): + '''(INTERNAL) Base class + ''' + _enum_names_ = {} + + def __str__(self): + n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,)) + return '.'.join((self.__class__.__name__, n)) + + def __repr__(self): + return '.'.join((self.__class__.__module__, self.__str__())) + + def __eq__(self, other): + return ( (isinstance(other, _Enum) and self.value == other.value) + or (isinstance(other, _Ints) and self.value == other) ) + + def __ne__(self, other): + return not self.__eq__(other) + +class EventType(_Enum): + '''Event types. + ''' + _enum_names_ = { + 0: 'MediaMetaChanged', + 1: 'MediaSubItemAdded', + 2: 'MediaDurationChanged', + 3: 'MediaParsedChanged', + 4: 'MediaFreed', + 5: 'MediaStateChanged', + 0x100: 'MediaPlayerMediaChanged', + 257: 'MediaPlayerNothingSpecial', + 258: 'MediaPlayerOpening', + 259: 'MediaPlayerBuffering', + 260: 'MediaPlayerPlaying', + 261: 'MediaPlayerPaused', + 262: 'MediaPlayerStopped', + 263: 'MediaPlayerForward', + 264: 'MediaPlayerBackward', + 265: 'MediaPlayerEndReached', + 266: 'MediaPlayerEncounteredError', + 267: 'MediaPlayerTimeChanged', + 268: 'MediaPlayerPositionChanged', + 269: 'MediaPlayerSeekableChanged', + 270: 'MediaPlayerPausableChanged', + 271: 'MediaPlayerTitleChanged', + 272: 'MediaPlayerSnapshotTaken', + 273: 'MediaPlayerLengthChanged', + 0x200: 'MediaListItemAdded', + 513: 'MediaListWillAddItem', + 514: 'MediaListItemDeleted', + 515: 'MediaListWillDeleteItem', + 0x300: 'MediaListViewItemAdded', + 769: 'MediaListViewWillAddItem', + 770: 'MediaListViewItemDeleted', + 771: 'MediaListViewWillDeleteItem', + 0x400: 'MediaListPlayerPlayed', + 1025: 'MediaListPlayerNextItemSet', + 1026: 'MediaListPlayerStopped', + 0x500: 'MediaDiscovererStarted', + 1281: 'MediaDiscovererEnded', + 0x600: 'VlmMediaAdded', + 1537: 'VlmMediaRemoved', + 1538: 'VlmMediaChanged', + 1539: 'VlmMediaInstanceStarted', + 1540: 'VlmMediaInstanceStopped', + 1541: 'VlmMediaInstanceStatusInit', + 1542: 'VlmMediaInstanceStatusOpening', + 1543: 'VlmMediaInstanceStatusPlaying', + 1544: 'VlmMediaInstanceStatusPause', + 1545: 'VlmMediaInstanceStatusEnd', + 1546: 'VlmMediaInstanceStatusError', + } +EventType.MediaDiscovererEnded = EventType(1281) +EventType.MediaDiscovererStarted = EventType(0x500) +EventType.MediaDurationChanged = EventType(2) +EventType.MediaFreed = EventType(4) +EventType.MediaListItemAdded = EventType(0x200) +EventType.MediaListItemDeleted = EventType(514) +EventType.MediaListPlayerNextItemSet = EventType(1025) +EventType.MediaListPlayerPlayed = EventType(0x400) +EventType.MediaListPlayerStopped = EventType(1026) +EventType.MediaListViewItemAdded = EventType(0x300) +EventType.MediaListViewItemDeleted = EventType(770) +EventType.MediaListViewWillAddItem = EventType(769) +EventType.MediaListViewWillDeleteItem = EventType(771) +EventType.MediaListWillAddItem = EventType(513) +EventType.MediaListWillDeleteItem = EventType(515) +EventType.MediaMetaChanged = EventType(0) +EventType.MediaParsedChanged = EventType(3) +EventType.MediaPlayerBackward = EventType(264) +EventType.MediaPlayerBuffering = EventType(259) +EventType.MediaPlayerEncounteredError = EventType(266) +EventType.MediaPlayerEndReached = EventType(265) +EventType.MediaPlayerForward = EventType(263) +EventType.MediaPlayerLengthChanged = EventType(273) +EventType.MediaPlayerMediaChanged = EventType(0x100) +EventType.MediaPlayerNothingSpecial = EventType(257) +EventType.MediaPlayerOpening = EventType(258) +EventType.MediaPlayerPausableChanged = EventType(270) +EventType.MediaPlayerPaused = EventType(261) +EventType.MediaPlayerPlaying = EventType(260) +EventType.MediaPlayerPositionChanged = EventType(268) +EventType.MediaPlayerSeekableChanged = EventType(269) +EventType.MediaPlayerSnapshotTaken = EventType(272) +EventType.MediaPlayerStopped = EventType(262) +EventType.MediaPlayerTimeChanged = EventType(267) +EventType.MediaPlayerTitleChanged = EventType(271) +EventType.MediaStateChanged = EventType(5) +EventType.MediaSubItemAdded = EventType(1) +EventType.VlmMediaAdded = EventType(0x600) +EventType.VlmMediaChanged = EventType(1538) +EventType.VlmMediaInstanceStarted = EventType(1539) +EventType.VlmMediaInstanceStatusEnd = EventType(1545) +EventType.VlmMediaInstanceStatusError = EventType(1546) +EventType.VlmMediaInstanceStatusInit = EventType(1541) +EventType.VlmMediaInstanceStatusOpening = EventType(1542) +EventType.VlmMediaInstanceStatusPause = EventType(1544) +EventType.VlmMediaInstanceStatusPlaying = EventType(1543) +EventType.VlmMediaInstanceStopped = EventType(1540) +EventType.VlmMediaRemoved = EventType(1537) + +class Meta(_Enum): + '''Meta data types. + ''' + _enum_names_ = { + 0: 'Title', + 1: 'Artist', + 2: 'Genre', + 3: 'Copyright', + 4: 'Album', + 5: 'TrackNumber', + 6: 'Description', + 7: 'Rating', + 8: 'Date', + 9: 'Setting', + 10: 'URL', + 11: 'Language', + 12: 'NowPlaying', + 13: 'Publisher', + 14: 'EncodedBy', + 15: 'ArtworkURL', + 16: 'TrackID', + } +Meta.Album = Meta(4) +Meta.Artist = Meta(1) +Meta.ArtworkURL = Meta(15) +Meta.Copyright = Meta(3) +Meta.Date = Meta(8) +Meta.Description = Meta(6) +Meta.EncodedBy = Meta(14) +Meta.Genre = Meta(2) +Meta.Language = Meta(11) +Meta.NowPlaying = Meta(12) +Meta.Publisher = Meta(13) +Meta.Rating = Meta(7) +Meta.Setting = Meta(9) +Meta.Title = Meta(0) +Meta.TrackID = Meta(16) +Meta.TrackNumber = Meta(5) +Meta.URL = Meta(10) + +class State(_Enum): + '''Note the order of libvlc_state_t enum must match exactly the order of +See mediacontrol_playerstatus, See input_state_e enums, +and videolan.libvlc.state (at bindings/cil/src/media.cs). +expected states by web plugins are: +idle/close=0, opening=1, buffering=2, playing=3, paused=4, +stopping=5, ended=6, error=7. + ''' + _enum_names_ = { + 0: 'NothingSpecial', + 1: 'Opening', + 2: 'Buffering', + 3: 'Playing', + 4: 'Paused', + 5: 'Stopped', + 6: 'Ended', + 7: 'Error', + } +State.Buffering = State(2) +State.Ended = State(6) +State.Error = State(7) +State.NothingSpecial = State(0) +State.Opening = State(1) +State.Paused = State(4) +State.Playing = State(3) +State.Stopped = State(5) + +class TrackType(_Enum): + '''N/A + ''' + _enum_names_ = { + -1: 'unknown', + 0: 'audio', + 1: 'video', + 2: 'text', + } +TrackType.audio = TrackType(0) +TrackType.text = TrackType(2) +TrackType.unknown = TrackType(-1) +TrackType.video = TrackType(1) + +class PlaybackMode(_Enum): + '''Defines playback modes for playlist. + ''' + _enum_names_ = { + 0: 'default', + 1: 'loop', + 2: 'repeat', + } +PlaybackMode.default = PlaybackMode(0) +PlaybackMode.loop = PlaybackMode(1) +PlaybackMode.repeat = PlaybackMode(2) + +class VideoMarqueeOption(_Enum): + '''Marq options definition. + ''' + _enum_names_ = { + 0: 'Enable', + 1: 'Text', + 2: 'Color', + 3: 'Opacity', + 4: 'Position', + 5: 'Refresh', + 6: 'Size', + 7: 'Timeout', + 8: 'marquee_X', + 9: 'marquee_Y', + } +VideoMarqueeOption.Color = VideoMarqueeOption(2) +VideoMarqueeOption.Enable = VideoMarqueeOption(0) +VideoMarqueeOption.Opacity = VideoMarqueeOption(3) +VideoMarqueeOption.Position = VideoMarqueeOption(4) +VideoMarqueeOption.Refresh = VideoMarqueeOption(5) +VideoMarqueeOption.Size = VideoMarqueeOption(6) +VideoMarqueeOption.Text = VideoMarqueeOption(1) +VideoMarqueeOption.Timeout = VideoMarqueeOption(7) +VideoMarqueeOption.marquee_X = VideoMarqueeOption(8) +VideoMarqueeOption.marquee_Y = VideoMarqueeOption(9) + +class NavigateMode(_Enum): + '''Navigation mode. + ''' + _enum_names_ = { + 0: 'activate', + 1: 'up', + 2: 'down', + 3: 'left', + 4: 'right', + } +NavigateMode.activate = NavigateMode(0) +NavigateMode.down = NavigateMode(2) +NavigateMode.left = NavigateMode(3) +NavigateMode.right = NavigateMode(4) +NavigateMode.up = NavigateMode(1) + +class VideoLogoOption(_Enum): + '''Option values for libvlc_video_{get,set}_logo_{int,string}. + ''' + _enum_names_ = { + 0: 'enable', + 1: 'file', + 2: 'logo_x', + 3: 'logo_y', + 4: 'delay', + 5: 'repeat', + 6: 'opacity', + 7: 'position', + } +VideoLogoOption.delay = VideoLogoOption(4) +VideoLogoOption.enable = VideoLogoOption(0) +VideoLogoOption.file = VideoLogoOption(1) +VideoLogoOption.logo_x = VideoLogoOption(2) +VideoLogoOption.logo_y = VideoLogoOption(3) +VideoLogoOption.opacity = VideoLogoOption(6) +VideoLogoOption.position = VideoLogoOption(7) +VideoLogoOption.repeat = VideoLogoOption(5) + +class VideoAdjustOption(_Enum): + '''Option values for libvlc_video_{get,set}_adjust_{int,float,bool}. + ''' + _enum_names_ = { + 0: 'Enable', + 1: 'Contrast', + 2: 'Brightness', + 3: 'Hue', + 4: 'Saturation', + 5: 'Gamma', + } +VideoAdjustOption.Brightness = VideoAdjustOption(2) +VideoAdjustOption.Contrast = VideoAdjustOption(1) +VideoAdjustOption.Enable = VideoAdjustOption(0) +VideoAdjustOption.Gamma = VideoAdjustOption(5) +VideoAdjustOption.Hue = VideoAdjustOption(3) +VideoAdjustOption.Saturation = VideoAdjustOption(4) + +class AudioOutputDeviceTypes(_Enum): + '''Audio device types. + ''' + _enum_names_ = { + -1: 'Error', + 1: 'Mono', + 2: 'Stereo', + 4: '_2F2R', + 5: '_3F2R', + 6: '_5_1', + 7: '_6_1', + 8: '_7_1', + 10: 'SPDIF', + } +AudioOutputDeviceTypes.Error = AudioOutputDeviceTypes(-1) +AudioOutputDeviceTypes.Mono = AudioOutputDeviceTypes(1) +AudioOutputDeviceTypes.SPDIF = AudioOutputDeviceTypes(10) +AudioOutputDeviceTypes.Stereo = AudioOutputDeviceTypes(2) +AudioOutputDeviceTypes._2F2R = AudioOutputDeviceTypes(4) +AudioOutputDeviceTypes._3F2R = AudioOutputDeviceTypes(5) +AudioOutputDeviceTypes._5_1 = AudioOutputDeviceTypes(6) +AudioOutputDeviceTypes._6_1 = AudioOutputDeviceTypes(7) +AudioOutputDeviceTypes._7_1 = AudioOutputDeviceTypes(8) + +class AudioOutputChannel(_Enum): + '''Audio channels. + ''' + _enum_names_ = { + -1: 'Error', + 1: 'Stereo', + 2: 'RStereo', + 3: 'Left', + 4: 'Right', + 5: 'Dolbys', + } +AudioOutputChannel.Dolbys = AudioOutputChannel(5) +AudioOutputChannel.Error = AudioOutputChannel(-1) +AudioOutputChannel.Left = AudioOutputChannel(3) +AudioOutputChannel.RStereo = AudioOutputChannel(2) +AudioOutputChannel.Right = AudioOutputChannel(4) +AudioOutputChannel.Stereo = AudioOutputChannel(1) + + # End of generated enum types # + + # From libvlc_structures.h + +class AudioOutput(ctypes.Structure): + + def __str__(self): + return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.description) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +AudioOutput._fields_ = [ # recursive struct + ('name', ctypes.c_char_p), + ('description', ctypes.c_char_p), + ('next', ctypes.POINTER(AudioOutput)), + ] + +class LogMessage(ctypes.Structure): + _fields_ = [ + ('size', ctypes.c_uint ), + ('severity', ctypes.c_int ), + ('type', ctypes.c_char_p), + ('name', ctypes.c_char_p), + ('header', ctypes.c_char_p), + ('message', ctypes.c_char_p), + ] + + def __init__(self): + super(LogMessage, self).__init__() + self.size = ctypes.sizeof(self) + + def __str__(self): + return '%s(%d:%s): %s' % (self.__class__.__name__, self.severity, self.type, self.message) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +class MediaEvent(ctypes.Structure): + _fields_ = [ + ('media_name', ctypes.c_char_p), + ('instance_name', ctypes.c_char_p), + ] + +class MediaStats(ctypes.Structure): + _fields_ = [ + ('read_bytes', ctypes.c_int ), + ('input_bitrate', ctypes.c_float), + ('demux_read_bytes', ctypes.c_int ), + ('demux_bitrate', ctypes.c_float), + ('demux_corrupted', ctypes.c_int ), + ('demux_discontinuity', ctypes.c_int ), + ('decoded_video', ctypes.c_int ), + ('decoded_audio', ctypes.c_int ), + ('displayed_pictures', ctypes.c_int ), + ('lost_pictures', ctypes.c_int ), + ('played_abuffers', ctypes.c_int ), + ('lost_abuffers', ctypes.c_int ), + ('sent_packets', ctypes.c_int ), + ('sent_bytes', ctypes.c_int ), + ('send_bitrate', ctypes.c_float), + ] + + def __str__(self): + l = [' %s:\t%s' % (n, getattr(self, n)) for n, t in self._fields_] + return '\n'.join([self.__class__.__name__] + l) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +class MediaTrackInfo(ctypes.Structure): + _fields_ = [ + ('codec', ctypes.c_uint32), + ('id', ctypes.c_int ), + ('type', TrackType ), + ('profile', ctypes.c_int ), + ('level', ctypes.c_int ), + ('channels_or_height', ctypes.c_uint ), + ('rate_or_width', ctypes.c_uint ), + ] + + def __str__(self): + l = [" %s:\t%s" % (n, getattr(self, n)) for n, t in self._fields_] + return "\n".join([self.__class__.__name__] + l) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +class PlaylistItem(ctypes.Structure): + _fields_ = [ + ('id', ctypes.c_int ), + ('uri', ctypes.c_char_p), + ('name', ctypes.c_char_p), + ] + + def __str__(self): + return '%s #%d %s (uri %s)' % (self.__class__.__name__, self.id, self.name, self.uri) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +class Position(object): + """Enum-like, immutable window position constants. + + See e.g. VideoMarqueeOption.Position. + """ + Center = 0 + Left = 1 + CenterLeft = 1 + Right = 2 + CenterRight = 2 + Top = 4 + TopCenter = 4 + TopLeft = 5 + TopRight = 6 + Bottom = 8 + BottomCenter = 8 + BottomLeft = 9 + BottomRight = 10 + def __init__(self, *unused): + raise TypeError('constants only') + def __setattr__(self, *unused): #PYCHOK expected + raise TypeError('immutable constants') + +class Rectangle(ctypes.Structure): + _fields_ = [ + ('top', ctypes.c_int), + ('left', ctypes.c_int), + ('bottom', ctypes.c_int), + ('right', ctypes.c_int), + ] + +class TrackDescription(ctypes.Structure): + + def __str__(self): + return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self.__str__()) + +TrackDescription._fields_ = [ # recursive struct + ('id', ctypes.c_int ), + ('name', ctypes.c_char_p), + ('next', ctypes.POINTER(TrackDescription)), + ] + +def track_description_list(head): + """Convert a TrackDescription linked list to a Python list (and release the former). + """ + r = [] + if head: + item = head + while item: + item = item.contents + r.append((item.id, item.name)) + item = item.next + libvlc_track_description_release(head) + return r + +class EventUnion(ctypes.Union): + _fields_ = [ + ('meta_type', ctypes.c_uint ), + ('new_child', ctypes.c_uint ), + ('new_duration', ctypes.c_longlong), + ('new_status', ctypes.c_int ), + ('media', ctypes.c_void_p ), + ('new_state', ctypes.c_uint ), + # Media instance + ('new_position', ctypes.c_float ), + ('new_time', ctypes.c_longlong), + ('new_title', ctypes.c_int ), + ('new_seekable', ctypes.c_longlong), + ('new_pausable', ctypes.c_longlong), + # FIXME: Skipped MediaList and MediaListView... + ('filename', ctypes.c_char_p ), + ('new_length', ctypes.c_longlong), + ('media_event', MediaEvent ), + ] + +class Event(ctypes.Structure): + _fields_ = [ + ('type', EventType ), + ('object', ctypes.c_void_p), + ('u', EventUnion ), + ] + +class ModuleDescription(ctypes.Structure): + def __str__(self): + return '%s %s (%s)' % (self.__class__.__name__, self.shortname, self.name) + +ModuleDescription._fields_ = [ # recursive struct + ('name', ctypes.c_char_p), + ('shortname', ctypes.c_char_p), + ('longname', ctypes.c_char_p), + ('help', ctypes.c_char_p), + ('next', ctypes.POINTER(ModuleDescription)), + ] + +def module_description_list(head): + """Convert a ModuleDescription linked list to a Python list (and release the former). + """ + r = [] + if head: + item = head + while item: + item = item.contents + r.append((item.name, item.shortname, item.longname, item.help)) + item = item.next + libvlc_module_description_list_release(head) + return r + + # End of header.py # + +class EventManager(_Ctype): + '''Create an event manager with callback handler. + + This class interposes the registration and handling of + event notifications in order to (a) remove the need for + decorating each callback functions with the decorator + '@callbackmethod', (b) allow any number of positional + and/or keyword arguments to the callback (in addition + to the Event instance) and (c) to preserve the Python + objects such that the callback and argument objects + remain alive (i.e. are not garbage collected) until + B{after} the notification has been unregistered. + + @note: Only a single notification can be registered + for each event type in an EventManager instance. + + ''' + + _callback_handler = None + _callbacks = {} + + def __new__(cls, ptr=_internal_guard): + if ptr == _internal_guard: + raise VLCException("(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.") + return _Constructor(cls, ptr) + + def event_attach(self, eventtype, callback, *args, **kwds): + """Register an event notification. + + @param eventtype: the desired event type to be notified about. + @param callback: the function to call when the event occurs. + @param args: optional positional arguments for the callback. + @param kwds: optional keyword arguments for the callback. + @return: 0 on success, ENOMEM on error. + + @note: The callback function must have at least one argument, + an Event instance. Any other, optional positional and keyword + arguments are in B{addition} to the first one. + """ + if not isinstance(eventtype, EventType): + raise VLCException("%s required: %r" % ('EventType', eventtype)) + if not hasattr(callback, '__call__'): # callable() + raise VLCException("%s required: %r" % ('callable', callback)) + # check that the callback expects arguments + if not any(getargspec(callback)[:2]): # list(...) + raise VLCException("%s required: %r" % ('argument', callback)) + + if self._callback_handler is None: + _called_from_ctypes = ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p) + @_called_from_ctypes + def _callback_handler(event, k): + """(INTERNAL) handle callback call from ctypes. + + @note: We cannot simply make this an EventManager + method since ctypes does not prepend self as the + first parameter, hence this closure. + """ + try: # retrieve Python callback and arguments + call, args, kwds = self._callbacks[k] + # deref event.contents to simplify callback code + call(event.contents, *args, **kwds) + except KeyError: # detached? + pass + self._callback_handler = _callback_handler + self._callbacks = {} + + k = eventtype.value + r = libvlc_event_attach(self, k, self._callback_handler, k) + if not r: + self._callbacks[k] = (callback, args, kwds) + return r + + def event_detach(self, eventtype): + """Unregister an event notification. + + @param eventtype: the event type notification to be removed. + """ + if not isinstance(eventtype, EventType): + raise VLCException("%s required: %r" % ('EventType', eventtype)) + + k = eventtype.value + if k in self._callbacks: + del self._callbacks[k] # remove, regardless of libvlc return value + libvlc_event_detach(self, k, self._callback_handler, k) + +class Instance(_Ctype): + '''Create a new Instance instance. + + It may take as parameter either: + - a string + - a list of strings as first parameters + - the parameters given as the constructor parameters (must be strings) + + ''' + + def __new__(cls, *args): + if len(args) == 1: + # Only 1 arg. It is either a C pointer, or an arg string, + # or a tuple. + i = args[0] + if isinstance(i, _Ints): + return _Constructor(cls, i) + elif isinstance(i, basestring): + args = i.strip().split() + elif isinstance(i, _Seqs): + args = i + else: + raise VLCException('Instance %r' % (args,)) + + if not args and plugin_path is not None: + # no parameters passed, for win32 and MacOS, + # specify the plugin_path if detected earlier + args = ['vlc', '--plugin-path=' + plugin_path] + return libvlc_new(len(args), args) + + def media_player_new(self, uri=None): + """Create a new MediaPlayer instance. + + @param uri: an optional URI to play in the player. + """ + p = libvlc_media_player_new(self) + if uri: + p.set_media(self.media_new(uri)) + p._instance = self + return p + + def media_list_player_new(self): + """Create a new MediaListPlayer instance. + """ + p = libvlc_media_list_player_new(self) + p._instance = self + return p + + def media_new(self, mrl, *options): + """Create a new Media instance. + + Options can be specified as supplementary string parameters, e.g. + + C{m = i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}', 'vout-filter=invert')} + + Alternatively, the options can be added to the media using the Media.add_options method: + + C{m.add_options('foo.avi', 'sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} + + @param options: optional media option=value strings + """ + m = libvlc_media_new_location(self, mrl) + for o in options: + libvlc_media_add_option(m, o) + m._instance = self + return m + + def media_list_new(self, mrls=None): + """Create a new MediaList instance. + @param mrls: optional list of MRL strings + """ + l = libvlc_media_list_new(self) + # We should take the lock, but since we did not leak the + # reference, nobody else can access it. + if mrls: + for m in mrls: + l.add_media(m) + l._instance = self + return l + + def audio_output_enumerate_devices(self): + """Enumerate the defined audio output devices. + + @return: list of dicts {name:, description:, devices:} + """ + r = [] + head = libvlc_audio_output_list_get(self) + if head: + i = head + while i: + i = i.contents + d = [{'id': libvlc_audio_output_device_id (self, i.name, d), + 'longname': libvlc_audio_output_device_longname(self, i.name, d)} + for d in range(libvlc_audio_output_device_count (self, i.name))] + r.append({'name': i.name, 'description': i.description, 'devices': d}) + i = i.next + libvlc_audio_output_list_release(head) + return r + + def audio_filter_list_get(self): + """Returns a list of available audio filters. + + """ + return module_description_list(libvlc_audio_filter_list_get(self)) + + def video_filter_list_get(self): + """Returns a list of available video filters. + + """ + return module_description_list(libvlc_video_filter_list_get(self)) + + + def release(self): + '''Decrement the reference count of a libvlc instance, and destroy it + if it reaches zero. + ''' + return libvlc_release(self) + + def retain(self): + '''Increments the reference count of a libvlc instance. + The initial reference count is 1 after L{new}() returns. + ''' + return libvlc_retain(self) + + def add_intf(self, name): + '''Try to start a user interface for the libvlc instance. + @param name: interface name, or NULL for default. + @return: 0 on success, -1 on error. + ''' + return libvlc_add_intf(self, name) + + def wait(self): + '''Waits until an interface causes the instance to exit. + You should start at least one interface first, using L{add_intf}(). + ''' + return libvlc_wait(self) + + def set_user_agent(self, name, http): + '''Sets the application name. LibVLC passes this as the user agent string + when a protocol requires it. + @param name: human-readable application name, e.g. "FooBar player 1.2.3". + @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0". + @version: LibVLC 1.1.1 or later. + ''' + return libvlc_set_user_agent(self, name, http) + + def get_log_verbosity(self): + '''Always returns minus one. + This function is only provided for backward compatibility. + @return: always -1. + ''' + return libvlc_get_log_verbosity(self) + + def set_log_verbosity(self, level): + '''This function does nothing. + It is only provided for backward compatibility. + @param level: ignored. + ''' + return libvlc_set_log_verbosity(self, level) + + def log_open(self): + '''This function does nothing useful. + It is only provided for backward compatibility. + @return: an unique pointer or NULL on error. + ''' + return libvlc_log_open(self) + + def media_new_location(self, psz_mrl): + '''Create a media with a certain given media resource location, + for instance a valid URL. + @note: To refer to a local file with this function, + the file://... URI syntax B{must} be used (see IETF RFC3986). + We recommend using L{media_new_path}() instead when dealing with + local files. + See L{media_release}. + @param psz_mrl: the media location. + @return: the newly created media or NULL on error. + ''' + return libvlc_media_new_location(self, psz_mrl) + + def media_new_path(self, path): + '''Create a media for a certain file path. + See L{media_release}. + @param path: local filesystem path. + @return: the newly created media or NULL on error. + ''' + return libvlc_media_new_path(self, path) + + def media_new_fd(self, fd): + '''Create a media for an already open file descriptor. + The file descriptor shall be open for reading (or reading and writing). + Regular file descriptors, pipe read descriptors and character device + descriptors (including TTYs) are supported on all platforms. + Block device descriptors are supported where available. + Directory descriptors are supported on systems that provide fdopendir(). + Sockets are supported on all platforms where they are file descriptors, + i.e. all except Windows. + @note: This library will B{not} automatically close the file descriptor + under any circumstance. Nevertheless, a file descriptor can usually only be + rendered once in a media player. To render it a second time, the file + descriptor should probably be rewound to the beginning with lseek(). + See L{media_release}. + @param fd: open file descriptor. + @return: the newly created media or NULL on error. + @version: LibVLC 1.1.5 and later. + ''' + return libvlc_media_new_fd(self, fd) + + def media_new_as_node(self, psz_name): + '''Create a media as an empty node with a given name. + See L{media_release}. + @param psz_name: the name of the node. + @return: the new empty media or NULL on error. + ''' + return libvlc_media_new_as_node(self, psz_name) + + def media_discoverer_new_from_name(self, psz_name): + '''Discover media service by name. + @param psz_name: service name. + @return: media discover object or NULL in case of error. + ''' + return libvlc_media_discoverer_new_from_name(self, psz_name) + + def media_library_new(self): + '''Create an new Media Library object. + @return: a new object or NULL on error. + ''' + return libvlc_media_library_new(self) + + def audio_output_list_get(self): + '''Get the list of available audio outputs. + @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. + ''' + return libvlc_audio_output_list_get(self) + + def audio_output_device_count(self, psz_audio_output): + '''Get count of devices for audio output, these devices are hardware oriented + like analor or digital output of sound card. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @return: number of devices. + ''' + return libvlc_audio_output_device_count(self, psz_audio_output) + + def audio_output_device_longname(self, psz_audio_output, i_device): + '''Get long name of device, if not available short name given. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param i_device: device index. + @return: long name of device. + ''' + return libvlc_audio_output_device_longname(self, psz_audio_output, i_device) + + def audio_output_device_id(self, psz_audio_output, i_device): + '''Get id name of device. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param i_device: device index. + @return: id name of device, use for setting device, need to be free after use. + ''' + return libvlc_audio_output_device_id(self, psz_audio_output, i_device) + + def vlm_release(self): + '''Release the vlm instance related to the given L{Instance}. + ''' + return libvlc_vlm_release(self) + + def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): + '''Add a broadcast, with one input. + @param psz_name: the name of the new broadcast. + @param psz_input: the input MRL. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new broadcast. + @param b_loop: Should this broadcast be played in loop ? + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) + + def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux): + '''Add a vod, with one input. + @param psz_name: the name of the new vod media. + @param psz_input: the input MRL. + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new vod. + @param psz_mux: the muxer of the vod media. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux) + + def vlm_del_media(self, psz_name): + '''Delete a media (VOD or broadcast). + @param psz_name: the media to delete. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_del_media(self, psz_name) + + def vlm_set_enabled(self, psz_name, b_enabled): + '''Enable or disable a media (VOD or broadcast). + @param psz_name: the media to work on. + @param b_enabled: the new status. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_set_enabled(self, psz_name, b_enabled) + + def vlm_set_output(self, psz_name, psz_output): + '''Set the output for a media. + @param psz_name: the media to work on. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_set_output(self, psz_name, psz_output) + + def vlm_set_input(self, psz_name, psz_input): + '''Set a media's input MRL. This will delete all existing inputs and + add the specified one. + @param psz_name: the media to work on. + @param psz_input: the input MRL. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_set_input(self, psz_name, psz_input) + + def vlm_add_input(self, psz_name, psz_input): + '''Add a media's input MRL. This will add the specified one. + @param psz_name: the media to work on. + @param psz_input: the input MRL. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_add_input(self, psz_name, psz_input) + + def vlm_set_loop(self, psz_name, b_loop): + '''Set a media's loop status. + @param psz_name: the media to work on. + @param b_loop: the new status. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_set_loop(self, psz_name, b_loop) + + def vlm_set_mux(self, psz_name, psz_mux): + '''Set a media's vod muxer. + @param psz_name: the media to work on. + @param psz_mux: the new muxer. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_set_mux(self, psz_name, psz_mux) + + def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): + '''Edit the parameters of a media. This will delete all existing inputs and + add the specified one. + @param psz_name: the name of the new broadcast. + @param psz_input: the input MRL. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new broadcast. + @param b_loop: Should this broadcast be played in loop ? + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) + + def vlm_play_media(self, psz_name): + '''Play the named broadcast. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_play_media(self, psz_name) + + def vlm_stop_media(self, psz_name): + '''Stop the named broadcast. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_stop_media(self, psz_name) + + def vlm_pause_media(self, psz_name): + '''Pause the named broadcast. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_pause_media(self, psz_name) + + def vlm_seek_media(self, psz_name, f_percentage): + '''Seek in the named broadcast. + @param psz_name: the name of the broadcast. + @param f_percentage: the percentage to seek to. + @return: 0 on success, -1 on error. + ''' + return libvlc_vlm_seek_media(self, psz_name, f_percentage) + + def vlm_show_media(self, psz_name): + '''Return information about the named media as a JSON + string representation. + This function is mainly intended for debugging use, + if you want programmatic access to the state of + a vlm_media_instance_t, please use the corresponding + libvlc_vlm_get_media_instance_xxx -functions. + Currently there are no such functions available for + vlm_media_t though. + @param psz_name: the name of the media, if the name is an empty string, all media is described. + @return: string with information about named media, or NULL on error. + ''' + return libvlc_vlm_show_media(self, psz_name) + + def vlm_get_media_instance_position(self, psz_name, i_instance): + '''Get vlm_media instance position by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: position as float or -1. on error. + ''' + return libvlc_vlm_get_media_instance_position(self, psz_name, i_instance) + + def vlm_get_media_instance_time(self, psz_name, i_instance): + '''Get vlm_media instance time by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: time as integer or -1 on error. + ''' + return libvlc_vlm_get_media_instance_time(self, psz_name, i_instance) + + def vlm_get_media_instance_length(self, psz_name, i_instance): + '''Get vlm_media instance length by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: length of media item or -1 on error. + ''' + return libvlc_vlm_get_media_instance_length(self, psz_name, i_instance) + + def vlm_get_media_instance_rate(self, psz_name, i_instance): + '''Get vlm_media instance playback rate by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: playback rate or -1 on error. + ''' + return libvlc_vlm_get_media_instance_rate(self, psz_name, i_instance) + + def vlm_get_media_instance_title(self, psz_name, i_instance): + '''Get vlm_media instance title number by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: title as number or -1 on error. + @bug: will always return 0. + ''' + return libvlc_vlm_get_media_instance_title(self, psz_name, i_instance) + + def vlm_get_media_instance_chapter(self, psz_name, i_instance): + '''Get vlm_media instance chapter number by name or instance id. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: chapter as number or -1 on error. + @bug: will always return 0. + ''' + return libvlc_vlm_get_media_instance_chapter(self, psz_name, i_instance) + + def vlm_get_media_instance_seekable(self, psz_name, i_instance): + '''Is libvlc instance seekable ? + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: 1 if seekable, 0 if not, -1 if media does not exist. + @bug: will always return 0. + ''' + return libvlc_vlm_get_media_instance_seekable(self, psz_name, i_instance) + + def vlm_get_event_manager(self): + '''Get libvlc_event_manager from a vlm media. + The p_event_manager is immutable, so you don't have to hold the lock. + @return: libvlc_event_manager. + ''' + return libvlc_vlm_get_event_manager(self) + +class Log(_Ctype): + '''Create a new VLC log instance. + + ''' + + def __new__(cls, ptr=_internal_guard): + '''(INTERNAL) ctypes wrapper constructor. + ''' + return _Constructor(cls, ptr) + + def __iter__(self): + return self.get_iterator() + + def dump(self): + return [ str(m) for m in self ] + + + def close(self): + '''Frees memory allocated by L{open}(). + ''' + return libvlc_log_close(self) + + def count(self): + '''Always returns zero. + This function is only provided for backward compatibility. + @return: always zero. + ''' + return libvlc_log_count(self) + + def __len__(self): + return libvlc_log_count(self) + + def clear(self): + '''This function does nothing. + It is only provided for backward compatibility. + ''' + return libvlc_log_clear(self) + + def get_iterator(self): + '''This function does nothing useful. + It is only provided for backward compatibility. + @return: an unique pointer or NULL on error or if the parameter was NULL. + ''' + return libvlc_log_get_iterator(self) + +class LogIterator(_Ctype): + '''Create a new VLC log iterator. + + ''' + + def __new__(cls, ptr=_internal_guard): + '''(INTERNAL) ctypes wrapper constructor. + ''' + return _Constructor(cls, ptr) + + def __iter__(self): + return self + + def next(self): + if self.has_next(): + b = LogMessage() + i = libvlc_log_iterator_next(self, b) + return i.contents + raise StopIteration + + + def free(self): + '''Frees memory allocated by L{log_get_iterator}(). + ''' + return libvlc_log_iterator_free(self) + + def has_next(self): + '''Always returns zero. + This function is only provided for backward compatibility. + @return: always zero. + ''' + return libvlc_log_iterator_has_next(self) + +class Media(_Ctype): + '''Create a new Media instance. + + Usage: Media(MRL, *options) + + See vlc.Instance.media_new documentation for details. + + ''' + + def __new__(cls, *args): + if args: + i = args[0] + if isinstance(i, _Ints): + return _Constructor(cls, i) + if isinstance(i, Instance): + return i.media_new(*args[1:]) + + o = get_default_instance().media_new(*args) + return o + + def get_instance(self): + return getattr(self, '_instance', None) + + def add_options(self, *options): + """Add a list of options to the media. + + Options must be written without the double-dash, e.g.: + + C{m.add_options('sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} + + Alternatively, the options can directly be passed in the Instance.media_new method: + + C{m = instance.media_new('foo.avi', 'sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} + + @param options: optional media option=value strings + """ + for o in options: + self.add_option(o) + + + def add_option(self, ppsz_options): + '''Add an option to the media. + This option will be used to determine how the media_player will + read the media. This allows to use VLC's advanced + reading/streaming options on a per-media basis. + The options are detailed in vlc --long-help, for instance "--sout-all". + @param ppsz_options: the options (as a string). + ''' + return libvlc_media_add_option(self, ppsz_options) + + def add_option_flag(self, ppsz_options, i_flags): + '''Add an option to the media with configurable flags. + This option will be used to determine how the media_player will + read the media. This allows to use VLC's advanced + reading/streaming options on a per-media basis. + The options are detailed in vlc --long-help, for instance "--sout-all". + @param ppsz_options: the options (as a string). + @param i_flags: the flags for this option. + ''' + return libvlc_media_add_option_flag(self, ppsz_options, i_flags) + + def retain(self): + '''Retain a reference to a media descriptor object (libvlc_media_t). Use + L{release}() to decrement the reference count of a + media descriptor object. + ''' + return libvlc_media_retain(self) + + def release(self): + '''Decrement the reference count of a media descriptor object. If the + reference count is 0, then L{release}() will release the + media descriptor object. It will send out an libvlc_MediaFreed event + to all listeners. If the media descriptor object has been released it + should not be used again. + ''' + return libvlc_media_release(self) + + def get_mrl(self): + '''Get the media resource locator (mrl) from a media descriptor object. + @return: string with mrl of media descriptor object. + ''' + return libvlc_media_get_mrl(self) + + def duplicate(self): + '''Duplicate a media descriptor object. + ''' + return libvlc_media_duplicate(self) + + def get_meta(self, e_meta): + '''Read the meta of the media. + If the media has not yet been parsed this will return NULL. + This methods automatically calls L{parse_async}(), so after calling + it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous + version ensure that you call L{parse}() before get_meta(). + See L{parse} + See L{parse_async} + See libvlc_MediaMetaChanged. + @param e_meta: the meta to read. + @return: the media's meta. + ''' + return libvlc_media_get_meta(self, e_meta) + + def set_meta(self, e_meta, psz_value): + '''Set the meta of the media (this function will not save the meta, call + L{save_meta} in order to save the meta). + @param e_meta: the meta to write. + @param psz_value: the media's meta. + ''' + return libvlc_media_set_meta(self, e_meta, psz_value) + + def save_meta(self): + '''Save the meta previously set. + @return: true if the write operation was successfull. + ''' + return libvlc_media_save_meta(self) + + def get_state(self): + '''Get current state of media descriptor object. Possible media states + are defined in libvlc_structures.c ( libvlc_NothingSpecial=0, + libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, + libvlc_Stopped, libvlc_Ended, + libvlc_Error). + See libvlc_state_t. + @return: state of media descriptor object. + ''' + return libvlc_media_get_state(self) + + def get_stats(self, p_stats): + '''Get the current statistics about the media. + @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). + @return: true if the statistics are available, false otherwise \libvlc_return_bool. + ''' + return libvlc_media_get_stats(self, p_stats) + + def event_manager(self): + '''Get event manager from media descriptor object. + NOTE: this function doesn't increment reference counting. + @return: event manager object. + ''' + return libvlc_media_event_manager(self) + + def get_duration(self): + '''Get duration (in ms) of media descriptor object item. + @return: duration of media item or -1 on error. + ''' + return libvlc_media_get_duration(self) + + def parse(self): + '''Parse a media. + This fetches (local) meta data and tracks information. + The method is synchronous. + See L{parse_async} + See L{get_meta} + See L{get_tracks_info}. + ''' + return libvlc_media_parse(self) + + def parse_async(self): + '''Parse a media. + This fetches (local) meta data and tracks information. + The method is the asynchronous of L{parse}(). + To track when this is over you can listen to libvlc_MediaParsedChanged + event. However if the media was already parsed you will not receive this + event. + See L{parse} + See libvlc_MediaParsedChanged + See L{get_meta} + See L{get_tracks_info}. + ''' + return libvlc_media_parse_async(self) + + def is_parsed(self): + '''Get Parsed status for media descriptor object. + See libvlc_MediaParsedChanged. + @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool. + ''' + return libvlc_media_is_parsed(self) + + def set_user_data(self, p_new_user_data): + '''Sets media descriptor's user_data. user_data is specialized data + accessed by the host application, VLC.framework uses it as a pointer to + an native object that references a L{Media} pointer. + @param p_new_user_data: pointer to user data. + ''' + return libvlc_media_set_user_data(self, p_new_user_data) + + def get_user_data(self): + '''Get media descriptor's user_data. user_data is specialized data + accessed by the host application, VLC.framework uses it as a pointer to + an native object that references a L{Media} pointer. + ''' + return libvlc_media_get_user_data(self) + + def get_tracks_info(self): + '''Get media descriptor's elementary streams description + Note, you need to call L{parse}() or play the media at least once + before calling this function. + Not doing this will result in an empty array. + @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller). + @return: the number of Elementary Streams. + ''' + return libvlc_media_get_tracks_info(self) + + def player_new_from_media(self): + '''Create a Media Player object from a Media. + @return: a new media player object, or NULL on error. + ''' + return libvlc_media_player_new_from_media(self) + +class MediaDiscoverer(_Ctype): + '''N/A + ''' + + def __new__(cls, ptr=_internal_guard): + '''(INTERNAL) ctypes wrapper constructor. + ''' + return _Constructor(cls, ptr) + def release(self): + '''Release media discover object. If the reference count reaches 0, then + the object will be released. + ''' + return libvlc_media_discoverer_release(self) + + def localized_name(self): + '''Get media service discover object its localized name. + @return: localized name. + ''' + return libvlc_media_discoverer_localized_name(self) + + def media_list(self): + '''Get media service discover media list. + @return: list of media items. + ''' + return libvlc_media_discoverer_media_list(self) + + def event_manager(self): + '''Get event manager from media service discover object. + @return: event manager object. + ''' + return libvlc_media_discoverer_event_manager(self) + + def is_running(self): + '''Query if media service discover object is running. + @return: true if running, false if not \libvlc_return_bool. + ''' + return libvlc_media_discoverer_is_running(self) + +class MediaLibrary(_Ctype): + '''N/A + ''' + + def __new__(cls, ptr=_internal_guard): + '''(INTERNAL) ctypes wrapper constructor. + ''' + return _Constructor(cls, ptr) + def release(self): + '''Release media library object. This functions decrements the + reference count of the media library object. If it reaches 0, + then the object will be released. + ''' + return libvlc_media_library_release(self) + + def retain(self): + '''Retain a reference to a media library object. This function will + increment the reference counting for this object. Use + L{release}() to decrement the reference count. + ''' + return libvlc_media_library_retain(self) + + def load(self): + '''Load media library. + @return: 0 on success, -1 on error. + ''' + return libvlc_media_library_load(self) + + def media_list(self): + '''Get media library subitems. + @return: media list subitems. + ''' + return libvlc_media_library_media_list(self) + +class MediaList(_Ctype): + '''Create a new MediaList instance. + + Usage: MediaList(list_of_MRLs) + + See vlc.Instance.media_list_new documentation for details. + + ''' + + def __new__(cls, *args): + if args: + i = args[0] + if isinstance(i, _Ints): + return _Constructor(cls, i) + if isinstance(i, Instance): + return i.media_list_new(*args[1:]) + + o = get_default_instance().media_list_new(*args) + return o + + def get_instance(self): + return getattr(self, '_instance', None) + + def add_media(self, mrl): + """Add media instance to media list. + + The L{lock} should be held upon entering this function. + @param p_md: a media instance or a MRL. + @return: 0 on success, -1 if the media list is read-only. + """ + if isinstance(mrl, basestring): + mrl = (self.get_instance() or get_default_instance()).media_new(mrl) + return libvlc_media_list_add_media(self, mrl) + + + def release(self): + '''Release media list created with L{new}(). + ''' + return libvlc_media_list_release(self) + + def retain(self): + '''Retain reference to a media list. + ''' + return libvlc_media_list_retain(self) + + def set_media(self, p_md): + '''Associate media instance with this media list instance. + If another media instance was present it will be released. + The L{lock} should NOT be held upon entering this function. + @param p_md: media instance to add. + ''' + return libvlc_media_list_set_media(self, p_md) + + def media(self): + '''Get media instance from this media list instance. This action will increase + the refcount on the media instance. + The L{lock} should NOT be held upon entering this function. + @return: media instance. + ''' + return libvlc_media_list_media(self) + + def insert_media(self, p_md, i_pos): + '''Insert media instance in media list on a position + The L{lock} should be held upon entering this function. + @param p_md: a media instance. + @param i_pos: position in array where to insert. + @return: 0 on success, -1 if the media list is read-only. + ''' + return libvlc_media_list_insert_media(self, p_md, i_pos) + + def remove_index(self, i_pos): + '''Remove media instance from media list on a position + The L{lock} should be held upon entering this function. + @param i_pos: position in array where to insert. + @return: 0 on success, -1 if the list is read-only or the item was not found. + ''' + return libvlc_media_list_remove_index(self, i_pos) + + def count(self): + '''Get count on media list items + The L{lock} should be held upon entering this function. + @return: number of items in media list. + ''' + return libvlc_media_list_count(self) + + def __len__(self): + return libvlc_media_list_count(self) + + def item_at_index(self, i_pos): + '''List media instance in media list at a position + The L{lock} should be held upon entering this function. + @param i_pos: position in array where to insert. + @return: media instance at position i_pos, or NULL if not found. In case of success, L{media_retain}() is called to increase the refcount on the media. + ''' + return libvlc_media_list_item_at_index(self, i_pos) + + def __getitem__(self, i): + return libvlc_media_list_item_at_index(self, i) + + def __iter__(self): + for i in range(len(self)): + yield self[i] + + def index_of_item(self, p_md): + '''Find index position of List media instance in media list. + Warning: the function will return the first matched position. + The L{lock} should be held upon entering this function. + @param p_md: media instance. + @return: position of media instance or -1 if media not found. + ''' + return libvlc_media_list_index_of_item(self, p_md) + + def is_readonly(self): + '''This indicates if this media list is read-only from a user point of view. + @return: 1 on readonly, 0 on readwrite \libvlc_return_bool. + ''' + return libvlc_media_list_is_readonly(self) + + def lock(self): + '''Get lock on media list items. + ''' + return libvlc_media_list_lock(self) + + def unlock(self): + '''Release lock on media list items + The L{lock} should be held upon entering this function. + ''' + return libvlc_media_list_unlock(self) + + def event_manager(self): + '''Get libvlc_event_manager from this media list instance. + The p_event_manager is immutable, so you don't have to hold the lock. + @return: libvlc_event_manager. + ''' + return libvlc_media_list_event_manager(self) + +class MediaListPlayer(_Ctype): + '''Create a new MediaListPlayer instance. + + It may take as parameter either: + - a vlc.Instance + - nothing + + ''' + + def __new__(cls, arg=None): + if arg is None: + i = get_default_instance() + elif isinstance(arg, Instance): + i = arg + elif isinstance(arg, _Ints): + return _Constructor(cls, arg) + else: + raise TypeError('MediaListPlayer %r' % (arg,)) + + return i.media_list_player_new() + + def get_instance(self): + """Return the associated Instance. + """ + return self._instance #PYCHOK expected + + + def release(self): + '''Release a media_list_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{release}() will + release the media player object. If the media player object + has been released, then it should not be used again. + ''' + return libvlc_media_list_player_release(self) + + def retain(self): + '''Retain a reference to a media player list object. Use + L{release}() to decrement reference count. + ''' + return libvlc_media_list_player_retain(self) + + def event_manager(self): + '''Return the event manager of this media_list_player. + @return: the event manager. + ''' + return libvlc_media_list_player_event_manager(self) + + def set_media_player(self, p_mi): + '''Replace media player in media_list_player with this instance. + @param p_mi: media player instance. + ''' + return libvlc_media_list_player_set_media_player(self, p_mi) + + def set_media_list(self, p_mlist): + '''Set the media list associated with the player. + @param p_mlist: list of media. + ''' + return libvlc_media_list_player_set_media_list(self, p_mlist) + + def play(self): + '''Play media list. + ''' + return libvlc_media_list_player_play(self) + + def pause(self): + '''Pause media list. + ''' + return libvlc_media_list_player_pause(self) + + def is_playing(self): + '''Is media list playing? + @return: true for playing and false for not playing \libvlc_return_bool. + ''' + return libvlc_media_list_player_is_playing(self) + + def get_state(self): + '''Get current libvlc_state of media list player. + @return: libvlc_state_t for media list player. + ''' + return libvlc_media_list_player_get_state(self) + + def play_item_at_index(self, i_index): + '''Play media list item at position index. + @param i_index: index in media list to play. + @return: 0 upon success -1 if the item wasn't found. + ''' + return libvlc_media_list_player_play_item_at_index(self, i_index) + + def __getitem__(self, i): + return libvlc_media_list_player_play_item_at_index(self, i) + + def __iter__(self): + for i in range(len(self)): + yield self[i] + + def play_item(self, p_md): + '''Play the given media item. + @param p_md: the media instance. + @return: 0 upon success, -1 if the media is not part of the media list. + ''' + return libvlc_media_list_player_play_item(self, p_md) + + def stop(self): + '''Stop playing media list. + ''' + return libvlc_media_list_player_stop(self) + + def next(self): + '''Play next item from media list. + @return: 0 upon success -1 if there is no next item. + ''' + return libvlc_media_list_player_next(self) + + def previous(self): + '''Play previous item from media list. + @return: 0 upon success -1 if there is no previous item. + ''' + return libvlc_media_list_player_previous(self) + + def set_playback_mode(self, e_mode): + '''Sets the playback mode for the playlist. + @param e_mode: playback mode specification. + ''' + return libvlc_media_list_player_set_playback_mode(self, e_mode) + +class MediaPlayer(_Ctype): + '''Create a new MediaPlayer instance. + + It may take as parameter either: + - a string (media URI), options... In this case, a vlc.Instance will be created. + - a vlc.Instance, a string (media URI), options... + + ''' + + def __new__(cls, *args): + if len(args) == 1 and isinstance(args[0], _Ints): + return _Constructor(cls, args[0]) + + if args and isinstance(args[0], Instance): + instance = args[0] + args = args[1:] + else: + instance = get_default_instance() + + o = instance.media_player_new() + if args: + o.set_media(instance.media_new(*args)) + return o + + def get_instance(self): + """Return the associated Instance. + """ + return self._instance #PYCHOK expected + + def set_mrl(self, mrl, *options): + """Set the MRL to play. + + @param mrl: The MRL + @param options: optional media option=value strings + @return: the Media object + """ + m = self.get_instance().media_new(mrl, *options) + self.set_media(m) + return m + + def video_get_spu_description(self): + """Get the description of available video subtitles. + """ + return track_description_list(libvlc_video_get_spu_description(self)) + + def video_get_title_description(self): + """Get the description of available titles. + """ + return track_description_list(libvlc_video_get_title_description(self)) + + def video_get_chapter_description(self, title): + """Get the description of available chapters for specific title. + + @param title: selected title (int) + """ + return track_description_list(libvlc_video_get_chapter_description(self, title)) + + def video_get_track_description(self): + """Get the description of available video tracks. + """ + return track_description_list(libvlc_video_get_track_description(self)) + + def audio_get_track_description(self): + """Get the description of available audio tracks. + """ + return track_description_list(libvlc_audio_get_track_description(self)) + + def video_get_size(self, num=0): + """Get the video size in pixels as 2-tuple (width, height). + + @param num: video number (default 0). + """ + r = libvlc_video_get_size(self, num) + if isinstance(r, tuple) and len(r) == 2: + return r + else: + raise VLCException('invalid video number (%s)' % (num,)) + + def set_hwnd(self, drawable): + """Set a Win32/Win64 API window handle (HWND). + + Specify where the media player should render its video + output. If LibVLC was built without Win32/Win64 API output + support, then this has no effects. + + @param drawable: windows handle of the drawable. + """ + if not isinstance(drawable, ctypes.c_void_p): + drawable = ctypes.c_void_p(int(drawable)) + libvlc_media_player_set_hwnd(self, drawable) + + def video_get_width(self, num=0): + """Get the width of a video in pixels. + + @param num: video number (default 0). + """ + return self.video_get_size(num)[0] + + def video_get_height(self, num=0): + """Get the height of a video in pixels. + + @param num: video number (default 0). + """ + return self.video_get_size(num)[1] + + def video_get_cursor(self, num=0): + """Get the mouse pointer coordinates over a video as 2-tuple (x, y). + + Coordinates are expressed in terms of the decoded video resolution, + B{not} in terms of pixels on the screen/viewport. To get the + latter, you must query your windowing system directly. + + Either coordinate may be negative or larger than the corresponding + size of the video, if the cursor is outside the rendering area. + + @warning: The coordinates may be out-of-date if the pointer is not + located on the video rendering area. LibVLC does not track the + mouse pointer if the latter is outside the video widget. + + @note: LibVLC does not support multiple mouse pointers (but does + support multiple input devices sharing the same pointer). + + @param num: video number (default 0). + """ + r = libvlc_video_get_cursor(self, num) + if isinstance(r, tuple) and len(r) == 2: + return r + raise VLCException('invalid video number (%s)' % (num,)) + + + def release(self): + '''Release a media_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{release}() will + release the media player object. If the media player object + has been released, then it should not be used again. + ''' + return libvlc_media_player_release(self) + + def retain(self): + '''Retain a reference to a media player object. Use + L{release}() to decrement reference count. + ''' + return libvlc_media_player_retain(self) + + def set_media(self, p_md): + '''Set the media that will be used by the media_player. If any, + previous md will be released. + @param p_md: the Media. Afterwards the p_md can be safely destroyed. + ''' + return libvlc_media_player_set_media(self, p_md) + + def get_media(self): + '''Get the media used by the media_player. + @return: the media associated with p_mi, or NULL if no media is associated. + ''' + return libvlc_media_player_get_media(self) + + def event_manager(self): + '''Get the Event Manager from which the media player send event. + @return: the event manager associated with p_mi. + ''' + return libvlc_media_player_event_manager(self) + + def is_playing(self): + '''is_playing. + @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool. + ''' + return libvlc_media_player_is_playing(self) + + def play(self): + '''Play. + @return: 0 if playback started (and was already started), or -1 on error. + ''' + return libvlc_media_player_play(self) + + def set_pause(self, do_pause): + '''Pause or resume (no effect if there is no media). + @param do_pause: play/resume if zero, pause if non-zero. + @version: LibVLC 1.1.1 or later. + ''' + return libvlc_media_player_set_pause(self, do_pause) + + def pause(self): + '''Toggle pause (no effect if there is no media). + ''' + return libvlc_media_player_pause(self) + + def stop(self): + '''Stop (no effect if there is no media). + ''' + return libvlc_media_player_stop(self) + + def video_set_format(self, chroma, width, height, pitch): + '''Set decoded video chroma and dimensions. + This only works in combination with libvlc_video_set_callbacks(), + and is mutually exclusive with libvlc_video_set_format_callbacks(). + @param chroma: a four-characters string identifying the chroma (e.g. "RV32" or "YUYV"). + @param width: pixel width. + @param height: pixel height. + @param pitch: line pitch (in bytes). + @version: LibVLC 1.1.1 or later. + @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using libvlc_video_set_format_callbacks() instead. + ''' + return libvlc_video_set_format(self, chroma, width, height, pitch) + + def set_nsobject(self, drawable): + '''Set the NSView handler where the media player should render its video output. + Use the vout called "macosx". + The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding + protocol: + @begincode + \@protocol VLCOpenGLVideoViewEmbedding + - (void)addVoutSubview:(NSView *)view; + - (void)removeVoutSubview:(NSView *)view; + \@end + @endcode + Or it can be an NSView object. + If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then + the following code should work: + @begincode + + NSView *video = [[NSView alloc] init]; + QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); + L{set_nsobject}(mp, video); + [video release]; + + @endcode + You can find a live example in VLCVideoView in VLCKit.framework. + @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. + ''' + return libvlc_media_player_set_nsobject(self, drawable) + + def get_nsobject(self): + '''Get the NSView handler previously set with L{set_nsobject}(). + @return: the NSView handler or 0 if none where set. + ''' + return libvlc_media_player_get_nsobject(self) + + def set_agl(self, drawable): + '''Set the agl handler where the media player should render its video output. + @param drawable: the agl handler. + ''' + return libvlc_media_player_set_agl(self, drawable) + + def get_agl(self): + '''Get the agl handler previously set with L{set_agl}(). + @return: the agl handler or 0 if none where set. + ''' + return libvlc_media_player_get_agl(self) + + def set_xwindow(self, drawable): + '''Set an X Window System drawable where the media player should render its + video output. If LibVLC was built without X11 output support, then this has + no effects. + The specified identifier must correspond to an existing Input/Output class + X11 window. Pixmaps are B{not} supported. The caller shall ensure that + the X11 server is the same as the one the VLC instance has been configured + with. This function must be called before video playback is started; + otherwise it will only take effect after playback stop and restart. + @param drawable: the ID of the X window. + ''' + return libvlc_media_player_set_xwindow(self, drawable) + + def get_xwindow(self): + '''Get the X Window System window identifier previously set with + L{set_xwindow}(). Note that this will return the identifier + even if VLC is not currently using it (for instance if it is playing an + audio-only input). + @return: an X window ID, or 0 if none where set. + ''' + return libvlc_media_player_get_xwindow(self) + + def get_hwnd(self): + '''Get the Windows API window handle (HWND) previously set with + L{set_hwnd}(). The handle will be returned even if LibVLC + is not currently outputting any video to it. + @return: a window handle or NULL if there are none. + ''' + return libvlc_media_player_get_hwnd(self) + + def audio_set_format(self, format, rate, channels): + '''Set decoded audio format. + This only works in combination with libvlc_audio_set_callbacks(), + and is mutually exclusive with libvlc_audio_set_format_callbacks(). + @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param rate: sample rate (expressed in Hz). + @param channels: channels count. + @version: LibVLC 1.2.0 or later. + ''' + return libvlc_audio_set_format(self, format, rate, channels) + + def get_length(self): + '''Get the current movie length (in ms). + @return: the movie length (in ms), or -1 if there is no media. + ''' + return libvlc_media_player_get_length(self) + + def get_time(self): + '''Get the current movie time (in ms). + @return: the movie time (in ms), or -1 if there is no media. + ''' + return libvlc_media_player_get_time(self) + + def set_time(self, i_time): + '''Set the movie time (in ms). This has no effect if no media is being played. + Not all formats and protocols support this. + @param i_time: the movie time (in ms). + ''' + return libvlc_media_player_set_time(self, i_time) + + def get_position(self): + '''Get movie position. + @return: movie position, or -1. in case of error. + ''' + return libvlc_media_player_get_position(self) + + def set_position(self, f_pos): + '''Set movie position. This has no effect if playback is not enabled. + This might not work depending on the underlying input format and protocol. + @param f_pos: the position. + ''' + return libvlc_media_player_set_position(self, f_pos) + + def set_chapter(self, i_chapter): + '''Set movie chapter (if applicable). + @param i_chapter: chapter number to play. + ''' + return libvlc_media_player_set_chapter(self, i_chapter) + + def get_chapter(self): + '''Get movie chapter. + @return: chapter number currently playing, or -1 if there is no media. + ''' + return libvlc_media_player_get_chapter(self) + + def get_chapter_count(self): + '''Get movie chapter count. + @return: number of chapters in movie, or -1. + ''' + return libvlc_media_player_get_chapter_count(self) + + def will_play(self): + '''Is the player able to play. + @return: boolean \libvlc_return_bool. + ''' + return libvlc_media_player_will_play(self) + + def get_chapter_count_for_title(self, i_title): + '''Get title chapter count. + @param i_title: title. + @return: number of chapters in title, or -1. + ''' + return libvlc_media_player_get_chapter_count_for_title(self, i_title) + + def set_title(self, i_title): + '''Set movie title. + @param i_title: title number to play. + ''' + return libvlc_media_player_set_title(self, i_title) + + def get_title(self): + '''Get movie title. + @return: title number currently playing, or -1. + ''' + return libvlc_media_player_get_title(self) + + def get_title_count(self): + '''Get movie title count. + @return: title number count, or -1. + ''' + return libvlc_media_player_get_title_count(self) + + def previous_chapter(self): + '''Set previous chapter (if applicable). + ''' + return libvlc_media_player_previous_chapter(self) + + def next_chapter(self): + '''Set next chapter (if applicable). + ''' + return libvlc_media_player_next_chapter(self) + + def get_rate(self): + '''Get the requested movie play rate. + @warning: Depending on the underlying media, the requested rate may be + different from the real playback rate. + @return: movie play rate. + ''' + return libvlc_media_player_get_rate(self) + + def set_rate(self, rate): + '''Set movie play rate. + @param rate: movie play rate to set. + @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol). + ''' + return libvlc_media_player_set_rate(self, rate) + + def get_state(self): + '''Get current movie state. + @return: the current state of the media player (playing, paused, ...) See libvlc_state_t. + ''' + return libvlc_media_player_get_state(self) + + def get_fps(self): + '''Get movie fps rate. + @return: frames per second (fps) for this playing movie, or 0 if unspecified. + ''' + return libvlc_media_player_get_fps(self) + + def has_vout(self): + '''How many video outputs does this media player have? + @return: the number of video outputs. + ''' + return libvlc_media_player_has_vout(self) + + def is_seekable(self): + '''Is this media player seekable? + @return: true if the media player can seek \libvlc_return_bool. + ''' + return libvlc_media_player_is_seekable(self) + + def can_pause(self): + '''Can this media player be paused? + @return: true if the media player can pause \libvlc_return_bool. + ''' + return libvlc_media_player_can_pause(self) + + def next_frame(self): + '''Display the next frame (if supported). + ''' + return libvlc_media_player_next_frame(self) + + def navigate(self, navigate): + '''Navigate through DVD Menu. + @param navigate: the Navigation mode. + @version: libVLC 1.2.0 or later. + ''' + return libvlc_media_player_navigate(self, navigate) + + def toggle_fullscreen(self): + '''Toggle fullscreen status on non-embedded video outputs. + @warning: The same limitations applies to this function + as to L{set_fullscreen}(). + ''' + return libvlc_toggle_fullscreen(self) + + def set_fullscreen(self, b_fullscreen): + '''Enable or disable fullscreen. + @warning: With most window managers, only a top-level windows can be in + full-screen mode. Hence, this function will not operate properly if + L{set_xwindow}() was used to embed the video in a + non-top-level window. In that case, the embedding window must be reparented + to the root window B{before} fullscreen mode is enabled. You will want + to reparent it back to its normal parent when disabling fullscreen. + @param b_fullscreen: boolean for fullscreen status. + ''' + return libvlc_set_fullscreen(self, b_fullscreen) + + def get_fullscreen(self): + '''Get current fullscreen status. + @return: the fullscreen status (boolean) \libvlc_return_bool. + ''' + return libvlc_get_fullscreen(self) + + def video_set_key_input(self, on): + '''Enable or disable key press events handling, according to the LibVLC hotkeys + configuration. By default and for historical reasons, keyboard events are + handled by the LibVLC video widget. + @note: On X11, there can be only one subscriber for key press and mouse + click events per window. If your application has subscribed to those events + for the X window ID of the video widget, then LibVLC will not be able to + handle key presses and mouse clicks in any case. + @warning: This function is only implemented for X11 and Win32 at the moment. + @param on: true to handle key press events, false to ignore them. + ''' + return libvlc_video_set_key_input(self, on) + + def video_set_mouse_input(self, on): + '''Enable or disable mouse click events handling. By default, those events are + handled. This is needed for DVD menus to work, as well as a few video + filters such as "puzzle". + See L{video_set_key_input}(). + @warning: This function is only implemented for X11 and Win32 at the moment. + @param on: true to handle mouse click events, false to ignore them. + ''' + return libvlc_video_set_mouse_input(self, on) + + def video_get_scale(self): + '''Get the current video scaling factor. + See also L{video_set_scale}(). + @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically. + ''' + return libvlc_video_get_scale(self) + + def video_set_scale(self, f_factor): + '''Set the video scaling factor. That is the ratio of the number of pixels on + screen to the number of pixels in the original decoded video in each + dimension. Zero is a special value; it will adjust the video to the output + window/drawable (in windowed mode) or the entire screen. + Note that not all video outputs support scaling. + @param f_factor: the scaling factor, or zero. + ''' + return libvlc_video_set_scale(self, f_factor) + + def video_get_aspect_ratio(self): + '''Get current video aspect ratio. + @return: the video aspect ratio or NULL if unspecified (the result must be released with free() or L{free}()). + ''' + return libvlc_video_get_aspect_ratio(self) + + def video_set_aspect_ratio(self, psz_aspect): + '''Set new video aspect ratio. + @param psz_aspect: new video aspect-ratio or NULL to reset to default @note Invalid aspect ratios are ignored. + ''' + return libvlc_video_set_aspect_ratio(self, psz_aspect) + + def video_get_spu(self): + '''Get current video subtitle. + @return: the video subtitle selected, or -1 if none. + ''' + return libvlc_video_get_spu(self) + + def video_get_spu_count(self): + '''Get the number of available video subtitles. + @return: the number of available video subtitles. + ''' + return libvlc_video_get_spu_count(self) + + def video_set_spu(self, i_spu): + '''Set new video subtitle. + @param i_spu: new video subtitle to select. + @return: 0 on success, -1 if out of range. + ''' + return libvlc_video_set_spu(self, i_spu) + + def video_set_subtitle_file(self, psz_subtitle): + '''Set new video subtitle file. + @param psz_subtitle: new video subtitle file. + @return: the success status (boolean). + ''' + return libvlc_video_set_subtitle_file(self, psz_subtitle) + + def video_get_crop_geometry(self): + '''Get current crop filter geometry. + @return: the crop filter geometry or NULL if unset. + ''' + return libvlc_video_get_crop_geometry(self) + + def video_set_crop_geometry(self, psz_geometry): + '''Set new crop filter geometry. + @param psz_geometry: new crop filter geometry (NULL to unset). + ''' + return libvlc_video_set_crop_geometry(self, psz_geometry) + + def video_get_teletext(self): + '''Get current teletext page requested. + @return: the current teletext page requested. + ''' + return libvlc_video_get_teletext(self) + + def video_set_teletext(self, i_page): + '''Set new teletext page to retrieve. + @param i_page: teletex page number requested. + ''' + return libvlc_video_set_teletext(self, i_page) + + def toggle_teletext(self): + '''Toggle teletext transparent status on video output. + ''' + return libvlc_toggle_teletext(self) + + def video_get_track_count(self): + '''Get number of available video tracks. + @return: the number of available video tracks (int). + ''' + return libvlc_video_get_track_count(self) + + def video_get_track(self): + '''Get current video track. + @return: the video track (int) or -1 if none. + ''' + return libvlc_video_get_track(self) + + def video_set_track(self, i_track): + '''Set video track. + @param i_track: the track (int). + @return: 0 on success, -1 if out of range. + ''' + return libvlc_video_set_track(self, i_track) + + def video_take_snapshot(self, num, psz_filepath, i_width, i_height): + '''Take a snapshot of the current video window. + If i_width AND i_height is 0, original size is used. + If i_width XOR i_height is 0, original aspect-ratio is preserved. + @param num: number of video output (typically 0 for the first/only one). + @param psz_filepath: the path where to save the screenshot to. + @param i_width: the snapshot's width. + @param i_height: the snapshot's height. + @return: 0 on success, -1 if the video was not found. + ''' + return libvlc_video_take_snapshot(self, num, psz_filepath, i_width, i_height) + + def video_set_deinterlace(self, psz_mode): + '''Enable or disable deinterlace filter. + @param psz_mode: type of deinterlace filter, NULL to disable. + ''' + return libvlc_video_set_deinterlace(self, psz_mode) + + def video_get_marquee_int(self, option): + '''Get an integer marquee option value. + @param option: marq option to get See libvlc_video_marquee_int_option_t. + ''' + return libvlc_video_get_marquee_int(self, option) + + def video_get_marquee_string(self, option): + '''Get a string marquee option value. + @param option: marq option to get See libvlc_video_marquee_string_option_t. + ''' + return libvlc_video_get_marquee_string(self, option) + + def video_set_marquee_int(self, option, i_val): + '''Enable, disable or set an integer marquee option + Setting libvlc_marquee_Enable has the side effect of enabling (arg !0) + or disabling (arg 0) the marq filter. + @param option: marq option to set See libvlc_video_marquee_int_option_t. + @param i_val: marq option value. + ''' + return libvlc_video_set_marquee_int(self, option, i_val) + + def video_set_marquee_string(self, option, psz_text): + '''Set a marquee string option. + @param option: marq option to set See libvlc_video_marquee_string_option_t. + @param psz_text: marq option value. + ''' + return libvlc_video_set_marquee_string(self, option, psz_text) + + def video_get_logo_int(self, option): + '''Get integer logo option. + @param option: logo option to get, values of libvlc_video_logo_option_t. + ''' + return libvlc_video_get_logo_int(self, option) + + def video_set_logo_int(self, option, value): + '''Set logo option as integer. Options that take a different type value + are ignored. + Passing libvlc_logo_enable as option value has the side effect of + starting (arg !0) or stopping (arg 0) the logo filter. + @param option: logo option to set, values of libvlc_video_logo_option_t. + @param value: logo option value. + ''' + return libvlc_video_set_logo_int(self, option, value) + + def video_set_logo_string(self, option, psz_value): + '''Set logo option as string. Options that take a different type value + are ignored. + @param option: logo option to set, values of libvlc_video_logo_option_t. + @param psz_value: logo option value. + ''' + return libvlc_video_set_logo_string(self, option, psz_value) + + def video_get_adjust_int(self, option): + '''Get integer adjust option. + @param option: adjust option to get, values of libvlc_video_adjust_option_t. + @version: LibVLC 1.1.1 and later. + ''' + return libvlc_video_get_adjust_int(self, option) + + def video_set_adjust_int(self, option, value): + '''Set adjust option as integer. Options that take a different type value + are ignored. + Passing libvlc_adjust_enable as option value has the side effect of + starting (arg !0) or stopping (arg 0) the adjust filter. + @param option: adust option to set, values of libvlc_video_adjust_option_t. + @param value: adjust option value. + @version: LibVLC 1.1.1 and later. + ''' + return libvlc_video_set_adjust_int(self, option, value) + + def video_get_adjust_float(self, option): + '''Get float adjust option. + @param option: adjust option to get, values of libvlc_video_adjust_option_t. + @version: LibVLC 1.1.1 and later. + ''' + return libvlc_video_get_adjust_float(self, option) + + def video_set_adjust_float(self, option, value): + '''Set adjust option as float. Options that take a different type value + are ignored. + @param option: adust option to set, values of libvlc_video_adjust_option_t. + @param value: adjust option value. + @version: LibVLC 1.1.1 and later. + ''' + return libvlc_video_set_adjust_float(self, option, value) + + def audio_output_set(self, psz_name): + '''Set the audio output. + Change will be applied after stop and play. + @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. + @return: 0 if function succeded, -1 on error. + ''' + return libvlc_audio_output_set(self, psz_name) + + def audio_output_device_set(self, psz_audio_output, psz_device_id): + '''Set audio output device. Changes are only effective after stop and play. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param psz_device_id: device. + ''' + return libvlc_audio_output_device_set(self, psz_audio_output, psz_device_id) + + def audio_output_get_device_type(self): + '''Get current audio device type. Device type describes something like + character of output sound - stereo sound, 2.1, 5.1 etc. + @return: the audio devices type See libvlc_audio_output_device_types_t. + ''' + return libvlc_audio_output_get_device_type(self) + + def audio_output_set_device_type(self, device_type): + '''Set current audio device type. + @param device_type: the audio device type, + ''' + return libvlc_audio_output_set_device_type(self, device_type) + + def audio_toggle_mute(self): + '''Toggle mute status. + ''' + return libvlc_audio_toggle_mute(self) + + def audio_get_mute(self): + '''Get current mute status. + @return: the mute status (boolean) \libvlc_return_bool. + ''' + return libvlc_audio_get_mute(self) + + def audio_set_mute(self, status): + '''Set mute status. + @param status: If status is true then mute, otherwise unmute. + ''' + return libvlc_audio_set_mute(self, status) + + def audio_get_volume(self): + '''Get current software audio volume. + @return: the software volume in percents (0 = mute, 100 = nominal / 0dB). + ''' + return libvlc_audio_get_volume(self) + + def audio_set_volume(self, i_volume): + '''Set current software audio volume. + @param i_volume: the volume in percents (0 = mute, 100 = 0dB). + @return: 0 if the volume was set, -1 if it was out of range. + ''' + return libvlc_audio_set_volume(self, i_volume) + + def audio_get_track_count(self): + '''Get number of available audio tracks. + @return: the number of available audio tracks (int), or -1 if unavailable. + ''' + return libvlc_audio_get_track_count(self) + + def audio_get_track(self): + '''Get current audio track. + @return: the audio track (int), or -1 if none. + ''' + return libvlc_audio_get_track(self) + + def audio_set_track(self, i_track): + '''Set current audio track. + @param i_track: the track (int). + @return: 0 on success, -1 on error. + ''' + return libvlc_audio_set_track(self, i_track) + + def audio_get_channel(self): + '''Get current audio channel. + @return: the audio channel See libvlc_audio_output_channel_t. + ''' + return libvlc_audio_get_channel(self) + + def audio_set_channel(self, channel): + '''Set current audio channel. + @param channel: the audio channel, See libvlc_audio_output_channel_t. + @return: 0 on success, -1 on error. + ''' + return libvlc_audio_set_channel(self, channel) + + def audio_get_delay(self): + '''Get current audio delay. + @return: the audio delay (microseconds). + @version: LibVLC 1.1.1 or later. + ''' + return libvlc_audio_get_delay(self) + + def audio_set_delay(self, i_delay): + '''Set current audio delay. The audio delay will be reset to zero each time the media changes. + @param i_delay: the audio delay (microseconds). + @return: 0 on success, -1 on error. + @version: LibVLC 1.1.1 or later. + ''' + return libvlc_audio_set_delay(self, i_delay) + + + # LibVLC __version__ functions # + +def libvlc_errmsg(): + '''A human-readable error message for the last LibVLC error in the calling + thread. The resulting string is valid until another error occurs (at least + until the next LibVLC call). + @warning + This will be NULL if there was no error. + ''' + f = _Cfunctions.get('libvlc_errmsg', None) or \ + _Cfunction('libvlc_errmsg', (), None, + ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_errmsg + libvlc_errmsg = f + return f() + +def libvlc_clearerr(): + '''Clears the LibVLC error status for the current thread. This is optional. + By default, the error status is automatically overridden when a new error + occurs, and destroyed when the thread exits. + ''' + f = _Cfunctions.get('libvlc_clearerr', None) or \ + _Cfunction('libvlc_clearerr', (), None, + None) + if not __debug__: # i.e. python -O or -OO + global libvlc_clearerr + libvlc_clearerr = f + return f() + +def libvlc_new(argc, argv): + '''Create and initialize a libvlc instance. + This functions accept a list of "command line" arguments similar to the + main(). These arguments affect the LibVLC instance default configuration. + @param argc: the number of arguments (should be 0). + @param argv: list of arguments (should be NULL). + @return: the libvlc instance or NULL in case of error. + @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging. + ''' + f = _Cfunctions.get('libvlc_new', None) or \ + _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance), + ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p)) + if not __debug__: # i.e. python -O or -OO + global libvlc_new + libvlc_new = f + return f(argc, argv) + +def libvlc_release(p_instance): + '''Decrement the reference count of a libvlc instance, and destroy it + if it reaches zero. + @param p_instance: the instance to destroy. + ''' + f = _Cfunctions.get('libvlc_release', None) or \ + _Cfunction('libvlc_release', ((1,),), None, + None, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_release + libvlc_release = f + return f(p_instance) + +def libvlc_retain(p_instance): + '''Increments the reference count of a libvlc instance. + The initial reference count is 1 after L{libvlc_new}() returns. + @param p_instance: the instance to reference. + ''' + f = _Cfunctions.get('libvlc_retain', None) or \ + _Cfunction('libvlc_retain', ((1,),), None, + None, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_retain + libvlc_retain = f + return f(p_instance) + +def libvlc_add_intf(p_instance, name): + '''Try to start a user interface for the libvlc instance. + @param p_instance: the instance. + @param name: interface name, or NULL for default. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_add_intf', None) or \ + _Cfunction('libvlc_add_intf', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_add_intf + libvlc_add_intf = f + return f(p_instance, name) + +def libvlc_wait(p_instance): + '''Waits until an interface causes the instance to exit. + You should start at least one interface first, using L{libvlc_add_intf}(). + @param p_instance: the instance. + ''' + f = _Cfunctions.get('libvlc_wait', None) or \ + _Cfunction('libvlc_wait', ((1,),), None, + None, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_wait + libvlc_wait = f + return f(p_instance) + +def libvlc_set_user_agent(p_instance, name, http): + '''Sets the application name. LibVLC passes this as the user agent string + when a protocol requires it. + @param p_instance: LibVLC instance. + @param name: human-readable application name, e.g. "FooBar player 1.2.3". + @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0". + @version: LibVLC 1.1.1 or later. + ''' + f = _Cfunctions.get('libvlc_set_user_agent', None) or \ + _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), None, + None, Instance, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_set_user_agent + libvlc_set_user_agent = f + return f(p_instance, name, http) + +def libvlc_get_version(): + '''Retrieve libvlc version. + Example: "1.1.0-git The Luggage". + @return: a string containing the libvlc version. + ''' + f = _Cfunctions.get('libvlc_get_version', None) or \ + _Cfunction('libvlc_get_version', (), None, + ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_get_version + libvlc_get_version = f + return f() + +def libvlc_get_compiler(): + '''Retrieve libvlc compiler version. + Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)". + @return: a string containing the libvlc compiler version. + ''' + f = _Cfunctions.get('libvlc_get_compiler', None) or \ + _Cfunction('libvlc_get_compiler', (), None, + ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_get_compiler + libvlc_get_compiler = f + return f() + +def libvlc_get_changeset(): + '''Retrieve libvlc changeset. + Example: "aa9bce0bc4". + @return: a string containing the libvlc changeset. + ''' + f = _Cfunctions.get('libvlc_get_changeset', None) or \ + _Cfunction('libvlc_get_changeset', (), None, + ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_get_changeset + libvlc_get_changeset = f + return f() + +def libvlc_free(ptr): + '''Frees an heap allocation returned by a LibVLC function. + If you know you're using the same underlying C run-time as the LibVLC + implementation, then you can call ANSI C free() directly instead. + @param ptr: the pointer. + ''' + f = _Cfunctions.get('libvlc_free', None) or \ + _Cfunction('libvlc_free', ((1,),), None, + None, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_free + libvlc_free = f + return f(ptr) + +def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data): + '''Register for an event notification. + @param p_event_manager: the event manager to which you want to attach to. Generally it is obtained by vlc_my_object_event_manager() where my_object is the object you want to listen to. + @param i_event_type: the desired event to which we want to listen. + @param f_callback: the function to call when i_event_type occurs. + @param user_data: user provided data to carry with the event. + @return: 0 on success, ENOMEM on error. + ''' + f = _Cfunctions.get('libvlc_event_attach', None) or \ + _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), None, + ctypes.c_int, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_event_attach + libvlc_event_attach = f + return f(p_event_manager, i_event_type, f_callback, user_data) + +def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data): + '''Unregister an event notification. + @param p_event_manager: the event manager. + @param i_event_type: the desired event to which we want to unregister. + @param f_callback: the function to call when i_event_type occurs. + @param p_user_data: user provided data to carry with the event. + ''' + f = _Cfunctions.get('libvlc_event_detach', None) or \ + _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), None, + None, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_event_detach + libvlc_event_detach = f + return f(p_event_manager, i_event_type, f_callback, p_user_data) + +def libvlc_event_type_name(event_type): + '''Get an event's type name. + @param event_type: the desired event. + ''' + f = _Cfunctions.get('libvlc_event_type_name', None) or \ + _Cfunction('libvlc_event_type_name', ((1,),), None, + ctypes.c_char_p, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_event_type_name + libvlc_event_type_name = f + return f(event_type) + +def libvlc_get_log_verbosity(p_instance): + '''Always returns minus one. + This function is only provided for backward compatibility. + @param p_instance: ignored. + @return: always -1. + ''' + f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \ + _Cfunction('libvlc_get_log_verbosity', ((1,),), None, + ctypes.c_uint, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_get_log_verbosity + libvlc_get_log_verbosity = f + return f(p_instance) + +def libvlc_set_log_verbosity(p_instance, level): + '''This function does nothing. + It is only provided for backward compatibility. + @param p_instance: ignored. + @param level: ignored. + ''' + f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \ + _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None, + None, Instance, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_set_log_verbosity + libvlc_set_log_verbosity = f + return f(p_instance, level) + +def libvlc_log_open(p_instance): + '''This function does nothing useful. + It is only provided for backward compatibility. + @param p_instance: libvlc instance. + @return: an unique pointer or NULL on error. + ''' + f = _Cfunctions.get('libvlc_log_open', None) or \ + _Cfunction('libvlc_log_open', ((1,),), class_result(Log), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_open + libvlc_log_open = f + return f(p_instance) + +def libvlc_log_close(p_log): + '''Frees memory allocated by L{libvlc_log_open}(). + @param p_log: libvlc log instance or NULL. + ''' + f = _Cfunctions.get('libvlc_log_close', None) or \ + _Cfunction('libvlc_log_close', ((1,),), None, + None, Log) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_close + libvlc_log_close = f + return f(p_log) + +def libvlc_log_count(p_log): + '''Always returns zero. + This function is only provided for backward compatibility. + @param p_log: ignored. + @return: always zero. + ''' + f = _Cfunctions.get('libvlc_log_count', None) or \ + _Cfunction('libvlc_log_count', ((1,),), None, + ctypes.c_uint, Log) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_count + libvlc_log_count = f + return f(p_log) + +def libvlc_log_clear(p_log): + '''This function does nothing. + It is only provided for backward compatibility. + @param p_log: ignored. + ''' + f = _Cfunctions.get('libvlc_log_clear', None) or \ + _Cfunction('libvlc_log_clear', ((1,),), None, + None, Log) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_clear + libvlc_log_clear = f + return f(p_log) + +def libvlc_log_get_iterator(p_log): + '''This function does nothing useful. + It is only provided for backward compatibility. + @param p_log: ignored. + @return: an unique pointer or NULL on error or if the parameter was NULL. + ''' + f = _Cfunctions.get('libvlc_log_get_iterator', None) or \ + _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator), + ctypes.c_void_p, Log) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_get_iterator + libvlc_log_get_iterator = f + return f(p_log) + +def libvlc_log_iterator_free(p_iter): + '''Frees memory allocated by L{libvlc_log_get_iterator}(). + @param p_iter: libvlc log iterator or NULL. + ''' + f = _Cfunctions.get('libvlc_log_iterator_free', None) or \ + _Cfunction('libvlc_log_iterator_free', ((1,),), None, + None, LogIterator) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_iterator_free + libvlc_log_iterator_free = f + return f(p_iter) + +def libvlc_log_iterator_has_next(p_iter): + '''Always returns zero. + This function is only provided for backward compatibility. + @param p_iter: ignored. + @return: always zero. + ''' + f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \ + _Cfunction('libvlc_log_iterator_has_next', ((1,),), None, + ctypes.c_int, LogIterator) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_iterator_has_next + libvlc_log_iterator_has_next = f + return f(p_iter) + +def libvlc_log_iterator_next(p_iter, p_buffer): + '''Always returns NULL. + This function is only provided for backward compatibility. + @param p_iter: libvlc log iterator or NULL. + @param p_buffer: ignored. + @return: always NULL. + ''' + f = _Cfunctions.get('libvlc_log_iterator_next', None) or \ + _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None, + ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage)) + if not __debug__: # i.e. python -O or -OO + global libvlc_log_iterator_next + libvlc_log_iterator_next = f + return f(p_iter, p_buffer) + +def libvlc_module_description_list_release(p_list): + '''Release a list of module descriptions. + @param p_list: the list to be released. + ''' + f = _Cfunctions.get('libvlc_module_description_list_release', None) or \ + _Cfunction('libvlc_module_description_list_release', ((1,),), None, + None, ctypes.POINTER(ModuleDescription)) + if not __debug__: # i.e. python -O or -OO + global libvlc_module_description_list_release + libvlc_module_description_list_release = f + return f(p_list) + +def libvlc_audio_filter_list_get(p_instance): + '''Returns a list of audio filters that are available. + @param p_instance: libvlc instance. + @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. + ''' + f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \ + _Cfunction('libvlc_audio_filter_list_get', ((1,),), None, + ctypes.POINTER(ModuleDescription), Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_filter_list_get + libvlc_audio_filter_list_get = f + return f(p_instance) + +def libvlc_video_filter_list_get(p_instance): + '''Returns a list of video filters that are available. + @param p_instance: libvlc instance. + @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. + ''' + f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \ + _Cfunction('libvlc_video_filter_list_get', ((1,),), None, + ctypes.POINTER(ModuleDescription), Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_filter_list_get + libvlc_video_filter_list_get = f + return f(p_instance) + +def libvlc_clock(): + '''Return the current time as defined by LibVLC. The unit is the microsecond. + Time increases monotonically (regardless of time zone changes and RTC + adjustements). + The origin is arbitrary but consistent across the whole system + (e.g. the system uptim, the time since the system was booted). + @note: On systems that support it, the POSIX monotonic clock is used. + ''' + f = _Cfunctions.get('libvlc_clock', None) or \ + _Cfunction('libvlc_clock', (), None, + ctypes.c_int64) + if not __debug__: # i.e. python -O or -OO + global libvlc_clock + libvlc_clock = f + return f() + +def libvlc_media_new_location(p_instance, psz_mrl): + '''Create a media with a certain given media resource location, + for instance a valid URL. + @note: To refer to a local file with this function, + the file://... URI syntax B{must} be used (see IETF RFC3986). + We recommend using L{libvlc_media_new_path}() instead when dealing with + local files. + See L{libvlc_media_release}. + @param p_instance: the instance. + @param psz_mrl: the media location. + @return: the newly created media or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_new_location', None) or \ + _Cfunction('libvlc_media_new_location', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_new_location + libvlc_media_new_location = f + return f(p_instance, psz_mrl) + +def libvlc_media_new_path(p_instance, path): + '''Create a media for a certain file path. + See L{libvlc_media_release}. + @param p_instance: the instance. + @param path: local filesystem path. + @return: the newly created media or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_new_path', None) or \ + _Cfunction('libvlc_media_new_path', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_new_path + libvlc_media_new_path = f + return f(p_instance, path) + +def libvlc_media_new_fd(p_instance, fd): + '''Create a media for an already open file descriptor. + The file descriptor shall be open for reading (or reading and writing). + Regular file descriptors, pipe read descriptors and character device + descriptors (including TTYs) are supported on all platforms. + Block device descriptors are supported where available. + Directory descriptors are supported on systems that provide fdopendir(). + Sockets are supported on all platforms where they are file descriptors, + i.e. all except Windows. + @note: This library will B{not} automatically close the file descriptor + under any circumstance. Nevertheless, a file descriptor can usually only be + rendered once in a media player. To render it a second time, the file + descriptor should probably be rewound to the beginning with lseek(). + See L{libvlc_media_release}. + @param p_instance: the instance. + @param fd: open file descriptor. + @return: the newly created media or NULL on error. + @version: LibVLC 1.1.5 and later. + ''' + f = _Cfunctions.get('libvlc_media_new_fd', None) or \ + _Cfunction('libvlc_media_new_fd', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_new_fd + libvlc_media_new_fd = f + return f(p_instance, fd) + +def libvlc_media_new_as_node(p_instance, psz_name): + '''Create a media as an empty node with a given name. + See L{libvlc_media_release}. + @param p_instance: the instance. + @param psz_name: the name of the node. + @return: the new empty media or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_new_as_node', None) or \ + _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_new_as_node + libvlc_media_new_as_node = f + return f(p_instance, psz_name) + +def libvlc_media_add_option(p_md, ppsz_options): + '''Add an option to the media. + This option will be used to determine how the media_player will + read the media. This allows to use VLC's advanced + reading/streaming options on a per-media basis. + The options are detailed in vlc --long-help, for instance "--sout-all". + @param p_md: the media descriptor. + @param ppsz_options: the options (as a string). + ''' + f = _Cfunctions.get('libvlc_media_add_option', None) or \ + _Cfunction('libvlc_media_add_option', ((1,), (1,),), None, + None, Media, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_add_option + libvlc_media_add_option = f + return f(p_md, ppsz_options) + +def libvlc_media_add_option_flag(p_md, ppsz_options, i_flags): + '''Add an option to the media with configurable flags. + This option will be used to determine how the media_player will + read the media. This allows to use VLC's advanced + reading/streaming options on a per-media basis. + The options are detailed in vlc --long-help, for instance "--sout-all". + @param p_md: the media descriptor. + @param ppsz_options: the options (as a string). + @param i_flags: the flags for this option. + ''' + f = _Cfunctions.get('libvlc_media_add_option_flag', None) or \ + _Cfunction('libvlc_media_add_option_flag', ((1,), (1,), (1,),), None, + None, Media, ctypes.c_char_p, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_add_option_flag + libvlc_media_add_option_flag = f + return f(p_md, ppsz_options, i_flags) + +def libvlc_media_retain(p_md): + '''Retain a reference to a media descriptor object (libvlc_media_t). Use + L{libvlc_media_release}() to decrement the reference count of a + media descriptor object. + @param p_md: the media descriptor. + ''' + f = _Cfunctions.get('libvlc_media_retain', None) or \ + _Cfunction('libvlc_media_retain', ((1,),), None, + None, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_retain + libvlc_media_retain = f + return f(p_md) + +def libvlc_media_release(p_md): + '''Decrement the reference count of a media descriptor object. If the + reference count is 0, then L{libvlc_media_release}() will release the + media descriptor object. It will send out an libvlc_MediaFreed event + to all listeners. If the media descriptor object has been released it + should not be used again. + @param p_md: the media descriptor. + ''' + f = _Cfunctions.get('libvlc_media_release', None) or \ + _Cfunction('libvlc_media_release', ((1,),), None, + None, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_release + libvlc_media_release = f + return f(p_md) + +def libvlc_media_get_mrl(p_md): + '''Get the media resource locator (mrl) from a media descriptor object. + @param p_md: a media descriptor object. + @return: string with mrl of media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_get_mrl', None) or \ + _Cfunction('libvlc_media_get_mrl', ((1,),), string_result, + ctypes.c_void_p, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_mrl + libvlc_media_get_mrl = f + return f(p_md) + +def libvlc_media_duplicate(p_md): + '''Duplicate a media descriptor object. + @param p_md: a media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_duplicate', None) or \ + _Cfunction('libvlc_media_duplicate', ((1,),), class_result(Media), + ctypes.c_void_p, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_duplicate + libvlc_media_duplicate = f + return f(p_md) + +def libvlc_media_get_meta(p_md, e_meta): + '''Read the meta of the media. + If the media has not yet been parsed this will return NULL. + This methods automatically calls L{libvlc_media_parse_async}(), so after calling + it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous + version ensure that you call L{libvlc_media_parse}() before get_meta(). + See L{libvlc_media_parse} + See L{libvlc_media_parse_async} + See libvlc_MediaMetaChanged. + @param p_md: the media descriptor. + @param e_meta: the meta to read. + @return: the media's meta. + ''' + f = _Cfunctions.get('libvlc_media_get_meta', None) or \ + _Cfunction('libvlc_media_get_meta', ((1,), (1,),), string_result, + ctypes.c_void_p, Media, Meta) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_meta + libvlc_media_get_meta = f + return f(p_md, e_meta) + +def libvlc_media_set_meta(p_md, e_meta, psz_value): + '''Set the meta of the media (this function will not save the meta, call + L{libvlc_media_save_meta} in order to save the meta). + @param p_md: the media descriptor. + @param e_meta: the meta to write. + @param psz_value: the media's meta. + ''' + f = _Cfunctions.get('libvlc_media_set_meta', None) or \ + _Cfunction('libvlc_media_set_meta', ((1,), (1,), (1,),), None, + None, Media, Meta, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_set_meta + libvlc_media_set_meta = f + return f(p_md, e_meta, psz_value) + +def libvlc_media_save_meta(p_md): + '''Save the meta previously set. + @param p_md: the media desriptor. + @return: true if the write operation was successfull. + ''' + f = _Cfunctions.get('libvlc_media_save_meta', None) or \ + _Cfunction('libvlc_media_save_meta', ((1,),), None, + ctypes.c_int, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_save_meta + libvlc_media_save_meta = f + return f(p_md) + +def libvlc_media_get_state(p_md): + '''Get current state of media descriptor object. Possible media states + are defined in libvlc_structures.c ( libvlc_NothingSpecial=0, + libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, + libvlc_Stopped, libvlc_Ended, + libvlc_Error). + See libvlc_state_t. + @param p_md: a media descriptor object. + @return: state of media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_get_state', None) or \ + _Cfunction('libvlc_media_get_state', ((1,),), None, + State, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_state + libvlc_media_get_state = f + return f(p_md) + +def libvlc_media_get_stats(p_md, p_stats): + '''Get the current statistics about the media. + @param p_md:: media descriptor object. + @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). + @return: true if the statistics are available, false otherwise \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_get_stats', None) or \ + _Cfunction('libvlc_media_get_stats', ((1,), (1,),), None, + ctypes.c_int, Media, ctypes.POINTER(MediaStats)) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_stats + libvlc_media_get_stats = f + return f(p_md, p_stats) + +def libvlc_media_event_manager(p_md): + '''Get event manager from media descriptor object. + NOTE: this function doesn't increment reference counting. + @param p_md: a media descriptor object. + @return: event manager object. + ''' + f = _Cfunctions.get('libvlc_media_event_manager', None) or \ + _Cfunction('libvlc_media_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_event_manager + libvlc_media_event_manager = f + return f(p_md) + +def libvlc_media_get_duration(p_md): + '''Get duration (in ms) of media descriptor object item. + @param p_md: media descriptor object. + @return: duration of media item or -1 on error. + ''' + f = _Cfunctions.get('libvlc_media_get_duration', None) or \ + _Cfunction('libvlc_media_get_duration', ((1,),), None, + ctypes.c_longlong, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_duration + libvlc_media_get_duration = f + return f(p_md) + +def libvlc_media_parse(p_md): + '''Parse a media. + This fetches (local) meta data and tracks information. + The method is synchronous. + See L{libvlc_media_parse_async} + See L{libvlc_media_get_meta} + See L{libvlc_media_get_tracks_info}. + @param p_md: media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_parse', None) or \ + _Cfunction('libvlc_media_parse', ((1,),), None, + None, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_parse + libvlc_media_parse = f + return f(p_md) + +def libvlc_media_parse_async(p_md): + '''Parse a media. + This fetches (local) meta data and tracks information. + The method is the asynchronous of L{libvlc_media_parse}(). + To track when this is over you can listen to libvlc_MediaParsedChanged + event. However if the media was already parsed you will not receive this + event. + See L{libvlc_media_parse} + See libvlc_MediaParsedChanged + See L{libvlc_media_get_meta} + See L{libvlc_media_get_tracks_info}. + @param p_md: media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_parse_async', None) or \ + _Cfunction('libvlc_media_parse_async', ((1,),), None, + None, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_parse_async + libvlc_media_parse_async = f + return f(p_md) + +def libvlc_media_is_parsed(p_md): + '''Get Parsed status for media descriptor object. + See libvlc_MediaParsedChanged. + @param p_md: media descriptor object. + @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_is_parsed', None) or \ + _Cfunction('libvlc_media_is_parsed', ((1,),), None, + ctypes.c_int, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_is_parsed + libvlc_media_is_parsed = f + return f(p_md) + +def libvlc_media_set_user_data(p_md, p_new_user_data): + '''Sets media descriptor's user_data. user_data is specialized data + accessed by the host application, VLC.framework uses it as a pointer to + an native object that references a L{Media} pointer. + @param p_md: media descriptor object. + @param p_new_user_data: pointer to user data. + ''' + f = _Cfunctions.get('libvlc_media_set_user_data', None) or \ + _Cfunction('libvlc_media_set_user_data', ((1,), (1,),), None, + None, Media, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_set_user_data + libvlc_media_set_user_data = f + return f(p_md, p_new_user_data) + +def libvlc_media_get_user_data(p_md): + '''Get media descriptor's user_data. user_data is specialized data + accessed by the host application, VLC.framework uses it as a pointer to + an native object that references a L{Media} pointer. + @param p_md: media descriptor object. + ''' + f = _Cfunctions.get('libvlc_media_get_user_data', None) or \ + _Cfunction('libvlc_media_get_user_data', ((1,),), None, + ctypes.c_void_p, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_user_data + libvlc_media_get_user_data = f + return f(p_md) + +def libvlc_media_get_tracks_info(p_md): + '''Get media descriptor's elementary streams description + Note, you need to call L{libvlc_media_parse}() or play the media at least once + before calling this function. + Not doing this will result in an empty array. + @param p_md: media descriptor object. + @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller). + @return: the number of Elementary Streams. + ''' + f = _Cfunctions.get('libvlc_media_get_tracks_info', None) or \ + _Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), None, + ctypes.c_int, Media, ctypes.POINTER(ctypes.c_void_p)) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_get_tracks_info + libvlc_media_get_tracks_info = f + return f(p_md) + +def libvlc_media_discoverer_new_from_name(p_inst, psz_name): + '''Discover media service by name. + @param p_inst: libvlc instance. + @param psz_name: service name. + @return: media discover object or NULL in case of error. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \ + _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer), + ctypes.c_void_p, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_new_from_name + libvlc_media_discoverer_new_from_name = f + return f(p_inst, psz_name) + +def libvlc_media_discoverer_release(p_mdis): + '''Release media discover object. If the reference count reaches 0, then + the object will be released. + @param p_mdis: media service discover object. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \ + _Cfunction('libvlc_media_discoverer_release', ((1,),), None, + None, MediaDiscoverer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_release + libvlc_media_discoverer_release = f + return f(p_mdis) + +def libvlc_media_discoverer_localized_name(p_mdis): + '''Get media service discover object its localized name. + @param p_mdis: media discover object. + @return: localized name. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_localized_name', None) or \ + _Cfunction('libvlc_media_discoverer_localized_name', ((1,),), string_result, + ctypes.c_void_p, MediaDiscoverer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_localized_name + libvlc_media_discoverer_localized_name = f + return f(p_mdis) + +def libvlc_media_discoverer_media_list(p_mdis): + '''Get media service discover media list. + @param p_mdis: media service discover object. + @return: list of media items. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \ + _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList), + ctypes.c_void_p, MediaDiscoverer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_media_list + libvlc_media_discoverer_media_list = f + return f(p_mdis) + +def libvlc_media_discoverer_event_manager(p_mdis): + '''Get event manager from media service discover object. + @param p_mdis: media service discover object. + @return: event manager object. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_event_manager', None) or \ + _Cfunction('libvlc_media_discoverer_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaDiscoverer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_event_manager + libvlc_media_discoverer_event_manager = f + return f(p_mdis) + +def libvlc_media_discoverer_is_running(p_mdis): + '''Query if media service discover object is running. + @param p_mdis: media service discover object. + @return: true if running, false if not \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \ + _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None, + ctypes.c_int, MediaDiscoverer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_discoverer_is_running + libvlc_media_discoverer_is_running = f + return f(p_mdis) + +def libvlc_media_library_new(p_instance): + '''Create an new Media Library object. + @param p_instance: the libvlc instance. + @return: a new object or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_library_new', None) or \ + _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_library_new + libvlc_media_library_new = f + return f(p_instance) + +def libvlc_media_library_release(p_mlib): + '''Release media library object. This functions decrements the + reference count of the media library object. If it reaches 0, + then the object will be released. + @param p_mlib: media library object. + ''' + f = _Cfunctions.get('libvlc_media_library_release', None) or \ + _Cfunction('libvlc_media_library_release', ((1,),), None, + None, MediaLibrary) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_library_release + libvlc_media_library_release = f + return f(p_mlib) + +def libvlc_media_library_retain(p_mlib): + '''Retain a reference to a media library object. This function will + increment the reference counting for this object. Use + L{libvlc_media_library_release}() to decrement the reference count. + @param p_mlib: media library object. + ''' + f = _Cfunctions.get('libvlc_media_library_retain', None) or \ + _Cfunction('libvlc_media_library_retain', ((1,),), None, + None, MediaLibrary) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_library_retain + libvlc_media_library_retain = f + return f(p_mlib) + +def libvlc_media_library_load(p_mlib): + '''Load media library. + @param p_mlib: media library object. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_media_library_load', None) or \ + _Cfunction('libvlc_media_library_load', ((1,),), None, + ctypes.c_int, MediaLibrary) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_library_load + libvlc_media_library_load = f + return f(p_mlib) + +def libvlc_media_library_media_list(p_mlib): + '''Get media library subitems. + @param p_mlib: media library object. + @return: media list subitems. + ''' + f = _Cfunctions.get('libvlc_media_library_media_list', None) or \ + _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList), + ctypes.c_void_p, MediaLibrary) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_library_media_list + libvlc_media_library_media_list = f + return f(p_mlib) + +def libvlc_media_list_new(p_instance): + '''Create an empty media list. + @param p_instance: libvlc instance. + @return: empty media list, or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_list_new', None) or \ + _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_new + libvlc_media_list_new = f + return f(p_instance) + +def libvlc_media_list_release(p_ml): + '''Release media list created with L{libvlc_media_list_new}(). + @param p_ml: a media list created with L{libvlc_media_list_new}(). + ''' + f = _Cfunctions.get('libvlc_media_list_release', None) or \ + _Cfunction('libvlc_media_list_release', ((1,),), None, + None, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_release + libvlc_media_list_release = f + return f(p_ml) + +def libvlc_media_list_retain(p_ml): + '''Retain reference to a media list. + @param p_ml: a media list created with L{libvlc_media_list_new}(). + ''' + f = _Cfunctions.get('libvlc_media_list_retain', None) or \ + _Cfunction('libvlc_media_list_retain', ((1,),), None, + None, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_retain + libvlc_media_list_retain = f + return f(p_ml) + +def libvlc_media_list_set_media(p_ml, p_md): + '''Associate media instance with this media list instance. + If another media instance was present it will be released. + The L{libvlc_media_list_lock} should NOT be held upon entering this function. + @param p_ml: a media list instance. + @param p_md: media instance to add. + ''' + f = _Cfunctions.get('libvlc_media_list_set_media', None) or \ + _Cfunction('libvlc_media_list_set_media', ((1,), (1,),), None, + None, MediaList, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_set_media + libvlc_media_list_set_media = f + return f(p_ml, p_md) + +def libvlc_media_list_media(p_ml): + '''Get media instance from this media list instance. This action will increase + the refcount on the media instance. + The L{libvlc_media_list_lock} should NOT be held upon entering this function. + @param p_ml: a media list instance. + @return: media instance. + ''' + f = _Cfunctions.get('libvlc_media_list_media', None) or \ + _Cfunction('libvlc_media_list_media', ((1,),), class_result(Media), + ctypes.c_void_p, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_media + libvlc_media_list_media = f + return f(p_ml) + +def libvlc_media_list_add_media(p_ml, p_md): + '''Add media instance to media list + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @param p_md: a media instance. + @return: 0 on success, -1 if the media list is read-only. + ''' + f = _Cfunctions.get('libvlc_media_list_add_media', None) or \ + _Cfunction('libvlc_media_list_add_media', ((1,), (1,),), None, + ctypes.c_int, MediaList, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_add_media + libvlc_media_list_add_media = f + return f(p_ml, p_md) + +def libvlc_media_list_insert_media(p_ml, p_md, i_pos): + '''Insert media instance in media list on a position + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @param p_md: a media instance. + @param i_pos: position in array where to insert. + @return: 0 on success, -1 if the media list is read-only. + ''' + f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \ + _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None, + ctypes.c_int, MediaList, Media, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_insert_media + libvlc_media_list_insert_media = f + return f(p_ml, p_md, i_pos) + +def libvlc_media_list_remove_index(p_ml, i_pos): + '''Remove media instance from media list on a position + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @param i_pos: position in array where to insert. + @return: 0 on success, -1 if the list is read-only or the item was not found. + ''' + f = _Cfunctions.get('libvlc_media_list_remove_index', None) or \ + _Cfunction('libvlc_media_list_remove_index', ((1,), (1,),), None, + ctypes.c_int, MediaList, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_remove_index + libvlc_media_list_remove_index = f + return f(p_ml, i_pos) + +def libvlc_media_list_count(p_ml): + '''Get count on media list items + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @return: number of items in media list. + ''' + f = _Cfunctions.get('libvlc_media_list_count', None) or \ + _Cfunction('libvlc_media_list_count', ((1,),), None, + ctypes.c_int, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_count + libvlc_media_list_count = f + return f(p_ml) + +def libvlc_media_list_item_at_index(p_ml, i_pos): + '''List media instance in media list at a position + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @param i_pos: position in array where to insert. + @return: media instance at position i_pos, or NULL if not found. In case of success, L{libvlc_media_retain}() is called to increase the refcount on the media. + ''' + f = _Cfunctions.get('libvlc_media_list_item_at_index', None) or \ + _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, MediaList, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_item_at_index + libvlc_media_list_item_at_index = f + return f(p_ml, i_pos) + +def libvlc_media_list_index_of_item(p_ml, p_md): + '''Find index position of List media instance in media list. + Warning: the function will return the first matched position. + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + @param p_md: media instance. + @return: position of media instance or -1 if media not found. + ''' + f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \ + _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None, + ctypes.c_int, MediaList, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_index_of_item + libvlc_media_list_index_of_item = f + return f(p_ml, p_md) + +def libvlc_media_list_is_readonly(p_ml): + '''This indicates if this media list is read-only from a user point of view. + @param p_ml: media list instance. + @return: 1 on readonly, 0 on readwrite \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \ + _Cfunction('libvlc_media_list_is_readonly', ((1,),), None, + ctypes.c_int, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_is_readonly + libvlc_media_list_is_readonly = f + return f(p_ml) + +def libvlc_media_list_lock(p_ml): + '''Get lock on media list items. + @param p_ml: a media list instance. + ''' + f = _Cfunctions.get('libvlc_media_list_lock', None) or \ + _Cfunction('libvlc_media_list_lock', ((1,),), None, + None, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_lock + libvlc_media_list_lock = f + return f(p_ml) + +def libvlc_media_list_unlock(p_ml): + '''Release lock on media list items + The L{libvlc_media_list_lock} should be held upon entering this function. + @param p_ml: a media list instance. + ''' + f = _Cfunctions.get('libvlc_media_list_unlock', None) or \ + _Cfunction('libvlc_media_list_unlock', ((1,),), None, + None, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_unlock + libvlc_media_list_unlock = f + return f(p_ml) + +def libvlc_media_list_event_manager(p_ml): + '''Get libvlc_event_manager from this media list instance. + The p_event_manager is immutable, so you don't have to hold the lock. + @param p_ml: a media list instance. + @return: libvlc_event_manager. + ''' + f = _Cfunctions.get('libvlc_media_list_event_manager', None) or \ + _Cfunction('libvlc_media_list_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_event_manager + libvlc_media_list_event_manager = f + return f(p_ml) + +def libvlc_media_list_player_new(p_instance): + '''Create new media_list_player. + @param p_instance: libvlc instance. + @return: media list player instance or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_list_player_new', None) or \ + _Cfunction('libvlc_media_list_player_new', ((1,),), class_result(MediaListPlayer), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_new + libvlc_media_list_player_new = f + return f(p_instance) + +def libvlc_media_list_player_release(p_mlp): + '''Release a media_list_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{libvlc_media_list_player_release}() will + release the media player object. If the media player object + has been released, then it should not be used again. + @param p_mlp: media list player instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_release', None) or \ + _Cfunction('libvlc_media_list_player_release', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_release + libvlc_media_list_player_release = f + return f(p_mlp) + +def libvlc_media_list_player_retain(p_mlp): + '''Retain a reference to a media player list object. Use + L{libvlc_media_list_player_release}() to decrement reference count. + @param p_mlp: media player list object. + ''' + f = _Cfunctions.get('libvlc_media_list_player_retain', None) or \ + _Cfunction('libvlc_media_list_player_retain', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_retain + libvlc_media_list_player_retain = f + return f(p_mlp) + +def libvlc_media_list_player_event_manager(p_mlp): + '''Return the event manager of this media_list_player. + @param p_mlp: media list player instance. + @return: the event manager. + ''' + f = _Cfunctions.get('libvlc_media_list_player_event_manager', None) or \ + _Cfunction('libvlc_media_list_player_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_event_manager + libvlc_media_list_player_event_manager = f + return f(p_mlp) + +def libvlc_media_list_player_set_media_player(p_mlp, p_mi): + '''Replace media player in media_list_player with this instance. + @param p_mlp: media list player instance. + @param p_mi: media player instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_set_media_player', None) or \ + _Cfunction('libvlc_media_list_player_set_media_player', ((1,), (1,),), None, + None, MediaListPlayer, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_set_media_player + libvlc_media_list_player_set_media_player = f + return f(p_mlp, p_mi) + +def libvlc_media_list_player_set_media_list(p_mlp, p_mlist): + '''Set the media list associated with the player. + @param p_mlp: media list player instance. + @param p_mlist: list of media. + ''' + f = _Cfunctions.get('libvlc_media_list_player_set_media_list', None) or \ + _Cfunction('libvlc_media_list_player_set_media_list', ((1,), (1,),), None, + None, MediaListPlayer, MediaList) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_set_media_list + libvlc_media_list_player_set_media_list = f + return f(p_mlp, p_mlist) + +def libvlc_media_list_player_play(p_mlp): + '''Play media list. + @param p_mlp: media list player instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_play', None) or \ + _Cfunction('libvlc_media_list_player_play', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_play + libvlc_media_list_player_play = f + return f(p_mlp) + +def libvlc_media_list_player_pause(p_mlp): + '''Pause media list. + @param p_mlp: media list player instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \ + _Cfunction('libvlc_media_list_player_pause', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_pause + libvlc_media_list_player_pause = f + return f(p_mlp) + +def libvlc_media_list_player_is_playing(p_mlp): + '''Is media list playing? + @param p_mlp: media list player instance. + @return: true for playing and false for not playing \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \ + _Cfunction('libvlc_media_list_player_is_playing', ((1,),), None, + ctypes.c_int, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_is_playing + libvlc_media_list_player_is_playing = f + return f(p_mlp) + +def libvlc_media_list_player_get_state(p_mlp): + '''Get current libvlc_state of media list player. + @param p_mlp: media list player instance. + @return: libvlc_state_t for media list player. + ''' + f = _Cfunctions.get('libvlc_media_list_player_get_state', None) or \ + _Cfunction('libvlc_media_list_player_get_state', ((1,),), None, + State, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_get_state + libvlc_media_list_player_get_state = f + return f(p_mlp) + +def libvlc_media_list_player_play_item_at_index(p_mlp, i_index): + '''Play media list item at position index. + @param p_mlp: media list player instance. + @param i_index: index in media list to play. + @return: 0 upon success -1 if the item wasn't found. + ''' + f = _Cfunctions.get('libvlc_media_list_player_play_item_at_index', None) or \ + _Cfunction('libvlc_media_list_player_play_item_at_index', ((1,), (1,),), None, + ctypes.c_int, MediaListPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_play_item_at_index + libvlc_media_list_player_play_item_at_index = f + return f(p_mlp, i_index) + +def libvlc_media_list_player_play_item(p_mlp, p_md): + '''Play the given media item. + @param p_mlp: media list player instance. + @param p_md: the media instance. + @return: 0 upon success, -1 if the media is not part of the media list. + ''' + f = _Cfunctions.get('libvlc_media_list_player_play_item', None) or \ + _Cfunction('libvlc_media_list_player_play_item', ((1,), (1,),), None, + ctypes.c_int, MediaListPlayer, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_play_item + libvlc_media_list_player_play_item = f + return f(p_mlp, p_md) + +def libvlc_media_list_player_stop(p_mlp): + '''Stop playing media list. + @param p_mlp: media list player instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_stop', None) or \ + _Cfunction('libvlc_media_list_player_stop', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_stop + libvlc_media_list_player_stop = f + return f(p_mlp) + +def libvlc_media_list_player_next(p_mlp): + '''Play next item from media list. + @param p_mlp: media list player instance. + @return: 0 upon success -1 if there is no next item. + ''' + f = _Cfunctions.get('libvlc_media_list_player_next', None) or \ + _Cfunction('libvlc_media_list_player_next', ((1,),), None, + ctypes.c_int, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_next + libvlc_media_list_player_next = f + return f(p_mlp) + +def libvlc_media_list_player_previous(p_mlp): + '''Play previous item from media list. + @param p_mlp: media list player instance. + @return: 0 upon success -1 if there is no previous item. + ''' + f = _Cfunctions.get('libvlc_media_list_player_previous', None) or \ + _Cfunction('libvlc_media_list_player_previous', ((1,),), None, + ctypes.c_int, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_previous + libvlc_media_list_player_previous = f + return f(p_mlp) + +def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode): + '''Sets the playback mode for the playlist. + @param p_mlp: media list player instance. + @param e_mode: playback mode specification. + ''' + f = _Cfunctions.get('libvlc_media_list_player_set_playback_mode', None) or \ + _Cfunction('libvlc_media_list_player_set_playback_mode', ((1,), (1,),), None, + None, MediaListPlayer, PlaybackMode) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_set_playback_mode + libvlc_media_list_player_set_playback_mode = f + return f(p_mlp, e_mode) + +def libvlc_media_player_new(p_libvlc_instance): + '''Create an empty Media Player object. + @param p_libvlc_instance: the libvlc instance in which the Media Player should be created. + @return: a new media player object, or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_player_new', None) or \ + _Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_new + libvlc_media_player_new = f + return f(p_libvlc_instance) + +def libvlc_media_player_new_from_media(p_md): + '''Create a Media Player object from a Media. + @param p_md: the media. Afterwards the p_md can be safely destroyed. + @return: a new media player object, or NULL on error. + ''' + f = _Cfunctions.get('libvlc_media_player_new_from_media', None) or \ + _Cfunction('libvlc_media_player_new_from_media', ((1,),), class_result(MediaPlayer), + ctypes.c_void_p, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_new_from_media + libvlc_media_player_new_from_media = f + return f(p_md) + +def libvlc_media_player_release(p_mi): + '''Release a media_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{libvlc_media_player_release}() will + release the media player object. If the media player object + has been released, then it should not be used again. + @param p_mi: the Media Player to free. + ''' + f = _Cfunctions.get('libvlc_media_player_release', None) or \ + _Cfunction('libvlc_media_player_release', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_release + libvlc_media_player_release = f + return f(p_mi) + +def libvlc_media_player_retain(p_mi): + '''Retain a reference to a media player object. Use + L{libvlc_media_player_release}() to decrement reference count. + @param p_mi: media player object. + ''' + f = _Cfunctions.get('libvlc_media_player_retain', None) or \ + _Cfunction('libvlc_media_player_retain', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_retain + libvlc_media_player_retain = f + return f(p_mi) + +def libvlc_media_player_set_media(p_mi, p_md): + '''Set the media that will be used by the media_player. If any, + previous md will be released. + @param p_mi: the Media Player. + @param p_md: the Media. Afterwards the p_md can be safely destroyed. + ''' + f = _Cfunctions.get('libvlc_media_player_set_media', None) or \ + _Cfunction('libvlc_media_player_set_media', ((1,), (1,),), None, + None, MediaPlayer, Media) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_media + libvlc_media_player_set_media = f + return f(p_mi, p_md) + +def libvlc_media_player_get_media(p_mi): + '''Get the media used by the media_player. + @param p_mi: the Media Player. + @return: the media associated with p_mi, or NULL if no media is associated. + ''' + f = _Cfunctions.get('libvlc_media_player_get_media', None) or \ + _Cfunction('libvlc_media_player_get_media', ((1,),), class_result(Media), + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_media + libvlc_media_player_get_media = f + return f(p_mi) + +def libvlc_media_player_event_manager(p_mi): + '''Get the Event Manager from which the media player send event. + @param p_mi: the Media Player. + @return: the event manager associated with p_mi. + ''' + f = _Cfunctions.get('libvlc_media_player_event_manager', None) or \ + _Cfunction('libvlc_media_player_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_event_manager + libvlc_media_player_event_manager = f + return f(p_mi) + +def libvlc_media_player_is_playing(p_mi): + '''is_playing. + @param p_mi: the Media Player. + @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \ + _Cfunction('libvlc_media_player_is_playing', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_is_playing + libvlc_media_player_is_playing = f + return f(p_mi) + +def libvlc_media_player_play(p_mi): + '''Play. + @param p_mi: the Media Player. + @return: 0 if playback started (and was already started), or -1 on error. + ''' + f = _Cfunctions.get('libvlc_media_player_play', None) or \ + _Cfunction('libvlc_media_player_play', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_play + libvlc_media_player_play = f + return f(p_mi) + +def libvlc_media_player_set_pause(mp, do_pause): + '''Pause or resume (no effect if there is no media). + @param mp: the Media Player. + @param do_pause: play/resume if zero, pause if non-zero. + @version: LibVLC 1.1.1 or later. + ''' + f = _Cfunctions.get('libvlc_media_player_set_pause', None) or \ + _Cfunction('libvlc_media_player_set_pause', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_pause + libvlc_media_player_set_pause = f + return f(mp, do_pause) + +def libvlc_media_player_pause(p_mi): + '''Toggle pause (no effect if there is no media). + @param p_mi: the Media Player. + ''' + f = _Cfunctions.get('libvlc_media_player_pause', None) or \ + _Cfunction('libvlc_media_player_pause', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_pause + libvlc_media_player_pause = f + return f(p_mi) + +def libvlc_media_player_stop(p_mi): + '''Stop (no effect if there is no media). + @param p_mi: the Media Player. + ''' + f = _Cfunctions.get('libvlc_media_player_stop', None) or \ + _Cfunction('libvlc_media_player_stop', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_stop + libvlc_media_player_stop = f + return f(p_mi) + +def libvlc_video_set_format(mp, chroma, width, height, pitch): + '''Set decoded video chroma and dimensions. + This only works in combination with libvlc_video_set_callbacks(), + and is mutually exclusive with libvlc_video_set_format_callbacks(). + @param mp: the media player. + @param chroma: a four-characters string identifying the chroma (e.g. "RV32" or "YUYV"). + @param width: pixel width. + @param height: pixel height. + @param pitch: line pitch (in bytes). + @version: LibVLC 1.1.1 or later. + @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using libvlc_video_set_format_callbacks() instead. + ''' + f = _Cfunctions.get('libvlc_video_set_format', None) or \ + _Cfunction('libvlc_video_set_format', ((1,), (1,), (1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_format + libvlc_video_set_format = f + return f(mp, chroma, width, height, pitch) + +def libvlc_media_player_set_nsobject(p_mi, drawable): + '''Set the NSView handler where the media player should render its video output. + Use the vout called "macosx". + The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding + protocol: + @begincode + \@protocol VLCOpenGLVideoViewEmbedding + - (void)addVoutSubview:(NSView *)view; + - (void)removeVoutSubview:(NSView *)view; + \@end + @endcode + Or it can be an NSView object. + If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then + the following code should work: + @begincode + + NSView *video = [[NSView alloc] init]; + QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); + L{libvlc_media_player_set_nsobject}(mp, video); + [video release]; + + @endcode + You can find a live example in VLCVideoView in VLCKit.framework. + @param p_mi: the Media Player. + @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. + ''' + f = _Cfunctions.get('libvlc_media_player_set_nsobject', None) or \ + _Cfunction('libvlc_media_player_set_nsobject', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_nsobject + libvlc_media_player_set_nsobject = f + return f(p_mi, drawable) + +def libvlc_media_player_get_nsobject(p_mi): + '''Get the NSView handler previously set with L{libvlc_media_player_set_nsobject}(). + @param p_mi: the Media Player. + @return: the NSView handler or 0 if none where set. + ''' + f = _Cfunctions.get('libvlc_media_player_get_nsobject', None) or \ + _Cfunction('libvlc_media_player_get_nsobject', ((1,),), None, + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_nsobject + libvlc_media_player_get_nsobject = f + return f(p_mi) + +def libvlc_media_player_set_agl(p_mi, drawable): + '''Set the agl handler where the media player should render its video output. + @param p_mi: the Media Player. + @param drawable: the agl handler. + ''' + f = _Cfunctions.get('libvlc_media_player_set_agl', None) or \ + _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint32) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_agl + libvlc_media_player_set_agl = f + return f(p_mi, drawable) + +def libvlc_media_player_get_agl(p_mi): + '''Get the agl handler previously set with L{libvlc_media_player_set_agl}(). + @param p_mi: the Media Player. + @return: the agl handler or 0 if none where set. + ''' + f = _Cfunctions.get('libvlc_media_player_get_agl', None) or \ + _Cfunction('libvlc_media_player_get_agl', ((1,),), None, + ctypes.c_uint32, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_agl + libvlc_media_player_get_agl = f + return f(p_mi) + +def libvlc_media_player_set_xwindow(p_mi, drawable): + '''Set an X Window System drawable where the media player should render its + video output. If LibVLC was built without X11 output support, then this has + no effects. + The specified identifier must correspond to an existing Input/Output class + X11 window. Pixmaps are B{not} supported. The caller shall ensure that + the X11 server is the same as the one the VLC instance has been configured + with. This function must be called before video playback is started; + otherwise it will only take effect after playback stop and restart. + @param p_mi: the Media Player. + @param drawable: the ID of the X window. + ''' + f = _Cfunctions.get('libvlc_media_player_set_xwindow', None) or \ + _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint32) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_xwindow + libvlc_media_player_set_xwindow = f + return f(p_mi, drawable) + +def libvlc_media_player_get_xwindow(p_mi): + '''Get the X Window System window identifier previously set with + L{libvlc_media_player_set_xwindow}(). Note that this will return the identifier + even if VLC is not currently using it (for instance if it is playing an + audio-only input). + @param p_mi: the Media Player. + @return: an X window ID, or 0 if none where set. + ''' + f = _Cfunctions.get('libvlc_media_player_get_xwindow', None) or \ + _Cfunction('libvlc_media_player_get_xwindow', ((1,),), None, + ctypes.c_uint32, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_xwindow + libvlc_media_player_get_xwindow = f + return f(p_mi) + +def libvlc_media_player_set_hwnd(p_mi, drawable): + '''Set a Win32/Win64 API window handle (HWND) where the media player should + render its video output. If LibVLC was built without Win32/Win64 API output + support, then this has no effects. + @param p_mi: the Media Player. + @param drawable: windows handle of the drawable. + ''' + f = _Cfunctions.get('libvlc_media_player_set_hwnd', None) or \ + _Cfunction('libvlc_media_player_set_hwnd', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_void_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_hwnd + libvlc_media_player_set_hwnd = f + return f(p_mi, drawable) + +def libvlc_media_player_get_hwnd(p_mi): + '''Get the Windows API window handle (HWND) previously set with + L{libvlc_media_player_set_hwnd}(). The handle will be returned even if LibVLC + is not currently outputting any video to it. + @param p_mi: the Media Player. + @return: a window handle or NULL if there are none. + ''' + f = _Cfunctions.get('libvlc_media_player_get_hwnd', None) or \ + _Cfunction('libvlc_media_player_get_hwnd', ((1,),), None, + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_hwnd + libvlc_media_player_get_hwnd = f + return f(p_mi) + +def libvlc_audio_set_format(mp, format, rate, channels): + '''Set decoded audio format. + This only works in combination with libvlc_audio_set_callbacks(), + and is mutually exclusive with libvlc_audio_set_format_callbacks(). + @param mp: the media player. + @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param rate: sample rate (expressed in Hz). + @param channels: channels count. + @version: LibVLC 1.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_set_format', None) or \ + _Cfunction('libvlc_audio_set_format', ((1,), (1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_format + libvlc_audio_set_format = f + return f(mp, format, rate, channels) + +def libvlc_media_player_get_length(p_mi): + '''Get the current movie length (in ms). + @param p_mi: the Media Player. + @return: the movie length (in ms), or -1 if there is no media. + ''' + f = _Cfunctions.get('libvlc_media_player_get_length', None) or \ + _Cfunction('libvlc_media_player_get_length', ((1,),), None, + ctypes.c_longlong, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_length + libvlc_media_player_get_length = f + return f(p_mi) + +def libvlc_media_player_get_time(p_mi): + '''Get the current movie time (in ms). + @param p_mi: the Media Player. + @return: the movie time (in ms), or -1 if there is no media. + ''' + f = _Cfunctions.get('libvlc_media_player_get_time', None) or \ + _Cfunction('libvlc_media_player_get_time', ((1,),), None, + ctypes.c_longlong, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_time + libvlc_media_player_get_time = f + return f(p_mi) + +def libvlc_media_player_set_time(p_mi, i_time): + '''Set the movie time (in ms). This has no effect if no media is being played. + Not all formats and protocols support this. + @param p_mi: the Media Player. + @param i_time: the movie time (in ms). + ''' + f = _Cfunctions.get('libvlc_media_player_set_time', None) or \ + _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_longlong) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_time + libvlc_media_player_set_time = f + return f(p_mi, i_time) + +def libvlc_media_player_get_position(p_mi): + '''Get movie position. + @param p_mi: the Media Player. + @return: movie position, or -1. in case of error. + ''' + f = _Cfunctions.get('libvlc_media_player_get_position', None) or \ + _Cfunction('libvlc_media_player_get_position', ((1,),), None, + ctypes.c_float, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_position + libvlc_media_player_get_position = f + return f(p_mi) + +def libvlc_media_player_set_position(p_mi, f_pos): + '''Set movie position. This has no effect if playback is not enabled. + This might not work depending on the underlying input format and protocol. + @param p_mi: the Media Player. + @param f_pos: the position. + ''' + f = _Cfunctions.get('libvlc_media_player_set_position', None) or \ + _Cfunction('libvlc_media_player_set_position', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_float) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_position + libvlc_media_player_set_position = f + return f(p_mi, f_pos) + +def libvlc_media_player_set_chapter(p_mi, i_chapter): + '''Set movie chapter (if applicable). + @param p_mi: the Media Player. + @param i_chapter: chapter number to play. + ''' + f = _Cfunctions.get('libvlc_media_player_set_chapter', None) or \ + _Cfunction('libvlc_media_player_set_chapter', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_chapter + libvlc_media_player_set_chapter = f + return f(p_mi, i_chapter) + +def libvlc_media_player_get_chapter(p_mi): + '''Get movie chapter. + @param p_mi: the Media Player. + @return: chapter number currently playing, or -1 if there is no media. + ''' + f = _Cfunctions.get('libvlc_media_player_get_chapter', None) or \ + _Cfunction('libvlc_media_player_get_chapter', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_chapter + libvlc_media_player_get_chapter = f + return f(p_mi) + +def libvlc_media_player_get_chapter_count(p_mi): + '''Get movie chapter count. + @param p_mi: the Media Player. + @return: number of chapters in movie, or -1. + ''' + f = _Cfunctions.get('libvlc_media_player_get_chapter_count', None) or \ + _Cfunction('libvlc_media_player_get_chapter_count', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_chapter_count + libvlc_media_player_get_chapter_count = f + return f(p_mi) + +def libvlc_media_player_will_play(p_mi): + '''Is the player able to play. + @param p_mi: the Media Player. + @return: boolean \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_player_will_play', None) or \ + _Cfunction('libvlc_media_player_will_play', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_will_play + libvlc_media_player_will_play = f + return f(p_mi) + +def libvlc_media_player_get_chapter_count_for_title(p_mi, i_title): + '''Get title chapter count. + @param p_mi: the Media Player. + @param i_title: title. + @return: number of chapters in title, or -1. + ''' + f = _Cfunctions.get('libvlc_media_player_get_chapter_count_for_title', None) or \ + _Cfunction('libvlc_media_player_get_chapter_count_for_title', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_chapter_count_for_title + libvlc_media_player_get_chapter_count_for_title = f + return f(p_mi, i_title) + +def libvlc_media_player_set_title(p_mi, i_title): + '''Set movie title. + @param p_mi: the Media Player. + @param i_title: title number to play. + ''' + f = _Cfunctions.get('libvlc_media_player_set_title', None) or \ + _Cfunction('libvlc_media_player_set_title', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_title + libvlc_media_player_set_title = f + return f(p_mi, i_title) + +def libvlc_media_player_get_title(p_mi): + '''Get movie title. + @param p_mi: the Media Player. + @return: title number currently playing, or -1. + ''' + f = _Cfunctions.get('libvlc_media_player_get_title', None) or \ + _Cfunction('libvlc_media_player_get_title', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_title + libvlc_media_player_get_title = f + return f(p_mi) + +def libvlc_media_player_get_title_count(p_mi): + '''Get movie title count. + @param p_mi: the Media Player. + @return: title number count, or -1. + ''' + f = _Cfunctions.get('libvlc_media_player_get_title_count', None) or \ + _Cfunction('libvlc_media_player_get_title_count', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_title_count + libvlc_media_player_get_title_count = f + return f(p_mi) + +def libvlc_media_player_previous_chapter(p_mi): + '''Set previous chapter (if applicable). + @param p_mi: the Media Player. + ''' + f = _Cfunctions.get('libvlc_media_player_previous_chapter', None) or \ + _Cfunction('libvlc_media_player_previous_chapter', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_previous_chapter + libvlc_media_player_previous_chapter = f + return f(p_mi) + +def libvlc_media_player_next_chapter(p_mi): + '''Set next chapter (if applicable). + @param p_mi: the Media Player. + ''' + f = _Cfunctions.get('libvlc_media_player_next_chapter', None) or \ + _Cfunction('libvlc_media_player_next_chapter', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_next_chapter + libvlc_media_player_next_chapter = f + return f(p_mi) + +def libvlc_media_player_get_rate(p_mi): + '''Get the requested movie play rate. + @warning: Depending on the underlying media, the requested rate may be + different from the real playback rate. + @param p_mi: the Media Player. + @return: movie play rate. + ''' + f = _Cfunctions.get('libvlc_media_player_get_rate', None) or \ + _Cfunction('libvlc_media_player_get_rate', ((1,),), None, + ctypes.c_float, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_rate + libvlc_media_player_get_rate = f + return f(p_mi) + +def libvlc_media_player_set_rate(p_mi, rate): + '''Set movie play rate. + @param p_mi: the Media Player. + @param rate: movie play rate to set. + @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol). + ''' + f = _Cfunctions.get('libvlc_media_player_set_rate', None) or \ + _Cfunction('libvlc_media_player_set_rate', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_float) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_set_rate + libvlc_media_player_set_rate = f + return f(p_mi, rate) + +def libvlc_media_player_get_state(p_mi): + '''Get current movie state. + @param p_mi: the Media Player. + @return: the current state of the media player (playing, paused, ...) See libvlc_state_t. + ''' + f = _Cfunctions.get('libvlc_media_player_get_state', None) or \ + _Cfunction('libvlc_media_player_get_state', ((1,),), None, + State, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_state + libvlc_media_player_get_state = f + return f(p_mi) + +def libvlc_media_player_get_fps(p_mi): + '''Get movie fps rate. + @param p_mi: the Media Player. + @return: frames per second (fps) for this playing movie, or 0 if unspecified. + ''' + f = _Cfunctions.get('libvlc_media_player_get_fps', None) or \ + _Cfunction('libvlc_media_player_get_fps', ((1,),), None, + ctypes.c_float, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_get_fps + libvlc_media_player_get_fps = f + return f(p_mi) + +def libvlc_media_player_has_vout(p_mi): + '''How many video outputs does this media player have? + @param p_mi: the media player. + @return: the number of video outputs. + ''' + f = _Cfunctions.get('libvlc_media_player_has_vout', None) or \ + _Cfunction('libvlc_media_player_has_vout', ((1,),), None, + ctypes.c_uint, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_has_vout + libvlc_media_player_has_vout = f + return f(p_mi) + +def libvlc_media_player_is_seekable(p_mi): + '''Is this media player seekable? + @param p_mi: the media player. + @return: true if the media player can seek \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \ + _Cfunction('libvlc_media_player_is_seekable', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_is_seekable + libvlc_media_player_is_seekable = f + return f(p_mi) + +def libvlc_media_player_can_pause(p_mi): + '''Can this media player be paused? + @param p_mi: the media player. + @return: true if the media player can pause \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \ + _Cfunction('libvlc_media_player_can_pause', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_can_pause + libvlc_media_player_can_pause = f + return f(p_mi) + +def libvlc_media_player_next_frame(p_mi): + '''Display the next frame (if supported). + @param p_mi: the media player. + ''' + f = _Cfunctions.get('libvlc_media_player_next_frame', None) or \ + _Cfunction('libvlc_media_player_next_frame', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_next_frame + libvlc_media_player_next_frame = f + return f(p_mi) + +def libvlc_media_player_navigate(p_mi, navigate): + '''Navigate through DVD Menu. + @param p_mi: the Media Player. + @param navigate: the Navigation mode. + @version: libVLC 1.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_player_navigate', None) or \ + _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_player_navigate + libvlc_media_player_navigate = f + return f(p_mi, navigate) + +def libvlc_track_description_release(p_track_description): + '''Release (free) L{TrackDescription}. + @param p_track_description: the structure to release. + ''' + f = _Cfunctions.get('libvlc_track_description_release', None) or \ + _Cfunction('libvlc_track_description_release', ((1,),), None, + None, ctypes.POINTER(TrackDescription)) + if not __debug__: # i.e. python -O or -OO + global libvlc_track_description_release + libvlc_track_description_release = f + return f(p_track_description) + +def libvlc_toggle_fullscreen(p_mi): + '''Toggle fullscreen status on non-embedded video outputs. + @warning: The same limitations applies to this function + as to L{libvlc_set_fullscreen}(). + @param p_mi: the media player. + ''' + f = _Cfunctions.get('libvlc_toggle_fullscreen', None) or \ + _Cfunction('libvlc_toggle_fullscreen', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_toggle_fullscreen + libvlc_toggle_fullscreen = f + return f(p_mi) + +def libvlc_set_fullscreen(p_mi, b_fullscreen): + '''Enable or disable fullscreen. + @warning: With most window managers, only a top-level windows can be in + full-screen mode. Hence, this function will not operate properly if + L{libvlc_media_player_set_xwindow}() was used to embed the video in a + non-top-level window. In that case, the embedding window must be reparented + to the root window B{before} fullscreen mode is enabled. You will want + to reparent it back to its normal parent when disabling fullscreen. + @param p_mi: the media player. + @param b_fullscreen: boolean for fullscreen status. + ''' + f = _Cfunctions.get('libvlc_set_fullscreen', None) or \ + _Cfunction('libvlc_set_fullscreen', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_set_fullscreen + libvlc_set_fullscreen = f + return f(p_mi, b_fullscreen) + +def libvlc_get_fullscreen(p_mi): + '''Get current fullscreen status. + @param p_mi: the media player. + @return: the fullscreen status (boolean) \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_get_fullscreen', None) or \ + _Cfunction('libvlc_get_fullscreen', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_get_fullscreen + libvlc_get_fullscreen = f + return f(p_mi) + +def libvlc_video_set_key_input(p_mi, on): + '''Enable or disable key press events handling, according to the LibVLC hotkeys + configuration. By default and for historical reasons, keyboard events are + handled by the LibVLC video widget. + @note: On X11, there can be only one subscriber for key press and mouse + click events per window. If your application has subscribed to those events + for the X window ID of the video widget, then LibVLC will not be able to + handle key presses and mouse clicks in any case. + @warning: This function is only implemented for X11 and Win32 at the moment. + @param p_mi: the media player. + @param on: true to handle key press events, false to ignore them. + ''' + f = _Cfunctions.get('libvlc_video_set_key_input', None) or \ + _Cfunction('libvlc_video_set_key_input', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_key_input + libvlc_video_set_key_input = f + return f(p_mi, on) + +def libvlc_video_set_mouse_input(p_mi, on): + '''Enable or disable mouse click events handling. By default, those events are + handled. This is needed for DVD menus to work, as well as a few video + filters such as "puzzle". + See L{libvlc_video_set_key_input}(). + @warning: This function is only implemented for X11 and Win32 at the moment. + @param p_mi: the media player. + @param on: true to handle mouse click events, false to ignore them. + ''' + f = _Cfunctions.get('libvlc_video_set_mouse_input', None) or \ + _Cfunction('libvlc_video_set_mouse_input', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_mouse_input + libvlc_video_set_mouse_input = f + return f(p_mi, on) + +def libvlc_video_get_size(p_mi, num): + '''Get the pixel dimensions of a video. + @param p_mi: media player. + @param num: number of the video (starting from, and most commonly 0). + @return: px pixel width, py pixel height. + ''' + f = _Cfunctions.get('libvlc_video_get_size', None) or \ + _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_size + libvlc_video_get_size = f + return f(p_mi, num) + +def libvlc_video_get_cursor(p_mi, num): + '''Get the mouse pointer coordinates over a video. + Coordinates are expressed in terms of the decoded video resolution, + B{not} in terms of pixels on the screen/viewport (to get the latter, + you can query your windowing system directly). + Either of the coordinates may be negative or larger than the corresponding + dimension of the video, if the cursor is outside the rendering area. + @warning: The coordinates may be out-of-date if the pointer is not located + on the video rendering area. LibVLC does not track the pointer if it is + outside of the video widget. + @note: LibVLC does not support multiple pointers (it does of course support + multiple input devices sharing the same pointer) at the moment. + @param p_mi: media player. + @param num: number of the video (starting from, and most commonly 0). + @return: px abscissa, py ordinate. + ''' + f = _Cfunctions.get('libvlc_video_get_cursor', None) or \ + _Cfunction('libvlc_video_get_cursor', ((1,), (1,), (2,), (2,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_cursor + libvlc_video_get_cursor = f + return f(p_mi, num) + +def libvlc_video_get_scale(p_mi): + '''Get the current video scaling factor. + See also L{libvlc_video_set_scale}(). + @param p_mi: the media player. + @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically. + ''' + f = _Cfunctions.get('libvlc_video_get_scale', None) or \ + _Cfunction('libvlc_video_get_scale', ((1,),), None, + ctypes.c_float, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_scale + libvlc_video_get_scale = f + return f(p_mi) + +def libvlc_video_set_scale(p_mi, f_factor): + '''Set the video scaling factor. That is the ratio of the number of pixels on + screen to the number of pixels in the original decoded video in each + dimension. Zero is a special value; it will adjust the video to the output + window/drawable (in windowed mode) or the entire screen. + Note that not all video outputs support scaling. + @param p_mi: the media player. + @param f_factor: the scaling factor, or zero. + ''' + f = _Cfunctions.get('libvlc_video_set_scale', None) or \ + _Cfunction('libvlc_video_set_scale', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_float) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_scale + libvlc_video_set_scale = f + return f(p_mi, f_factor) + +def libvlc_video_get_aspect_ratio(p_mi): + '''Get current video aspect ratio. + @param p_mi: the media player. + @return: the video aspect ratio or NULL if unspecified (the result must be released with free() or L{libvlc_free}()). + ''' + f = _Cfunctions.get('libvlc_video_get_aspect_ratio', None) or \ + _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), string_result, + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_aspect_ratio + libvlc_video_get_aspect_ratio = f + return f(p_mi) + +def libvlc_video_set_aspect_ratio(p_mi, psz_aspect): + '''Set new video aspect ratio. + @param p_mi: the media player. + @param psz_aspect: new video aspect-ratio or NULL to reset to default @note Invalid aspect ratios are ignored. + ''' + f = _Cfunctions.get('libvlc_video_set_aspect_ratio', None) or \ + _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_aspect_ratio + libvlc_video_set_aspect_ratio = f + return f(p_mi, psz_aspect) + +def libvlc_video_get_spu(p_mi): + '''Get current video subtitle. + @param p_mi: the media player. + @return: the video subtitle selected, or -1 if none. + ''' + f = _Cfunctions.get('libvlc_video_get_spu', None) or \ + _Cfunction('libvlc_video_get_spu', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_spu + libvlc_video_get_spu = f + return f(p_mi) + +def libvlc_video_get_spu_count(p_mi): + '''Get the number of available video subtitles. + @param p_mi: the media player. + @return: the number of available video subtitles. + ''' + f = _Cfunctions.get('libvlc_video_get_spu_count', None) or \ + _Cfunction('libvlc_video_get_spu_count', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_spu_count + libvlc_video_get_spu_count = f + return f(p_mi) + +def libvlc_video_get_spu_description(p_mi): + '''Get the description of available video subtitles. + @param p_mi: the media player. + @return: list containing description of available video subtitles. + ''' + f = _Cfunctions.get('libvlc_video_get_spu_description', None) or \ + _Cfunction('libvlc_video_get_spu_description', ((1,),), None, + ctypes.POINTER(TrackDescription), MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_spu_description + libvlc_video_get_spu_description = f + return f(p_mi) + +def libvlc_video_set_spu(p_mi, i_spu): + '''Set new video subtitle. + @param p_mi: the media player. + @param i_spu: new video subtitle to select. + @return: 0 on success, -1 if out of range. + ''' + f = _Cfunctions.get('libvlc_video_set_spu', None) or \ + _Cfunction('libvlc_video_set_spu', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_spu + libvlc_video_set_spu = f + return f(p_mi, i_spu) + +def libvlc_video_set_subtitle_file(p_mi, psz_subtitle): + '''Set new video subtitle file. + @param p_mi: the media player. + @param psz_subtitle: new video subtitle file. + @return: the success status (boolean). + ''' + f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \ + _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_subtitle_file + libvlc_video_set_subtitle_file = f + return f(p_mi, psz_subtitle) + +def libvlc_video_get_title_description(p_mi): + '''Get the description of available titles. + @param p_mi: the media player. + @return: list containing description of available titles. + ''' + f = _Cfunctions.get('libvlc_video_get_title_description', None) or \ + _Cfunction('libvlc_video_get_title_description', ((1,),), None, + ctypes.POINTER(TrackDescription), MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_title_description + libvlc_video_get_title_description = f + return f(p_mi) + +def libvlc_video_get_chapter_description(p_mi, i_title): + '''Get the description of available chapters for specific title. + @param p_mi: the media player. + @param i_title: selected title. + @return: list containing description of available chapter for title i_title. + ''' + f = _Cfunctions.get('libvlc_video_get_chapter_description', None) or \ + _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), None, + ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_chapter_description + libvlc_video_get_chapter_description = f + return f(p_mi, i_title) + +def libvlc_video_get_crop_geometry(p_mi): + '''Get current crop filter geometry. + @param p_mi: the media player. + @return: the crop filter geometry or NULL if unset. + ''' + f = _Cfunctions.get('libvlc_video_get_crop_geometry', None) or \ + _Cfunction('libvlc_video_get_crop_geometry', ((1,),), string_result, + ctypes.c_void_p, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_crop_geometry + libvlc_video_get_crop_geometry = f + return f(p_mi) + +def libvlc_video_set_crop_geometry(p_mi, psz_geometry): + '''Set new crop filter geometry. + @param p_mi: the media player. + @param psz_geometry: new crop filter geometry (NULL to unset). + ''' + f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \ + _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_crop_geometry + libvlc_video_set_crop_geometry = f + return f(p_mi, psz_geometry) + +def libvlc_video_get_teletext(p_mi): + '''Get current teletext page requested. + @param p_mi: the media player. + @return: the current teletext page requested. + ''' + f = _Cfunctions.get('libvlc_video_get_teletext', None) or \ + _Cfunction('libvlc_video_get_teletext', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_teletext + libvlc_video_get_teletext = f + return f(p_mi) + +def libvlc_video_set_teletext(p_mi, i_page): + '''Set new teletext page to retrieve. + @param p_mi: the media player. + @param i_page: teletex page number requested. + ''' + f = _Cfunctions.get('libvlc_video_set_teletext', None) or \ + _Cfunction('libvlc_video_set_teletext', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_teletext + libvlc_video_set_teletext = f + return f(p_mi, i_page) + +def libvlc_toggle_teletext(p_mi): + '''Toggle teletext transparent status on video output. + @param p_mi: the media player. + ''' + f = _Cfunctions.get('libvlc_toggle_teletext', None) or \ + _Cfunction('libvlc_toggle_teletext', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_toggle_teletext + libvlc_toggle_teletext = f + return f(p_mi) + +def libvlc_video_get_track_count(p_mi): + '''Get number of available video tracks. + @param p_mi: media player. + @return: the number of available video tracks (int). + ''' + f = _Cfunctions.get('libvlc_video_get_track_count', None) or \ + _Cfunction('libvlc_video_get_track_count', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_track_count + libvlc_video_get_track_count = f + return f(p_mi) + +def libvlc_video_get_track_description(p_mi): + '''Get the description of available video tracks. + @param p_mi: media player. + @return: list with description of available video tracks, or NULL on error. + ''' + f = _Cfunctions.get('libvlc_video_get_track_description', None) or \ + _Cfunction('libvlc_video_get_track_description', ((1,),), None, + ctypes.POINTER(TrackDescription), MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_track_description + libvlc_video_get_track_description = f + return f(p_mi) + +def libvlc_video_get_track(p_mi): + '''Get current video track. + @param p_mi: media player. + @return: the video track (int) or -1 if none. + ''' + f = _Cfunctions.get('libvlc_video_get_track', None) or \ + _Cfunction('libvlc_video_get_track', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_track + libvlc_video_get_track = f + return f(p_mi) + +def libvlc_video_set_track(p_mi, i_track): + '''Set video track. + @param p_mi: media player. + @param i_track: the track (int). + @return: 0 on success, -1 if out of range. + ''' + f = _Cfunctions.get('libvlc_video_set_track', None) or \ + _Cfunction('libvlc_video_set_track', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_track + libvlc_video_set_track = f + return f(p_mi, i_track) + +def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height): + '''Take a snapshot of the current video window. + If i_width AND i_height is 0, original size is used. + If i_width XOR i_height is 0, original aspect-ratio is preserved. + @param p_mi: media player instance. + @param num: number of video output (typically 0 for the first/only one). + @param psz_filepath: the path where to save the screenshot to. + @param i_width: the snapshot's width. + @param i_height: the snapshot's height. + @return: 0 on success, -1 if the video was not found. + ''' + f = _Cfunctions.get('libvlc_video_take_snapshot', None) or \ + _Cfunction('libvlc_video_take_snapshot', ((1,), (1,), (1,), (1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_take_snapshot + libvlc_video_take_snapshot = f + return f(p_mi, num, psz_filepath, i_width, i_height) + +def libvlc_video_set_deinterlace(p_mi, psz_mode): + '''Enable or disable deinterlace filter. + @param p_mi: libvlc media player. + @param psz_mode: type of deinterlace filter, NULL to disable. + ''' + f = _Cfunctions.get('libvlc_video_set_deinterlace', None) or \ + _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_deinterlace + libvlc_video_set_deinterlace = f + return f(p_mi, psz_mode) + +def libvlc_video_get_marquee_int(p_mi, option): + '''Get an integer marquee option value. + @param p_mi: libvlc media player. + @param option: marq option to get See libvlc_video_marquee_int_option_t. + ''' + f = _Cfunctions.get('libvlc_video_get_marquee_int', None) or \ + _Cfunction('libvlc_video_get_marquee_int', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_marquee_int + libvlc_video_get_marquee_int = f + return f(p_mi, option) + +def libvlc_video_get_marquee_string(p_mi, option): + '''Get a string marquee option value. + @param p_mi: libvlc media player. + @param option: marq option to get See libvlc_video_marquee_string_option_t. + ''' + f = _Cfunctions.get('libvlc_video_get_marquee_string', None) or \ + _Cfunction('libvlc_video_get_marquee_string', ((1,), (1,),), string_result, + ctypes.c_void_p, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_marquee_string + libvlc_video_get_marquee_string = f + return f(p_mi, option) + +def libvlc_video_set_marquee_int(p_mi, option, i_val): + '''Enable, disable or set an integer marquee option + Setting libvlc_marquee_Enable has the side effect of enabling (arg !0) + or disabling (arg 0) the marq filter. + @param p_mi: libvlc media player. + @param option: marq option to set See libvlc_video_marquee_int_option_t. + @param i_val: marq option value. + ''' + f = _Cfunctions.get('libvlc_video_set_marquee_int', None) or \ + _Cfunction('libvlc_video_set_marquee_int', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_marquee_int + libvlc_video_set_marquee_int = f + return f(p_mi, option, i_val) + +def libvlc_video_set_marquee_string(p_mi, option, psz_text): + '''Set a marquee string option. + @param p_mi: libvlc media player. + @param option: marq option to set See libvlc_video_marquee_string_option_t. + @param psz_text: marq option value. + ''' + f = _Cfunctions.get('libvlc_video_set_marquee_string', None) or \ + _Cfunction('libvlc_video_set_marquee_string', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_marquee_string + libvlc_video_set_marquee_string = f + return f(p_mi, option, psz_text) + +def libvlc_video_get_logo_int(p_mi, option): + '''Get integer logo option. + @param p_mi: libvlc media player instance. + @param option: logo option to get, values of libvlc_video_logo_option_t. + ''' + f = _Cfunctions.get('libvlc_video_get_logo_int', None) or \ + _Cfunction('libvlc_video_get_logo_int', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_logo_int + libvlc_video_get_logo_int = f + return f(p_mi, option) + +def libvlc_video_set_logo_int(p_mi, option, value): + '''Set logo option as integer. Options that take a different type value + are ignored. + Passing libvlc_logo_enable as option value has the side effect of + starting (arg !0) or stopping (arg 0) the logo filter. + @param p_mi: libvlc media player instance. + @param option: logo option to set, values of libvlc_video_logo_option_t. + @param value: logo option value. + ''' + f = _Cfunctions.get('libvlc_video_set_logo_int', None) or \ + _Cfunction('libvlc_video_set_logo_int', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_logo_int + libvlc_video_set_logo_int = f + return f(p_mi, option, value) + +def libvlc_video_set_logo_string(p_mi, option, psz_value): + '''Set logo option as string. Options that take a different type value + are ignored. + @param p_mi: libvlc media player instance. + @param option: logo option to set, values of libvlc_video_logo_option_t. + @param psz_value: logo option value. + ''' + f = _Cfunctions.get('libvlc_video_set_logo_string', None) or \ + _Cfunction('libvlc_video_set_logo_string', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_logo_string + libvlc_video_set_logo_string = f + return f(p_mi, option, psz_value) + +def libvlc_video_get_adjust_int(p_mi, option): + '''Get integer adjust option. + @param p_mi: libvlc media player instance. + @param option: adjust option to get, values of libvlc_video_adjust_option_t. + @version: LibVLC 1.1.1 and later. + ''' + f = _Cfunctions.get('libvlc_video_get_adjust_int', None) or \ + _Cfunction('libvlc_video_get_adjust_int', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_adjust_int + libvlc_video_get_adjust_int = f + return f(p_mi, option) + +def libvlc_video_set_adjust_int(p_mi, option, value): + '''Set adjust option as integer. Options that take a different type value + are ignored. + Passing libvlc_adjust_enable as option value has the side effect of + starting (arg !0) or stopping (arg 0) the adjust filter. + @param p_mi: libvlc media player instance. + @param option: adust option to set, values of libvlc_video_adjust_option_t. + @param value: adjust option value. + @version: LibVLC 1.1.1 and later. + ''' + f = _Cfunctions.get('libvlc_video_set_adjust_int', None) or \ + _Cfunction('libvlc_video_set_adjust_int', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_adjust_int + libvlc_video_set_adjust_int = f + return f(p_mi, option, value) + +def libvlc_video_get_adjust_float(p_mi, option): + '''Get float adjust option. + @param p_mi: libvlc media player instance. + @param option: adjust option to get, values of libvlc_video_adjust_option_t. + @version: LibVLC 1.1.1 and later. + ''' + f = _Cfunctions.get('libvlc_video_get_adjust_float', None) or \ + _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), None, + ctypes.c_float, MediaPlayer, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_get_adjust_float + libvlc_video_get_adjust_float = f + return f(p_mi, option) + +def libvlc_video_set_adjust_float(p_mi, option, value): + '''Set adjust option as float. Options that take a different type value + are ignored. + @param p_mi: libvlc media player instance. + @param option: adust option to set, values of libvlc_video_adjust_option_t. + @param value: adjust option value. + @version: LibVLC 1.1.1 and later. + ''' + f = _Cfunctions.get('libvlc_video_set_adjust_float', None) or \ + _Cfunction('libvlc_video_set_adjust_float', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_uint, ctypes.c_float) + if not __debug__: # i.e. python -O or -OO + global libvlc_video_set_adjust_float + libvlc_video_set_adjust_float = f + return f(p_mi, option, value) + +def libvlc_audio_output_list_get(p_instance): + '''Get the list of available audio outputs. + @param p_instance: libvlc instance. + @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. + ''' + f = _Cfunctions.get('libvlc_audio_output_list_get', None) or \ + _Cfunction('libvlc_audio_output_list_get', ((1,),), None, + ctypes.POINTER(AudioOutput), Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_list_get + libvlc_audio_output_list_get = f + return f(p_instance) + +def libvlc_audio_output_list_release(p_list): + '''Free the list of available audio outputs. + @param p_list: list with audio outputs for release. + ''' + f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \ + _Cfunction('libvlc_audio_output_list_release', ((1,),), None, + None, ctypes.POINTER(AudioOutput)) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_list_release + libvlc_audio_output_list_release = f + return f(p_list) + +def libvlc_audio_output_set(p_mi, psz_name): + '''Set the audio output. + Change will be applied after stop and play. + @param p_mi: media player. + @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. + @return: 0 if function succeded, -1 on error. + ''' + f = _Cfunctions.get('libvlc_audio_output_set', None) or \ + _Cfunction('libvlc_audio_output_set', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_set + libvlc_audio_output_set = f + return f(p_mi, psz_name) + +def libvlc_audio_output_device_count(p_instance, psz_audio_output): + '''Get count of devices for audio output, these devices are hardware oriented + like analor or digital output of sound card. + @param p_instance: libvlc instance. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @return: number of devices. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_count', None) or \ + _Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_device_count + libvlc_audio_output_device_count = f + return f(p_instance, psz_audio_output) + +def libvlc_audio_output_device_longname(p_instance, psz_audio_output, i_device): + '''Get long name of device, if not available short name given. + @param p_instance: libvlc instance. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param i_device: device index. + @return: long name of device. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_longname', None) or \ + _Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_device_longname + libvlc_audio_output_device_longname = f + return f(p_instance, psz_audio_output, i_device) + +def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device): + '''Get id name of device. + @param p_instance: libvlc instance. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param i_device: device index. + @return: id name of device, use for setting device, need to be free after use. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_id', None) or \ + _Cfunction('libvlc_audio_output_device_id', ((1,), (1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_device_id + libvlc_audio_output_device_id = f + return f(p_instance, psz_audio_output, i_device) + +def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): + '''Set audio output device. Changes are only effective after stop and play. + @param p_mi: media player. + @param psz_audio_output: - name of audio output, See L{AudioOutput}. + @param psz_device_id: device. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \ + _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_device_set + libvlc_audio_output_device_set = f + return f(p_mi, psz_audio_output, psz_device_id) + +def libvlc_audio_output_get_device_type(p_mi): + '''Get current audio device type. Device type describes something like + character of output sound - stereo sound, 2.1, 5.1 etc. + @param p_mi: media player. + @return: the audio devices type See libvlc_audio_output_device_types_t. + ''' + f = _Cfunctions.get('libvlc_audio_output_get_device_type', None) or \ + _Cfunction('libvlc_audio_output_get_device_type', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_get_device_type + libvlc_audio_output_get_device_type = f + return f(p_mi) + +def libvlc_audio_output_set_device_type(p_mi, device_type): + '''Set current audio device type. + @param p_mi: vlc instance. + @param device_type: the audio device type, + ''' + f = _Cfunctions.get('libvlc_audio_output_set_device_type', None) or \ + _Cfunction('libvlc_audio_output_set_device_type', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_output_set_device_type + libvlc_audio_output_set_device_type = f + return f(p_mi, device_type) + +def libvlc_audio_toggle_mute(p_mi): + '''Toggle mute status. + @param p_mi: media player. + ''' + f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \ + _Cfunction('libvlc_audio_toggle_mute', ((1,),), None, + None, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_toggle_mute + libvlc_audio_toggle_mute = f + return f(p_mi) + +def libvlc_audio_get_mute(p_mi): + '''Get current mute status. + @param p_mi: media player. + @return: the mute status (boolean) \libvlc_return_bool. + ''' + f = _Cfunctions.get('libvlc_audio_get_mute', None) or \ + _Cfunction('libvlc_audio_get_mute', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_mute + libvlc_audio_get_mute = f + return f(p_mi) + +def libvlc_audio_set_mute(p_mi, status): + '''Set mute status. + @param p_mi: media player. + @param status: If status is true then mute, otherwise unmute. + ''' + f = _Cfunctions.get('libvlc_audio_set_mute', None) or \ + _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None, + None, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_mute + libvlc_audio_set_mute = f + return f(p_mi, status) + +def libvlc_audio_get_volume(p_mi): + '''Get current software audio volume. + @param p_mi: media player. + @return: the software volume in percents (0 = mute, 100 = nominal / 0dB). + ''' + f = _Cfunctions.get('libvlc_audio_get_volume', None) or \ + _Cfunction('libvlc_audio_get_volume', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_volume + libvlc_audio_get_volume = f + return f(p_mi) + +def libvlc_audio_set_volume(p_mi, i_volume): + '''Set current software audio volume. + @param p_mi: media player. + @param i_volume: the volume in percents (0 = mute, 100 = 0dB). + @return: 0 if the volume was set, -1 if it was out of range. + ''' + f = _Cfunctions.get('libvlc_audio_set_volume', None) or \ + _Cfunction('libvlc_audio_set_volume', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_volume + libvlc_audio_set_volume = f + return f(p_mi, i_volume) + +def libvlc_audio_get_track_count(p_mi): + '''Get number of available audio tracks. + @param p_mi: media player. + @return: the number of available audio tracks (int), or -1 if unavailable. + ''' + f = _Cfunctions.get('libvlc_audio_get_track_count', None) or \ + _Cfunction('libvlc_audio_get_track_count', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_track_count + libvlc_audio_get_track_count = f + return f(p_mi) + +def libvlc_audio_get_track_description(p_mi): + '''Get the description of available audio tracks. + @param p_mi: media player. + @return: list with description of available audio tracks, or NULL. + ''' + f = _Cfunctions.get('libvlc_audio_get_track_description', None) or \ + _Cfunction('libvlc_audio_get_track_description', ((1,),), None, + ctypes.POINTER(TrackDescription), MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_track_description + libvlc_audio_get_track_description = f + return f(p_mi) + +def libvlc_audio_get_track(p_mi): + '''Get current audio track. + @param p_mi: media player. + @return: the audio track (int), or -1 if none. + ''' + f = _Cfunctions.get('libvlc_audio_get_track', None) or \ + _Cfunction('libvlc_audio_get_track', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_track + libvlc_audio_get_track = f + return f(p_mi) + +def libvlc_audio_set_track(p_mi, i_track): + '''Set current audio track. + @param p_mi: media player. + @param i_track: the track (int). + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_audio_set_track', None) or \ + _Cfunction('libvlc_audio_set_track', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_track + libvlc_audio_set_track = f + return f(p_mi, i_track) + +def libvlc_audio_get_channel(p_mi): + '''Get current audio channel. + @param p_mi: media player. + @return: the audio channel See libvlc_audio_output_channel_t. + ''' + f = _Cfunctions.get('libvlc_audio_get_channel', None) or \ + _Cfunction('libvlc_audio_get_channel', ((1,),), None, + ctypes.c_int, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_channel + libvlc_audio_get_channel = f + return f(p_mi) + +def libvlc_audio_set_channel(p_mi, channel): + '''Set current audio channel. + @param p_mi: media player. + @param channel: the audio channel, See libvlc_audio_output_channel_t. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_audio_set_channel', None) or \ + _Cfunction('libvlc_audio_set_channel', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_channel + libvlc_audio_set_channel = f + return f(p_mi, channel) + +def libvlc_audio_get_delay(p_mi): + '''Get current audio delay. + @param p_mi: media player. + @return: the audio delay (microseconds). + @version: LibVLC 1.1.1 or later. + ''' + f = _Cfunctions.get('libvlc_audio_get_delay', None) or \ + _Cfunction('libvlc_audio_get_delay', ((1,),), None, + ctypes.c_int64, MediaPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_get_delay + libvlc_audio_get_delay = f + return f(p_mi) + +def libvlc_audio_set_delay(p_mi, i_delay): + '''Set current audio delay. The audio delay will be reset to zero each time the media changes. + @param p_mi: media player. + @param i_delay: the audio delay (microseconds). + @return: 0 on success, -1 on error. + @version: LibVLC 1.1.1 or later. + ''' + f = _Cfunctions.get('libvlc_audio_set_delay', None) or \ + _Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int64) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_delay + libvlc_audio_set_delay = f + return f(p_mi, i_delay) + +def libvlc_vlm_release(p_instance): + '''Release the vlm instance related to the given L{Instance}. + @param p_instance: the instance. + ''' + f = _Cfunctions.get('libvlc_vlm_release', None) or \ + _Cfunction('libvlc_vlm_release', ((1,),), None, + None, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_release + libvlc_vlm_release = f + return f(p_instance) + +def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): + '''Add a broadcast, with one input. + @param p_instance: the instance. + @param psz_name: the name of the new broadcast. + @param psz_input: the input MRL. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new broadcast. + @param b_loop: Should this broadcast be played in loop ? + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \ + _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_add_broadcast + libvlc_vlm_add_broadcast = f + return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) + +def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux): + '''Add a vod, with one input. + @param p_instance: the instance. + @param psz_name: the name of the new vod media. + @param psz_input: the input MRL. + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new vod. + @param psz_mux: the muxer of the vod media. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \ + _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_add_vod + libvlc_vlm_add_vod = f + return f(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux) + +def libvlc_vlm_del_media(p_instance, psz_name): + '''Delete a media (VOD or broadcast). + @param p_instance: the instance. + @param psz_name: the media to delete. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_del_media', None) or \ + _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_del_media + libvlc_vlm_del_media = f + return f(p_instance, psz_name) + +def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled): + '''Enable or disable a media (VOD or broadcast). + @param p_instance: the instance. + @param psz_name: the media to work on. + @param b_enabled: the new status. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_set_enabled', None) or \ + _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_set_enabled + libvlc_vlm_set_enabled = f + return f(p_instance, psz_name, b_enabled) + +def libvlc_vlm_set_output(p_instance, psz_name, psz_output): + '''Set the output for a media. + @param p_instance: the instance. + @param psz_name: the media to work on. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_set_output', None) or \ + _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_set_output + libvlc_vlm_set_output = f + return f(p_instance, psz_name, psz_output) + +def libvlc_vlm_set_input(p_instance, psz_name, psz_input): + '''Set a media's input MRL. This will delete all existing inputs and + add the specified one. + @param p_instance: the instance. + @param psz_name: the media to work on. + @param psz_input: the input MRL. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_set_input', None) or \ + _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_set_input + libvlc_vlm_set_input = f + return f(p_instance, psz_name, psz_input) + +def libvlc_vlm_add_input(p_instance, psz_name, psz_input): + '''Add a media's input MRL. This will add the specified one. + @param p_instance: the instance. + @param psz_name: the media to work on. + @param psz_input: the input MRL. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_add_input', None) or \ + _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_add_input + libvlc_vlm_add_input = f + return f(p_instance, psz_name, psz_input) + +def libvlc_vlm_set_loop(p_instance, psz_name, b_loop): + '''Set a media's loop status. + @param p_instance: the instance. + @param psz_name: the media to work on. + @param b_loop: the new status. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_set_loop', None) or \ + _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_set_loop + libvlc_vlm_set_loop = f + return f(p_instance, psz_name, b_loop) + +def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux): + '''Set a media's vod muxer. + @param p_instance: the instance. + @param psz_name: the media to work on. + @param psz_mux: the new muxer. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_set_mux', None) or \ + _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_set_mux + libvlc_vlm_set_mux = f + return f(p_instance, psz_name, psz_mux) + +def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): + '''Edit the parameters of a media. This will delete all existing inputs and + add the specified one. + @param p_instance: the instance. + @param psz_name: the name of the new broadcast. + @param psz_input: the input MRL. + @param psz_output: the output MRL (the parameter to the "sout" variable). + @param i_options: number of additional options. + @param ppsz_options: additional options. + @param b_enabled: boolean for enabling the new broadcast. + @param b_loop: Should this broadcast be played in loop ? + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_change_media', None) or \ + _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_change_media + libvlc_vlm_change_media = f + return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) + +def libvlc_vlm_play_media(p_instance, psz_name): + '''Play the named broadcast. + @param p_instance: the instance. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_play_media', None) or \ + _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_play_media + libvlc_vlm_play_media = f + return f(p_instance, psz_name) + +def libvlc_vlm_stop_media(p_instance, psz_name): + '''Stop the named broadcast. + @param p_instance: the instance. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_stop_media', None) or \ + _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_stop_media + libvlc_vlm_stop_media = f + return f(p_instance, psz_name) + +def libvlc_vlm_pause_media(p_instance, psz_name): + '''Pause the named broadcast. + @param p_instance: the instance. + @param psz_name: the name of the broadcast. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_pause_media', None) or \ + _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_pause_media + libvlc_vlm_pause_media = f + return f(p_instance, psz_name) + +def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage): + '''Seek in the named broadcast. + @param p_instance: the instance. + @param psz_name: the name of the broadcast. + @param f_percentage: the percentage to seek to. + @return: 0 on success, -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_seek_media', None) or \ + _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_seek_media + libvlc_vlm_seek_media = f + return f(p_instance, psz_name, f_percentage) + +def libvlc_vlm_show_media(p_instance, psz_name): + '''Return information about the named media as a JSON + string representation. + This function is mainly intended for debugging use, + if you want programmatic access to the state of + a vlm_media_instance_t, please use the corresponding + libvlc_vlm_get_media_instance_xxx -functions. + Currently there are no such functions available for + vlm_media_t though. + @param p_instance: the instance. + @param psz_name: the name of the media, if the name is an empty string, all media is described. + @return: string with information about named media, or NULL on error. + ''' + f = _Cfunctions.get('libvlc_vlm_show_media', None) or \ + _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_show_media + libvlc_vlm_show_media = f + return f(p_instance, psz_name) + +def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance): + '''Get vlm_media instance position by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: position as float or -1. on error. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_position', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), None, + ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_position + libvlc_vlm_get_media_instance_position = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance): + '''Get vlm_media instance time by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: time as integer or -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_time', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_time + libvlc_vlm_get_media_instance_time = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance): + '''Get vlm_media instance length by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: length of media item or -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_length', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_length + libvlc_vlm_get_media_instance_length = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance): + '''Get vlm_media instance playback rate by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: playback rate or -1 on error. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_rate', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_rate + libvlc_vlm_get_media_instance_rate = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance): + '''Get vlm_media instance title number by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: title as number or -1 on error. + @bug: will always return 0. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_title', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_title + libvlc_vlm_get_media_instance_title = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance): + '''Get vlm_media instance chapter number by name or instance id. + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: chapter as number or -1 on error. + @bug: will always return 0. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_chapter', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_chapter + libvlc_vlm_get_media_instance_chapter = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance): + '''Is libvlc instance seekable ? + @param p_instance: a libvlc instance. + @param psz_name: name of vlm media instance. + @param i_instance: instance id. + @return: 1 if seekable, 0 if not, -1 if media does not exist. + @bug: will always return 0. + ''' + f = _Cfunctions.get('libvlc_vlm_get_media_instance_seekable', None) or \ + _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), None, + ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_media_instance_seekable + libvlc_vlm_get_media_instance_seekable = f + return f(p_instance, psz_name, i_instance) + +def libvlc_vlm_get_event_manager(p_instance): + '''Get libvlc_event_manager from a vlm media. + The p_event_manager is immutable, so you don't have to hold the lock. + @param p_instance: a libvlc instance. + @return: libvlc_event_manager. + ''' + f = _Cfunctions.get('libvlc_vlm_get_event_manager', None) or \ + _Cfunction('libvlc_vlm_get_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, Instance) + if not __debug__: # i.e. python -O or -OO + global libvlc_vlm_get_event_manager + libvlc_vlm_get_event_manager = f + return f(p_instance) + + +# 6 function(s) blacklisted: +# libvlc_audio_set_callbacks +# libvlc_audio_set_format_callbacks +# libvlc_audio_set_volume_callback +# libvlc_set_exit_handler +# libvlc_video_set_callbacks +# libvlc_video_set_format_callbacks + +# 12 function(s) not wrapped as methods: +# libvlc_audio_output_list_release +# libvlc_clearerr +# libvlc_clock +# libvlc_errmsg +# libvlc_event_type_name +# libvlc_free +# libvlc_get_changeset +# libvlc_get_compiler +# libvlc_get_version +# libvlc_module_description_list_release +# libvlc_new +# libvlc_track_description_release + +# Start of footer.py # + +# Backward compatibility +def callbackmethod(callback): + """Now obsolete @callbackmethod decorator.""" + return callback + +# libvlc_free is not present in some versions of libvlc. If it is not +# in the library, then emulate it by calling libc.free +if not hasattr(dll, 'libvlc_free'): + # need to find the free function in the C runtime. This is + # platform specific. + # For Linux and MacOSX + libc_path = find_library('c') + if libc_path: + libc = ctypes.CDLL(libc_path) + libvlc_free = libc.free + else: + # On win32, it is impossible to guess the proper lib to call + # (msvcrt, mingw...). Just ignore the call: it will memleak, + # but not prevent to run the application. + def libvlc_free(p): + pass + + # ensure argtypes is right, because default type of int won't work + # on 64-bit systems + libvlc_free.argtypes = [ ctypes.c_void_p ] + +# Version functions +def _dot2int(v): + '''(INTERNAL) Convert 'i.i.i[.i]' str to int. + ''' + t = [int(i) for i in v.split('.')] + if len(t) == 3: + t.append(0) + elif len(t) != 4: + raise ValueError('"i.i.i[.i]": %r' % (v,)) + if min(t) < 0 or max(t) > 255: + raise ValueError('[0..255]: %r' % (v,)) + i = t.pop(0) + while t: + i = (i << 8) + t.pop(0) + return i + +def hex_version(): + """Return the version of these bindings in hex or 0 if unavailable. + """ + try: + return _dot2int(__version__.split('-')[-1]) + except (NameError, ValueError): + return 0 + +def libvlc_hex_version(): + """Return the libvlc version in hex or 0 if unavailable. + """ + try: + return _dot2int(libvlc_get_version().split()[0]) + except ValueError: + return 0 + + +def debug_callback(event, *args, **kwds): + '''Example callback, useful for debugging. + ''' + l = ['event %s' % (event.type,)] + if args: + l.extend(map(str, args)) + if kwds: + l.extend(sorted('%s=%s' % t for t in kwds.items())) + print('Debug callback (%s)' % ', '.join(l)) + +if __name__ == '__main__': + + try: + from msvcrt import getch + except ImportError: + import termios + import tty + + def getch(): # getchar(), getc(stdin) #PYCHOK flake + fd = sys.stdin.fileno() + old = termios.tcgetattr(fd) + try: + tty.setraw(fd) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(fd, termios.TCSADRAIN, old) + return ch + + def end_callback(event): + print('End of media stream (event %s)' % event.type) + sys.exit(0) + + echo_position = False + def pos_callback(event, player): + if echo_position: + sys.stdout.write('\r%s to %.2f%% (%.2f%%)' % (event.type, + event.u.new_position * 100, + player.get_position() * 100)) + sys.stdout.flush() + + def print_version(): + """Print libvlc version""" + try: + print('Build date: %s (%#x)' % (build_date, hex_version())) + print('LibVLC version: %s (%#x)' % (libvlc_get_version(), libvlc_hex_version())) + print('LibVLC compiler: %s' % libvlc_get_compiler()) + if plugin_path: + print('Plugin path: %s' % plugin_path) + except: + print('Error: %s' % sys.exc_info()[1]) + + if sys.argv[1:] and sys.argv[1] not in ('-h', '--help'): + + movie = os.path.expanduser(sys.argv[1]) + if not os.access(movie, os.R_OK): + print('Error: %s file not readable' % movie) + sys.exit(1) + + instance = Instance() + try: + media = instance.media_new(movie, 'sub-filter=marq') # load marqee option + except NameError: + print('NameError: %s (%s vs LibVLC %s)' % (sys.exc_info()[1], + __version__, + libvlc_get_version())) + sys.exit(1) + player = instance.media_player_new() + player.set_media(media) + player.play() + + # Some marquee examples. Marquee requires 'sub-filter=marq' in the + # media_new() call above. See also the Media.add_options method + # and + player.video_set_marquee_int(VideoMarqueeOption.Enable, 1) + player.video_set_marquee_int(VideoMarqueeOption.Size, 24) # pixels + player.video_set_marquee_int(VideoMarqueeOption.Position, Position.Bottom) + if True: # only one marquee can be specified + player.video_set_marquee_int(VideoMarqueeOption.Timeout, 5000) # millisec, 0==forever + t = media.get_mrl() # movie + else: # update marquee text periodically + player.video_set_marquee_int(VideoMarqueeOption.Timeout, 0) # millisec, 0==forever + player.video_set_marquee_int(VideoMarqueeOption.Refresh, 1000) # millisec (or sec?) + ##t = '$L / $D or $P at $T' + t = '%Y-%m-%d %H:%M:%S' + player.video_set_marquee_string(VideoMarqueeOption.Text, t) + + # Some event manager examples. Note, the callback can be any Python + # callable and does not need to be decorated. Optionally, specify + # any number of positional and/or keyword arguments to be passed + # to the callback (in addition to the first one, an Event instance). + event_manager = player.event_manager() + event_manager.event_attach(EventType.MediaPlayerEndReached, end_callback) + event_manager.event_attach(EventType.MediaPlayerPositionChanged, pos_callback, player) + + def mspf(): + """Milliseconds per frame.""" + return int(1000 // (player.get_fps() or 25)) + + def print_info(): + """Print information about the media""" + try: + print_version() + media = player.get_media() + print('State: %s' % player.get_state()) + print('Media: %s' % media.get_mrl()) + print('Track: %s/%s' % (player.video_get_track(), player.video_get_track_count())) + print('Current time: %s/%s' % (player.get_time(), media.get_duration())) + print('Position: %s' % player.get_position()) + print('FPS: %s (%d ms)' % (player.get_fps(), mspf())) + print('Rate: %s' % player.get_rate()) + print('Video size: %s' % str(player.video_get_size(0))) # num=0 + print('Scale: %s' % player.video_get_scale()) + print('Aspect ratio: %s' % player.video_get_aspect_ratio()) + #print('Window:' % player.get_hwnd() + except Exception: + print('Error: %s', sys.exc_info()[1]) + + def sec_forward(): + """Go forward one sec""" + player.set_time(player.get_time() + 1000) + + def sec_backward(): + """Go backward one sec""" + player.set_time(player.get_time() - 1000) + + def frame_forward(): + """Go forward one frame""" + player.set_time(player.get_time() + mspf()) + + def frame_backward(): + """Go backward one frame""" + player.set_time(player.get_time() - mspf()) + + def print_help(): + """Print help""" + print('Single-character commands:') + for k, m in sorted(keybindings.items()): + m = (m.__doc__ or m.__name__).splitlines()[0] + print(' %s: %s.' % (k, m.rstrip('.'))) + print('0-9: go to that fraction of the movie') + + def quit_app(): + """Stop and exit""" + sys.exit(0) + + def toggle_echo_position(): + """Toggle echoing of media position""" + global echo_position + echo_position = not echo_position + + keybindings = { + ' ': player.pause, + '+': sec_forward, + '-': sec_backward, + '.': frame_forward, + ',': frame_backward, + 'f': player.toggle_fullscreen, + 'i': print_info, + 'p': toggle_echo_position, + 'q': quit_app, + '?': print_help, + } + + print('Press q to quit, ? to get help.%s' % os.linesep) + while True: + k = getch().decode('utf8') # Python 3+ + print('> %s' % k) + if k in keybindings: + keybindings[k]() + elif k.isdigit(): + # jump to fraction of the movie. + player.set_position(float('0.'+k)) + + else: + print('Usage: %s ' % sys.argv[0]) + print('Once launched, type ? for help.') + print('') + print_version() diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py new file mode 100644 index 000000000..2adf0a2d1 --- /dev/null +++ b/openlp/core/ui/media/vlcplayer.py @@ -0,0 +1,220 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # +# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # +# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 +import sys, os +from datetime import datetime +try: + import vlc + vlc_available = bool(vlc.get_default_instance()) +except (ImportError, NameError): + vlc_available = False +except OSError, e: + if sys.platform.startswith('win'): + if isinstance(e, WindowsError) and e.winerror == 126: + vlc_available = False + else: + raise + else: + raise + +from PyQt4 import QtCore, QtGui +from openlp.core.lib import Receiver +from openlp.core.lib.mediaplayer import MediaPlayer +from openlp.core.ui.media import MediaState + +log = logging.getLogger(__name__) + +AUDIO_EXT = [ + u'*.mp3' + , u'*.wav' + , u'*.ogg' + ] + +VIDEO_EXT = [ + u'*.3gp' + , u'*.asf', u'*.wmv' + , u'*.au' + , u'*.avi' + , u'*.flv' + , u'*.mov' + , u'*.mp4' + , u'*.ogm' + , u'*.mkv', u'*.mka' + , u'*.ts', u'*.mpg' + , u'*.mpg', u'*.mp2' + , u'*.nsc' + , u'*.nsv' + , u'*.nut' + , u'*.ra', u'*.ram', u'*.rm', u'*.rv' ,u'*.rmbv' + , u'*.a52', u'*.dts', u'*.aac', u'*.flac' ,u'*.dv', u'*.vid' + , u'*.tta', u'*.tac' + , u'*.ty' + , u'*.dts' + , u'*.xa' + , u'*.iso' + , u'*.vob' + ] + + +class VlcPlayer(MediaPlayer): + """ + A specialised version of the MediaPlayer class, which provides a QtWebKit + display. + """ + + def __init__(self, parent): + MediaPlayer.__init__(self, parent, u'vlc') + self.parent = parent + self.canFolder = True + self.audio_extensions_list = AUDIO_EXT + self.video_extensions_list = VIDEO_EXT + + def setup(self, display): + display.vlcWidget = QtGui.QFrame(display) + # creating a basic vlc instance + command_line_options = u'--no-video-title-show' + if not display.hasAudio: + command_line_options += u' --no-audio --no-video-title-show' + if QtCore.QSettings().value(u'advanced/hide mouse', + QtCore.QVariant(False)).toBool() and \ + display.controller.isLive: + command_line_options += u' --mouse-hide-timeout=0' + display.vlcInstance = vlc.Instance(command_line_options) + display.vlcInstance.set_log_verbosity(2) + # creating an empty vlc media player + display.vlcMediaPlayer = display.vlcInstance.media_player_new() + display.vlcWidget.resize(display.size()) + display.vlcWidget.raise_() + display.vlcWidget.hide() + # the media player has to be 'connected' to the QFrame + # (otherwise a video would be displayed in it's own window) + # this is platform specific! + # you have to give the id of the QFrame (or similar object) to + # vlc, different platforms have different functions for this + if sys.platform == "win32": # for Windows + display.vlcMediaPlayer.set_hwnd(int(display.vlcWidget.winId())) + elif sys.platform == "darwin": # for MacOS + display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId())) + else: + # for Linux using the X Server + display.vlcMediaPlayer.set_xwindow(int(display.vlcWidget.winId())) + self.hasOwnWidget = True + + def check_available(self): + return vlc_available + + def load(self, display): + log.debug(u'load vid in Vlc Controller') + controller = display.controller + volume = controller.media_info.volume + file_path = str( + controller.media_info.file_info.absoluteFilePath().toUtf8()) + path = os.path.normcase(file_path) + # create the media + display.vlcMedia = display.vlcInstance.media_new_path(path) + # put the media in the media player + display.vlcMediaPlayer.set_media(display.vlcMedia) + # parse the metadata of the file + display.vlcMedia.parse() + self.volume(display, volume) + return True + + def media_state_wait(self, display, mediaState): + """ + Wait for the video to change its state + Wait no longer than 60 seconds. (loading an iso file needs a long time) + """ + start = datetime.now() + while not mediaState == display.vlcMedia.get_state(): + if display.vlcMedia.get_state() == vlc.State.Error: + return False + Receiver.send_message(u'openlp_process_events') + if (datetime.now() - start).seconds > 60: + return False + return True + + def resize(self, display): + display.vlcWidget.resize(display.size()) + + def play(self, display): + controller = display.controller + start_time = 0 + if controller.media_info.start_time > 0: + start_time = controller.media_info.start_time + display.vlcMediaPlayer.play() + if self.media_state_wait(display, vlc.State.Playing): + if start_time > 0: + self.seek(display, controller.media_info.start_time * 1000) + controller.media_info.length = \ + int(display.vlcMediaPlayer.get_media().get_duration() / 1000) + controller.seekSlider.setMaximum(controller.media_info.length * 1000) + self.state = MediaState.Playing + display.vlcWidget.raise_() + return True + else: + return False + + def pause(self, display): + if display.vlcMedia.get_state() != vlc.State.Playing: + return + display.vlcMediaPlayer.pause() + if self.media_state_wait(display, vlc.State.Paused): + self.state = MediaState.Paused + + def stop(self, display): + display.vlcMediaPlayer.stop() + self.state = MediaState.Stopped + + def volume(self, display, vol): + if display.hasAudio: + display.vlcMediaPlayer.audio_set_volume(vol) + + def seek(self, display, seekVal): + if display.vlcMediaPlayer.is_seekable(): + display.vlcMediaPlayer.set_time(seekVal) + + def reset(self, display): + display.vlcMediaPlayer.stop() + display.vlcWidget.setVisible(False) + self.state = MediaState.Off + + def set_visible(self, display, status): + if self.hasOwnWidget: + display.vlcWidget.setVisible(status) + + def update_ui(self, display): + controller = display.controller + if controller.media_info.end_time > 0: + if display.vlcMediaPlayer.get_time() > \ + controller.media_info.end_time * 1000: + self.stop(display) + self.set_visible(display, False) + if not controller.seekSlider.isSliderDown(): + controller.seekSlider.setSliderPosition( \ + display.vlcMediaPlayer.get_time()) + diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 3f7bc37be..abb5355d0 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -294,7 +294,7 @@ class WebkitPlayer(MediaPlayer): def load(self, display): log.debug(u'load vid in Webkit Controller') controller = display.controller - if display.hasAudio: + if display.hasAudio and not controller.media_info.is_background: volume = controller.media_info.volume vol = float(volume) / float(100) else: diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index cc6cc92bc..1b8666cd3 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 3fc4bf34b..a9a38a9eb 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 6933bd8fc..435181568 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 8287ef02a..6d39fea55 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 4d1dc71c8..3e650765d 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 5b81c8be8..d576f0e58 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -222,6 +222,21 @@ class ScreenList(object): log.debug(u'reset_current_display') self.set_current_display(self.current[u'number']) + def which_screen(self, window): + """ + Return the screen number that the centre of the passed window is in. + + ``window`` + A QWidget we are finding the location of. + """ + x = window.x() + (window.width() / 2) + y = window.y() + (window.height() / 2) + for screen in self.screen_list: + size = screen[u'size'] + if x >= size.x() and x <= (size.x() + size.width()) \ + and y >= size.y() and y <= (size.y() + size.height()): + return screen[u'number'] + def _load_screen_settings(self): """ Loads the screen size and the monitor number from the settings. diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index d821430b2..362687137 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 974133c3d..3541870ba 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 0eb1e77c5..2217dc168 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -31,6 +31,7 @@ import os import shutil import zipfile from tempfile import mkstemp +from datetime import datetime, timedelta log = logging.getLogger(__name__) @@ -43,8 +44,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ context_menu_action, context_menu_separator, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm -from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ - split_filename +from openlp.core.utils import AppLocation, delete_file, split_filename from openlp.core.utils.actions import ActionList, CategoryOrder class ServiceManagerList(QtGui.QTreeWidget): @@ -596,7 +596,10 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.finishedProgressBar() Receiver.send_message(u'cursor_normal') if success: - shutil.copy(temp_file_name, path_file_name) + try: + shutil.copy(temp_file_name, path_file_name) + except: + return self.saveFileAs() self.mainwindow.addRecentFile(path_file_name) self.setModified(False) try: @@ -610,10 +613,44 @@ class ServiceManager(QtGui.QWidget): Get a file name and then call :func:`ServiceManager.saveFile` to save the file. """ + default_service_enabled = QtCore.QSettings().value( + u'advanced/default service enabled', QtCore.QVariant(True)).toBool() + if default_service_enabled: + service_day = QtCore.QSettings().value( + u'advanced/default service day', 7).toInt()[0] + if service_day == 7: + time = datetime.now() + else: + service_hour = QtCore.QSettings().value( + u'advanced/default service hour', 11).toInt()[0] + service_minute = QtCore.QSettings().value( + u'advanced/default service minute', 0).toInt()[0] + now = datetime.now() + day_delta = service_day - now.weekday() + if day_delta < 0: + day_delta += 7 + time = now + timedelta(days=day_delta) + time = time.replace(hour=service_hour, minute=service_minute) + default_pattern = unicode(QtCore.QSettings().value( + u'advanced/default service name', + translate('OpenLP.AdvancedTab', + 'Service %Y-%m-%d %H-%M', + 'This is the default default service name template, which can ' + 'be found under Advanced in Settings, Configure OpenLP. ' + 'Please do not include any of the following characters: ' + '/\\?*|<>\[\]":+\n' + 'You can use any of the directives as shown on page ' + 'http://docs.python.org/library/datetime.html' + '#strftime-strptime-behavior , but if possible, please keep ' + 'the resulting string sortable by name.')).toString()) + default_filename = time.strftime(default_pattern) + else: + default_filename = u'' + directory = unicode(SettingsManager.get_last_dir( + self.mainwindow.servicemanagerSettingsSection)) + path = os.path.join(directory, default_filename) fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, - UiStrings().SaveService, - SettingsManager.get_last_dir( - self.mainwindow.servicemanagerSettingsSection), + UiStrings().SaveService, path, translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)'))) if not fileName: return False @@ -636,8 +673,11 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(fileName) for zipinfo in zip.infolist(): - ucsfile = file_is_unicode(zipinfo.filename) - if not ucsfile: + try: + ucsfile = zipinfo.filename.decode(u'utf-8') + except UnicodeDecodeError: + log.exception(u'Filename "%s" is not valid UTF-8' % + zipinfo.filename.decode(u'utf-8', u'replace')) critical_error_message_box( message=translate('OpenLP.ServiceManager', 'File is not a valid service.\n' @@ -821,7 +861,7 @@ class ServiceManager(QtGui.QWidget): lookFor = 1 serviceIterator += 1 - def previousItem(self): + def previousItem(self, message): """ Called by the SlideController to select the previous service item. """ @@ -829,15 +869,26 @@ class ServiceManager(QtGui.QWidget): return selected = self.serviceManagerList.selectedItems()[0] prevItem = None + prevItemLastSlide = None serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) while serviceIterator.value(): if serviceIterator.value() == selected: - if prevItem: + if message == u'last slide' and prevItemLastSlide: + pos = prevItem.data(0, QtCore.Qt.UserRole).toInt()[0] + check_expanded = self.serviceItems[pos - 1][u'expanded'] + self.serviceManagerList.setCurrentItem(prevItemLastSlide) + if not check_expanded: + self.serviceManagerList.collapseItem(prevItem) + self.makeLive() + self.serviceManagerList.setCurrentItem(prevItem) + elif prevItem: self.serviceManagerList.setCurrentItem(prevItem) self.makeLive() return if serviceIterator.value().parent() is None: prevItem = serviceIterator.value() + if serviceIterator.value().parent() is prevItem: + prevItemLastSlide = serviceIterator.value() serviceIterator += 1 def onSetItem(self, message): diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index ddfcb3381..392a6f32d 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 643ab0a6e..8d692de7b 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index b25a3a856..0aa5d44d0 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index a9b9b22cf..eaee35afa 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 1eccddc95..211946793 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -344,8 +344,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if category.name is None: continue for action in category.actions: - if self.changedActions .has_key(action): + if action in self.changedActions: + old_shortcuts = map(unicode, + map(QtGui.QKeySequence.toString, action.shortcuts())) action.setShortcuts(self.changedActions[action]) + self.action_list.update_shortcut_map(action, old_shortcuts) settings.setValue( action.objectName(), QtCore.QVariant(action.shortcuts())) settings.endGroup() @@ -452,7 +455,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): those shortcuts which are not saved yet but already assigned (as changes are applied when closing the dialog). """ - if self.changedActions.has_key(action): + if action in self.changedActions: return self.changedActions[action] return action.shortcuts() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index cd4663297..f7be9a191 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -33,8 +33,9 @@ from collections import deque from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ - translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem + translate, build_icon, build_html, PluginManager, ServiceItem from openlp.core.lib.ui import UiStrings, shortcut_action +from openlp.core.lib import SlideLimits, ServiceItemAction from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList from openlp.core.utils.actions import ActionList, CategoryOrder @@ -45,9 +46,10 @@ class SlideList(QtGui.QTableWidget): Customised version of QTableWidget which can respond to keyboard events. """ - def __init__(self, parent=None, name=None): + def __init__(self, parent=None): QtGui.QTableWidget.__init__(self, parent.controller) + class Controller(QtGui.QWidget): """ Controller is a general controller widget. @@ -82,8 +84,11 @@ class SlideController(Controller): """ Controller.__init__(self, parent, isLive) self.screens = ScreenList.get_instance() - self.ratio = float(self.screens.current[u'size'].width()) / \ - float(self.screens.current[u'size'].height()) + try: + self.ratio = float(self.screens.current[u'size'].width()) / \ + float(self.screens.current[u'size'].height()) + except ZeroDivisionError: + self.ratio = 1 self.imageManager = self.parent().imageManager self.mediaController = self.parent().mediaController self.loopList = [ @@ -95,13 +100,15 @@ class SlideController(Controller): u'Edit Song', ] self.nextPreviousList = [ - u'Previous Slide', + u'Previous Slide', u'Next Slide' ] self.timer_id = 0 self.songEdit = False self.selectedRow = 0 self.serviceItem = None + self.slide_limits = None + self.updateSlideLimits() self.panel = QtGui.QWidget(parent.controlSplitter) self.slideList = {} # Layout for holding panel @@ -114,8 +121,8 @@ class SlideController(Controller): self.typeLabel.setText(UiStrings().Live) self.split = 1 self.typePrefix = u'live' - self.keypress_queue = deque() - self.keypress_loop = False + self.keypress_queue = deque() + self.keypress_loop = False else: self.typeLabel.setText(UiStrings().Preview) self.split = 0 @@ -187,7 +194,7 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Hide'), self.toolbar)) self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen', [QtCore.Qt.Key_Period], self.onBlankDisplay, - u':/slides/slide_blank.png', False, + u':/slides/slide_blank.png', False, unicode(UiStrings().LiveToolbar)) self.blankScreen.setText( translate('OpenLP.SlideController', 'Blank Screen')) @@ -271,13 +278,48 @@ class SlideController(Controller): self.toolbar.addToolbarWidget(u'Song Menu', self.songMenu) self.songMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Go To'), self.toolbar)) - self.toolbar.makeWidgetsInvisible([u'Song Menu']) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarButton( - u'Pause Audio', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Pause audio.'), - self.onAudioPauseClicked, True) + self.audioPauseItem = QtGui.QToolButton(self.toolbar) + self.audioPauseItem.setIcon( + QtGui.QIcon(u':/slides/media_playback_pause.png')) + self.audioPauseItem.setText(translate('OpenLP.SlideController', + 'Pause audio.')) + self.audioPauseItem.setCheckable(True) + self.toolbar.addToolbarWidget(u'Pause Audio', self.audioPauseItem) + QtCore.QObject.connect(self.audioPauseItem, + QtCore.SIGNAL(u'clicked(bool)'), self.onAudioPauseClicked) self.audioPauseItem.setVisible(False) + self.audioMenu = QtGui.QMenu( + translate('OpenLP.SlideController', 'Background Audio'), + self.toolbar) + self.nextTrackItem = shortcut_action(self.audioMenu, + u'nextTrackItem', [], self.onNextTrackClicked, + u':/slides/media_playback_next.png', + category=unicode(UiStrings().LiveToolbar)) + self.nextTrackItem.setText( + translate('OpenLP.SlideController', 'Next Track')) + self.audioMenu.addAction(self.nextTrackItem) + self.trackMenu = self.audioMenu.addMenu( + translate('OpenLP.SlideController', 'Tracks')) + self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup) + self.audioPauseItem.setMenu(self.audioMenu) + self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) + self.audioTimeLabel.setAlignment( + QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) + self.audioTimeLabel.setStyleSheet( + u'background-color: palette(background); ' + u'border-top-color: palette(shadow); ' + u'border-left-color: palette(shadow); ' + u'border-bottom-color: palette(light); ' + u'border-right-color: palette(light); ' + u'border-radius: 3px; border-style: inset; ' + u'border-width: 1; font-family: monospace; margin: 2px;' + ) + self.audioTimeLabel.setObjectName(u'audioTimeLabel') + self.toolbar.addToolbarWidget( + u'Time Remaining', self.audioTimeLabel) + self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', + u'Time Remaining']) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -412,6 +454,9 @@ class SlideController(Controller): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_spin_delay'), self.receiveSpinDelay) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_toggle_display'), + self.toggleDisplay) self.toolbar.makeWidgetsInvisible(self.loopList) else: QtCore.QObject.connect(self.previewListWidget, @@ -447,6 +492,9 @@ class SlideController(Controller): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), self.onSlideUnblank) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_update_slide_limits'), + self.updateSlideLimits) def slideShortcutActivated(self): """ @@ -532,7 +580,7 @@ class SlideController(Controller): # Reset the shortcut. self.current_shortcut = u'' - def setPreviewHotkeys(self, parent=None): + def setPreviewHotkeys(self): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() @@ -570,18 +618,33 @@ class SlideController(Controller): self.display.setVisible(False) self.mediaController.video_stop([self]) + def toggleDisplay(self, action): + """ + Toggle the display settings triggered from remote messages. + """ + if action == u'blank' or action == u'hide': + self.onBlankDisplay(True) + elif action == u'theme': + self.onThemeDisplay(True) + elif action == u'desktop': + self.onHideDisplay(True) + elif action == u'show': + self.onBlankDisplay(False) + self.onThemeDisplay(False) + self.onHideDisplay(False) + def servicePrevious(self): """ Live event to select the previous service item from the service manager. """ - self.keypress_queue.append(u'previous') + self.keypress_queue.append(ServiceItemAction.Previous) self._process_queue() def serviceNext(self): """ Live event to select the next service item from the service manager. """ - self.keypress_queue.append(u'next') + self.keypress_queue.append(ServiceItemAction.Next) self._process_queue() def _process_queue(self): @@ -592,8 +655,12 @@ class SlideController(Controller): if len(self.keypress_queue): while len(self.keypress_queue) and not self.keypress_loop: self.keypress_loop = True - if self.keypress_queue.popleft() == u'previous': + keypressCommand = self.keypress_queue.popleft() + if keypressCommand == ServiceItemAction.Previous: Receiver.send_message('servicemanager_previous_item') + elif keypressCommand == ServiceItemAction.PreviousLastSlide: + # Go to the last slide of the previous item + Receiver.send_message('servicemanager_previous_item', u'last slide') else: Receiver.send_message('servicemanager_next_item') self.keypress_loop = False @@ -611,15 +678,20 @@ class SlideController(Controller): self.display.setup() if self.isLive: self.__addActionsToWidget(self.display) + self.display.audioPlayer.connectSlot( + QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining) # The SlidePreview's ratio. - self.ratio = float(self.screens.current[u'size'].width()) / \ - float(self.screens.current[u'size'].height()) + try: + self.ratio = float(self.screens.current[u'size'].width()) / \ + float(self.screens.current[u'size'].height()) + except ZeroDivisionError: + self.ratio = 1 self.mediaController.setup_display(self.display) self.previewSizeChanged() self.previewDisplay.setup() serviceItem = ServiceItem() - self.previewDisplay.webView.setHtml(build_html(serviceItem, - self.previewDisplay.screen, None, self.isLive, None, + self.previewDisplay.webView.setHtml(build_html(serviceItem, + self.previewDisplay.screen, None, self.isLive, plugins=PluginManager.get_instance().plugins)) self.mediaController.setup_display(self.previewDisplay) if self.serviceItem: @@ -682,6 +754,14 @@ class SlideController(Controller): """ self.delaySpinBox.setValue(int(value)) + def updateSlideLimits(self): + """ + Updates the Slide Limits variable from the settings. + """ + self.slide_limits = QtCore.QSettings().value( + self.parent().advancedlSettingsSection + u'/slide limits', + QtCore.QVariant(SlideLimits.End)).toInt()[0] + def enableToolBar(self, item): """ Allows the toolbars to be reconfigured based on Controller Type @@ -818,10 +898,23 @@ class SlideController(Controller): self.display.audioPlayer.reset() self.setAudioItemsVisibility(False) self.audioPauseItem.setChecked(False) + # If the current item has background audio if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio): log.debug(u'Starting to play...') self.display.audioPlayer.addToPlaylist( self.serviceItem.background_audio) + self.trackMenu.clear() + for counter in range(len(self.serviceItem.background_audio)): + action = self.trackMenu.addAction(os.path.basename( + self.serviceItem.background_audio[counter])) + action.setData(counter) + QtCore.QObject.connect(action, + QtCore.SIGNAL(u'triggered(bool)'), + self.onTrackTriggered) + self.display.audioPlayer.repeat = QtCore.QSettings().value( + self.parent().generalSettingsSection + \ + u'/audio repeat list', + QtCore.QVariant(False)).toBool() if QtCore.QSettings().value( self.parent().generalSettingsSection + \ u'/audio start paused', @@ -873,7 +966,7 @@ class SlideController(Controller): self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) - if slideHeight != 0: + if not slideHeight: self.previewListWidget.setRowHeight(framenumber, slideHeight) self.previewListWidget.setVerticalHeaderLabels(text) if self.serviceItem.is_text(): @@ -938,7 +1031,8 @@ class SlideController(Controller): display_type = QtCore.QSettings().value( self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'')).toString() - if not self.display.primary: + if self.screens.which_screen(self.window()) != \ + self.screens.which_screen(self.display): # Order done to handle initial conversion if display_type == u'themed': self.onThemeDisplay(True) @@ -949,7 +1043,7 @@ class SlideController(Controller): else: Receiver.send_message(u'live_display_show') else: - Receiver.send_message(u'live_display_hide', HideMode.Screen) + self.liveEscape() def onSlideBlank(self): """ @@ -1074,7 +1168,7 @@ class SlideController(Controller): else: Receiver.send_message(u'live_display_show') - def onSlideSelected(self, start=False): + def onSlideSelected(self): """ Slide selected in controller """ @@ -1158,10 +1252,14 @@ class SlideController(Controller): row = self.previewListWidget.currentRow() + 1 if row == self.previewListWidget.rowCount(): if wrap is None: - wrap = QtCore.QSettings().value( - self.parent().generalSettingsSection + - u'/enable slide loop', QtCore.QVariant(True)).toBool() - if wrap: + if self.slide_limits == SlideLimits.Wrap: + row = 0 + elif self.isLive and self.slide_limits == SlideLimits.Next: + self.serviceNext() + return + else: + row = self.previewListWidget.rowCount() - 1 + elif wrap: row = 0 else: row = self.previewListWidget.rowCount() - 1 @@ -1181,9 +1279,12 @@ class SlideController(Controller): else: row = self.previewListWidget.currentRow() - 1 if row == -1: - if QtCore.QSettings().value(self.parent().generalSettingsSection - + u'/enable slide loop', QtCore.QVariant(True)).toBool(): + if self.slide_limits == SlideLimits.Wrap: row = self.previewListWidget.rowCount() - 1 + elif self.isLive and self.slide_limits == SlideLimits.Next: + self.keypress_queue.append(ServiceItemAction.PreviousLastSlide) + self._process_queue() + return else: row = 0 self.__checkUpdateSelectedSlide(row) @@ -1263,7 +1364,12 @@ class SlideController(Controller): self.onToggleLoop() def setAudioItemsVisibility(self, visible): - self.audioPauseItem.setVisible(visible) + if visible: + self.toolbar.makeWidgetsVisible( + [u'Song Menu', u'Pause Audio', u'Time Remaining']) + else: + self.toolbar.makeWidgetsInvisible( + [u'Song Menu', u'Pause Audio', u'Time Remaining']) def onAudioPauseClicked(self, checked): if not self.audioPauseItem.isVisible(): @@ -1374,3 +1480,17 @@ class SlideController(Controller): return HideMode.Screen else: return None + + def onNextTrackClicked(self): + self.display.audioPlayer.next() + + def onAudioTimeRemaining(self, time): + seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 + minutes = seconds // 60 + seconds %= 60 + self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) + + def onTrackTriggered(self): + action = self.sender() + index = action.data().toInt()[0] + self.display.audioPlayer.goTo(index) diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 036daf968..7ab2d9798 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index 61e4eb662..236795b01 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index 45c0b70b7..61c57e417 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 9ccd91d08..face5938f 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -359,11 +359,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.gradientEndButton.setStyleSheet(u'background-color: %s' % self.theme.background_end_color) self.setField(u'background_type', QtCore.QVariant(1)) - else: + elif self.theme.background_type == \ + BackgroundType.to_string(BackgroundType.Image): self.imageColorButton.setStyleSheet(u'background-color: %s' % self.theme.background_border_color) self.imageFileEdit.setText(self.theme.background_filename) self.setField(u'background_type', QtCore.QVariant(2)) + elif self.theme.background_type == \ + BackgroundType.to_string(BackgroundType.Transparent): + self.setField(u'background_type', QtCore.QVariant(3)) if self.theme.background_direction == \ BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): self.setField(u'gradient', QtCore.QVariant(0)) diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index 56bfe79bb..26346392b 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index 57d8bd952..1a28a5397 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b8767d736..3585e5c97 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -30,6 +30,7 @@ import zipfile import shutil import logging import locale +import re from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui @@ -43,8 +44,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ context_menu_action, context_menu_separator from openlp.core.theme import Theme from openlp.core.ui import FileRenameForm, ThemeForm -from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ - get_filesystem_encoding +from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding log = logging.getLogger(__name__) @@ -147,6 +147,7 @@ class ThemeManager(QtGui.QWidget): check_directory_exists(self.thumbPath) self.themeForm.path = self.path self.oldBackgroundImage = None + self.bad_v1_name_chars = re.compile(r'[%+\[\]]') # Last little bits of setting up self.configUpdated() @@ -524,44 +525,50 @@ class ThemeManager(QtGui.QWidget): filexml = None try: zip = zipfile.ZipFile(filename) - themename = None - for file in zip.namelist(): - # Handle UTF-8 files - ucsfile = file_is_unicode(file) - if not ucsfile: - # Handle native Unicode files from Windows - ucsfile = file - osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) - theme_dir = None - if osfile.endswith(os.path.sep): - theme_dir = os.path.join(dir, osfile) - check_directory_exists(theme_dir) - else: - fullpath = os.path.join(dir, osfile) - names = osfile.split(os.path.sep) - if len(names) > 1: - # not preview file - if themename is None: - themename = names[0] - if theme_dir is None: - theme_dir = os.path.join(dir, names[0]) - check_directory_exists(theme_dir) - if os.path.splitext(ucsfile)[1].lower() in [u'.xml']: - xml_data = zip.read(file) - xml_data = file_is_unicode(xml_data) - if not xml_data: - break - filexml = self._checkVersionAndConvert(xml_data) - outfile = open(fullpath, u'w') - outfile.write(filexml.encode(u'utf-8')) - else: - outfile = open(fullpath, u'wb') - outfile.write(zip.read(file)) - except (IOError, NameError, zipfile.BadZipfile): - critical_error_message_box( - translate('OpenLP.ThemeManager', 'Validation Error'), - translate('OpenLP.ThemeManager', 'File is not a valid theme.')) + xmlfile = filter(lambda name: + os.path.splitext(name)[1].lower() == u'.xml', zip.namelist()) + if len(xmlfile) != 1: + log.exception(u'Theme contains "%s" XML files' % len(xmlfile)) + raise Exception(u'validation') + xml_tree = ElementTree(element=XML(zip.read(xmlfile[0]))).getroot() + v1_background = xml_tree.find(u'BackgroundType') + if v1_background is not None: + (themename, filexml, outfile) = self.unzipVersion122(dir, zip, + xmlfile[0], xml_tree, v1_background, outfile) + else: + themename = xml_tree.find(u'name').text.strip() + for name in zip.namelist(): + try: + uname = unicode(name, u'utf-8') + except UnicodeDecodeError: + log.exception(u'Theme file contains non utf-8 filename' + u' "%s"' % name.decode(u'utf-8', u'replace')) + raise Exception(u'validation') + uname = unicode(QtCore.QDir.toNativeSeparators(uname)) + splitname = uname.split(os.path.sep) + if splitname[-1] == u'' or len(splitname) == 1: + # is directory or preview file + continue + fullname = os.path.join(dir, uname) + check_directory_exists(os.path.dirname(fullname)) + if os.path.splitext(uname)[1].lower() == u'.xml': + filexml = unicode(zip.read(name), u'utf-8') + outfile = open(fullname, u'w') + outfile.write(filexml.encode(u'utf-8')) + else: + outfile = open(fullname, u'wb') + outfile.write(zip.read(name)) + outfile.close() + except (IOError, zipfile.BadZipfile): log.exception(u'Importing theme from zip failed %s' % filename) + raise Exception(u'validation') + except Exception as info: + if unicode(info) == u'validation': + critical_error_message_box(translate('OpenLP.ThemeManager', + 'Validation Error'), translate('OpenLP.ThemeManager', + 'File is not a valid theme.')) + else: + raise finally: # Close the files, to be able to continue creating the theme. if zip: @@ -582,6 +589,36 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme file does not contain XML data %s' % filename) + def unzipVersion122(self, dir, zip, xmlfile, xml_tree, background, outfile): + """ + Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling + this method, please keep in mind, that some parameters are redundant. + """ + themename = xml_tree.find(u'Name').text.strip() + themename = self.bad_v1_name_chars.sub(u'', themename) + themedir = os.path.join(dir, themename) + check_directory_exists(themedir) + filexml = unicode(zip.read(xmlfile), u'utf-8') + filexml = self._migrateVersion122(filexml) + outfile = open(os.path.join(themedir, themename + u'.xml'), u'w') + outfile.write(filexml.encode(u'utf-8')) + outfile.close() + if background.text.strip() == u'2': + imagename = xml_tree.find(u'BackgroundParameter1').text.strip() + # image file has same extension and is in subfolder + imagefile = filter(lambda name: os.path.splitext(name)[1].lower() + == os.path.splitext(imagename)[1].lower() and name.find(r'/'), + zip.namelist()) + if len(imagefile) >= 1: + outfile = open(os.path.join(themedir, imagename), u'wb') + outfile.write(zip.read(imagefile[0])) + outfile.close() + else: + log.exception(u'Theme file does not contain image file "%s"' % + imagename.decode(u'utf-8', u'replace')) + raise Exception(u'validation') + return (themename, filexml, outfile) + def checkIfThemeExists(self, themeName): """ Check if theme already exists and displays error message @@ -692,22 +729,6 @@ class ThemeManager(QtGui.QWidget): image = os.path.join(self.path, theme + u'.png') return image - def _checkVersionAndConvert(self, xml_data): - """ - Check if a theme is from OpenLP version 1 - - ``xml_data`` - Theme XML to check the version of - """ - log.debug(u'checkVersion1 ') - theme = xml_data.encode(u'ascii', u'xmlcharrefreplace') - tree = ElementTree(element=XML(theme)).getroot() - # look for old version 1 tags - if tree.find(u'BackgroundType') is None: - return xml_data - else: - return self._migrateVersion122(xml_data) - def _createThemeFromXml(self, themeXml, path): """ Return a theme object using information parsed from XML @@ -772,7 +793,7 @@ class ThemeManager(QtGui.QWidget): """ theme = Theme(xml_data) newtheme = ThemeXML() - newtheme.theme_name = theme.Name + newtheme.theme_name = self.bad_v1_name_chars.sub(u'', theme.Name) if theme.BackgroundType == 0: newtheme.background_type = \ BackgroundType.to_string(BackgroundType.Solid) @@ -792,10 +813,13 @@ class ThemeManager(QtGui.QWidget): unicode(theme.BackgroundParameter1.name()) newtheme.background_end_color = \ unicode(theme.BackgroundParameter2.name()) - else: + elif theme.BackgroundType == 2: newtheme.background_type = \ BackgroundType.to_string(BackgroundType.Image) newtheme.background_filename = unicode(theme.BackgroundParameter1) + elif theme.BackgroundType == 3: + newtheme.background_type = \ + BackgroundType.to_string(BackgroundType.Transparent) newtheme.font_main_name = theme.FontName newtheme.font_main_color = unicode(theme.FontColor.name()) newtheme.font_main_size = theme.FontProportion * 3 diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 572efdf4b..3439ade28 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 1135db274..fc471ded6 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -54,7 +54,7 @@ class Ui_ThemeWizard(object): self.backgroundLabel = QtGui.QLabel(self.backgroundPage) self.backgroundLabel.setObjectName(u'BackgroundLabel') self.backgroundComboBox = QtGui.QComboBox(self.backgroundPage) - self.backgroundComboBox.addItems([u'', u'', u'']) + self.backgroundComboBox.addItems([u'', u'', u'', u'']) self.backgroundComboBox.setObjectName(u'BackgroundComboBox') self.backgroundTypeLayout.addRow(self.backgroundLabel, self.backgroundComboBox) @@ -126,6 +126,12 @@ class Ui_ThemeWizard(object): self.imageLayout.addRow(self.imageLabel, self.imageFileLayout) self.imageLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.imageWidget) + self.transparentWidget = QtGui.QWidget(self.backgroundPage) + self.transparentWidget.setObjectName(u'TransparentWidget') + self.transparentLayout = QtGui.QFormLayout(self.transparentWidget) + self.transparentLayout.setMargin(0) + self.transparentLayout.setObjectName(u'TransparentLayout') + self.backgroundStack.addWidget(self.transparentWidget) self.backgroundLayout.addLayout(self.backgroundStack) themeWizard.addPage(self.backgroundPage) # Main Area Page @@ -432,6 +438,8 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Gradient')) self.backgroundComboBox.setItemText( BackgroundType.Image, UiStrings().Image) + self.backgroundComboBox.setItemText(BackgroundType.Transparent, + translate('OpenLP.ThemeWizard', 'Transparent')) self.colorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.gradientStartLabel.setText( translate(u'OpenLP.ThemeWizard', 'Starting color:')) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 9d8a106ed..91aa42e43 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -47,7 +47,7 @@ class WizardStrings(object): CCLI = u'CCLI/SongSelect' CSV = u'CSV' EW = u'EasyWorship' - ES = u'EasiSlides' + ES = u'EasySlides' FP = u'Foilpresenter' OL = u'OpenLyrics' OS = u'OpenSong' diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index fbf185474..9fa5bcd77 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -455,26 +455,6 @@ def get_web_page(url, header=None, update_openlp=False): log.debug(page) return page -def file_is_unicode(filename): - """ - Checks if a file is valid unicode and returns the unicode decoded file or - None. - - ``filename`` - File to check is valid unicode. - """ - if not filename: - return None - ucsfile = None - try: - ucsfile = filename.decode(u'utf-8') - except UnicodeDecodeError: - log.exception(u'Filename "%s" is not valid UTF-8' % - filename.decode(u'utf-8', u'replace')) - if not ucsfile: - return None - return ucsfile - def get_uno_command(): """ Returns the UNO command to launch an openoffice.org instance. @@ -507,5 +487,5 @@ from actions import ActionList __all__ = [u'AppLocation', u'get_application_version', u'check_latest_version', u'add_actions', u'get_filesystem_encoding', u'LanguageManager', - u'ActionList', u'get_web_page', u'file_is_unicode', u'get_uno_command', - u'get_uno_instance', u'delete_file', u'clean_filename'] + u'ActionList', u'get_web_page', u'get_uno_command', u'get_uno_instance', + u'delete_file', u'clean_filename'] diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 8b807bf9e..d363f1426 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -188,6 +188,7 @@ class ActionList(object): actions or categories. """ instance = None + shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -224,17 +225,45 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - if not category: - # Stop here, as this action is not configurable. - return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() + settings.endGroup() + if not shortcuts: + action.setShortcuts([]) + return + # We have to do this to ensure that the loaded shortcut list e. g. + # STRG+O (German) is converted to CTRL+O, which is only done when we + # convert the strings in this way (QKeySequence -> QString -> unicode). + shortcuts = map(QtGui.QKeySequence, shortcuts) + shortcuts = map(unicode, map(QtGui.QKeySequence.toString, shortcuts)) + # Check the alternate shortcut first, to avoid problems when the + # alternate shortcut becomes the primary shortcut after removing the + # (initial) primary shortcut due to conflicts. + if len(shortcuts) == 2: + existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._is_shortcut_available(existing_actions, action): + actions = ActionList.shortcut_map.get(shortcuts[1], []) + actions.append(action) + ActionList.shortcut_map[shortcuts[1]] = actions + else: + shortcuts.remove(shortcuts[1]) + # Check the primary shortcut. + existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._is_shortcut_available(existing_actions, action): + actions = ActionList.shortcut_map.get(shortcuts[0], []) + actions.append(action) + ActionList.shortcut_map[shortcuts[0]] = actions + else: + shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) - settings.endGroup() def remove_action(self, action, category=None): """ @@ -242,7 +271,7 @@ class ActionList(object): automatically removed. ``action`` - The QAction object to be removed. + The ``QAction`` object to be removed. ``category`` The name (unicode string) of the category, which contains the @@ -254,6 +283,15 @@ class ActionList(object): # Remove empty categories. if len(self.categories[category].actions) == 0: self.categories.remove(category) + shortcuts = map(unicode, + map(QtGui.QKeySequence.toString, action.shortcuts())) + for shortcut in shortcuts: + # Remove action from the list of actions which are using this + # shortcut. + ActionList.shortcut_map[shortcut].remove(action) + # Remove empty entries. + if not ActionList.shortcut_map[shortcut]: + del ActionList.shortcut_map[shortcut] def add_category(self, name, weight): """ @@ -275,6 +313,60 @@ class ActionList(object): return self.categories.add(name, weight) + def update_shortcut_map(self, action, old_shortcuts): + """ + Remove the action for the given ``old_shortcuts`` from the + ``shortcut_map`` to ensure its up-to-dateness. + + **Note**: The new action's shortcuts **must** be assigned to the given + ``action`` **before** calling this method. + + ``action`` + The action whose shortcuts are supposed to be updated in the + ``shortcut_map``. + + ``old_shortcuts`` + A list of unicode keysequences. + """ + for old_shortcut in old_shortcuts: + # Remove action from the list of actions which are using this + # shortcut. + ActionList.shortcut_map[old_shortcut].remove(action) + # Remove empty entries. + if not ActionList.shortcut_map[old_shortcut]: + del ActionList.shortcut_map[old_shortcut] + new_shortcuts = map(unicode, + map(QtGui.QKeySequence.toString, action.shortcuts())) + # Add the new shortcuts to the map. + for new_shortcut in new_shortcuts: + existing_actions = ActionList.shortcut_map.get(new_shortcut, []) + existing_actions.append(action) + ActionList.shortcut_map[new_shortcut] = existing_actions + + def _is_shortcut_available(self, existing_actions, action): + """ + Checks if the given ``action`` may use its assigned shortcut(s) or not. + Returns ``True`` or ``False. + + ``existing_actions`` + A list of actions which already use a particular shortcut. + + ``action`` + The action which wants to use a particular shortcut. + """ + for existing_action in existing_actions: + if action is existing_action: + continue + if existing_action.parent() is action.parent(): + return False + if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + if action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + return True + class CategoryOrder(object): """ diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 7b57ee2bc..929105ad2 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/__init__.py b/openlp/plugins/__init__.py index 48fe8cb77..63bbf5147 100644 --- a/openlp/plugins/__init__.py +++ b/openlp/plugins/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/__init__.py b/openlp/plugins/alerts/__init__.py index 006db9361..6c511cb8b 100644 --- a/openlp/plugins/alerts/__init__.py +++ b/openlp/plugins/alerts/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index ba2af74e8..e67ef0686 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index 3b11d7c92..ab18207e3 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index e42680165..6cd59f9a2 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 45d283f28..188914c5d 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py index 780f295a8..f9c6e626d 100644 --- a/openlp/plugins/alerts/lib/__init__.py +++ b/openlp/plugins/alerts/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index e73273fe7..7c92df75e 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 90e06caab..fc7c74ea5 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/alerts/lib/db.py b/openlp/plugins/alerts/lib/db.py index b5c4f8d60..7cc1227e6 100644 --- a/openlp/plugins/alerts/lib/db.py +++ b/openlp/plugins/alerts/lib/db.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/__init__.py b/openlp/plugins/bibles/__init__.py index d468ae0dc..202cd0edd 100644 --- a/openlp/plugins/bibles/__init__.py +++ b/openlp/plugins/bibles/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 68b4d1ce8..2f9a4fd6d 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 5b19d9f24..89bfbfff3 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 7577e86a3..ee7b5a063 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 322e3219a..7c7f14979 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # # Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # # Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index e9211b3d5..4b67fa826 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # # Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # # Tibble, Carsten Tinggaard, Frode Woldsund # diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index b07f28bf1..e786d720a 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # # Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # # Tibble, Carsten Tinggaard, Frode Woldsund # diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 5c1325a54..390977ee9 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # # Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # # Tibble, Carsten Tinggaard, Frode Woldsund # diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index c5069815b..cf027341d 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # # Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # # Tibble, Carsten Tinggaard, Frode Woldsund # diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 7e40b6230..6189f108f 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -31,8 +31,15 @@ plugin. import logging import re +from PyQt4 import QtCore + +from openlp.core.lib import translate + log = logging.getLogger(__name__) +REFERENCE_MATCHES = {} +REFERENCE_SEPARATORS = {} + class LayoutStyle(object): """ An enumeration for bible screen layout styles. @@ -52,39 +59,85 @@ class DisplayStyle(object): Square = 3 +def update_reference_separators(): + """ + Updates separators and matches for parsing and formating scripture + references. + """ + default_separators = unicode(translate('BiblesPlugin', + ':|v|V|verse|verses;;-|to;;,|and;;end', + 'This are 4 values seperated each by two semicolons representing the ' + 'seperators for parsing references. This values are verse separators, ' + 'range separators, list separators and end mark. Alternative values ' + 'to be seperated by a vertical bar "|". In this case the first value ' + 'is the default and used for the display format. If a semicolon should ' + 'be used you have to give an alternative separator afterwards to allow ' + 'OpenLP correct splitting of the translation.')).split(u';;') + settings = QtCore.QSettings() + settings.beginGroup(u'bibles') + custom_separators = [ + unicode(settings.value(u'verse separator').toString()), + unicode(settings.value(u'range separator').toString()), + unicode(settings.value(u'list separator').toString()), + unicode(settings.value(u'end separator').toString())] + settings.endGroup() + for index, role in enumerate([u'v', u'r', u'l', u'e']): + if custom_separators[index].strip(u'|') == u'': + source_string = default_separators[index].strip(u'|') + else: + source_string = custom_separators[index].strip(u'|') + while u'||' in source_string: + source_string = source_string.replace(u'||', u'|') + if role != u'e': + REFERENCE_SEPARATORS[u'sep_%s_display' % role] = \ + source_string.split(u'|')[0] + # escape reserved characters + for character in u'\\.^$*+?{}[]()': + source_string = source_string.replace(character, u'\\' + character) + # add various unicode alternatives + source_string = source_string.replace(u'-', + u'(?:[-\u00AD\u2010\u2011\u2012\u2013\u2014\u2212\uFE63\uFF0D])') + source_string = source_string.replace(u',', u'(?:[,\u201A])') + REFERENCE_SEPARATORS[u'sep_%s' % role] = u'\s*(?:%s)\s*' % source_string + REFERENCE_SEPARATORS[u'sep_%s_default' % role] = \ + default_separators[index] + # verse range match: (:)?(-((:)?|end)?)? + range_regex = u'(?:(?P[0-9]+)%(sep_v)s)?' \ + u'(?P[0-9]+)(?P%(sep_r)s(?:(?:(?P' \ + u'[0-9]+)%(sep_v)s)?(?P[0-9]+)|%(sep_e)s)?)?' % \ + REFERENCE_SEPARATORS + REFERENCE_MATCHES[u'range'] = re.compile(u'^\s*%s\s*$' % range_regex, + re.UNICODE) + REFERENCE_MATCHES[u'range_separator'] = re.compile( + REFERENCE_SEPARATORS[u'sep_l'], re.UNICODE) + # full reference match: ((,(?!$)|(?=$)))+ + REFERENCE_MATCHES[u'full'] = re.compile( + u'^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \ + % dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]), + re.UNICODE) + +def get_reference_separator(separator_type): + """ + Provides separators for parsing and formatting scripture references. + + ``separator_type`` + The role and format of the separator. + """ + if len(REFERENCE_SEPARATORS) == 0: + update_reference_separators() + return REFERENCE_SEPARATORS[separator_type] + def get_reference_match(match_type): """ - Provides the regexes and matches to use while parsing strings for bible - references. + Provides matches for parsing scripture references strings. ``match_type`` - The type of reference information trying to be extracted in this call. + The type of match is ``range_separator``, ``range`` or ``full``. """ - local_separator = unicode(u':;;\s*[:vV]\s*;;-;;\s*-\s*;;,;;\s*,\s*;;end' - ).split(u';;') # English - # local_separator = unicode(u',;;\s*,\s*;;-;;\s*-\s*;;.;;\.;;[Ee]nde' - # ).split(u';;') # German - separators = { - u'sep_v_display': local_separator[0], u'sep_v': local_separator[1], - u'sep_r_display': local_separator[2], u'sep_r': local_separator[3], - u'sep_l_display': local_separator[4], u'sep_l': local_separator[5], - u'sep_e': local_separator[6]} - - # verse range match: (:)?(-((:)?|end)?)? - range_string = str(r'(?:(?P[0-9]+)%(sep_v)s)?(?P' - r'[0-9]+)(?P%(sep_r)s(?:(?:(?P[0-9]+)%(sep_v)s)?' - r'(?P[0-9]+)|%(sep_e)s)?)?') % separators - if match_type == u'range': - return re.compile(r'^\s*' + range_string + r'\s*$', re.UNICODE) - elif match_type == u'range_separator': - return re.compile(separators[u'sep_l']) - elif match_type == u'full': - # full reference match: ((,|(?=$)))+ - return re.compile(str(r'^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:' + range_string + r'(?:%(sep_l)s|(?=\s*$)))+)\s*$') - % separators, re.UNICODE) - else: - return separators[match_type] + if len(REFERENCE_MATCHES) == 0: + update_reference_separators() + return REFERENCE_MATCHES[match_type] def parse_reference(reference): """ @@ -140,7 +193,7 @@ def parse_reference(reference): If there is a range separator without further verse declaration the last refered chapter is addressed until the end. - ``range_string`` is a regular expression which matches for verse range + ``range_regex`` is a regular expression which matches for verse range declarations: ``(?:(?P[0-9]+)%(sep_v)s)?`` @@ -169,9 +222,9 @@ def parse_reference(reference): are optional leading digits followed by non-digits. The group ends before the whitspace in front of the next digit. - ``(?P(?:`` + range_string + ``(?:%(sep_l)s|(?=\s*$)))+)\s*$`` + ``(?P(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$`` The second group contains all ``ranges``. This can be multiple - declarations of a range_string separated by a list separator. + declarations of range_regex separated by a list separator. """ log.debug(u'parse_reference("%s")', reference) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 4a24c146d..e8e0d9e2c 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -30,8 +30,9 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsTab, translate -from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box +from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ + update_reference_separators, get_reference_separator log = logging.getLogger(__name__) @@ -90,6 +91,55 @@ class BiblesTab(SettingsTab): self.changeNoteLabel.setObjectName(u'changeNoteLabel') self.verseDisplayLayout.addRow(self.changeNoteLabel) self.leftLayout.addWidget(self.verseDisplayGroupBox) + self.scriptureReferenceGroupBox = QtGui.QGroupBox(self.leftColumn) + self.scriptureReferenceGroupBox.setObjectName( + u'scriptureReferenceGroupBox') + self.scriptureReferenceLayout = QtGui.QGridLayout( + self.scriptureReferenceGroupBox) + self.verseSeparatorCheckBox = QtGui.QCheckBox( + self.scriptureReferenceGroupBox) + self.verseSeparatorCheckBox.setObjectName(u'verseSeparatorCheckBox') + self.scriptureReferenceLayout.addWidget(self.verseSeparatorCheckBox, 0, + 0) + self.verseSeparatorLineEdit = QtGui.QLineEdit( + self.scriptureReferenceGroupBox) +# self.verseSeparatorLineEdit.setPalette + self.verseSeparatorLineEdit.setObjectName(u'verseSeparatorLineEdit') + self.scriptureReferenceLayout.addWidget(self.verseSeparatorLineEdit, 0, + 1) + self.rangeSeparatorCheckBox = QtGui.QCheckBox( + self.scriptureReferenceGroupBox) + self.rangeSeparatorCheckBox.setObjectName(u'rangeSeparatorCheckBox') + self.scriptureReferenceLayout.addWidget(self.rangeSeparatorCheckBox, 1, + 0) + self.rangeSeparatorLineEdit = QtGui.QLineEdit( + self.scriptureReferenceGroupBox) + self.rangeSeparatorLineEdit.setObjectName(u'rangeSeparatorLineEdit') + self.scriptureReferenceLayout.addWidget(self.rangeSeparatorLineEdit, 1, + 1) + self.listSeparatorCheckBox = QtGui.QCheckBox( + self.scriptureReferenceGroupBox) + self.listSeparatorCheckBox.setObjectName(u'listSeparatorCheckBox') + self.scriptureReferenceLayout.addWidget(self.listSeparatorCheckBox, 2, + 0) + self.listSeparatorLineEdit = QtGui.QLineEdit( + self.scriptureReferenceGroupBox) + self.listSeparatorLineEdit.setObjectName(u'listSeparatorLineEdit') + self.scriptureReferenceLayout.addWidget(self.listSeparatorLineEdit, 2, + 1) + self.endSeparatorCheckBox = QtGui.QCheckBox( + self.scriptureReferenceGroupBox) + self.endSeparatorCheckBox.setObjectName(u'endSeparatorCheckBox') + self.scriptureReferenceLayout.addWidget(self.endSeparatorCheckBox, 3, + 0) + self.endSeparatorLineEdit = QtGui.QLineEdit( + self.scriptureReferenceGroupBox) + self.endSeparatorLineEdit.setObjectName(u'endSeparatorLineEdit') + self.endSeparatorLineEdit.setValidator(QtGui.QRegExpValidator( + QtCore.QRegExp(r'[^0-9]*'), self.endSeparatorLineEdit)) + self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3, + 1) + self.leftLayout.addWidget(self.scriptureReferenceGroupBox) self.leftLayout.addStretch() self.rightColumn.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) @@ -110,6 +160,42 @@ class BiblesTab(SettingsTab): QtCore.QObject.connect( self.bibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onBibleSecondCheckBox) + QtCore.QObject.connect( + self.verseSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'), + self.onVerseSeparatorCheckBoxClicked) + QtCore.QObject.connect( + self.verseSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), + self.onVerseSeparatorLineEditEdited) + QtCore.QObject.connect( + self.verseSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'), + self.onVerseSeparatorLineEditFinished) + QtCore.QObject.connect( + self.rangeSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'), + self.onRangeSeparatorCheckBoxClicked) + QtCore.QObject.connect( + self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), + self.onRangeSeparatorLineEditEdited) + QtCore.QObject.connect( + self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'), + self.onRangeSeparatorLineEditFinished) + QtCore.QObject.connect( + self.listSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'), + self.onListSeparatorCheckBoxClicked) + QtCore.QObject.connect( + self.listSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), + self.onListSeparatorLineEditEdited) + QtCore.QObject.connect( + self.listSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'), + self.onListSeparatorLineEditFinished) + QtCore.QObject.connect( + self.endSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'), + self.onEndSeparatorCheckBoxClicked) + QtCore.QObject.connect( + self.endSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), + self.onEndSeparatorLineEditEdited) + QtCore.QObject.connect( + self.endSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'), + self.onEndSeparatorLineEditFinished) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) @@ -141,6 +227,36 @@ class BiblesTab(SettingsTab): 'Note:\nChanges do not affect verses already in the service.')) self.bibleSecondCheckBox.setText( translate('BiblesPlugin.BiblesTab', 'Display second Bible verses')) + self.scriptureReferenceGroupBox.setTitle( + translate('BiblesPlugin.BiblesTab', 'Custom Scripture References')) + self.verseSeparatorCheckBox.setText( + translate('BiblesPlugin.BiblesTab', 'Verse Separator:')) + self.rangeSeparatorCheckBox.setText( + translate('BiblesPlugin.BiblesTab', 'Range Separator:')) + self.listSeparatorCheckBox.setText( + translate('BiblesPlugin.BiblesTab', 'List Separator:')) + self.endSeparatorCheckBox.setText( + translate('BiblesPlugin.BiblesTab', 'End Mark:')) + self.verseSeparatorLineEdit.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple alternative ' + 'verse separators may be defined.\nThey have to be separated ' + 'by a vertical bar "|".\nPlease clear this edit line to use ' + 'the default value.')) + self.rangeSeparatorLineEdit.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple alternative ' + 'range separators may be defined.\nThey have to be separated ' + 'by a vertical bar "|".\nPlease clear this edit line to use ' + 'the default value.')) + self.listSeparatorLineEdit.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple alternative ' + 'list separators may be defined.\nThey have to be separated ' + 'by a vertical bar "|".\nPlease clear this edit line to use ' + 'the default value.')) + self.endSeparatorLineEdit.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple alternative ' + 'end marks may be defined.\nThey have to be separated by a ' + 'vertical bar "|".\nPlease clear this edit line to use the ' + 'default value.')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.bibleThemeComboBox.currentText() @@ -163,6 +279,106 @@ class BiblesTab(SettingsTab): if check_state == QtCore.Qt.Checked: self.second_bibles = True + def onVerseSeparatorCheckBoxClicked(self, checked): + if checked: + self.verseSeparatorLineEdit.setFocus() + else: + self.verseSeparatorLineEdit.setText( + get_reference_separator(u'sep_v_default')) + self.verseSeparatorLineEdit.setPalette( + self.getGreyTextPalette(not checked)) + + def onVerseSeparatorLineEditEdited(self, text): + self.verseSeparatorCheckBox.setChecked(True) + self.verseSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + + def onVerseSeparatorLineEditFinished(self): + if self.verseSeparatorLineEdit.isModified(): + text = self.verseSeparatorLineEdit.text() + if text == get_reference_separator(u'sep_v_default') or \ + text.remove(u'|').isEmpty(): + self.verseSeparatorCheckBox.setChecked(False) + self.verseSeparatorLineEdit.setText( + get_reference_separator(u'sep_v_default')) + self.verseSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + + def onRangeSeparatorCheckBoxClicked(self, checked): + if checked: + self.rangeSeparatorLineEdit.setFocus() + else: + self.rangeSeparatorLineEdit.setText( + get_reference_separator(u'sep_r_default')) + self.rangeSeparatorLineEdit.setPalette( + self.getGreyTextPalette(not checked)) + + def onRangeSeparatorLineEditEdited(self, text): + self.rangeSeparatorCheckBox.setChecked(True) + self.rangeSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + + def onRangeSeparatorLineEditFinished(self): + if self.rangeSeparatorLineEdit.isModified(): + text = self.rangeSeparatorLineEdit.text() + if text == get_reference_separator(u'sep_r_default') or \ + text.remove(u'|').isEmpty(): + self.rangeSeparatorCheckBox.setChecked(False) + self.rangeSeparatorLineEdit.setText( + get_reference_separator(u'sep_r_default')) + self.rangeSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + + def onListSeparatorCheckBoxClicked(self, checked): + if checked: + self.listSeparatorLineEdit.setFocus() + else: + self.listSeparatorLineEdit.setText( + get_reference_separator(u'sep_l_default')) + self.listSeparatorLineEdit.setPalette( + self.getGreyTextPalette(not checked)) + + def onListSeparatorLineEditEdited(self, text): + self.listSeparatorCheckBox.setChecked(True) + self.listSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + + def onListSeparatorLineEditFinished(self): + if self.listSeparatorLineEdit.isModified(): + text = self.listSeparatorLineEdit.text() + if text == get_reference_separator(u'sep_l_default') or \ + text.remove(u'|').isEmpty(): + self.listSeparatorCheckBox.setChecked(False) + self.listSeparatorLineEdit.setText( + get_reference_separator(u'sep_l_default')) + self.listSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + + def onEndSeparatorCheckBoxClicked(self, checked): + if checked: + self.endSeparatorLineEdit.setFocus() + else: + self.endSeparatorLineEdit.setText( + get_reference_separator(u'sep_e_default')) + self.endSeparatorLineEdit.setPalette( + self.getGreyTextPalette(not checked)) + + def onEndSeparatorLineEditEdited(self, text): + self.endSeparatorCheckBox.setChecked(True) + self.endSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + + def onEndSeparatorLineEditFinished(self): + if self.endSeparatorLineEdit.isModified(): + text = self.endSeparatorLineEdit.text() + if text == get_reference_separator(u'sep_e_default') or \ + text.remove(u'|').isEmpty(): + self.endSeparatorCheckBox.setChecked(False) + self.endSeparatorLineEdit.setText( + get_reference_separator(u'sep_e_default')) + self.endSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + def load(self): settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) @@ -180,6 +396,58 @@ class BiblesTab(SettingsTab): self.displayStyleComboBox.setCurrentIndex(self.display_style) self.layoutStyleComboBox.setCurrentIndex(self.layout_style) self.bibleSecondCheckBox.setChecked(self.second_bibles) + verse_separator = unicode(settings.value(u'verse separator').toString()) + if (verse_separator.strip(u'|') == u'') or \ + (verse_separator == get_reference_separator(u'sep_v_default')): + self.verseSeparatorLineEdit.setText( + get_reference_separator(u'sep_v_default')) + self.verseSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + self.verseSeparatorCheckBox.setChecked(False) + else: + self.verseSeparatorLineEdit.setText(verse_separator) + self.verseSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + self.verseSeparatorCheckBox.setChecked(True) + range_separator = unicode(settings.value(u'range separator').toString()) + if (range_separator.strip(u'|') == u'') or \ + (range_separator == get_reference_separator(u'sep_r_default')): + self.rangeSeparatorLineEdit.setText( + get_reference_separator(u'sep_r_default')) + self.rangeSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + self.rangeSeparatorCheckBox.setChecked(False) + else: + self.rangeSeparatorLineEdit.setText(range_separator) + self.rangeSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + self.rangeSeparatorCheckBox.setChecked(True) + list_separator = unicode(settings.value(u'list separator').toString()) + if (list_separator.strip(u'|') == u'') or \ + (list_separator == get_reference_separator(u'sep_l_default')): + self.listSeparatorLineEdit.setText( + get_reference_separator(u'sep_l_default')) + self.listSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + self.listSeparatorCheckBox.setChecked(False) + else: + self.listSeparatorLineEdit.setText(list_separator) + self.listSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + self.listSeparatorCheckBox.setChecked(True) + end_separator = unicode(settings.value(u'end separator').toString()) + if (end_separator.strip(u'|') == u'') or \ + (end_separator == get_reference_separator(u'sep_e_default')): + self.endSeparatorLineEdit.setText( + get_reference_separator(u'sep_e_default')) + self.endSeparatorLineEdit.setPalette( + self.getGreyTextPalette(True)) + self.endSeparatorCheckBox.setChecked(False) + else: + self.endSeparatorLineEdit.setText(end_separator) + self.endSeparatorLineEdit.setPalette( + self.getGreyTextPalette(False)) + self.endSeparatorCheckBox.setChecked(True) settings.endGroup() def save(self): @@ -193,6 +461,27 @@ class BiblesTab(SettingsTab): QtCore.QVariant(self.layout_style)) settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles)) settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) + if self.verseSeparatorCheckBox.isChecked(): + settings.setValue(u'verse separator', + self.verseSeparatorLineEdit.text()) + else: + settings.remove(u'verse separator') + if self.rangeSeparatorCheckBox.isChecked(): + settings.setValue(u'range separator', + self.rangeSeparatorLineEdit.text()) + else: + settings.remove(u'range separator') + if self.listSeparatorCheckBox.isChecked(): + settings.setValue(u'list separator', + self.listSeparatorLineEdit.text()) + else: + settings.remove(u'list separator') + if self.endSeparatorCheckBox.isChecked(): + settings.setValue(u'end separator', + self.endSeparatorLineEdit.text()) + else: + settings.remove(u'end separator') + update_reference_separators() settings.endGroup() def updateThemeList(self, theme_list): @@ -209,3 +498,15 @@ class BiblesTab(SettingsTab): for theme in theme_list: self.bibleThemeComboBox.addItem(theme) find_and_set_in_combo_box(self.bibleThemeComboBox, self.bible_theme) + + def getGreyTextPalette(self, greyed): + """ + Returns a QPalette with greyed out text as used for placeholderText. + """ + palette = QtGui.QPalette() + color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Text) + if greyed: + color.setAlpha(128) + palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color) + return palette + diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 55feae7d4..cd4b921a1 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 243e7f967..5f3b7a6c9 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 228d4758c..72ffed487 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -92,6 +92,15 @@ class BGExtract(object): if headings: for heading in headings: heading.extract() + chapter_notes = soup.findAll('div', 'footnotes') + if chapter_notes: + log.debug('Found chapter notes') + for note in chapter_notes: + note.extract() + note_comments = soup.findAll(text=u'end of footnotes') + if note_comments: + for comment in note_comments: + comment.extract() cleanup = [(re.compile('\s+'), lambda match: ' ')] verses = BeautifulSoup(str(soup), markupMassage=cleanup) verse_list = {} diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 934aa2d90..c231f2062 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -33,7 +33,7 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file -from openlp.plugins.bibles.lib import parse_reference +from openlp.plugins.bibles.lib import parse_reference, get_reference_separator from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible @@ -309,19 +309,29 @@ class BibleManager(object): return self.db_cache[bible].get_verses(reflist, show_error) else: if show_error: + reference_seperators = { + u'verse': get_reference_separator(u'sep_v_display'), + u'range': get_reference_separator(u'sep_r_display'), + u'list': get_reference_separator(u'sep_l_display')} Receiver.send_message(u'openlp_information_message', { u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - u'message': translate('BiblesPlugin.BibleManager', + u'message': unicode(translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by ' 'OpenLP or is invalid. Please make sure your reference ' - 'conforms to one of the following patterns:\n\n' + 'conforms to one of the following patterns or consult the ' + 'manual:\n\n' 'Book Chapter\n' - 'Book Chapter-Chapter\n' - 'Book Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Verse,Verse-Verse\n' - 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Chapter:Verse') + 'Book Chapter%(range)sChapter\n' + 'Book Chapter%(verse)sVerse%(range)sVerse\n' + 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' + '%(range)sVerse\n' + 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' + '%(verse)sVerse%(range)sVerse\n' + 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse', + 'Please pay attention to the appended "s" of the wildcards ' + 'and refrain from translating the words inside the ' + 'names in the brackets.')) % reference_seperators }) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 31effe189..29172a334 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -31,14 +31,14 @@ import locale from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate + translate, create_separated_list from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box, \ find_and_set_in_combo_box, build_icon from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - VerseReferenceList, get_reference_match + VerseReferenceList, get_reference_separator log = logging.getLogger(__name__) @@ -634,8 +634,8 @@ class BibleMediaItem(MediaManagerItem): chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() verse_to = self.advancedToVerse.currentText() - verse_separator = get_reference_match(u'sep_v_display') - range_separator = get_reference_match(u'sep_r_display') + verse_separator = get_reference_separator(u'sep_v_display') + range_separator = get_reference_separator(u'sep_r_display') verse_range = chapter_from + verse_separator + verse_from + \ range_separator + chapter_to + verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) @@ -737,7 +737,7 @@ class BibleMediaItem(MediaManagerItem): Displays the search results in the media manager. All data needed for further action is saved for/in each row. """ - verse_separator = get_reference_match(u'sep_v_display') + verse_separator = get_reference_separator(u'sep_v_display') version = self.plugin.manager.get_meta_data(bible, u'Version').value copyright = self.plugin.manager.get_meta_data(bible, u'Copyright').value permissions = \ @@ -868,7 +868,7 @@ class BibleMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanLoop) service_item.add_capability(ItemCapabilities.CanWordSplit) # Service Item: Title - service_item.title = u', '.join(raw_title) + service_item.title = create_separated_list(raw_title) # Service Item: Theme if len(self.settings.bible_theme) == 0: service_item.theme = None @@ -890,8 +890,8 @@ class BibleMediaItem(MediaManagerItem): ``old_item`` The last item of a range. """ - verse_separator = get_reference_match(u'sep_v_display') - range_separator = get_reference_match(u'sep_r_display') + verse_separator = get_reference_separator(u'sep_v_display') + range_separator = get_reference_separator(u'sep_r_display') old_chapter = self._decodeQtObject(old_bitem, 'chapter') old_verse = self._decodeQtObject(old_bitem, 'verse') start_book = self._decodeQtObject(start_bitem, 'book') @@ -971,7 +971,7 @@ class BibleMediaItem(MediaManagerItem): ``verse`` The verse number (int). """ - verse_separator = get_reference_match(u'sep_v_display') + verse_separator = get_reference_separator(u'sep_v_display') if not self.settings.show_new_chapters or old_chapter != chapter: verse_text = unicode(chapter) + verse_separator + unicode(verse) else: diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index b822b9b9d..25aa109de 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -27,6 +27,7 @@ import logging import sqlite +import sys from openlp.core.lib import Receiver from openlp.core.ui.wizard import WizardStrings @@ -53,9 +54,14 @@ class OpenLP1Bible(BibleDB): connection = None cursor = None try: - connection = sqlite.connect(self.filename) + connection = sqlite.connect( + self.filename.encode(sys.getfilesystemencoding())) cursor = connection.cursor() - except: + except sqlite.DatabaseError: + log.exception(u'File "%s" is encrypted or not a sqlite database, ' + 'therefore not an openlp.org 1.x database either' % self.filename) + # Please add an user error here! + # This file is not an openlp.org 1.x bible database. return False #Create the bible language language_id = self.get_language(bible_name) @@ -63,7 +69,14 @@ class OpenLP1Bible(BibleDB): log.exception(u'Importing books from "%s" failed' % self.filename) return False # Create all books. - cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') + try: + cursor.execute( + u'SELECT id, testament_id, name, abbreviation FROM book') + except sqlite.DatabaseError as error: + log.exception(u'DatabaseError: %s' % error) + # Please add an user error here! + # This file is not an openlp.org 1.x bible database. + return False books = cursor.fetchall() self.wizard.progressBar.setMaximum(len(books) + 1) for book in books: diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 16820229c..ab03ef22f 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index d4d797513..4afee912d 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -53,6 +53,7 @@ class OSISBible(BibleDB): self.filename = kwargs[u'filename'] fbibles = None self.books = {} + self.language_regex = re.compile(r'(.*?)') self.verse_regex = re.compile( r'(.*?)') self.note_regex = re.compile(r'(.*?)') @@ -107,19 +108,32 @@ class OSISBible(BibleDB): finally: if detect_file: detect_file.close() - # Set meta language_id - language_id = self.get_language(bible_name) - if not language_id: - log.exception(u'Importing books from "%s" failed' % self.filename) - return False try: osis = codecs.open(self.filename, u'r', details['encoding']) repl = replacement + language_id = False for file_record in osis: if self.stop_import_flag: break + # Try to find the bible language + if not language_id: + language_match = self.language_regex.search(file_record) + if language_match: + language = BiblesResourcesDB.get_language( + language_match.group(1)) + if language: + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) + continue match = self.verse_regex.search(file_record) if match: + # Set meta language_id if not detected till now + if not language_id: + language_id = self.get_language(bible_name) + if not language_id: + log.exception(u'Importing books from "%s" failed' + % self.filename) + return False match_count += 1 book = match.group(1) chapter = int(match.group(2)) diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index a1727655e..73710468b 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/__init__.py b/openlp/plugins/custom/__init__.py index 3446f597e..2d28ae53c 100644 --- a/openlp/plugins/custom/__init__.py +++ b/openlp/plugins/custom/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index e9260f926..51206901d 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/forms/__init__.py b/openlp/plugins/custom/forms/__init__.py index e901095c2..71605ebd7 100644 --- a/openlp/plugins/custom/forms/__init__.py +++ b/openlp/plugins/custom/forms/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 3eee1cfd4..1d79968f5 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a85daa38b..6a72907a9 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 759f6b19d..a616075c0 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index 71696ebc1..d7d022a66 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/lib/__init__.py b/openlp/plugins/custom/lib/__init__.py index 0e343b6cc..c7737441d 100644 --- a/openlp/plugins/custom/lib/__init__.py +++ b/openlp/plugins/custom/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 8a7762f37..0466cf696 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/lib/customxmlhandler.py b/openlp/plugins/custom/lib/customxmlhandler.py index ff9fab7a7..a2210f8c6 100644 --- a/openlp/plugins/custom/lib/customxmlhandler.py +++ b/openlp/plugins/custom/lib/customxmlhandler.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/lib/db.py b/openlp/plugins/custom/lib/db.py index 0cefaf012..b8d96ecea 100644 --- a/openlp/plugins/custom/lib/db.py +++ b/openlp/plugins/custom/lib/db.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 59d6b4fb6..584f22e7b 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -33,7 +33,6 @@ from sqlalchemy.sql import or_, func from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ check_item_selected, translate -from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser @@ -70,35 +69,8 @@ class CustomMediaItem(MediaManagerItem): def addEndHeaderBar(self): self.addToolbarSeparator() - self.searchWidget = QtGui.QWidget(self) - self.searchWidget.setObjectName(u'searchWidget') - self.searchLayout = QtGui.QVBoxLayout(self.searchWidget) - self.searchLayout.setObjectName(u'searchLayout') - self.searchTextLayout = QtGui.QFormLayout() - self.searchTextLayout.setObjectName(u'searchTextLayout') - self.searchTextLabel = QtGui.QLabel(self.searchWidget) - self.searchTextLabel.setObjectName(u'searchTextLabel') - self.searchTextEdit = SearchEdit(self.searchWidget) - self.searchTextEdit.setObjectName(u'searchTextEdit') - self.searchTextLabel.setBuddy(self.searchTextEdit) - self.searchTextLayout.addRow(self.searchTextLabel, self.searchTextEdit) - self.searchLayout.addLayout(self.searchTextLayout) - self.searchButtonLayout = QtGui.QHBoxLayout() - self.searchButtonLayout.setObjectName(u'searchButtonLayout') - self.searchButtonLayout.addStretch() - self.searchTextButton = QtGui.QPushButton(self.searchWidget) - self.searchTextButton.setObjectName(u'searchTextButton') - self.searchButtonLayout.addWidget(self.searchTextButton) - self.searchLayout.addLayout(self.searchButtonLayout) - self.pageLayout.addWidget(self.searchWidget) + self.addSearchToToolBar() # Signals and slots - QtCore.QObject.connect(self.searchTextEdit, - QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClick) - QtCore.QObject.connect(self.searchTextButton, - QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick) - QtCore.QObject.connect(self.searchTextEdit, - QtCore.SIGNAL(u'textChanged(const QString&)'), - self.onSearchTextEditChanged) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, diff --git a/openlp/plugins/images/__init__.py b/openlp/plugins/images/__init__.py index b95ac000d..d724ebd57 100644 --- a/openlp/plugins/images/__init__.py +++ b/openlp/plugins/images/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 4b5a6f3c0..5997498d7 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/images/lib/__init__.py b/openlp/plugins/images/lib/__init__.py index e216623cd..08396a358 100644 --- a/openlp/plugins/images/lib/__init__.py +++ b/openlp/plugins/images/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 1aa39b63c..be54e207c 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index b1e815a3a..92779b991 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/media/__init__.py b/openlp/plugins/media/__init__.py index 32cff0c44..8625277ca 100644 --- a/openlp/plugins/media/__init__.py +++ b/openlp/plugins/media/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/media/lib/__init__.py b/openlp/plugins/media/lib/__init__.py index 25b8d531a..02a589ce6 100644 --- a/openlp/plugins/media/lib/__init__.py +++ b/openlp/plugins/media/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 0d5d8eeff..111a86209 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -54,7 +54,7 @@ class MediaMediaItem(MediaManagerItem): self.iconPath = u'images/image' self.background = False self.previewFunction = CLAPPERBOARD - self.Automatic = u'' + self.automatic = u'' MediaManagerItem.__init__(self, parent, plugin, icon) self.singleServiceItem = False self.hasSearch = True @@ -101,7 +101,7 @@ class MediaMediaItem(MediaManagerItem): self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) self.resetAction.setText(UiStrings().ResetBG) self.resetAction.setToolTip(UiStrings().ResetLiveBG) - self.Automatic = translate('MediaPlugin.MediaItem', + self.automatic = translate('MediaPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText( translate('MediaPlugin.MediaItem', 'Use Player:')) @@ -253,7 +253,7 @@ class MediaMediaItem(MediaManagerItem): # load the drop down selection self.displayTypeComboBox.addItem(title) if self.displayTypeComboBox.count() > 1: - self.displayTypeComboBox.insertItem(0, self.Automatic) + self.displayTypeComboBox.insertItem(0, self.automatic) self.displayTypeComboBox.setCurrentIndex(0) if QtCore.QSettings().value(self.settingsSection + u'/override player', QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 4e39bc419..aed6b96cc 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -35,7 +35,8 @@ class MediaTab(SettingsTab): MediaTab is the Media settings tab in the settings dialog. """ def __init__(self, parent, title, visible_title, media_players, icon_path): - self.media_players = media_players + self.mediaPlayers = media_players + self.savedUsedPlayers = None SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): @@ -45,13 +46,13 @@ class MediaTab(SettingsTab): self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox') self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox) self.mediaPlayerLayout.setObjectName(u'mediaPlayerLayout') - self.PlayerCheckBoxes = {} - for key in self.media_players: - player = self.media_players[key] + self.playerCheckBoxes = {} + for key, player in self.mediaPlayers.iteritems(): + player = self.mediaPlayers[key] checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox) checkbox.setEnabled(player.available) checkbox.setObjectName(player.name + u'CheckBox') - self.PlayerCheckBoxes[player.name] = checkbox + self.playerCheckBoxes[player.name] = checkbox self.mediaPlayerLayout.addWidget(checkbox) self.leftLayout.addWidget(self.mediaPlayerGroupBox) self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn) @@ -88,19 +89,19 @@ class MediaTab(SettingsTab): self.orderingButtonLayout.addWidget(self.orderingUpButton) self.playerOrderLayout.addWidget(self.orderingButtonsWidget) self.leftLayout.addWidget(self.playerOrderGroupBox) - self.AdvancedGroupBox = QtGui.QGroupBox(self.leftColumn) - self.AdvancedGroupBox.setObjectName(u'AdvancedGroupBox') - self.AdvancedLayout = QtGui.QVBoxLayout(self.AdvancedGroupBox) - self.AdvancedLayout.setObjectName(u'AdvancedLayout') - self.OverridePlayerCheckBox = QtGui.QCheckBox(self.AdvancedGroupBox) - self.OverridePlayerCheckBox.setObjectName(u'OverridePlayerCheckBox') - self.AdvancedLayout.addWidget(self.OverridePlayerCheckBox) - self.leftLayout.addWidget(self.AdvancedGroupBox) + self.advancedGroupBox = QtGui.QGroupBox(self.leftColumn) + self.advancedGroupBox.setObjectName(u'advancedGroupBox') + self.advancedLayout = QtGui.QVBoxLayout(self.advancedGroupBox) + self.advancedLayout.setObjectName(u'advancedLayout') + self.overridePlayerCheckBox = QtGui.QCheckBox(self.advancedGroupBox) + self.overridePlayerCheckBox.setObjectName(u'overridePlayerCheckBox') + self.advancedLayout.addWidget(self.overridePlayerCheckBox) + self.leftLayout.addWidget(self.advancedGroupBox) self.leftLayout.addStretch() self.rightLayout.addStretch() - for key in self.media_players: - player = self.media_players[key] - checkbox = self.PlayerCheckBoxes[player.name] + for key in self.mediaPlayers: + player = self.mediaPlayers[key] + checkbox = self.playerCheckBoxes[player.name] QtCore.QObject.connect(checkbox, QtCore.SIGNAL(u'stateChanged(int)'), self.onPlayerCheckBoxChanged) @@ -112,9 +113,9 @@ class MediaTab(SettingsTab): def retranslateUi(self): self.mediaPlayerGroupBox.setTitle( translate('MediaPlugin.MediaTab', 'Available Media Players')) - for key in self.media_players: - player = self.media_players[key] - checkbox = self.PlayerCheckBoxes[player.name] + for key in self.mediaPlayers: + player = self.mediaPlayers[key] + checkbox = self.playerCheckBoxes[player.name] if player.available: checkbox.setText(player.name) else: @@ -127,8 +128,8 @@ class MediaTab(SettingsTab): translate('MediaPlugin.MediaTab', 'Down')) self.orderingUpButton.setText( translate('MediaPlugin.MediaTab', 'Up')) - self.AdvancedGroupBox.setTitle(UiStrings().Advanced) - self.OverridePlayerCheckBox.setText( + self.advancedGroupBox.setTitle(UiStrings().Advanced) + self.overridePlayerCheckBox.setText( translate('MediaPlugin.MediaTab', 'Allow media player to be overriden')) @@ -138,18 +139,19 @@ class MediaTab(SettingsTab): if player not in self.usedPlayers: self.usedPlayers.append(player) else: - self.usedPlayers.takeAt(self.usedPlayers.indexOf(player)) + if player in self.usedPlayers: + self.usedPlayers.takeAt(self.usedPlayers.indexOf(player)) self.updatePlayerList() def updatePlayerList(self): self.playerOrderlistWidget.clear() for player in self.usedPlayers: - if player in self.PlayerCheckBoxes.keys(): + if player in self.playerCheckBoxes.keys(): if len(self.usedPlayers) == 1: - # at least one media player have to stay active - self.PlayerCheckBoxes[u'%s' % player].setEnabled(False) + # At least one media player has to stay active + self.playerCheckBoxes[u'%s' % player].setEnabled(False) else: - self.PlayerCheckBoxes[u'%s' % player].setEnabled(True) + self.playerCheckBoxes[u'%s' % player].setEnabled(True) self.playerOrderlistWidget.addItem(player) def onOrderingUpButtonPressed(self): @@ -169,37 +171,43 @@ class MediaTab(SettingsTab): self.usedPlayers.move(currentRow, currentRow + 1) def load(self): + if self.savedUsedPlayers: + self.usedPlayers = self.savedUsedPlayers + self.savedUsedPlayers = None self.usedPlayers = QtCore.QSettings().value( self.settingsSection + u'/players', QtCore.QVariant(u'webkit')).toString().split(u',') - for key in self.media_players: - player = self.media_players[key] - checkbox = self.PlayerCheckBoxes[player.name] + self.savedUsedPlayers = self.usedPlayers + for key in self.mediaPlayers: + player = self.mediaPlayers[key] + checkbox = self.playerCheckBoxes[player.name] if player.available and player.name in self.usedPlayers: checkbox.setChecked(True) + else: + checkbox.setChecked(False) self.updatePlayerList() - self.OverridePlayerCheckBox.setChecked(QtCore.QSettings().value( + self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value( self.settingsSection + u'/override player', QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0]) def save(self): override_changed = False player_string_changed = False - oldPlayerString = QtCore.QSettings().value( + old_players = QtCore.QSettings().value( self.settingsSection + u'/players', QtCore.QVariant(u'webkit')).toString() - newPlayerString = self.usedPlayers.join(u',') - if oldPlayerString != newPlayerString: + new_players = self.usedPlayers.join(u',') + if old_players != new_players: # clean old Media stuff QtCore.QSettings().setValue(self.settingsSection + u'/players', - QtCore.QVariant(newPlayerString)) + QtCore.QVariant(new_players)) player_string_changed = True override_changed = True setting_key = self.settingsSection + u'/override player' if QtCore.QSettings().value(setting_key) != \ - self.OverridePlayerCheckBox.checkState(): + self.overridePlayerCheckBox.checkState(): QtCore.QSettings().setValue(setting_key, - QtCore.QVariant(self.OverridePlayerCheckBox.checkState())) + QtCore.QVariant(self.overridePlayerCheckBox.checkState())) override_changed = True if override_changed: Receiver.send_message(u'mediaitem_media_rebuild') diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 2825d899e..cd3f8b3dd 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -27,6 +27,8 @@ import logging +from PyQt4 import QtCore + from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.plugins.media.lib import MediaMediaItem, MediaTab @@ -117,3 +119,29 @@ class MediaPlugin(Plugin): Add html code to htmlbuilder """ return self.mediaController.get_media_display_html() + + def appStartup(self): + """ + Do a couple of things when the app starts up. In this particular case + we want to check if we have the old "Use Phonon" setting, and convert + it to "enable Phonon" and "make it the first one in the list". + """ + settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) + if settings.contains(u'use phonon'): + log.info(u'Found old Phonon setting') + players = self.mediaController.mediaPlayers.keys() + has_phonon = u'phonon' in players + if settings.value(u'use phonon').toBool() and has_phonon: + log.debug(u'Converting old setting to new setting') + new_players = [] + if players: + new_players = [player for player in players \ + if player != u'phonon'] + new_players.insert(0, u'phonon') + self.mediaController.mediaPlayers[u'phonon'].isActive = True + settings.setValue(u'players', \ + QtCore.QVariant(u','.join(new_players))) + self.settings_tab.load() + settings.remove(u'use phonon') + settings.endGroup() diff --git a/openlp/plugins/presentations/__init__.py b/openlp/plugins/presentations/__init__.py index d7cb7afe5..96f5e9539 100644 --- a/openlp/plugins/presentations/__init__.py +++ b/openlp/plugins/presentations/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index 3c4e0499d..1092a7458 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 8355da5a8..0fd725b83 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -105,7 +105,6 @@ class ImpressController(PresentationController): cmd = get_uno_command() self.process = QtCore.QProcess() self.process.startDetached(cmd) - self.process.waitForStarted() def get_uno_desktop(self): """ diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 6dc57373a..03fdadb1b 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 0f38cf02f..1b795624b 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 8f551e411..da828b436 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index cd940da5c..4f3e43c6d 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index 50cf515dc..f41a228b0 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 7ff04179f..7702f19cd 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index c11f36c20..93174b3da 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # @@ -40,6 +40,7 @@ class PresentationTab(SettingsTab): """ self.controllers = controllers SettingsTab.__init__(self, parent, title, visible_title, icon_path) + self.activated = False def setupUi(self): """ @@ -110,8 +111,12 @@ class PresentationTab(SettingsTab): def save(self): """ - Save the settings. + Save the settings. If the tab hasn't been made visible to the user + then there is nothing to do, so exit. This removes the need to + start presentation applications unnecessarily. """ + if not self.activated: + return changed = False for key in self.controllers: controller = self.controllers[key] @@ -140,6 +145,7 @@ class PresentationTab(SettingsTab): """ Tab has just been made visible to the user """ + self.activated = True for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index e35659638..7121aff27 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/remotes/__init__.py b/openlp/plugins/remotes/__init__.py index ab1d8adbc..7012c14d4 100644 --- a/openlp/plugins/remotes/__init__.py +++ b/openlp/plugins/remotes/__init__.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 1339e9dda..7a2da3bea 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -27,6 +27,7 @@ --> + ${app_title} @@ -58,7 +59,7 @@
- ${back} + ${back}

${service_manager}

${refresh}
@@ -89,7 +90,7 @@
- ${back} + ${back}

${slide_controller}

${refresh}
@@ -120,7 +121,7 @@
- ${back} + ${back}

${alerts}

@@ -133,7 +134,7 @@