[gnome-music/wip/gbsneto/flowbox: 1/13] view: factor out function to setup the view



commit 2e08acc767ad1f2423b42ddf0f6ec314ed127c75
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 9 01:31:11 2016 -0300

    view: factor out function to setup the view
    
    Since the Albums view will handle the internal view
    differently, it makes sense to add a new method that
    will be overriden in the future.
    
    This patch moves the code related to setting up the
    view into a separate function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760164

 gnomemusic/view.py |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index c9b218a..1e627a5 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -89,10 +89,10 @@ class ViewContainer(Gtk.Stack):
             GObject.TYPE_BOOLEAN,
             GObject.TYPE_INT
         )
-        self.view = Gd.MainView(
-            shadow_type=Gtk.ShadowType.NONE
-        )
-        self.view.set_view_type(view_type)
+
+        # Setup the main view
+        self._setup_view(view_type)
+
         self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
         self._box.pack_start(self.view, True, True, 0)
         if use_sidebar:
@@ -111,9 +111,6 @@ class ViewContainer(Gtk.Stack):
             self._grid.add(self._box)
 
         self.star_handler = Widgets.StarHandler(self, 9)
-        self.view.click_handler = self.view.connect('item-activated', self._on_item_activated)
-        # self.star_handler.star_renderer_click = False
-        self.view.connect('selection-mode-request', self._on_selection_mode_request)
         self._cursor = None
         self.window = window
         self.header_bar = window.toolbar
@@ -147,6 +144,14 @@ class ViewContainer(Gtk.Stack):
         pass
 
     @log
+    def _setup_view(self, view_type):
+        self.view = Gd.MainView(shadow_type=Gtk.ShadowType.NONE)
+        self.view.set_view_type(view_type)
+
+        self.view.click_handler = self.view.connect('item-activated', self._on_item_activated)
+        self.view.connect('selection-mode-request', self._on_selection_mode_request)
+
+    @log
     def _on_header_bar_toggled(self, button):
         if button.get_active():
             self.view.set_selection_mode(True)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]