[gnome-music/glade] Fix sorting of titles of songs in albumsongs view
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/glade] Fix sorting of titles of songs in albumsongs view
- Date: Sat, 20 Apr 2013 16:51:32 +0000 (UTC)
commit 37984dc2b2a6d15076c73a35aede35ec7ffcd5ec
Author: Seif Lotfy <seif lotfy com>
Date: Sat Apr 20 18:50:38 2013 +0200
Fix sorting of titles of songs in albumsongs view
data/ArtistAlbumWidget.ui | 1 +
data/TrackWidget.ui | 4 +++-
src/widgets.js | 49 ++++++++++++++++++++++++++---------------------
3 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/data/ArtistAlbumWidget.ui b/data/ArtistAlbumWidget.ui
index a33c7ca..cf84412 100644
--- a/data/ArtistAlbumWidget.ui
+++ b/data/ArtistAlbumWidget.ui
@@ -72,6 +72,7 @@
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_top">24</property>
<property name="column_homogeneous">True</property>
<child>
<placeholder/>
diff --git a/data/TrackWidget.ui b/data/TrackWidget.ui
index eb084af..4479ec4 100644
--- a/data/TrackWidget.ui
+++ b/data/TrackWidget.ui
@@ -8,10 +8,11 @@
<property name="margin_bottom">1</property>
<child>
<object class="GtkLabel" id="num">
- <property name="width_request">32</property>
+ <property name="width_request">24</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
+ <property name="xalign">1</property>
<attributes>
<attribute name="foreground" value="#bababdbdb6b6"/>
</attributes>
@@ -36,6 +37,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="padding">9</property>
<property name="position">2</property>
</packing>
</child>
diff --git a/src/widgets.js b/src/widgets.js
index 9005b6c..1b3382d 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -276,6 +276,8 @@ const ArtistAlbumWidget = new Lang.Class({
this.album = album;
this.songs = [];
+ var track_count = album.get_childcount();
+
this.ui = new Gtk.Builder();
this.ui.add_from_resource('/org/gnome/music/ArtistAlbumWidget.ui');
this.model = this.ui.get_object("liststore1");
@@ -297,29 +299,32 @@ const ArtistAlbumWidget = new Lang.Class({
if (track != null) {
tracks.push(track);
track.origin = this;
- //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("box1");
- 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)
+ }
+ else {
+ var titles = []
+ for (var i=0; i<tracks.length; i++) {
+ track = tracks[i];
+ if (titles.indexOf(track.get_title()) == -1) {
+ titles.push(track.get_title())
+ var ui = new Gtk.Builder();
+ ui.add_from_resource('/org/gnome/music/TrackWidget.ui');
+ var songWidget = ui.get_object("box1");
+ 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, parseInt(i/(tracks.length/2)),
parseInt((i)%(tracks.length/2)), 1, 1)
+ }
+ this.ui.get_object("grid1").show_all();
+ }
}
- this.ui.get_object("grid1").show_all();
- //ui.get_object("image1").hide();
}
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]