From 68c1c86ac5acfcc571e93a5574e936b269447883 Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Wed, 13 Jul 2011 22:41:54 +0200 Subject: [PATCH 1/6] - fixed view adjustments for os x 10.6 - added compatibility with the file extension on os x - started to work on the "open with" file event on os x --- openlp.pyw | 23 +++++ resources/osx/Info.plist.master | 93 ++++++++++++++++++ .../osx/applescript-adjustview-10-5.master | 2 +- .../osx/applescript-adjustview-10-6.master | 14 ++- resources/osx/build.py | 12 ++- resources/osx/openlp-logo-with-text.icns | Bin resources/osx/openlp.spec.master | 2 +- 7 files changed, 135 insertions(+), 11 deletions(-) mode change 100755 => 100644 resources/osx/openlp-logo-with-text.icns diff --git a/openlp.pyw b/openlp.pyw index a39f6cf65..d1627a8a6 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -90,6 +90,7 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ + self.eventQueue = [] # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args = args @@ -135,6 +136,9 @@ class OpenLP(QtGui.QApplication): VersionThread(self.mainWindow).start() Receiver.send_message(u'maindisplay_blank_check') self.mainWindow.appStartup() + # do a check for queued events + for e in self.eventQueue: + self.event(e) DelayStartThread(self.mainWindow).start() return self.exec_() @@ -180,6 +184,25 @@ class OpenLP(QtGui.QApplication): """ self.restoreOverrideCursor() + def event(self, event): + """ + Enables direct file opening on OS X + """ + if event.type() == QtCore.QEvent.FileOpen: + file_name = event.file() + log.debug(u'Got open file event for %s!', file_name) + log.error(file_name) + try: + self.mainWindow.serviceManagerContents.loadFile(file_name) + return True + except AttributeError, NameError: + log.debug(u'The main window is not initialized yet,\ + will queue event!') + self.eventQueue.append(event) + return False + else: + return QtGui.QApplication.event(self, event) + def main(): """ The main function which parses command line options and then runs diff --git a/resources/osx/Info.plist.master b/resources/osx/Info.plist.master index 45aab92a5..5fc3aa48f 100755 --- a/resources/osx/Info.plist.master +++ b/resources/osx/Info.plist.master @@ -2,6 +2,99 @@ + + CFBundleDocumentTypes + + + CFBundleTypeExtension + + osz + + CFBundleTypeIconFiles + + openlp-logo-with-text.icns + + CFBundleTypeName + OpenLP Service + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSItemContentTypes + + org.openlp.osz + + + + CFBundleTypeExtension + + otz + + CFBundleTypeIconFiles + + openlp-logo-with-text.icns + + CFBundleTypeName + OpenLP Theme + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSItemContentTypes + + org.openlp.otz + + + + + UTExportedTypeDeclarations + + + UTTypeIdentifier + org.openlp.osz + UTTypeDescription + OpenLP Service + UTTypeConformsTo + + public.data + public.content + + UTTypeTagSpecification + + public.filename-extension + + osz + + public.mime-type + + application/x-openlp-service + + + + + UTTypeIdentifier + org.openlp.otz + UTTypeDescription + OpenLP Theme + UTTypeConformsTo + + public.data + public.content + + UTTypeTagSpecification + + public.filename-extension + + otz + + public.mime-type + + application/x-openlp-theme + + + + + CFBundleIdentifier org.openlp CFBundleShortVersionString diff --git a/resources/osx/applescript-adjustview-10-5.master b/resources/osx/applescript-adjustview-10-5.master index abc0e5a8d..19be239d0 100755 --- a/resources/osx/applescript-adjustview-10-5.master +++ b/resources/osx/applescript-adjustview-10-5.master @@ -48,7 +48,7 @@ on run set theViewOptions to the icon view options of container window set arrangement of theViewOptions to not arranged set icon size of theViewOptions to 128 - set background picture of theViewOptions to file ".installer-background.png" + set background picture of theViewOptions to file ".background:installer-background.png" if not exists file "Applications" then make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"} end if diff --git a/resources/osx/applescript-adjustview-10-6.master b/resources/osx/applescript-adjustview-10-6.master index 2b5a0c000..170842564 100755 --- a/resources/osx/applescript-adjustview-10-6.master +++ b/resources/osx/applescript-adjustview-10-6.master @@ -49,15 +49,19 @@ on run set theViewOptions to the icon view options of container window set arrangement of theViewOptions to not arranged set icon size of theViewOptions to 128 - set background picture of theViewOptions to file ".installer-background.png" - make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"} - delay 5 + set background picture of theViewOptions to file ".background:installer-background.png" + if not exists file "Applications" then + make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"} + end if + delay 1 set position of item "%s" of container window to {160, 200} set position of item ".Trashes" of container window to {100, 500} - set position of item ".installer-background.png" of container window to {200, 500} + set position of item ".background" of container window to {200, 500} set position of item ".DS_Store" of container window to {400, 500} set position of item "Applications" of container window to {550, 200} - set position of item ".VolumeIcon.icns" of container window to {500, 500} + if exists file ".VolumeIcon.icns" then + set position of item ".VolumeIcon.icns" of container window to {500, 500} + end if set position of item ".fseventsd" of container window to {300, 500} if exists POSIX file ".SymAVx86QSFile" then set position of item ".SymAVx86QSFile" of container window to {600, 500} diff --git a/resources/osx/build.py b/resources/osx/build.py index ff7f6bdfd..38e56e42a 100644 --- a/resources/osx/build.py +++ b/resources/osx/build.py @@ -93,8 +93,12 @@ script_name = "build" def build_application(settings, app_name_lower, app_dir): logging.info('[%s] now building the app with pyinstaller at "%s"...', script_name, settings['pyinstaller_basedir']) - result = os.system('python %s/pyinstaller.py openlp.spec' \ - % settings['pyinstaller_basedir']) + full_python_dir = os.path.join('/opt/local/Library/Frameworks', + 'Python.framework/Versions/2.6/Resources/', + 'Python.app/Contents/MacOS/Python') + result = os.system('arch -i386 %s %s/pyinstaller.py openlp.spec' \ + % ( full_python_dir, + settings['pyinstaller_basedir']) ) if (result != 0): logging.error('[%s] The pyinstaller build reported an error, cannot \ continue!', script_name) @@ -219,10 +223,10 @@ def create_dmg(settings): sys.exit(1) logging.info('[%s] copying the background image...', script_name) - # os.mkdir(volume_basedir + '/.background') + os.mkdir(volume_basedir + '/.background') result = os.system('CpMac %s %s' % (settings['installer_backgroundimage_file'], - volume_basedir + '/.installer-background.png')) + volume_basedir + '/.background/installer-background.png')) if (result != 0): logging.error('[%s] could not copy the background image, dmg creation\ failed!', script_name) diff --git a/resources/osx/openlp-logo-with-text.icns b/resources/osx/openlp-logo-with-text.icns old mode 100755 new mode 100644 diff --git a/resources/osx/openlp.spec.master b/resources/osx/openlp.spec.master index 94aec2a60..eb743c40b 100755 --- a/resources/osx/openlp.spec.master +++ b/resources/osx/openlp.spec.master @@ -1,5 +1,5 @@ # -*- mode: python -*- -a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), '%(openlp_basedir)s/openlp.pyw'], +a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(CONFIGDIR,'support/useUnicode.py'), '%(openlp_basedir)s/openlp.pyw'], pathex=['%(pyinstaller_basedir)s'], hookspath=['%(openlp_basedir)s/resources/pyinstaller']) pyz = PYZ(a.pure) exe = EXE(pyz, From 1c1cfddce41bf6436f3f91cc190c194129e60588 Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Sat, 23 Jul 2011 19:50:25 +0200 Subject: [PATCH 2/6] provide sample configuration --- resources/osx/openlp.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/osx/openlp.cfg b/resources/osx/openlp.cfg index 954bf861d..f72a8fca1 100755 --- a/resources/osx/openlp.cfg +++ b/resources/osx/openlp.cfg @@ -1,8 +1,8 @@ [openlp] openlp_appname = OpenLP -openlp_dmgname = OpenLP-1.9.6-bzr1684 -openlp_version = 1684 -openlp_basedir = /Users/openlp/repo/osx-fixes +openlp_dmgname = OpenLP-1.9.6-bzrXXXX +openlp_version = XXXX +openlp_basedir = /Users/openlp/repo/trunk openlp_icon_file = openlp-logo-with-text.icns openlp_dmg_icon_file = openlp-logo-420x420.png installer_backgroundimage_file = installation-background.png From 189d98dc397e455bace406b1285856ec060be51e Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Sun, 24 Jul 2011 00:39:37 +0200 Subject: [PATCH 3/6] using self.args way of opening a file on startup even on OS X --- .bzrignore | 1 + openlp.pyw | 20 ++++++-------------- resources/osx/openlp.cfg | 10 ---------- 3 files changed, 7 insertions(+), 24 deletions(-) delete mode 100755 resources/osx/openlp.cfg diff --git a/.bzrignore b/.bzrignore index 2620fea42..1d2bb8267 100644 --- a/.bzrignore +++ b/.bzrignore @@ -20,3 +20,4 @@ _eric4project openlp/core/resources.py.old *.qm resources/windows/warnOpenLP.txt +openlp.cfg diff --git a/openlp.pyw b/openlp.pyw index d1627a8a6..c01d29b00 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -79,6 +79,8 @@ class OpenLP(QtGui.QApplication): class in order to provide the core of the application. """ + args = [] + def exec_(self): """ Override exec method to allow the shared memory to be released on exit @@ -90,10 +92,10 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - self.eventQueue = [] + log.debug("run()") # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. - self.args = args + self.args.extend(args) # provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) @@ -136,9 +138,6 @@ class OpenLP(QtGui.QApplication): VersionThread(self.mainWindow).start() Receiver.send_message(u'maindisplay_blank_check') self.mainWindow.appStartup() - # do a check for queued events - for e in self.eventQueue: - self.event(e) DelayStartThread(self.mainWindow).start() return self.exec_() @@ -191,15 +190,8 @@ class OpenLP(QtGui.QApplication): if event.type() == QtCore.QEvent.FileOpen: file_name = event.file() log.debug(u'Got open file event for %s!', file_name) - log.error(file_name) - try: - self.mainWindow.serviceManagerContents.loadFile(file_name) - return True - except AttributeError, NameError: - log.debug(u'The main window is not initialized yet,\ - will queue event!') - self.eventQueue.append(event) - return False + self.args.insert(0, unicode(file_name)) + return True else: return QtGui.QApplication.event(self, event) diff --git a/resources/osx/openlp.cfg b/resources/osx/openlp.cfg deleted file mode 100755 index f72a8fca1..000000000 --- a/resources/osx/openlp.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[openlp] -openlp_appname = OpenLP -openlp_dmgname = OpenLP-1.9.6-bzrXXXX -openlp_version = XXXX -openlp_basedir = /Users/openlp/repo/trunk -openlp_icon_file = openlp-logo-with-text.icns -openlp_dmg_icon_file = openlp-logo-420x420.png -installer_backgroundimage_file = installation-background.png -pyinstaller_basedir = /Users/openlp/pyinstaller/trunk -qt_menu_basedir = /Library/Frameworks/QtGui.framework/Versions/4/Resources/qt_menu.nib From 099b11f175793589924e685e2187300bf6b694ca Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Sun, 24 Jul 2011 00:40:40 +0200 Subject: [PATCH 4/6] added build configuration sample --- resources/osx/openlp.cfg.sample | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 resources/osx/openlp.cfg.sample diff --git a/resources/osx/openlp.cfg.sample b/resources/osx/openlp.cfg.sample new file mode 100755 index 000000000..f72a8fca1 --- /dev/null +++ b/resources/osx/openlp.cfg.sample @@ -0,0 +1,10 @@ +[openlp] +openlp_appname = OpenLP +openlp_dmgname = OpenLP-1.9.6-bzrXXXX +openlp_version = XXXX +openlp_basedir = /Users/openlp/repo/trunk +openlp_icon_file = openlp-logo-with-text.icns +openlp_dmg_icon_file = openlp-logo-420x420.png +installer_backgroundimage_file = installation-background.png +pyinstaller_basedir = /Users/openlp/pyinstaller/trunk +qt_menu_basedir = /Library/Frameworks/QtGui.framework/Versions/4/Resources/qt_menu.nib From 16cd20a81ad1bcfba66be84781d9cb9b1db58668 Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Sun, 24 Jul 2011 00:48:07 +0200 Subject: [PATCH 5/6] fixed indentation issue --- openlp.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index c01d29b00..71a13de08 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -190,7 +190,7 @@ class OpenLP(QtGui.QApplication): if event.type() == QtCore.QEvent.FileOpen: file_name = event.file() log.debug(u'Got open file event for %s!', file_name) - self.args.insert(0, unicode(file_name)) + self.args.insert(0, unicode(file_name)) return True else: return QtGui.QApplication.event(self, event) From f5f95eef9a7fb3230505770b8abc329fb009f920 Mon Sep 17 00:00:00 2001 From: Matthias Hub Date: Sun, 24 Jul 2011 00:52:34 +0200 Subject: [PATCH 6/6] removed debug logging --- openlp.pyw | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index 71a13de08..fe96ebd23 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -92,7 +92,6 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - log.debug("run()") # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args)