예제 #1
0
    def switch_view(self, news_store: NewsStore, preferences: Preferences) -> NewsView:
        """ 
        Activates the view currently chosen in the preferences and returns it.
        """
        appearance_prefs = preferences.appearance_preferences()
        view_key = appearance_prefs['View']
        views = {'Two-Pane': TwoPaneView, 'Three-Pane': ThreePaneView}
        view_class = TwoPaneView  # views[view_key] # FIXME: Hardcoded for development

        if type(self.current_view) != view_class:  # Ensure not switching to same view.
            if self.current_view:
                self.current_view.destroy_display()

            self.current_view = view_class(news_store, appearance_prefs)
            self.add(self.current_view.top_level())
            self.show_all()

            self.get_preferred_size()  # TODO: Investigate if still needed.

        return self.current_view