# -*- coding: utf-8 -*-
"""
-@todo Restructure so there is a windows/ folder with a file per source
-@todo Add additional sources
-@todo Track recent
-@todo Presenter browsing when not active
-@todo Audio seek bar
-@todo Persisted Pause
-@todo Favorites
-@todo Sleep timer
@todo Reverse order option. Toggle between playing ascending/descending chronological order
-@todo Podcast integration
"""
from __future__ import with_statement
+import os
import gc
import logging
import ConfigParser
def __init__(self):
super(MormonChannelProgram, self).__init__()
- self._store = imagestore.ImageStore("../data", "../data")
+ 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:
self._osso_c = None
self._deviceState = None
- self._sourceSelector = windows.SourceSelector(self._player, self._store, self._index)
+ 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):
@misc_utils.log_exception(_moduleLogger)
def _on_destroy(self, widget = None, data = None):
- self.quit()
+ 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)
- try:
- self._osso_c.close()
- except AttributeError:
- pass # Either None or close was removed (in Fremantle)
- finally:
- gtk.main_quit()
-
- @misc_utils.log_exception(_moduleLogger)
- def _on_show_about(self, widget = None, data = None):
- dialog = gtk.AboutDialog()
- dialog.set_position(gtk.WIN_POS_CENTER)
- dialog.set_name(constants.__pretty_app_name__)
- dialog.set_version(constants.__version__)
- dialog.set_copyright("")
- dialog.set_website("")
- comments = "Mormon Radio and Audiobook Player"
- dialog.set_comments(comments)
- dialog.set_authors(["Ed Page <eopage@byu.net>"])
- dialog.run()
- dialog.destroy()
+ 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():
gtk.gdk.threads_init()
l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- hildonize.set_application_title(constants.__pretty_app_name__)
+ # HACK Playback while silent on Maemo 5
+ hildonize.set_application_name("FMRadio")
+
app = MormonChannelProgram()
if not PROFILE_STARTUP:
try:
except KeyboardInterrupt:
app.quit()
raise
+ else:
+ app.quit()
if __name__ == "__main__":