[gnome-music] toolbar: Rename states



commit e3087ddb7ed131ba7be78522f9e65ed059d0a97c
Author: Arnel Borja <arnelborja src gnome org>
Date:   Mon May 5 00:12:18 2014 +0800

    toolbar: Rename states
    
    Rename SINGLE and ALBUMS states to CHILD_VIEW and MAIN, respectively.
    Add new state SEARCH_VIEW for viewing a result in search view, which is
    like CHILD_VIEW except that the search button is not shown.

 gnomemusic/toolbar.py |   15 +++++++--------
 gnomemusic/view.py    |    4 ++--
 gnomemusic/window.py  |    6 +++---
 3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index d3dc718..0597588 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -38,11 +38,9 @@ logger = logging.getLogger(__name__)
 
 
 class ToolbarState:
-    SINGLE = 0
-    ALBUMS = 1
-    ARTISTS = 2
-    PLAYLISTS = 3
-    SONGS = 4
+    MAIN = 0
+    CHILD_VIEW = 1
+    SEARCH_VIEW = 2
 
 
 class Toolbar(GObject.GObject):
@@ -126,7 +124,7 @@ class Toolbar(GObject.GObject):
     def on_back_button_clicked(self, widget):
         view = self._stack_switcher.get_stack().get_visible_child()
         view._back_button_clicked(view)
-        self.set_state(ToolbarState.ALBUMS)
+        self.set_state(ToolbarState.MAIN)
 
     @log
     def set_state(self, state, btn=None):
@@ -136,12 +134,13 @@ class Toolbar(GObject.GObject):
 
     @log
     def _update(self):
-        if self._state == ToolbarState.SINGLE:
+        if self._state != ToolbarState.MAIN:
             self.header_bar.set_custom_title(None)
         elif self._selectionMode:
             self.header_bar.set_custom_title(self._selection_menu_button)
         else:
             self.reset_header_title()
 
-        self._back_button.set_visible(not self._selectionMode and self._state == ToolbarState.SINGLE)
+        self._search_button.set_visible(self._state != ToolbarState.SEARCH_VIEW)
+        self._back_button.set_visible(not self._selectionMode and self._state != ToolbarState.MAIN)
         self.header_bar.set_show_close_button(not self._selectionMode)
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index f89ff79..77a3162 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -372,7 +372,7 @@ class Albums(ViewContainer):
         item = self._model.get_value(_iter, 5)
         self._albumWidget.update(artist, title, item,
                                  self.header_bar, self.selection_toolbar)
-        self.header_bar.set_state(0)
+        self.header_bar.set_state(ToolbarState.CHILD_VIEW)
         escaped_title = albumArtCache.get_media_title(item)
         self.header_bar.header_bar.set_title(escaped_title)
         self.header_bar.header_bar.sub_title = artist
@@ -385,7 +385,7 @@ class Albums(ViewContainer):
 
     @log
     def get_selected_track_uris(self, callback):
-        if self.header_bar._state == ToolbarState.SINGLE:
+        if self.header_bar._state == ToolbarState.CHILD_VIEW:
             uris = []
             for path in self._albumWidget.view.get_selection():
                 _iter = self._albumWidget.model.get_iter(path)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 11c1f63..f22e0fa 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -209,7 +209,7 @@ class Window(Gtk.ApplicationWindow):
         self.selection_toolbar._remove_from_playlist_button.connect(
             'clicked', self._on_remove_from_playlist_button_clicked)
 
-        self.toolbar.set_state(ToolbarState.ALBUMS)
+        self.toolbar.set_state(ToolbarState.MAIN)
         self.toolbar.header_bar.show()
         self._overlay.show()
         self.player.eventBox.show_all()
@@ -251,7 +251,7 @@ class Window(Gtk.ApplicationWindow):
     def _on_select_all(self, action, param):
         if self.toolbar._selectionMode is False:
             return
-        if self.toolbar._state != ToolbarState.SINGLE:
+        if self.toolbar._state == ToolbarState.MAIN:
             model = self._stack.get_visible_child()._model
         else:
             model = self._stack.get_visible_child()._albumWidget.model
@@ -272,7 +272,7 @@ class Window(Gtk.ApplicationWindow):
 
     @log
     def _on_select_none(self, action, param):
-        if self.toolbar._state != ToolbarState.SINGLE:
+        if self.toolbar._state == ToolbarState.MAIN:
             model = self._stack.get_visible_child()._model
         else:
             model = self._stack.get_visible_child()._albumWidget.model


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