Related to weird switching of playback on Maemo 5, putting in asserts to confirm...
[watersofshiloah] / src / windows / _base.py
index 96ed2ec..d855fd8 100644 (file)
@@ -13,7 +13,6 @@ import util.go_utils as go_utils
 
 import stream_index
 import banners
-import playcontrol
 import presenter
 
 
@@ -90,7 +89,7 @@ class BasicWindow(gobject.GObject, go_utils.AutoSignal):
 
        def load_settings(self, config, sectionName):
                try:
-                       self._windowInFullscreen = config.getboolean(sectionName, "fullscreen")
+                       windowInFullscreen = config.getboolean(sectionName, "fullscreen")
                except ConfigParser.NoSectionError, e:
                        _moduleLogger.info(
                                "Settings file %s is missing section %s" % (
@@ -99,7 +98,7 @@ class BasicWindow(gobject.GObject, go_utils.AutoSignal):
                                )
                        )
 
-               if self._windowInFullscreen:
+               if windowInFullscreen:
                        self._window.fullscreen()
                else:
                        self._window.unfullscreen()
@@ -113,11 +112,14 @@ class BasicWindow(gobject.GObject, go_utils.AutoSignal):
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_window_state_change(self, widget, event, *args):
+               oldIsFull = self._windowInFullscreen
                if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
                        self._windowInFullscreen = True
                else:
                        self._windowInFullscreen = False
-               self.emit("fullscreen", self._windowInFullscreen)
+               if oldIsFull != self._windowInFullscreen:
+                       _moduleLogger.info("%r Emit fullscreen %s" % (self, self._windowInFullscreen))
+                       self.emit("fullscreen", self._windowInFullscreen)
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_key_press(self, widget, event, *args):
@@ -157,6 +159,15 @@ class BasicWindow(gobject.GObject, go_utils.AutoSignal):
                self._window.destroy()
 
        @misc_utils.log_exception(_moduleLogger)
+       def _on_child_fullscreen(self, source, isFull):
+               if isFull:
+                       _moduleLogger.info("Full screen %r to mirror child %r" % (self, source))
+                       self._window.fullscreen()
+               else:
+                       _moduleLogger.info("Unfull screen %r to mirror child %r" % (self, source))
+                       self._window.unfullscreen()
+
+       @misc_utils.log_exception(_moduleLogger)
        def _on_jump(self, source, node):
                raise NotImplementedError("On %s" % self)
 
@@ -198,14 +209,14 @@ class ListWindow(BasicWindow):
                self._treeScroller = hildonize.hildonize_scrollwindow(self._treeScroller)
 
                self._separator = gtk.HSeparator()
-               self._playcontrol = playcontrol.NavControl(self._player, self._store)
-               self._playcontrol.connect("home", self._on_home)
-               self._playcontrol.connect("jump-to", self._on_jump)
+               self._presenter = presenter.NavControl(self._player, self._store)
+               self._presenter.connect("home", self._on_home)
+               self._presenter.connect("jump-to", self._on_jump)
 
                self._contentLayout = gtk.VBox(False)
                self._contentLayout.pack_start(self._treeScroller, True, True)
                self._contentLayout.pack_start(self._separator, False, True)
-               self._contentLayout.pack_start(self._playcontrol.toplevel, False, True)
+               self._contentLayout.pack_start(self._presenter.toplevel, False, True)
 
                self._layout.pack_start(self._loadingBanner.toplevel, False, False)
                self._layout.pack_start(self._contentLayout, True, True)
@@ -217,7 +228,7 @@ class ListWindow(BasicWindow):
                self._loadingBanner.toplevel.hide()
 
                self._refresh()
-               self._playcontrol.refresh()
+               self._presenter.refresh()
 
        @classmethod
        def _get_columns(cls):
@@ -258,6 +269,7 @@ class ListWindow(BasicWindow):
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_player_title_change(self, player, node):
+               assert not self._isDestroyed
                self._select_row()
 
        @misc_utils.log_exception(_moduleLogger)
@@ -408,6 +420,7 @@ class PresenterWindow(BasicWindow):
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_player_state_change(self, player, newState):
+               assert not self._isDestroyed
                if self._active and self._player.state == self._player.STATE_PLAY:
                        self._seekbar.show()
                        assert self._updateSeek is None
@@ -424,6 +437,7 @@ class PresenterWindow(BasicWindow):
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_player_title_change(self, player, node):
+               assert not self._isDestroyed
                if not self._active or node in [None, self._node]:
                        self._playerNode = node
                        return
@@ -433,6 +447,7 @@ class PresenterWindow(BasicWindow):
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_player_error(self, player, err, debug):
+               assert not self._isDestroyed
                _moduleLogger.error("%r - %r" % (err, debug))
 
        @misc_utils.log_exception(_moduleLogger)