Commit 38a5fcdf authored by Marinus Schraal's avatar Marinus Schraal

window: Fix oversights in the view split

An oversight during the splitting of views resulted in non-working empty
state views.
parent 557cab76
# 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)
# 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>'
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment