[gnome-music/gril-pls: 1/2] add playlists controls ui



commit 67540632e092f032da523a58f6ee11974936f7cc
Author: Eslam Mostafa <me eslammostafa com>
Date:   Sun Jun 16 12:03:03 2013 +0200

    add playlists controls ui

 data/PlayListControls.ui |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 src/grilo.js             |   41 +++++++++++++++++++++++++++++++++++++++
 src/view.js              |    1 +
 3 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/data/PlayListControls.ui b/data/PlayListControls.ui
new file mode 100644
index 0000000..5f98314
--- /dev/null
+++ b/data/PlayListControls.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.10 -->
+  <object class="GtkBox" id="box1">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkToolbar" id="playlistsToolbar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show_arrow">False</property>
+        <style>
+          <class name="linked"/>
+        </style>
+        <child>
+          <object class="GtkToolButton" id="addPlayList">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="use_underline">True</property>
+            <property name="icon_name">list-add</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="homogeneous">True</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToolButton" id="removePlayList">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">toolbutton1</property>
+            <property name="use_underline">True</property>
+            <property name="icon_name">list-remove</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="homogeneous">True</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/src/grilo.js b/src/grilo.js
index e3b55fc..bc8c7eb 100644
--- a/src/grilo.js
+++ b/src/grilo.js
@@ -18,6 +18,7 @@
  *
  */
 
+const GLib = imports.gi.GLib;
 const Grl = imports.gi.Grl;
 const Lang = imports.lang;
 const Signals = imports.signals;
@@ -30,12 +31,20 @@ const Grilo = new Lang.Class({
     Name: 'Grilo',
 
     _init: function() {
+        this.playlistPath = GLib.build_filenamev([GLib.get_user_data_dir(), "gnome-music", "playlists"]);
+
         this.registry = Grl.Registry.get_default ();
+
+        let config = Grl.Config.new("grl-filesystem", "Filesystem");
+        config.set_string("base-path", this.playlistPath);
+        this.registry.add_config(config);
+
         this.registry.load_all_plugins();
 
         let sources = {};
         this.sources = sources;
         this.tracker = null;
+        this.filesystem = this.registry.lookup_source("grl-filesystem");
 
         this.registry.connect ("source_added",
             Lang.bind(this, this._onSourceAdded));
@@ -77,6 +86,22 @@ const Grilo = new Lang.Class({
         this.populateItems (Query.songs, offset, callback)
     },
 
+    populatePlaylists: function (offset, callback) {
+        var options = Grl.OperationOptions.new(null);
+        options.set_flags(Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY);
+        grilo.filesystem.get_media_from_uri(
+            GLib.filename_to_uri(this.playlistPath, null),
+            [Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_URL, Grl.METADATA_KEY_MIME],
+            options,
+            Lang.bind(this, function(source, id, media) {
+                grilo.filesystem.browse(
+                    media,
+                    [Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_URL, Grl.METADATA_KEY_MIME],
+                    options,
+                    Lang.bind(this, callback, null));
+            }));
+    },
+
     populateItems: function (query, offset, callback, count=50) {
         var options = Grl.OperationOptions.new(null);
         options.set_flags (Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY);
@@ -100,6 +125,22 @@ const Grilo = new Lang.Class({
                 Lang.bind(this, callback, null));
     },
 
+    getPlaylistSongs: function (playlist_url, callback) {
+        var options = Grl.OperationOptions.new(null);
+        options.set_flags (Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY);
+        grilo.filesystem.get_media_from_uri(
+            playlist_url,
+            [Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_URL, Grl.METADATA_KEY_MIME],
+            options,
+            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],
+                    options,
+                    Lang.bind(this, callback, null));
+            }));
+    },
+
     _searchCallback: function search_cb () {
         log ("yeah");
     },
diff --git a/src/view.js b/src/view.js
index ee4a21d..fad596b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -496,6 +496,7 @@ const Playlists = new Lang.Class({
 
     _init: function(header_bar, player) {
         this.parent("Playlists", header_bar);
+        this._playlist= {};
     },
 });
 


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