[gnome-music] window: Fix oversights in the view split



commit 38a5fcdf94ed67d29228803a68d346c35b8cd86b
Author: Marinus Schraal <mschraal src gnome org>
Date:   Sun Oct 9 21:04:21 2016 +0200

    window: Fix oversights in the view split
    
    An oversight during the splitting of views resulted in non-working empty
    state views.

 gnomemusic/views/emptyview.py        |   52 ++++++++++++++++++++++++++++++++++
 gnomemusic/views/initialstateview.py |   30 ++-----------------
 gnomemusic/window.py                 |   10 ++++--
 3 files changed, 62 insertions(+), 30 deletions(-)
---
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
new file mode 100644
index 0000000..641c4e0
--- /dev/null
+++ b/gnomemusic/views/emptyview.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2016 The GNOME Music Developers
+#
+# GNOME Music is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GNOME Music is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with GNOME Music; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# The GNOME Music authors hereby grant permission for non-GPL compatible
+# GStreamer plugins to be used and distributed together with GStreamer
+# and GNOME Music.  This permission is above and beyond the permissions
+# granted by the GPL license by which GNOME Music is covered.  If you
+# modify this code, you may extend this exception to your version of the
+# code, but you are not obligated to do so.  If you do not wish to do so,
+# delete this exception statement from your version.
+
+from gettext import gettext as _
+from gi.repository import Gtk
+
+from gnomemusic import log
+from gnomemusic.query import Query
+
+
+class EmptyView(Gtk.Stack):
+
+    def __repr__(self):
+        return '<EmptyView>'
+
+    @log
+    def __init__(self, window, player):
+        Gtk.Stack.__init__(self,
+                           transition_type=Gtk.StackTransitionType.CROSSFADE)
+        self.builder = Gtk.Builder()
+        self.builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
+        widget = self.builder.get_object('container')
+        self.update_empty_state_link()
+        self.add(widget)
+        self.show_all()
+
+    def update_empty_state_link(self):
+        label = self.builder.get_object('empty-state-label')
+        href_text = '<a href="%s">%s</a>' % (Query.MUSIC_URI,
+                                             _("Music folder"))
+        label.set_label(label.get_label() % href_text)
diff --git a/gnomemusic/views/initialstateview.py b/gnomemusic/views/initialstateview.py
index 8f2efc6..cc05bd7 100644
--- a/gnomemusic/views/initialstateview.py
+++ b/gnomemusic/views/initialstateview.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2016 The GNOME Music Developers
+#
 # GNOME Music is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -21,37 +23,13 @@
 # delete this exception statement from your version.
 
 from gettext import gettext as _
-from gi.repository import Gtk
 
 from gnomemusic import log
 from gnomemusic.albumartcache import ArtSize
-from gnomemusic.query import Query
-
-
-class Empty(Gtk.Stack):
-
-    def __repr__(self):
-        return '<Empty>'
-
-    @log
-    def __init__(self, window, player):
-        Gtk.Stack.__init__(self,
-                           transition_type=Gtk.StackTransitionType.CROSSFADE)
-        self.builder = Gtk.Builder()
-        self.builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
-        widget = self.builder.get_object('container')
-        self.update_empty_state_link()
-        self.add(widget)
-        self.show_all()
-
-    def update_empty_state_link(self):
-        label = self.builder.get_object('empty-state-label')
-        href_text = '<a href="%s">%s</a>' % (Query.MUSIC_URI,
-                                             _("Music folder"))
-        label.set_label(label.get_label() % href_text)
+from gnomemusic.views.emptyview import EmptyView
 
 
-class InitialStateView(Empty):
+class InitialStateView(EmptyView):
 
     def __repr__(self):
         return '<InitialStateView>'
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index a1acbb7..41b4b8c 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -41,7 +41,9 @@ from gnomemusic.player import Player, SelectionToolbar, RepeatType
 from gnomemusic.query import Query
 from gnomemusic.views.albumsview import AlbumsView
 from gnomemusic.views.artistsview import ArtistsView
+from gnomemusic.views.emptyview import EmptyView
 from gnomemusic.views.emptysearchview import EmptySearchView
+from gnomemusic.views.initialstateview import InitialStateView
 from gnomemusic.views.searchview import SearchView
 from gnomemusic.views.songsview import SongsView
 from gnomemusic.views.playlistview import PlaylistView
@@ -254,9 +256,9 @@ class Window(Gtk.ApplicationWindow):
         did_initial_state = self.settings.get_boolean('did-initial-state')
         view_class = None
         if did_initial_state:
-            view_class = Views.Empty
+            view_class = EmptyView
         else:
-            view_class = Views.InitialState
+            view_class = InitialStateView
         self.views.append(view_class(self, self.player))
 
         self._stack.add_titled(self.views[0], _("Empty"), _("Empty"))
@@ -337,7 +339,7 @@ class Window(Gtk.ApplicationWindow):
         if self.pl_todelete_notification:
             self.views[3].really_delete = False
             self.pl_todelete_notification.destroy()
-            Views.playlists.delete_playlist(self.views[3].pl_todelete)
+            playlist.delete_playlist(self.views[3].pl_todelete)
 
         self.notification = Gd.Notification()
         self.notification.set_timeout(20)
@@ -363,7 +365,7 @@ class Window(Gtk.ApplicationWindow):
     def _playlist_removal_notification_dismissed(self, widget):
         self.pl_todelete_notification = None
         if self.views[3].really_delete:
-            Views.playlists.delete_playlist(self.views[3].pl_todelete)
+            playlist.delete_playlist(self.views[3].pl_todelete)
         else:
             self.views[3].really_delete = True
 


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