[gnome-music/playlists] ..



commit 8cdf26246d5133a35d3e1c1d3741c49f79be41ea
Author: Eslam Mostafa <me eslammostafa com>
Date:   Tue Jun 18 17:19:11 2013 +0200

    ..

 data/PlaylistSongs.ui |  334 +++++++++++++++++++++++--------------------------
 src/grilo.js          |    2 +-
 src/view.js           |   16 ++--
 src/widgets.js        |   32 ++++-
 4 files changed, 192 insertions(+), 192 deletions(-)
---
diff --git a/data/PlaylistSongs.ui b/data/PlaylistSongs.ui
index 6c3e607..b3697a6 100644
--- a/data/PlaylistSongs.ui
+++ b/data/PlaylistSongs.ui
@@ -1,198 +1,180 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <object class="GtkFrame" id="frame">
+  <object class="GtkBox" id="container">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="label_xalign">0</property>
-    <property name="label_yalign">0</property>
-    <property name="shadow_type">none</property>
+    <property name="margin_left">24</property>
+    <property name="margin_top">18</property>
+    <property name="orientation">vertical</property>
     <child>
-      <object class="GtkScrolledWindow" id="scrolledwindow1">
+      <object class="GtkBox" id="box2">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="shadow_type">in</property>
+        <property name="can_focus">False</property>
         <child>
-          <object class="GtkViewport" id="viewport1">
+          <object class="GtkLabel" id="playlist">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label">label</property>
+            <property name="ellipsize">middle</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="spacer">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="playlistEditButton">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="focus_on_click">False</property>
+            <style>
+              <class name="circle-button"/>
+            </style>
             <child>
-              <object class="GtkBox" id="container">
+              <object class="GtkImage" id="image1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="margin_left">24</property>
-                <property name="margin_top">18</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <object class="GtkBox" id="box2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkLabel" id="playlist">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label">label</property>
-                        <property name="ellipsize">middle</property>
-                        <attributes>
-                          <attribute name="weight" value="bold"/>
-                        </attributes>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="spacer">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="playlistEditButton">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="focus_on_click">False</property>
-                        <style>
-                          <class name="circle-button"/>
-                        </style>
-                        <child>
-                          <object class="GtkImage" id="image1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="icon_name">applications-system-symbolic</property>
-                            <property name="use_fallback">True</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label1">
-                        <property name="width_request">24</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkBox" id="box1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="spacing">6</property>
-                    <child>
-                      <object class="GtkLabel" id="songsCount">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">00</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="songs">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Songs,</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="songsSize">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">size</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="songsDuration">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">duration</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSeparator" id="separator1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin_top">6</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
+                <property name="icon_name">applications-system-symbolic</property>
+                <property name="use_fallback">True</property>
               </object>
             </child>
           </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="width_request">24</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="songsCount">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">00</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="songs">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Songs,</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="songsSize">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">size</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="songsDuration">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">duration</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
         </child>
       </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
     </child>
-    <child type="label_item">
-      <placeholder/>
+    <child>
+      <object class="GtkScrolledWindow" id="scrolledwindow">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="hscrollbar_policy">never</property>
+        <child>
+          <object class="GtkViewport" id="viewport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">3</property>
+      </packing>
     </child>
   </object>
 </interface>
