import ConfigParser
import logging
+import webbrowser
import gobject
import gtk
gobject.TYPE_NONE,
(gobject.TYPE_BOOLEAN, ),
),
+ 'rotate' : (
+ gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_PYOBJECT, ),
+ ),
}
def __init__(self, app, player, store):
gobject.GObject.__init__(self)
self._isDestroyed = False
+ self._isPortrait = True
self._app = app
self._player = player
def jump_to(self, node):
raise NotImplementedError("On %s" % self)
+ def set_orientation(self, orientation):
+ oldIsPortrait = self._isPortrait
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ hildonize.window_to_portrait(self._window)
+ self._isPortrait = True
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ hildonize.window_to_landscape(self._window)
+ self._isPortrait = False
+ else:
+ raise NotImplementedError(orientation)
+ didChange = oldIsPortrait != self._isPortrait
+ if didChange:
+ self.emit("rotate", orientation)
+ return didChange
+
+ def _configure_child(self, childWindow):
+ if not hildonize.IS_FREMANTLE_SUPPORTED:
+ childWindow.window.set_modal(True)
+ childWindow.window.set_transient_for(self._window)
+ childWindow.window.set_default_size(*self._window.get_size())
+ if self._windowInFullscreen:
+ childWindow.window.fullscreen()
+ else:
+ childWindow.window.unfullscreen()
+ childWindow.set_orientation(
+ gtk.ORIENTATION_VERTICAL if self._isPortrait else gtk.ORIENTATION_HORIZONTAL
+ )
+ childWindow.connect_auto(childWindow, "quit", self._on_quit)
+ childWindow.connect_auto(childWindow, "home", self._on_home)
+ childWindow.connect_auto(childWindow, "jump-to", self._on_jump)
+ childWindow.connect_auto(childWindow, "fullscreen", self._on_child_fullscreen)
+ childWindow.connect_auto(childWindow, "rotate", self._on_child_rotate)
+
@misc_utils.log_exception(_moduleLogger)
def _on_about(self, *args):
- show_about()
+ sourceWindow = AboutWindow(self._app, self._player, self._store)
+ self._configure_child(sourceWindow)
+ sourceWindow.show()
@misc_utils.log_exception(_moduleLogger)
def _on_destroy(self, *args):
else:
self._window.fullscreen ()
return True
+ elif event.keyval == gtk.keysyms.o and event.get_state() & gtk.gdk.CONTROL_MASK:
+ if self._isPortrait:
+ self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+ else:
+ self.set_orientation(gtk.ORIENTATION_VERTICAL)
+ return True
elif (
event.keyval in (gtk.keysyms.w, ) and
event.get_state() & gtk.gdk.CONTROL_MASK
self._window.unfullscreen()
@misc_utils.log_exception(_moduleLogger)
+ def _on_child_rotate(self, source, orientation):
+ self.set_orientation(orientation)
+
+ @misc_utils.log_exception(_moduleLogger)
def _on_jump(self, source, node):
raise NotImplementedError("On %s" % self)
self._presenter = presenter.StreamPresenter(self._store)
self._presenter.set_context(
- self._get_background(),
+ self._get_background(
+ gtk.ORIENTATION_VERTICAL if self._isPortrait else gtk.ORIENTATION_HORIZONTAL
+ ),
self._node.title,
self._node.subtitle,
)
self._window.set_title(self._node.get_parent().title)
- def _get_background(self):
+ def _get_background(self, orientation):
raise NotImplementedError()
def show(self):
def jump_to(self, node):
assert self._node is node
+ def set_orientation(self, orientation):
+ didChange = BasicWindow.set_orientation(self, orientation)
+ if didChange:
+ self._presenter.set_orientation(orientation)
+ self._presenter.set_context(
+ self._get_background(orientation),
+ self._node.title,
+ self._node.subtitle,
+ )
+
@property
def _active(self):
return self._playerNode is self._node
self._errorBanner.push_message(str(e))
-def show_about():
- # @todo Turn this into a full-fledge window to keep it rotated
- 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("(c) 2010 Intellectual Reserve, Inc. All rights reserved.")
- dialog.set_website("http://www.lds.org")
- comments = "Mormon Radio and Audiobook Player"
- dialog.set_comments(comments)
- dialog.set_authors(["The Church of Jesus Christ of Latter-day Saints"])
- dialog.run()
- dialog.destroy()
+class AboutWindow(BasicWindow):
+
+ def __init__(self, app, player, store):
+ BasicWindow.__init__(self, app, player, store)
+ self._window.set_title(constants.__pretty_app_name__)
+
+ self._titleLabel = gtk.Label()
+ self._titleLabel.set_markup("""
+<big><b>Mormon Channel</b></big>
+<i>Maemo Edition</i>
+Version %s
+""" % (constants.__version__, ))
+ self._titleLabel.set_property("justify", gtk.JUSTIFY_CENTER)
+
+ self._copyLabel = gtk.Label()
+ self._copyLabel.set_markup("""
+<small>(c) 2010 Intellectual Reserve, Inc.
+All rights reserved.</small>
+""")
+ self._copyLabel.set_property("justify", gtk.JUSTIFY_CENTER)
+
+ self._linkButton = gtk.LinkButton("http://www.lds.org")
+ self._linkButton.set_label("LDS.org")
+ self._linkButton.connect("clicked", self._on_website)
+
+ self._spacedLayout = gtk.VBox(True)
+ self._spacedLayout.pack_start(self._titleLabel, False, False)
+ self._spacedLayout.pack_start(self._copyLabel, False, False)
+ self._spacedLayout.pack_start(self._linkButton, False, False)
+
+ self._separator = gtk.HSeparator()
+ self._presenter = presenter.NavControl(self._player, self._store)
+ self.connect_auto(self._presenter, "home", self._on_home)
+ self.connect_auto(self._presenter, "jump-to", self._on_jump)
+
+ self._layout.pack_start(self._spacedLayout, True, True)
+ self._layout.pack_start(self._presenter.toplevel, False, True)
+
+ def show(self):
+ BasicWindow.show(self)
+ self._window.show_all()
+ self._errorBanner.toplevel.hide()
+ self._presenter.refresh()
+
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_about(self, *args):
+ pass
+
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_website(self, widget):
+ uri = widget.get_uri()
+ webbrowser.open(uri)
+
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_jump(self, source, node):
+ self.emit("jump-to", node)
+ self._window.destroy()