[gnome-music] Implementing view for No Music



commit ab331fd7c46e77cfd06a146d830931f9d1e5217d
Author: Shivani Poddar <shivani poddar92 gmail com>
Date:   Mon May 13 12:17:43 2013 +0530

    Implementing view for No Music
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699824

 data/NoMusic.ui                |   45 ++++++++++++++++++++++++++++++++++++++++
 data/gnome-music.gresource.xml |    1 +
 src/view.js                    |   17 +++++++++++++++
 src/window.js                  |   17 ++++++++++++++-
 4 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/data/NoMusic.ui b/data/NoMusic.ui
new file mode 100644
index 0000000..adb97d1
--- /dev/null
+++ b/data/NoMusic.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkBox" id="container">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="halign">center</property>
+    <property name="valign">center</property>
+    <child>
+      <object class="GtkImage" id="image1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">1</property>
+        <property name="yalign">0.20000000298023224</property>
+        <property name="xpad">24</property>
+        <property name="ypad">61</property>
+        <property name="pixel_size">40</property>
+        <property name="icon_name">emblem-music-symbolic</property>
+        <property name="icon-size">0</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">0.4699999988079071</property>
+        <property name="yalign">0.46000000834465027</property>
+        <property name="xpad">5</property>
+        <property name="label" translatable="yes">No Music Found</property>
+        <property name="justify">center</property>
+        <property name="ellipsize">middle</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/data/gnome-music.gresource.xml b/data/gnome-music.gresource.xml
index c30b2e3..6e6b91f 100644
--- a/data/gnome-music.gresource.xml
+++ b/data/gnome-music.gresource.xml
@@ -8,5 +8,6 @@
     <file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
     <file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
     <file preprocess="xml-stripblanks">TrackWidget.ui</file>
+    <file preprocess="xml-stripblanks">NoMusic.ui</file>
   </gresource>
 </gresources>
diff --git a/src/view.js b/src/view.js
index 2dbb26b..9e92acf 100644
--- a/src/view.js
+++ b/src/view.js
@@ -275,6 +275,23 @@ const ViewContainer = new Lang.Class({
 });
 Signals.addSignalMethods(ViewContainer.prototype);
 
+//Class for the Empty View
+const Empty = new Lang.Class({
+    Name: "Empty",
+    Extends: Gd.Stack,
+
+    _init: function(header_bar,player){
+        this.parent({transition_type: Gd.StackTransitionType.CROSSFADE});
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/music/NoMusic.ui');
+        let widget = builder.get_object('container');
+        print(widget);
+        this.add(widget);
+        this.show_all();
+    }
+});
+
+
 const Albums = new Lang.Class({
     Name: "AlbumsView",
     Extends: ViewContainer,
diff --git a/src/window.js b/src/window.js
index 4559f52..1fd5448 100644
--- a/src/window.js
+++ b/src/window.js
@@ -29,6 +29,9 @@ const _ = imports.gettext.gettext;
 const Toolbar = imports.toolbar;
 const Views = imports.view;
 const Player = imports.player;
+const Query = imports.query;
+const Tracker = imports.gi.Tracker;
+const tracker = Tracker.SparqlConnection.get (null)
 
 const MainWindow = new Lang.Class({
     Name: "MainWindow",
@@ -63,7 +66,12 @@ const MainWindow = new Lang.Class({
         this._box.pack_start(this._stack, true, true, 0);
         this._box.pack_start(this.player.eventBox, false, false, 0);
         this.add(this._box);
-
+        let count = -1;
+        let cursor = tracker.query(Query.songs_count, null)
+        if(cursor!= null && cursor.next(null))
+            count = cursor.get_integer(0);
+        if(count > 0)
+        {
         this.views[0] = new Views.Albums(this.toolbar, this.player);
         this.views[1] = new Views.Artists(this.toolbar, this.player);
         this.views[2] = new Views.Songs(this.toolbar, this.player);
@@ -80,6 +88,13 @@ const MainWindow = new Lang.Class({
         //this._stack.connect("notify::visible-child", this._onNotifyMode);
 
         this.views[0].populate();
+        }
+        //To revert to the No Music View when no songs are found
+        else{
+            this.views[0] = new Views.Empty(this.toolbar, this.player);
+            this._stack.add_titled(this.views[0],"Empty","Empty");
+        }
+
         this.toolbar.set_stack(this._stack);
         this.toolbar.show();
         this.player.eventBox.show_all();


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