diff --git a/src/grilo.js b/src/grilo.js
index 5e9702e..56d9692 100644
--- a/src/grilo.js
+++ b/src/grilo.js
@@ -136,7 +136,7 @@ const Grilo = new Lang.Class({
             Lang.bind(this, function(source, id, media) {
                 grilo.filesystem.browse(
                     media,
-                    [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST, 
Grl.METADATA_KEY_CREATION_DATE, Grl.METADATA_KEY_DURATION],
+                    [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST, 
Grl.METADATA_KEY_ALBUM, Grl.METADATA_KEY_CREATION_DATE, Grl.METADATA_KEY_DURATION],
                     options,
                     Lang.bind(this, callback, null));
             }));
diff --git a/src/view.js b/src/view.js
index abfa2b9..74a4499 100644
--- a/src/view.js
+++ b/src/view.js
@@ -502,12 +502,12 @@ const Playlists = new Lang.Class({
         this.view.set_view_type(Gd.MainViewType.LIST);
         this.view.set_hexpand(false);
         let builder = new Gtk.Builder();
-        builder.add_from_resource('/org/gnome/music/PlaylistSongs.ui');
-        this._playlistSongsWidget = builder.get_object('frame');
-        let container = builder.get_object('container');
-        this._playlistLabel = builder.get_object("playlist");
+       // builder.add_from_resource('/org/gnome/music/PlaylistSongs.ui');
+        //this._playlistSongsWidget = builder.get_object('frame');
+        //let container = builder.get_object('container');
+        //this._playlistLabel = builder.get_object("playlist");
         this._songsListWidget = new Widgets.SongsList(this.player);
-        container.pack_end(this._songsListWidget, true, true, 0);
+        //container.pack_end(this._songsListWidget, true, true, 0);
         this.view.get_style_context().add_class("artist-panel");
         this.view.get_generic_view().get_selection().set_mode(Gtk.SelectionMode.SINGLE);
         builder.add_from_resource('/org/gnome/music/PlaylistControls.ui');
@@ -515,7 +515,7 @@ const Playlists = new Lang.Class({
         this._grid.attach(new Gtk.Separator(), 0, 1, 1, 1);
         this._grid.attach(controls, 0, 2, 1, 1);
         this._grid.attach(new Gtk.Separator({orientation: Gtk.Orientation.VERTICAL}), 1, 0, 1, 3);
-        this._grid.attach(this._playlistSongsWidget, 2, 0, 2, 3);
+        this._grid.attach(this._songsListWidget, 2, 0, 2, 3);
         this._addListRenderers();
         if(Gtk.Settings.get_default().gtk_application_prefer_dark_theme) {
             this.view.get_generic_view().get_style_context().add_class("artist-panel-dark");
@@ -550,9 +550,9 @@ const Playlists = new Lang.Class({
     _onItemActivated: function (widget, id, path) {
         let iter = this._model.get_iter (path)[1];
         let playlist = this._model.get_value (iter, 0);
-        this._playlistLabel.set_text(playlist);
+        //this._playlistLabel.set_text(playlist);
         let url = this._playlists[playlist.toLowerCase()]['url'];
-        this._songsListWidget.update(this._playlists[playlist.toLowerCase()]);
+        this._songsListWidget.update(playlist, this._playlists[playlist.toLowerCase()]);
     },
 
     _addItem: function (source, param, item) {
diff --git a/src/widgets.js b/src/widgets.js
index a6b07d8..e7fa5c9 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -324,12 +324,26 @@ Signals.addSignalMethods(AlbumWidget.prototype);
 
 const SongsList = new Lang.Class({
     Name: "SongsList",
-    Extends: Gd.MainView,
+    Extends: Gtk.Frame,
 
     _init: function(player){
         this.parent();
+        this.set_shadow_type(Gtk.ShadowType.NONE);
         this.player = player;
         this.playlist = null;
+        this._songsCount = 0;
+        this._songsDuration = 0;
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/music/PlaylistSongs.ui');
+        let container = builder.get_object('container');
+        let viewport = builder.get_object('viewport');
+        this._playlistLabel = builder.get_object('playlist');
+        this._songsCountLabel = builder.get_object('songsCount');
+        this._songsDurationLabel = builder.get_object('songsDuration');
+        this.add(container);
+        this.view = new Gd.MainView();
+        this.view.set_view_type(Gd.MainViewType.LIST);
+        this.view.get_generic_view().get_style_context().add_class("songs-list")
         this._model = Gtk.ListStore.new([
             GObject.TYPE_STRING,
             GObject.TYPE_STRING,
@@ -342,16 +356,18 @@ const SongsList = new Lang.Class({
             GObject.TYPE_BOOLEAN,
             GObject.TYPE_BOOLEAN
         ]);
-        this.set_view_type(Gd.MainViewType.LIST);
-        this.get_generic_view().get_style_context().add_class("songs-list")
-        this.set_model(this._model);
+        this.view.set_model(this._model);
+        container.pack_end(this.view, true, true, 0);
         this._addListRenderers();
         this.show_all();
-        this.connect('item-activated', Lang.bind(this, this._onItemActivated));
+        this.view.connect('item-activated', Lang.bind(this, this._onItemActivated));
     },
 
-    update: function(playlist) {
+    update: function(title, playlist) {
         this.playlist = playlist;
+        this._playlistLabel.set_text(title);
+//        this._songsCountLabel.set_text("%d" % this._songsCount);
+//        this._songsDurationLabel.set_text("%d" % this._songsDuration );
         this._model.clear();
         this._populate();
         this.show_all();
@@ -369,6 +385,8 @@ const SongsList = new Lang.Class({
         if (item == null)
             return;
         this._offset += 1;
+        this._songsCount += 1;
+        this._songsDuration += item.get_duration();
         var iter = this._model.append();
         if ((item.get_title() == null) && (item.get_url() != null)) {
             song.set_title (extractFileName(item.get_url()));
@@ -393,7 +411,7 @@ const SongsList = new Lang.Class({
     },
 
     _addListRenderers: function() {
-        let listWidget = this.get_generic_view();
+        let listWidget = this.view.get_generic_view();
         let cols = listWidget.get_columns();
         let cells = cols[0].get_cells();
         cells[2].visible = false;


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