From: Ed Page Date: Fri, 24 Sep 2010 01:47:46 +0000 (-0500) Subject: Starting on removing LDS Church affiliations X-Git-Url: http://git.maemo.org/git/?p=watersofshiloah;a=commitdiff_plain;h=39ef56dd54258f4564efd05a99da8015b98d5374 Starting on removing LDS Church affiliations --- diff --git a/Makefile b/Makefile index 9ab1ef6..7911860 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -PROJECT_NAME=MormonChannel +PROJECT_NAME=WatersOfShiloah SOURCE_PATH=src SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py") -PROGRAM=$(SOURCE_PATH)/mormonchannel_gtk.py +PROGRAM=$(SOURCE_PATH)/watersofshiloah_gtk.py DATA_PATH=data DATA_TYPES=*.ini *.map *.glade *.png DATA=$(foreach type, $(DATA_TYPES), $(shell find $(DATA_PATH) -iname "$(type)")) data/COPYING diff --git a/data/COPYING b/data/COPYING index 1bbeb88..533bd82 100644 --- a/data/COPYING +++ b/data/COPYING @@ -1 +1,140 @@ -Copyright 2010 Intellectual Reserve, Inc. +label_radio.png +http://en.wikipedia.org/wiki/File:Radio-icon.svg +FDL +CC-A-SA 3.0 Unported + +label_magazines.png +http://commons.wikimedia.org/wiki/File:Book-icon.svg +FDL +CC-A-SA 3.0 Unported +CC-A-SA 2.5 Generic, 2.0 Generic, 1.0 Generic + +label_scriptures.png +http://www.sshek.com/ +http://cdn.iconfinder.net/icondetails/46884/80/book_icon +Free for Commercial Use (but not resale) + +label_rss.png +http://cdn.iconfinder.net/icondetails/42454/32/broadcast_feed_rss_icon +CC-A-SA 3.0 Unported + +label_conference.png +http://cdn.iconfinder.net/icondetails/50702/48/man_person_user_icon +http://www.mirkku.com/ +Free for Commercial Use + +background_magazines_p.jpg +http://www.flickr.com/photos/sufw/4085028851/ +CC-A-SA 2.0 Generic +background_magazines_l.jpg +http://www.flickr.com/photos/jdsumsion/90539373/ +CC-A-SA 2.0 Generic + +background_conference_p.png +http://www.flickr.com/photos/twopoos/46251335/ +CC-A-SA 2.0 Generic +background_conference_l.png +http://www.flickr.com/photos/cbrown1023/2668350108/ +CC-A 2.0 Generic + +background_scriptures_l.png +http://www.flickr.com/photos/jmwk/3517372902/ +CC-A 2.0 Generic +background_scriptures_p.png +http://www.flickr.com/photos/29811338@N05/4949956227/ +CC-A 2.0 Generic + +button_play.png +http://www.iconfinder.com/icondetails/50039/48/button_grey_play_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_pause.png +http://www.iconfinder.com/icondetails/50038/48/button_grey_pause_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_stop.png +http://www.iconfinder.com/icondetails/50042/48/button_grey_stop_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_prev.png +http://www.iconfinder.com/icondetails/50041/48/button_grey_rewind_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_next.png +http://www.iconfinder.com/icondetails/50036/48/button_fastforward_grey_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_add.png +http://www.iconfinder.com/icondetails/50033/48/add_button_grey_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_remove.png +http://www.iconfinder.com/icondetails/50035/48/button_delete_grey_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_favorite.png +http://www.iconfinder.com/icondetails/50037/48/button_grey_heart_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_close.png +http://www.iconfinder.com/icondetails/50034/48/button_close_grey_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_play_pressed.png +http://www.iconfinder.com/icondetails/50029/48/button_green_play_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_pause_pressed.png +http://www.iconfinder.com/icondetails/50058/48/button_red_pause_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_stop_pressed.png +http://www.iconfinder.com/icondetails/50062/48/button_red_stop_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_prev_pressed.png +http://www.iconfinder.com/icondetails/50031/48/button_green_rewind_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_next_pressed.png +http://www.iconfinder.com/icondetails/50026/48/button_fastforward_green_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_add_pressed.png +http://www.iconfinder.com/icondetails/50023/48/add_button_green_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_remove_pressed.png +http://www.iconfinder.com/icondetails/50055/48/button_delete_red_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_favorite_pressed.png +http://www.iconfinder.com/icondetails/50027/48/button_green_heart_icon +http://www.mirkku.com/ +Free for Commercial Use + +button_close_pressed.png +http://www.iconfinder.com/icondetails/50054/48/button_close_red_icon +http://www.mirkku.com/ +Free for Commercial Use + +icon.png +http://www.iconfinder.com/icondetails/16619/129/animal_coccinelle_eau_insect_ladybird_leaf_pool_water_icon +http://iconka.com/2008/03/05/319/ +Free for public use with link to site diff --git a/data/LDSHomeIcon.png b/data/LDSHomeIcon.png deleted file mode 100644 index 2d57046..0000000 Binary files a/data/LDSHomeIcon.png and /dev/null differ diff --git a/data/MormonMessagesIcon.png b/data/MormonMessagesIcon.png deleted file mode 100644 index 163d1ff..0000000 Binary files a/data/MormonMessagesIcon.png and /dev/null differ diff --git a/data/ScripturesWebIcon.png b/data/ScripturesWebIcon.png deleted file mode 100644 index cd39caf..0000000 Binary files a/data/ScripturesWebIcon.png and /dev/null differ diff --git a/data/background_conference_l.png b/data/background_conference_l.png index 9ae766d..6f25a32 100644 Binary files a/data/background_conference_l.png and b/data/background_conference_l.png differ diff --git a/data/background_conference_p.png b/data/background_conference_p.png index 57d9a70..de16271 100644 Binary files a/data/background_conference_p.png and b/data/background_conference_p.png differ diff --git a/data/background_magazines_l.png b/data/background_magazines_l.png index eb4a771..7ddaa87 100644 Binary files a/data/background_magazines_l.png and b/data/background_magazines_l.png differ diff --git a/data/background_magazines_p.png b/data/background_magazines_p.png index 0be9cca..aa5581d 100644 Binary files a/data/background_magazines_p.png and b/data/background_magazines_p.png differ diff --git a/data/background_radio_l.png b/data/background_radio_l.png deleted file mode 100644 index 04ec814..0000000 Binary files a/data/background_radio_l.png and /dev/null differ diff --git a/data/background_radio_p.png b/data/background_radio_p.png deleted file mode 100644 index 3fe4558..0000000 Binary files a/data/background_radio_p.png and /dev/null differ diff --git a/data/background_scriptures_l.png b/data/background_scriptures_l.png index f66b108..3459f21 100644 Binary files a/data/background_scriptures_l.png and b/data/background_scriptures_l.png differ diff --git a/data/background_scriptures_p.png b/data/background_scriptures_p.png index 885668f..78abb45 100644 Binary files a/data/background_scriptures_p.png and b/data/background_scriptures_p.png differ diff --git a/data/button_add.png b/data/button_add.png new file mode 100644 index 0000000..34eebe6 Binary files /dev/null and b/data/button_add.png differ diff --git a/data/button_add_pressed.png b/data/button_add_pressed.png new file mode 100644 index 0000000..9008c7f Binary files /dev/null and b/data/button_add_pressed.png differ diff --git a/data/button_close.png b/data/button_close.png new file mode 100644 index 0000000..94696bb Binary files /dev/null and b/data/button_close.png differ diff --git a/data/button_close_pressed.png b/data/button_close_pressed.png new file mode 100644 index 0000000..b8007f0 Binary files /dev/null and b/data/button_close_pressed.png differ diff --git a/data/button_favorite.png b/data/button_favorite.png new file mode 100644 index 0000000..671563d Binary files /dev/null and b/data/button_favorite.png differ diff --git a/data/button_favorite_pressed.png b/data/button_favorite_pressed.png new file mode 100644 index 0000000..98fd842 Binary files /dev/null and b/data/button_favorite_pressed.png differ diff --git a/data/button_next.png b/data/button_next.png new file mode 100644 index 0000000..1c6770e Binary files /dev/null and b/data/button_next.png differ diff --git a/data/button_next_pressed.png b/data/button_next_pressed.png new file mode 100644 index 0000000..f0a3671 Binary files /dev/null and b/data/button_next_pressed.png differ diff --git a/data/button_pause.png b/data/button_pause.png new file mode 100644 index 0000000..d11411f Binary files /dev/null and b/data/button_pause.png differ diff --git a/data/button_pause_pressed.png b/data/button_pause_pressed.png new file mode 100644 index 0000000..5165a14 Binary files /dev/null and b/data/button_pause_pressed.png differ diff --git a/data/button_play.png b/data/button_play.png new file mode 100644 index 0000000..09437a6 Binary files /dev/null and b/data/button_play.png differ diff --git a/data/button_play_pressed.png b/data/button_play_pressed.png new file mode 100644 index 0000000..4f68c60 Binary files /dev/null and b/data/button_play_pressed.png differ diff --git a/data/button_prev.png b/data/button_prev.png new file mode 100644 index 0000000..050890d Binary files /dev/null and b/data/button_prev.png differ diff --git a/data/button_prev_pressed.png b/data/button_prev_pressed.png new file mode 100644 index 0000000..c3a09da Binary files /dev/null and b/data/button_prev_pressed.png differ diff --git a/data/button_remove.png b/data/button_remove.png new file mode 100644 index 0000000..69034c0 Binary files /dev/null and b/data/button_remove.png differ diff --git a/data/button_remove_pressed.png b/data/button_remove_pressed.png new file mode 100644 index 0000000..663d710 Binary files /dev/null and b/data/button_remove_pressed.png differ diff --git a/data/button_stop.png b/data/button_stop.png new file mode 100644 index 0000000..e15aa4b Binary files /dev/null and b/data/button_stop.png differ diff --git a/data/button_stop_pressed.png b/data/button_stop_pressed.png new file mode 100644 index 0000000..42d7a07 Binary files /dev/null and b/data/button_stop_pressed.png differ diff --git a/data/conference.png b/data/conference.png deleted file mode 100644 index 6f62f08..0000000 Binary files a/data/conference.png and /dev/null differ diff --git a/data/home.png b/data/home.png deleted file mode 100644 index 57dc225..0000000 Binary files a/data/home.png and /dev/null differ diff --git a/data/icon.png b/data/icon.png index e4949a6..2fe5024 100644 Binary files a/data/icon.png and b/data/icon.png differ diff --git a/data/magazines.png b/data/magazines.png deleted file mode 100644 index f30fe0e..0000000 Binary files a/data/magazines.png and /dev/null differ diff --git a/data/more.png b/data/more.png deleted file mode 100644 index 9824447..0000000 Binary files a/data/more.png and /dev/null differ diff --git a/data/next.png b/data/next.png deleted file mode 100644 index cfc53dd..0000000 Binary files a/data/next.png and /dev/null differ diff --git a/data/pause.png b/data/pause.png deleted file mode 100644 index e9d5aa6..0000000 Binary files a/data/pause.png and /dev/null differ diff --git a/data/pausepressed.png b/data/pausepressed.png deleted file mode 100644 index 34d1775..0000000 Binary files a/data/pausepressed.png and /dev/null differ diff --git a/data/play.png b/data/play.png deleted file mode 100644 index c863850..0000000 Binary files a/data/play.png and /dev/null differ diff --git a/data/playpressed.png b/data/playpressed.png deleted file mode 100644 index c3bd807..0000000 Binary files a/data/playpressed.png and /dev/null differ diff --git a/data/prev.png b/data/prev.png deleted file mode 100644 index cacd89e..0000000 Binary files a/data/prev.png and /dev/null differ diff --git a/data/radio.png b/data/radio.png deleted file mode 100644 index 7c70633..0000000 Binary files a/data/radio.png and /dev/null differ diff --git a/data/radio_header.png b/data/radio_header.png deleted file mode 100644 index f4faa65..0000000 Binary files a/data/radio_header.png and /dev/null differ diff --git a/data/scriptures.png b/data/scriptures.png deleted file mode 100644 index c8c06bf..0000000 Binary files a/data/scriptures.png and /dev/null differ diff --git a/data/small_home.png b/data/small_home.png deleted file mode 100644 index 54e61f7..0000000 Binary files a/data/small_home.png and /dev/null differ diff --git a/data/small_next.png b/data/small_next.png deleted file mode 100644 index 367a8b5..0000000 Binary files a/data/small_next.png and /dev/null differ diff --git a/data/small_pause.png b/data/small_pause.png deleted file mode 100644 index 7bdbfb8..0000000 Binary files a/data/small_pause.png and /dev/null differ diff --git a/data/small_pausepressed.png b/data/small_pausepressed.png deleted file mode 100644 index f523d16..0000000 Binary files a/data/small_pausepressed.png and /dev/null differ diff --git a/data/small_play.png b/data/small_play.png deleted file mode 100644 index c9a0fc7..0000000 Binary files a/data/small_play.png and /dev/null differ diff --git a/data/small_playpressed.png b/data/small_playpressed.png deleted file mode 100644 index c11e995..0000000 Binary files a/data/small_playpressed.png and /dev/null differ diff --git a/data/small_prev.png b/data/small_prev.png deleted file mode 100644 index 3140836..0000000 Binary files a/data/small_prev.png and /dev/null differ diff --git a/data/small_stop.png b/data/small_stop.png deleted file mode 100644 index 67a0d9e..0000000 Binary files a/data/small_stop.png and /dev/null differ diff --git a/data/small_stoppressed.png b/data/small_stoppressed.png deleted file mode 100644 index a712592..0000000 Binary files a/data/small_stoppressed.png and /dev/null differ diff --git a/data/stop.png b/data/stop.png deleted file mode 100644 index abffa48..0000000 Binary files a/data/stop.png and /dev/null differ diff --git a/data/stoppressed.png b/data/stoppressed.png deleted file mode 100644 index 6f895d2..0000000 Binary files a/data/stoppressed.png and /dev/null differ diff --git a/src/MormonChannel.py b/src/MormonChannel.py deleted file mode 100755 index 3dce591..0000000 --- a/src/MormonChannel.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -Copyright (C) 2007 Christoph Würstle -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. -""" - -import os -import sys -import logging - -_moduleLogger = logging.getLogger(__name__) -sys.path.append('../lib') - - -import constants -import mormonchannel_gtk - - -if __name__ == "__main__": - try: - os.makedirs(constants._data_path_) - except OSError, e: - if e.errno != 17: - raise - - try: - os.makedirs(constants._cache_path_) - except OSError, e: - if e.errno != 17: - raise - - logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s' - logging.basicConfig(level=logging.DEBUG, filename=constants._user_logpath_, format=logFormat) - _moduleLogger.info("%s %s-%s" % (constants.__app_name__, constants.__version__, constants.__build__)) - _moduleLogger.info("OS: %s" % (os.uname()[0], )) - _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:]) - _moduleLogger.info("Hostname: %s" % os.uname()[1]) - - mormonchannel_gtk.run() diff --git a/src/WatersOfShiloah.py b/src/WatersOfShiloah.py new file mode 100755 index 0000000..56b4917 --- /dev/null +++ b/src/WatersOfShiloah.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys +import logging + +_moduleLogger = logging.getLogger(__name__) +sys.path.append('../lib') + + +import constants +import watersofshiloah_gtk + + +if __name__ == "__main__": + try: + os.makedirs(constants._data_path_) + except OSError, e: + if e.errno != 17: + raise + + try: + os.makedirs(constants._cache_path_) + except OSError, e: + if e.errno != 17: + raise + + logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s' + logging.basicConfig(level=logging.DEBUG, filename=constants._user_logpath_, format=logFormat) + _moduleLogger.info("%s %s-%s" % (constants.__app_name__, constants.__version__, constants.__build__)) + _moduleLogger.info("OS: %s" % (os.uname()[0], )) + _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:]) + _moduleLogger.info("Hostname: %s" % os.uname()[1]) + + watersofshiloah_gtk.run() diff --git a/src/constants.py b/src/constants.py index 9559540..0d5ad42 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,7 +1,7 @@ import os -__pretty_app_name__ = "Mormon Channel" -__app_name__ = "mormonchannel" +__pretty_app_name__ = "Waters of Shiloah" +__app_name__ = "watersofshiloah" __version__ = "1.0.0" __build__ = 0 __app_magic__ = 0x1AFF5 diff --git a/src/imagestore.py b/src/imagestore.py index 5e9d333..263d9c5 100644 --- a/src/imagestore.py +++ b/src/imagestore.py @@ -17,27 +17,24 @@ _moduleLogger = logging.getLogger(__name__) class ImageStore(object): STORE_LOOKUP = { - "next": "next.png", - "prev": "prev.png", + "next": "button_next.png", + "prev": "button_prev.png", "home": "home.png", - "pause": "pause.png", - "play": "play.png", - "stop": "stop.png", - "pause_pressed": "pausepressed.png", - "play_pressed": "playpressed.png", - "stop_pressed": "stoppressed.png", - - "small_next": "small_next.png", - "small_prev": "small_prev.png", - "small_home": "small_home.png", - "small_pause": "small_pause.png", - "small_play": "small_play.png", - "small_stop": "small_stop.png", - "small_pause_pressed": "small_pausepressed.png", - "small_play_pressed": "small_playpressed.png", - "small_stop_pressed": "small_stoppressed.png", - - "loading": "loading.gif", + "pause": "button_pause.png", + "play": "button_play.png", + "stop": "button_stop.png", + "add": "button_add.png", + "remove": "button_remove.png", + "favorite": "button_favorite.png", + "next_pressed": "button_next_pressed.png", + "prev_pressed": "button_prev_pressed.png", + "home_pressed": "home_pressed.png", + "pause_pressed": "button_pause_pressed.png", + "play_pressed": "button_play_pressed.png", + "stop_pressed": "button_stop_pressed.png", + "add_pressed": "button_add_pressed.png", + "remove_pressed": "button_remove_pressed.png", + "favorite_pressed": "button_favorite_pressed.png", "radio_header": "radio_header.png", "conference_background": "background_conference_p.png", @@ -47,13 +44,12 @@ class ImageStore(object): "scripture_background": "background_scriptures_p.png", "scripture_background_landscape": "background_scriptures_l.png", - "conferences": "conference.png", - "magazines": "magazines.png", - "mormonmessages": "mormonmessages.png", - "radio": "radio.png", - "scriptures": "scriptures.png", + "conferences": "label_conference.png", + "magazines": "label_magazines.png", + "radio": "label_radio.png", + "scriptures": "label_scriptures.png", - "more": "more.png", + "loading": "loading.gif", "icon": "icon.png", "nomagazineimage": "nomagazineimage.png", } diff --git a/src/mormonchannel_gtk.py b/src/mormonchannel_gtk.py deleted file mode 100755 index b231799..0000000 --- a/src/mormonchannel_gtk.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -@todo Reverse order option. Toggle between playing ascending/descending chronological order -""" - -from __future__ import with_statement - -import os -import gc -import logging -import ConfigParser - -import gobject -import dbus -import dbus.mainloop.glib -import gtk - -try: - import osso -except ImportError: - osso = None - -import constants -import hildonize -import util.misc as misc_utils - -import imagestore -import player -import stream_index -import windows - - -_moduleLogger = logging.getLogger(__name__) -PROFILE_STARTUP = False - - -class MormonChannelProgram(hildonize.get_app_class()): - - def __init__(self): - super(MormonChannelProgram, self).__init__() - currentPath = os.path.abspath(__file__) - storePath = os.path.join(os.path.split(os.path.dirname(currentPath))[0], "data") - self._store = imagestore.ImageStore(storePath, constants._cache_path_) - self._index = stream_index.AudioIndex() - self._player = player.Player(self._index) - - self._store.start() - self._index.start() - try: - if not hildonize.IS_HILDON_SUPPORTED: - _moduleLogger.info("No hildonization support") - - if osso is not None: - self._osso_c = osso.Context(constants.__app_name__, constants.__version__, False) - self._deviceState = osso.DeviceState(self._osso_c) - self._deviceState.set_device_state_callback(self._on_device_state_change, 0) - else: - _moduleLogger.info("No osso support") - self._osso_c = None - self._deviceState = None - - self._sourceSelector = windows.source.SourceSelector(self, self._player, self._store, self._index) - self._sourceSelector.window.connect("destroy", self._on_destroy) - self._sourceSelector.window.set_default_size(400, 800) - self._sourceSelector.show() - self._load_settings() - except: - self._index.stop() - self._store.stop() - raise - - def _save_settings(self): - config = ConfigParser.SafeConfigParser() - - self._sourceSelector.save_settings(config, "Windows") - - with open(constants._user_settings_, "wb") as configFile: - config.write(configFile) - - def _load_settings(self): - config = ConfigParser.SafeConfigParser() - config.read(constants._user_settings_) - - self._sourceSelector.load_settings(config, "Windows") - - @misc_utils.log_exception(_moduleLogger) - def _on_device_state_change(self, shutdown, save_unsaved_data, memory_low, system_inactivity, message, userData): - """ - For system_inactivity, we have no background tasks to pause - - @note Hildon specific - """ - if memory_low: - gc.collect() - - if save_unsaved_data or shutdown: - self._save_settings() - - @misc_utils.log_exception(_moduleLogger) - def _on_destroy(self, widget = None, data = None): - try: - self.quit() - finally: - gtk.main_quit() - - def quit(self): - try: - self._save_settings() - except Exception: - _moduleLogger.exception("Error saving settigns") - - try: - self._player.stop() - except Exception: - _moduleLogger.exception("Error stopping player") - try: - self._index.stop() - except Exception: - _moduleLogger.exception("Error stopping index") - try: - self._store.stop() - except Exception: - _moduleLogger.exception("Error stopping store") - - try: - self._deviceState.close() - except AttributeError: - pass # Either None or close was removed (in Fremantle) - except Exception: - _moduleLogger.exception("Error closing device state") - try: - self._osso_c.close() - except AttributeError: - pass # Either None or close was removed (in Fremantle) - except Exception: - _moduleLogger.exception("Error closing osso state") - - -def run(): - gobject.threads_init() - gtk.gdk.threads_init() - l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - # HACK Playback while silent on Maemo 5 - hildonize.set_application_name("FMRadio") - - app = MormonChannelProgram() - if not PROFILE_STARTUP: - try: - gtk.main() - except KeyboardInterrupt: - app.quit() - raise - else: - app.quit() - - -if __name__ == "__main__": - logging.basicConfig(level=logging.DEBUG) - run() diff --git a/src/watersofshiloah_gtk.py b/src/watersofshiloah_gtk.py new file mode 100755 index 0000000..5f442f9 --- /dev/null +++ b/src/watersofshiloah_gtk.py @@ -0,0 +1,162 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@todo Reverse order option. Toggle between playing ascending/descending chronological order +""" + +from __future__ import with_statement + +import os +import gc +import logging +import ConfigParser + +import gobject +import dbus +import dbus.mainloop.glib +import gtk + +try: + import osso +except ImportError: + osso = None + +import constants +import hildonize +import util.misc as misc_utils + +import imagestore +import player +import stream_index +import windows + + +_moduleLogger = logging.getLogger(__name__) +PROFILE_STARTUP = False + + +class WatersOfShiloahProgram(hildonize.get_app_class()): + + def __init__(self): + super(WatersOfShiloahProgram, self).__init__() + currentPath = os.path.abspath(__file__) + storePath = os.path.join(os.path.split(os.path.dirname(currentPath))[0], "data") + self._store = imagestore.ImageStore(storePath, constants._cache_path_) + self._index = stream_index.AudioIndex() + self._player = player.Player(self._index) + + self._store.start() + self._index.start() + try: + if not hildonize.IS_HILDON_SUPPORTED: + _moduleLogger.info("No hildonization support") + + if osso is not None: + self._osso_c = osso.Context(constants.__app_name__, constants.__version__, False) + self._deviceState = osso.DeviceState(self._osso_c) + self._deviceState.set_device_state_callback(self._on_device_state_change, 0) + else: + _moduleLogger.info("No osso support") + self._osso_c = None + self._deviceState = None + + self._sourceSelector = windows.source.SourceSelector(self, self._player, self._store, self._index) + self._sourceSelector.window.connect("destroy", self._on_destroy) + self._sourceSelector.window.set_default_size(400, 800) + self._sourceSelector.show() + self._load_settings() + except: + self._index.stop() + self._store.stop() + raise + + def _save_settings(self): + config = ConfigParser.SafeConfigParser() + + self._sourceSelector.save_settings(config, "Windows") + + with open(constants._user_settings_, "wb") as configFile: + config.write(configFile) + + def _load_settings(self): + config = ConfigParser.SafeConfigParser() + config.read(constants._user_settings_) + + self._sourceSelector.load_settings(config, "Windows") + + @misc_utils.log_exception(_moduleLogger) + def _on_device_state_change(self, shutdown, save_unsaved_data, memory_low, system_inactivity, message, userData): + """ + For system_inactivity, we have no background tasks to pause + + @note Hildon specific + """ + if memory_low: + gc.collect() + + if save_unsaved_data or shutdown: + self._save_settings() + + @misc_utils.log_exception(_moduleLogger) + def _on_destroy(self, widget = None, data = None): + try: + self.quit() + finally: + gtk.main_quit() + + def quit(self): + try: + self._save_settings() + except Exception: + _moduleLogger.exception("Error saving settigns") + + try: + self._player.stop() + except Exception: + _moduleLogger.exception("Error stopping player") + try: + self._index.stop() + except Exception: + _moduleLogger.exception("Error stopping index") + try: + self._store.stop() + except Exception: + _moduleLogger.exception("Error stopping store") + + try: + self._deviceState.close() + except AttributeError: + pass # Either None or close was removed (in Fremantle) + except Exception: + _moduleLogger.exception("Error closing device state") + try: + self._osso_c.close() + except AttributeError: + pass # Either None or close was removed (in Fremantle) + except Exception: + _moduleLogger.exception("Error closing osso state") + + +def run(): + gobject.threads_init() + gtk.gdk.threads_init() + l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + # HACK Playback while silent on Maemo 5 + hildonize.set_application_name("FMRadio") + + app = WatersOfShiloahProgram() + if not PROFILE_STARTUP: + try: + gtk.main() + except KeyboardInterrupt: + app.quit() + raise + else: + app.quit() + + +if __name__ == "__main__": + logging.basicConfig(level=logging.DEBUG) + run() diff --git a/support/MormonChannel.desktop b/support/MormonChannel.desktop deleted file mode 100644 index 250130c..0000000 --- a/support/MormonChannel.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Name=MormonChannel -Exec=/usr/bin/run-standalone.sh /opt/MormonChannel/bin/MormonChannel.py -Icon=MormonChannel diff --git a/support/WatersOfShiloah.py b/support/WatersOfShiloah.py new file mode 100644 index 0000000..6a68b4d --- /dev/null +++ b/support/WatersOfShiloah.py @@ -0,0 +1,7 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Name=Waters of Shiloah +Exec=/usr/bin/run-standalone.sh /opt/WatersOfShiloah/bin/WatersOfShiloah.py +Icon=WatersOfShiloah diff --git a/support/builddeb.py b/support/builddeb.py index 6ea6339..fa86426 100755 --- a/support/builddeb.py +++ b/support/builddeb.py @@ -18,10 +18,10 @@ Supports streaming: * Conference precedings and magazines from The Church of Jesus Christ of Latter-day Saints * Scriptures, including King James Version of the Bible and the Book of Mormon . -Homepage: http://www.lds.org +Homepage: """ -__author__ = "The Church of Jesus Christ of Latter-day Saints" -__email__ = "lds-tech@ldschurch.org" +__author__ = "Ed Page" +__email__ = "eopage@byu.net" __version__ = constants.__version__ __build__ = constants.__build__ __changelog__ = """ @@ -96,10 +96,10 @@ def build_package(distribution): p.repository = "extras" p.changelog = __changelog__ p.postinstall = __postinstall__ - p.icon = "48x48-MormonChannel.png" - p["/opt/MormonChannel/bin"] = ["MormonChannel.py"] + p.icon = "48x48-WatersOfShiloah.png" + p["/opt/WatersOfShiloah/bin"] = ["WatersOfShiloah.py"] for relPath, files in unflatten_files(find_files("src", ".")).iteritems(): - fullPath = "/opt/MormonChannel/lib" + fullPath = "/opt/WatersOfShiloah/lib" if relPath: fullPath += os.sep+relPath p[fullPath] = list( @@ -107,15 +107,15 @@ def build_package(distribution): for (oldName, newName) in files ) for relPath, files in unflatten_files(find_files("data", ".")).iteritems(): - fullPath = "/opt/MormonChannel/share" + fullPath = "/opt/WatersOfShiloah/share" if relPath: fullPath += os.sep+relPath p[fullPath] = list( "|".join((oldName, newName)) for (oldName, newName) in files ) - p["/usr/share/applications/hildon"] = ["MormonChannel.desktop"] - p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-MormonChannel.png|MormonChannel.png"] + p["/usr/share/applications/hildon"] = ["WatersOfShiloah.desktop"] + p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-WatersOfShiloah.png|WatersOfShiloah.png"] if distribution == "debian": print p