[gnome-music/glade] Rewrite AlbumsWidget
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/glade] Rewrite AlbumsWidget
- Date: Sat, 20 Apr 2013 13:39:16 +0000 (UTC)
commit d5d459e4a4d3e9d071200bdf83b318f677d778b3
Author: Seif Lotfy <seif lotfy com>
Date: Sat Apr 20 07:21:57 2013 +0200
Rewrite AlbumsWidget
data/ArtistAlbumWidget.ui | 63 +++++++++++++++++-----------------
data/ArtistAlbumsWidget.ui | 5 +--
data/TrackWidget.ui | 78 ++++++++++++++++++++++++++++++++++++++++++
data/gnome-music.gresource.xml | 1 +
src/query.js | 4 ++-
src/widgets.js | 45 ++++++++++++++++++------
6 files changed, 150 insertions(+), 46 deletions(-)
---
diff --git a/data/ArtistAlbumWidget.ui b/data/ArtistAlbumWidget.ui
index 228beee..fb8ca5c 100644
--- a/data/ArtistAlbumWidget.ui
+++ b/data/ArtistAlbumWidget.ui
@@ -4,7 +4,6 @@
<object class="GtkBox" id="ArtistAlbumWidget">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
<child>
<object class="GtkImage" id="cover">
<property name="visible">True</property>
@@ -14,6 +13,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="padding">24</property>
<property name="position">0</property>
</packing>
</child>
@@ -33,7 +33,6 @@
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">6</property>
- <property name="label" translatable="yes">label</property>
<property name="ellipsize">middle</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -51,7 +50,6 @@
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
- <property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
@@ -67,42 +65,43 @@
</packing>
</child>
<child>
- <object class="GtkIconView" id="iconview1">
+ <object class="GtkGrid" id="grid1">
+ <property name="height_request">9</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_left">8</property>
- <property name="margin_top">8</property>
- <property name="hexpand">True</property>
- <property name="selection_mode">none</property>
- <property name="item_orientation">horizontal</property>
- <property name="model">liststore1</property>
- <property name="columns">2</property>
- <property name="row_spacing">1</property>
- <property name="activate_on_single_click">True</property>
- <style>
- <class name="content-view"/>
- <class name="view"/>
- </style>
+ <property name="can_focus">False</property>
+ <property name="row_homogeneous">True</property>
+ <property name="column_homogeneous">True</property>
<child>
- <object class="GtkCellRendererText" id="trackNumberRenderer">
- <property name="foreground_gdk">#bababdbdb6b6</property>
- </object>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
+ <placeholder/>
</child>
<child>
- <object class="GtkCellRendererText" id="titleRenderer">
- <property name="ellipsize">middle</property>
- </object>
- <attributes>
- <attribute name="markup">0</attribute>
- </attributes>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/data/ArtistAlbumsWidget.ui b/data/ArtistAlbumsWidget.ui
index 06c74d4..133b2b8 100644
--- a/data/ArtistAlbumsWidget.ui
+++ b/data/ArtistAlbumsWidget.ui
@@ -4,9 +4,9 @@
<object class="GtkBox" id="ArtistAlbumsWidget">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">24</property>
+ <property name="margin_left">24</property>
+ <property name="margin_top">24</property>
<property name="orientation">vertical</property>
- <property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="artist">
<property name="visible">True</property>
@@ -27,6 +27,7 @@
<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>
diff --git a/data/TrackWidget.ui b/data/TrackWidget.ui
new file mode 100644
index 0000000..74e8475
--- /dev/null
+++ b/data/TrackWidget.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">etched-out</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">9</property>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkLabel" id="num">
+ <property name="width_request">32</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">
+</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</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="GtkLabel" id="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">
+</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="duration">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">
+</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label_item">
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/data/gnome-music.gresource.xml b/data/gnome-music.gresource.xml
index fb5634f..c30b2e3 100644
--- a/data/gnome-music.gresource.xml
+++ b/data/gnome-music.gresource.xml
@@ -7,5 +7,6 @@
<file preprocess="xml-stripblanks">ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
<file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
+ <file preprocess="xml-stripblanks">TrackWidget.ui</file>
</gresource>
</gresources>
diff --git a/src/query.js b/src/query.js
index b63f9bf..4382f64 100644
--- a/src/query.js
+++ b/src/query.js
@@ -26,7 +26,9 @@ const artist = 'SELECT DISTINCT rdf:type(?album) tracker:id(?album) as id (SELEC
const album_count = 'SELECT COUNT(?album) AS childcount WHERE { ?album a nmm:MusicAlbum }';
-const songs = 'SELECT DISTINCT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as url
nie:title(?song) as title nmm:artistName(nmm:performer(?song)) as artist nie:title(nmm:musicAlbum(?song)) as
album nfo:duration(?song) as duration { ?song a nmm:MusicPiece } (SELECT fn:year-from-dateTime(?c) WHERE {
?_2 nmm:musicAlbum(?song); nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as creation-date ORDER
BY tracker:added(?song)';
+/*const songs = 'SELECT DISTINCT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as url
nie:title(?song) as title nmm:artistName(nmm:performer(?song)) as artist nie:title(nmm:musicAlbum(?song)) as
album nfo:duration(?song) as duration { ?song a nmm:MusicPiece } (SELECT fn:year-from-dateTime(?c) WHERE {
?_2 nmm:musicAlbum(?song); nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as creation-date ORDER
BY tracker:added(?song)';*/
+
+const songs = 'SELECT DISTINCT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as url
nie:title(?song) as title nmm:artistName(nmm:performer(?song)) as artist nie:title(nmm:musicAlbum(?song)) as
album nfo:duration(?song) as duration { ?song a nmm:MusicPiece } ORDER BY tracker:added(?song)';
const songs_count = 'SELECT COUNT(?song) AS childcount WHERE { ?song a nmm:MusicPiece }';
diff --git a/src/widgets.js b/src/widgets.js
index 19d122d..57e6d90 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -233,13 +233,15 @@ const ArtistAlbums = new Lang.Class({
this.parent();
this.ui = new Gtk.Builder();
this.ui.add_from_resource('/org/gnome/music/ArtistAlbumsWidget.ui');
- this.set_border_width(24)
- this.ui.get_object("artist").set_label(this.artist)
+ this.set_border_width(0);
+ this.ui.get_object("artist").set_label(this.artist);
var tracks = [];
var widgets = [];
+
+ this.pack_start(this.ui.get_object("ArtistAlbumsWidget"), false, false, 0);
for (var i=0; i < albums.length; i++) {
let widget = new ArtistAlbumWidget(artist, albums[i], this.player, tracks)
- this.pack_start(widget, true, true, 9);
+ this.pack_start(widget, false, false, 32);
widgets.push(widget);
}
this.show_all();
@@ -272,6 +274,7 @@ const ArtistAlbumWidget = new Lang.Class({
this.parent();
this.player = player;
this.album = album;
+ this.songs = [];
this.ui = new Gtk.Builder();
this.ui.add_from_resource('/org/gnome/music/ArtistAlbumWidget.ui');
@@ -282,6 +285,7 @@ const ArtistAlbumWidget = new Lang.Class({
let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 128, true);
}
+
this.ui.get_object("cover").set_from_pixbuf(pixbuf);
this.ui.get_object("title").set_label(album.get_title());
if (album.get_creation_date()) {
@@ -292,29 +296,47 @@ const ArtistAlbumWidget = new Lang.Class({
grilo.getAlbumSongs(album.get_id(), Lang.bind(this, function (source, prefs, track) {
if (track != null) {
tracks.push(track);
- let iter = this.model.append();
track.origin = this;
- track.iterator = iter;
- let path = "/usr/share/icons/gnome/scalable/actions/media-playback-start-symbolic.svg";
- let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 16, true);
- this.model.set(iter,
- [0, 1, 2, 3, 4, 5],
- [ track.get_title(), track.get_track_number(), "", false, pixbuf, track ]);
+ //let path = "/usr/share/icons/gnome/scalable/actions/media-playback-start-symbolic.svg";
+ //let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 16, true);
+ //this.model.set(iter,
+ // [0, 1, 2, 3, 4, 5],
+ // [ track.get_title(), track.get_track_number(), "", false, pixbuf, track ]);
+ var ui = new Gtk.Builder();
+ ui.add_from_resource('/org/gnome/music/TrackWidget.ui');
+ var songWidget = ui.get_object("frame1");
+ this.songs.push(songWidget);
+ ui.get_object("num").set_text(this.songs.length.toString());
+ if (track.get_title() != null)
+ ui.get_object("title").set_text(track.get_title());
+ //var songWidget = ui.get_object("duration").set_text(track.get_title());
+ ui.get_object("title").set_alignment(0.0, 0.5);
+ if (this.songs.length == 1) {
+ this.ui.get_object("grid1").add(songWidget);
+ }
+ else {
+ var i = this.songs.length - 1;
+ this.ui.get_object("grid1").attach(songWidget, i%2, parseInt(i/2), 1, 1)
+ }
+ this.ui.get_object("grid1").show_all();
+ //ui.get_object("image1").hide();
}
}));
this.pack_start(this.ui.get_object("ArtistAlbumWidget"), true, true, 0);
this.show_all();
- this.ui.get_object("iconview1").connect('item-activated', Lang.bind(
+ /*this.ui.get_object("iconview1").connect('item-activated', Lang.bind(
this, function(widget, path) {
var iter = this.model.get_iter (path)[1];
var item = this.model.get_value (iter, 5);
this.setPlayingSong(item.iterator);
}));
+ */
},
setPlayingSong: function(iter) {
+ /*
if (iter == -1) {
// Remove markup completely
let new_iter = this.model.get_iter_first()[1];
@@ -353,5 +375,6 @@ const ArtistAlbumWidget = new Lang.Class({
this.model.set_value(next_iter, 3, false);
}
}
+ */
},
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]