[gnome-music/wip/empty-state: 2/2] UI: add initial state
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/empty-state: 2/2] UI: add initial state
- Date: Fri, 23 Jan 2015 13:32:05 +0000 (UTC)
commit ed8c29653ca90bb1f4d484e1702be44fb3a773d3
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Fri Jan 23 14:31:38 2015 +0100
UI: add initial state
data/NoMusic.ui | 6 +++---
data/gnome-music.gresource.xml | 1 +
data/initial-state.png | Bin 0 -> 41719 bytes
data/org.gnome.Music.gschema.xml | 5 +++++
gnomemusic/view.py | 33 +++++++++++++++++++++++++++------
gnomemusic/window.py | 10 +++++++++-
6 files changed, 45 insertions(+), 10 deletions(-)
---
diff --git a/data/NoMusic.ui b/data/NoMusic.ui
index d89d91d..26a1487 100644
--- a/data/NoMusic.ui
+++ b/data/NoMusic.ui
@@ -8,7 +8,7 @@
<property name="halign">center</property>
<property name="valign">center</property>
<child>
- <object class="GtkImage" id="image1">
+ <object class="GtkImage" id="icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
@@ -25,10 +25,10 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="label">
+ <object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<child>
- <object class="GtkLabel" id="label1">
+ <object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="opacity">0.5</property>
<property name="can_focus">False</property>
diff --git a/data/gnome-music.gresource.xml b/data/gnome-music.gresource.xml
index b33c23d..a0db704 100644
--- a/data/gnome-music.gresource.xml
+++ b/data/gnome-music.gresource.xml
@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">AboutDialog.ui</file>
<file preprocess="xml-stripblanks">app-menu.ui</file>
<file>application.css</file>
+ <file>initial-state.png</file>
<file preprocess="xml-stripblanks">AlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
diff --git a/data/initial-state.png b/data/initial-state.png
new file mode 100644
index 0000000..0089aff
Binary files /dev/null and b/data/initial-state.png differ
diff --git a/data/org.gnome.Music.gschema.xml b/data/org.gnome.Music.gschema.xml
index d50112f..2948102 100644
--- a/data/org.gnome.Music.gschema.xml
+++ b/data/org.gnome.Music.gschema.xml
@@ -53,5 +53,10 @@
<summary>Internal: id for most played playlist</summary>
<description></description>
</key>
+ <key type="b" name="did-initial-state">
+ <default>false</default>
+ <summary>Inital state has been displayed</summary>
+ <description>Set to true when initial state has been displayed</description>
+ </key>
</schema>
</schemalist>
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 1158254..bb88699 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -34,6 +34,7 @@
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import Gd
+from gi.repository import Gio
from gi.repository import Grl
from gi.repository import Pango
from gi.repository import GLib
@@ -274,19 +275,39 @@ class Empty(Gtk.Stack):
def __init__(self, window, player):
Gtk.Stack.__init__(self,
transition_type=Gtk.StackTransitionType.CROSSFADE)
- builder = Gtk.Builder()
- builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
- widget = builder.get_object('container')
- self.update_empty_state_link(builder)
+ 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, builder):
- label = builder.get_object('empty-state-label')
+ 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)
+# Class for the Initial State
+class InitialState(Empty):
+ @log
+ def __init__(self, window, player):
+ Empty.__init__(self, window, player)
+
+ # Update image
+ icon = self.builder.get_object('icon')
+ icon.set_margin_bottom(32)
+ icon.set_opacity(1)
+ icon.set_from_resource('/org/gnome/Music/initial-state.png')
+ icon.set_size_request(256, 256)
+
+ # Update label
+ label = self.builder.get_object('label')
+ label.set_label(_("Hey DJ"))
+ label.set_opacity(1)
+ label.set_margin_bottom(18)
+
+
class Albums(ViewContainer):
@log
def __init__(self, window, player):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index b84f037..b660108 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -236,13 +236,21 @@ class Window(Gtk.ApplicationWindow):
@log
def _switch_to_empty_view(self):
- self.views.append(Views.Empty(self, self.player))
+ did_initial_state = self.settings.get_boolean('did-initial-state')
+ view_class = None
+ if did_initial_state:
+ view_class = Views.Empty
+ else:
+ view_class = Views.InitialState
+ self.views.append(view_class(self, self.player))
+
self._stack.add_titled(self.views[0], _("Empty"), _("Empty"))
self.toolbar._search_button.set_sensitive(False)
self.toolbar._select_button.set_sensitive(False)
@log
def _switch_to_player_view(self):
+ self.settings.set_boolean('did-initial-state', True)
self._on_notify_model_id = self._stack.connect('notify::visible-child', self._on_notify_mode)
self.connect('destroy', self._notify_mode_disconnect)
self._key_press_event_id = self.connect('key_press_event', self._on_key_press)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]