diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index b7ff201e3..a1b9d7180 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -18,10 +18,12 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ +from pluginconfig import PluginConfig from plugin import Plugin from settingstab import SettingsTab from mediamanageritem import MediaManagerItem from event import Event from xmlrootclass import XmlRootClass -__all__ = ['Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'XmlRootClass'] +__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', + 'XmlRootClass'] diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index b8d930450..c8b3f760e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -18,6 +18,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ +from lib import PluginConfig + class Plugin(object): """ Base class for openlp plugins to inherit from. @@ -70,6 +72,7 @@ class Plugin(object): self.Name = 'Plugin' if version is not None: self.Version = version + self.config = PluginConfig(self.Name) #self.MediaManagerItem = None self.SettingsTab = None self.ImportMenuItem = None diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py new file mode 100644 index 000000000..200a94699 --- /dev/null +++ b/openlp/core/lib/pluginconfig.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import os +from core.utils import ConfigHelper + +class PluginConfig(object): + """ + This is a generic config helper for plugins. + """ + def __init__(self, plugin_name): + """ + Initialise the plugin config object, setting the section name to the + plugin name. + """ + self.section = plugin_name.lower() + + def get_config(self, key, default=None): + """ + Get a configuration value from the configuration registry. + """ + return ConfigHelper.get_config(self.section, key, default) + + def set_config(self, key, value): + """ + Set a configuration value in the configuration registry. + """ + return ConfigHelper.set_config(self.section, key, value) + + def get_data_path(self): + app_data = ConfigHelper.get_data_path() + safe_name = self.section.replace(' ', '-') + plugin_data = self.get_config('data path', safe_name) + return os.path.join(app_data, plugin_data) + + def set_data_path(self, path): + return self.set_config('data path', os.path.basename(path)) diff --git a/openlp/core/utils/confighelper.py b/openlp/core/utils/confighelper.py index ded1a3c38..c7c1fadc2 100644 --- a/openlp/core/utils/confighelper.py +++ b/openlp/core/utils/confighelper.py @@ -27,24 +27,22 @@ class ConfigHelper(object): @staticmethod def get_data_path(): reg = ConfigHelper.get_registry() - return reg.get_value('main', 'data_path') + return reg.get_value('main', 'data path') @staticmethod - def get_data_path(): + def get_config(section, key, default=None): reg = ConfigHelper.get_registry() - return reg.get_value('main', 'data_path') + if reg.has_value(section, key): + return reg.get_value(section, key, default) + else: + return default @staticmethod - def get_songs_file(): - path = ConfigHelper.get_data_path() - songfile = os.path.join(path, "songs", "songs.olp") - if os.path.exists(songfile): - filename.set_filename(songfile) - print songfile - - @staticmethod - def getBiblePath(): - return os.path.join(ConfigHelper.getConfigPath(), "Data","Bibles") + def set_config(section, key, value): + reg = ConfigHelper.get_registry() + if not reg.has_section(section): + reg.create_section(section) + return reg.set_value(section, key, value) @staticmethod def get_registry(): diff --git a/openlp/plugins/biblemanager/bibleManager.py b/openlp/plugins/biblemanager/bibleManager.py index dcc004d0e..f2af3f8be 100644 --- a/openlp/plugins/biblemanager/bibleManager.py +++ b/openlp/plugins/biblemanager/bibleManager.py @@ -40,7 +40,7 @@ class BibleManager(): global log log=logging.getLogger("BibleMgr") log.info("Bible manager loaded") - def __init__(self): + def __init__(self, path): """ Finds all the bibles defined for the system Creates an Interface Object for each bible containing connection information @@ -51,7 +51,7 @@ class BibleManager(): log.debug( "Bible Initialising") self.bibleDBCache = {} # dict of bible database classes self.bibleHTTPCache = {} # dict of bible http readers - self.biblePath = ConfigHelper.getBiblePath() + self.biblePath = path #ConfigHelper.getBiblePath() self.dialogobject = None #log.debug( self.biblePath ) files = os.listdir(self.biblePath) diff --git a/openlp/plugins/biblemanager/bibleplugin.py b/openlp/plugins/biblemanager/bibleplugin.py index 60e39b041..9b22c758c 100644 --- a/openlp/plugins/biblemanager/bibleplugin.py +++ b/openlp/plugins/biblemanager/bibleplugin.py @@ -31,7 +31,7 @@ class BiblePlugin(Plugin): Plugin.__init__(self, 'Bible', '1.9.0') self.Weight = -9 #Register the bible Manager - #self.biblemanager = BibleManager() + #self.biblemanager = BibleManager(self.config.get_data_path()) self.textsearch = True def getMediaManagerItem(self): @@ -64,12 +64,12 @@ class BiblePlugin(Plugin): ## Add Bible Button ## self.MediaManagerItem.addToolbarButton('Change Search Style', 'Swap between the Bible search styles', ':/system/system_add.png', - self.onBibleSearchChangeClick, 'BibleSearchChange') + self.onBibleSearchChangeClick, 'BibleSearchChange') # Add the Biblelist Tables self.groupBox = QtGui.QGroupBox(self.MediaManagerItem) self.groupBox.setGeometry(QtCore.QRect(5, 5, 271, 391)) self.groupBox.setObjectName("groupBox") - + self.biblelabel = QtGui.QLabel(self.groupBox) self.biblelabel.setGeometry(QtCore.QRect(10, 20, 80, 25)) self.biblelabel.setObjectName("biblelabel") @@ -98,8 +98,8 @@ class BiblePlugin(Plugin): self.bookcomboBox.setObjectName("bookcomboBox") self.bookcomboBox.addItem("Genesis") self.bookcomboBox.addItem("Matthew") - self.bookcomboBox.addItem("Revelation") - + self.bookcomboBox.addItem("Revelation") + self.chapterlabel = QtGui.QLabel(self.groupBox) self.chapterlabel.setGeometry(QtCore.QRect(10, 110, 50, 25)) self.chapterlabel.setObjectName("chapterlabel") @@ -107,7 +107,7 @@ class BiblePlugin(Plugin): self.verselabel = QtGui.QLabel(self.groupBox) self.verselabel.setGeometry(QtCore.QRect(10, 140, 50, 25)) self.verselabel.setObjectName("verselabel") - self.verselabel.setText("Verse:") + self.verselabel.setText("Verse:") self.fromlabel = QtGui.QLabel(self.groupBox) self.fromlabel.setGeometry(QtCore.QRect(120, 80, 50, 25)) self.fromlabel.setObjectName("fromlabel") @@ -115,7 +115,7 @@ class BiblePlugin(Plugin): self.tolabel = QtGui.QLabel(self.groupBox) self.tolabel.setGeometry(QtCore.QRect(210, 80, 50, 25)) self.tolabel.setObjectName("tolabel") - self.tolabel.setText("To:") + self.tolabel.setText("To:") self.fromcomboBox_c = QtGui.QComboBox(self.groupBox) self.fromcomboBox_c.setGeometry(QtCore.QRect(120, 110, 45, 25)) self.fromcomboBox_c.setObjectName("fromcomboBox_c") @@ -130,18 +130,18 @@ class BiblePlugin(Plugin): self.tocomboBox_v.setObjectName("tocomboBox_v") for i in range(1, 20): self.fromcomboBox_c.addItem(str(i)) - self.tocomboBox_c.addItem(str(i)) + self.tocomboBox_c.addItem(str(i)) for i in range(1, 10): self.fromcomboBox_v.addItem(str(i)) - self.tocomboBox_v.addItem(str(i)) + self.tocomboBox_v.addItem(str(i)) self.searchButton = QtGui.QPushButton(self.groupBox) self.searchButton.setGeometry(QtCore.QRect(170, 170, 75, 27)) self.searchButton.setObjectName("searchButton") self.searchButton.setText("Search") - QtCore.QObject.connect(self.searchButton, QtCore.SIGNAL("pressed()"), self.onBibleSearchClick) + QtCore.QObject.connect(self.searchButton, QtCore.SIGNAL("pressed()"), self.onBibleSearchClick) + - self.listView = QtGui.QListView(self.groupBox) self.listView.setGeometry(QtCore.QRect(10, 200, 256, 192)) self.listView.setObjectName("listView") @@ -183,44 +183,44 @@ class BiblePlugin(Plugin): def onBibleAddClick(self): pass - + def onBibleSearchClick(self): if self.textsearch == True: print "Text / Verse Search" else: - print "Combo Search" + print "Combo Search" + - def onBibleSearchChangeClick(self): self.textsearchmode() - + def textsearchmode(self): if self.textsearch == True: self.textsearch = False self.searchcomboBox.hide() self.searchEdit.hide() - self.booklabel.show() + self.booklabel.show() self.bookcomboBox.show() self.fromcomboBox_c.show() - self.fromcomboBox_v.show() - self.tocomboBox_c.show() + self.fromcomboBox_v.show() + self.tocomboBox_c.show() self.tocomboBox_v.show() self.chapterlabel.show() - self.verselabel.show() + self.verselabel.show() self.fromlabel.show() - self.tolabel.show() + self.tolabel.show() else: self.textsearch = True self.searchcomboBox.show() self.searchEdit.show() - self.booklabel.hide() - self.bookcomboBox.hide() + self.booklabel.hide() + self.bookcomboBox.hide() self.fromcomboBox_c.hide() - self.fromcomboBox_v.hide() - self.tocomboBox_c.hide() + self.fromcomboBox_v.hide() + self.tocomboBox_c.hide() self.tocomboBox_v.hide() self.chapterlabel.hide() - self.verselabel.hide() + self.verselabel.hide() self.fromlabel.hide() - self.tolabel.hide() + self.tolabel.hide() diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..4306f75c9 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +from setuptools import setup APP = ['openlp.pyw'] OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4']} setup( + name='openlp.org', + version='1.9.0', + url='http://www.openlp.org/', app=APP, options={'py2app': OPTIONS}, setup_requires=['py2app'], )