[gnome-music] more code cleaning
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] more code cleaning
- Date: Mon, 22 Apr 2013 21:16:18 +0000 (UTC)
commit 3a5730007223a415b442ad1cabb903218f730427
Author: Guillaume Quintard <guillaume quintard gmail com>
Date: Sat Apr 20 23:49:11 2013 +0200
more code cleaning
put markup as pango attributes in the glade file.
Conflicts:
src/widgets.js
Signed-off-by: Seif Lotfy <seif lotfy com>
data/AlbumWidget.ui | 13 +++++++++++
src/widgets.js | 64 ++++++++++++++++++++---------------------------------
2 files changed, 37 insertions(+), 40 deletions(-)
---
diff --git a/data/AlbumWidget.ui b/data/AlbumWidget.ui
index c64ac82..3d39ed0 100644
--- a/data/AlbumWidget.ui
+++ b/data/AlbumWidget.ui
@@ -47,6 +47,10 @@
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.2"/>
+ </attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -58,6 +62,11 @@
<object class="GtkLabel" id="artist_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="foreground" value="#808080808080"/>
+ <attribute name="size" value="1"/>
+ </attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -182,6 +191,10 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="xalign">0.33000001311302185</property>
+ <attributes>
+ <attribute name="scale" value="0"/>
+ <attribute name="foreground" value="#808080808080"/>
+ </attributes>
</object>
<packing>
<property name="expand">True</property>
diff --git a/src/widgets.js b/src/widgets.js
index 8354b31..5e2ec87 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -43,12 +43,12 @@ const AlbumWidget = new Lang.Class({
this.scrolledWindow = new Gtk.ScrolledWindow();
this.model = Gtk.ListStore.new([
+ GObject.TYPE_STRING, /*title*/
GObject.TYPE_STRING,
GObject.TYPE_STRING,
- GObject.TYPE_STRING,
- GObject.TYPE_BOOLEAN,
- GdkPixbuf.Pixbuf,
- GObject.TYPE_OBJECT,
+ GObject.TYPE_BOOLEAN,/*icon shown*/
+ GdkPixbuf.Pixbuf, /*icon*/
+ GObject.TYPE_OBJECT, /*song object*/
GObject.TYPE_BOOLEAN
]);
this.ui = new Gtk.Builder();
@@ -106,7 +106,7 @@ const AlbumWidget = new Lang.Class({
new Gd.StyledTextRenderer({ xpad: 16 });
typeRenderer.set_property("ellipsize", 3);
typeRenderer.set_property("xalign", 0.0);
- // This function is not neede, just add the renderer!
+ // This function is not needed, just add the renderer!
listWidget.add_renderer(typeRenderer, Lang.bind(this,
function(col, cell, model, iter) {}
));
@@ -122,14 +122,9 @@ const AlbumWidget = new Lang.Class({
function(col, cell, model, iter) {
let item = model.get_value(iter, 5);
let duration = item.get_duration ();
- var minutes = parseInt(duration / 60);
- var seconds = duration % 60;
- var time = null
- if (seconds < 10)
- time = minutes + ":0" + seconds;
- else
- time = minutes + ":" + seconds;
- durationRenderer.text = time;
+ if (!item)
+ return;
+ durationRenderer.text = this.player.seconds_to_string(duration);
}));
},
@@ -139,8 +134,6 @@ const AlbumWidget = new Lang.Class({
if (released_date != null) {
this.ui.get_object("released_label_info").set_text(
released_date.get_year().toString());
- } else {
- this.ui.get_object("released_label_info").set_text("----");
}
let duration = 0;
this.model.clear()
@@ -163,15 +156,16 @@ const AlbumWidget = new Lang.Class({
this.player.setPlaylist(tracks);
this.player.setCurrentTrack(tracks[0]);
+ pixbuf = albumArtCache.lookup (256, artist, item.get_string(Grl.METADATA_KEY_ALBUM));
if (pixbuf == null) {
let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 256, true);
}
this.ui.get_object("cover").set_from_pixbuf (pixbuf);
- this.setArtistLabel(artist);
- this.setTitleLabel(album);
- this.setReleasedLabel(item.get_creation_date().get_year());
+ this.ui.get_object("artist_label").set_text(artist);
+ this.ui.get_object("title_label").set_text(album);
+ this.ui.get_object("released_label_info").set_text(item.get_creation_date().get_year().toString());
this.player.connect('song-changed', Lang.bind(this,
function(widget, id) {
@@ -205,21 +199,6 @@ const AlbumWidget = new Lang.Class({
}
));
},
-
- setArtistLabel: function(artist) {
- this.ui.get_object("artist_label").set_markup(
- "<b><span size='large' color='grey'>" + artist + "</span></b>");
- },
-
- setTitleLabel: function(title) {
- this.ui.get_object("title_label").set_markup(
- "<b><span size='large'>" + title + "</span></b>");
- },
-
- setReleasedLabel: function(year) {
- this.ui.get_object("released_label_info").set_markup(
- "<span>" + year + "</span>");
- },
});
const ArtistAlbums = new Lang.Class({
@@ -275,7 +254,6 @@ const ArtistAlbumWidget = new Lang.Class({
this.player = player;
this.album = album;
this.songs = [];
- this.tracks = [];
var track_count = album.get_childcount();
@@ -298,13 +276,13 @@ const ArtistAlbumWidget = new Lang.Class({
grilo.getAlbumSongs(album.get_id(), Lang.bind(this, function (source, prefs, track) {
if (track != null) {
- this.tracks.push(track);
+ tracks.push(track);
track.origin = this;
}
else {
var titles = []
- for (var i=0; i<this.tracks.length; i++) {
- track = this.tracks[i];
+ 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();
@@ -314,9 +292,15 @@ const ArtistAlbumWidget = new Lang.Class({
ui.get_object("num").set_text(this.songs.length.toString());
if (track.get_title() != null)
ui.get_object("title").set_text(track.get_title());
- this.ui.get_object("grid1").attach(songWidget,
- parseInt(i/(this.tracks.length/2)),
- parseInt((i)%(this.tracks.length/2)), 1, 1);
+ //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();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]