From 37720b9cdbebcdf4c1ed5e20029fb6080e83b282 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 17:00:32 +0100 Subject: [PATCH] Add add_actions support function --- openlp/core/utils/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 12fc4a293..d060c8ca2 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -64,7 +64,8 @@ class AppLocation(object): else: try: from xdg import BaseDirectory - path = os.path.join(BaseDirectory.xdg_config_home, u'openlp') + path = os.path.join( + BaseDirectory.xdg_config_home, u'openlp') except ImportError: path = os.path.join(os.getenv(u'HOME'), u'.openlp') return path @@ -117,7 +118,8 @@ def check_latest_version(config, current_version): if last_test != this_test: version_string = u'' if current_version[u'build']: - req = urllib2.Request(u'http://www.openlp.org/files/dev_version.txt') + req = urllib2.Request( + u'http://www.openlp.org/files/dev_version.txt') else: req = urllib2.Request(u'http://www.openlp.org/files/version.txt') req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full']) @@ -149,7 +151,24 @@ def variant_to_unicode(variant): string = string_to_unicode(string) return string +def add_actions(target, actions): + """ + Adds multiple actions to a menu or toolbar in one command. + + ``target`` + The menu or toolbar to add actions to. + + ``actions`` + The actions to be added. + """ + for action in actions: + if action is None: + target.addSeparator() + else: + target.addAction(action) + from registry import Registry from confighelper import ConfigHelper -__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', u'check_latest_version'] +__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', + u'check_latest_version', u'add_actions']