[gnome-music/glade] Store GUI in Glade files
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/glade] Store GUI in Glade files
- Date: Fri, 19 Apr 2013 09:47:37 +0000 (UTC)
commit 9b19987a6748b51c2adf2de6139949f326346f37
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Fri Apr 19 11:47:14 2013 +0200
Store GUI in Glade files
data/AlbumWidget.ui | 241 ++++++++++++++++++++++++++++++++
data/ArtistAlbumWidget.ui | 135 ++++++++++++++++++
data/ArtistAlbumsWidget.ui | 38 ++++++
data/PlayerToolbar.ui | 230 +++++++++++++++++++++++++++++++
data/gnome-music.gresource.xml | 4 +
src/grilo.js | 4 +-
src/query.js | 6 +-
src/view.js | 5 +-
src/widgets.js | 303 ++++++++++++++++++++++-------------------
9 files changed, 821 insertions(+), 145 deletions(-)
---
diff --git a/data/AlbumWidget.ui b/data/AlbumWidget.ui
new file mode 100644
index 0000000..4ed83d1
--- /dev/null
+++ b/data/AlbumWidget.ui
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkHBox" id="AlbumWidget">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkHBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">16</property>
+ <property name="margin_top">16</property>
+ <property name="margin_bottom">16</property>
+ <property name="spacing">32</property>
+ <child>
+ <object class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkImage" id="cover">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="stock">gtk-missing-image</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="artistBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="artist_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="infobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">36</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkVBox" id="infobox_titles">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="released_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><span
color='grey'>Released</span></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="running_length_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><span color='grey'>Running
Length</span></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="infobox_values">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="released_label_info">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">2</property>
+ <property name="label" translatable="yes">----</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="running_length_label_info">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">--:--</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </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>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">16</property>
+ <property name="margin_top">16</property>
+ <property name="margin_bottom">16</property>
+ <child>
+ <object class="GtkViewport" id="view">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkHBox" id="box3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <object class="GtkListStore" id="AlbumWidget_model">
+ <columns>
+ <!-- column-name gchararray1 -->
+ <column type="gchararray"/>
+ <!-- column-name gchararray2 -->
+ <column type="gchararray"/>
+ <!-- column-name gchararray3 -->
+ <column type="gchararray"/>
+ <!-- column-name gboolean1 -->
+ <column type="gboolean"/>
+ <!-- column-name GdkPixbuf1 -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name GObject1 -->
+ <column type="GObject"/>
+ <!-- column-name gboolean2 -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
+</interface>
diff --git a/data/ArtistAlbumWidget.ui b/data/ArtistAlbumWidget.ui
new file mode 100644
index 0000000..6250179
--- /dev/null
+++ b/data/ArtistAlbumWidget.ui
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.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>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</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="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="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <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"/>
+ </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="year">
+ <property name="visible">True</property>
+ <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>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkIconView" id="iconview1">
+ <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="activate_on_single_click">True</property>
+ <property name="row_spacing">1</property>
+ <style>
+ <class name="content-view"/>
+ <class name="view"/>
+ </style>
+ <child>
+ <object class="GtkCellRendererText" id="trackNumberRenderer">
+ <property name="foreground_gdk">#bababdbdb6b6</property>
+ </object>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="titleRenderer">
+ <property name="ellipsize">middle</property>
+ </object>
+ <attributes>
+ <attribute name="markup">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name gchararray1 -->
+ <column type="gchararray"/>
+ <!-- column-name gchararray2 -->
+ <column type="gchararray"/>
+ <!-- column-name gchararray3 -->
+ <column type="gchararray"/>
+ <!-- column-name gboolean1 -->
+ <column type="gboolean"/>
+ <!-- column-name GdkPixbuf1 -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name GObject1 -->
+ <column type="GObject"/>
+ <!-- column-name gboolean2 -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
+</interface>
diff --git a/data/ArtistAlbumsWidget.ui b/data/ArtistAlbumsWidget.ui
new file mode 100644
index 0000000..06c74d4
--- /dev/null
+++ b/data/ArtistAlbumsWidget.ui
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.6 -->
+ <object class="GtkBox" id="ArtistAlbumsWidget">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">24</property>
+ <property name="orientation">vertical</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="artist">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">label</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="separator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/data/PlayerToolbar.ui b/data/PlayerToolbar.ui
new file mode 100644
index 0000000..1026911
--- /dev/null
+++ b/data/PlayerToolbar.ui
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.6 -->
+ <object class="GtkFrame" id="eventBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <style>
+ <class name="play-bar"/>
+ </style>
+ <child>
+ <object class="GtkBox" id="player">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">9</property>
+ <property name="spacing">9</property>
+ <child>
+ <object class="GtkBox" id="buttons">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="previous_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">previous_image</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="play_button">
+ <property name="width_request">55</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">play_image</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="next_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">next_image</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="cover">
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="nowplaying">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="artist">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="ellipsize">middle</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ <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="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</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">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScale" id="progress_scale">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="round_digits">1</property>
+ <property name="draw_value">False</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="menu_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="time">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="playback">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">00:00</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="separator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</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>
+ <child>
+ <object class="GtkLabel" id="duration">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">00:00</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="play_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-playback-start-symbolic</property>
+ </object>
+ <object class="GtkImage" id="previous_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-skip-backward-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ <object class="GtkImage" id="next_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-skip-forward-symbolic</property>
+ </object>
+</interface>
diff --git a/data/gnome-music.gresource.xml b/data/gnome-music.gresource.xml
index 128f3e7..fb5634f 100644
--- a/data/gnome-music.gresource.xml
+++ b/data/gnome-music.gresource.xml
@@ -3,5 +3,9 @@
<gresource prefix="/org/gnome/music">
<file preprocess="xml-stripblanks">app-menu.ui</file>
<file>application.css</file>
+ <file preprocess="xml-stripblanks">AlbumWidget.ui</file>
+ <file preprocess="xml-stripblanks">ArtistAlbumWidget.ui</file>
+ <file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
+ <file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
</gresource>
</gresources>
diff --git a/src/grilo.js b/src/grilo.js
index fd3ca34..d597715 100644
--- a/src/grilo.js
+++ b/src/grilo.js
@@ -84,7 +84,7 @@ const Grilo = new Lang.Class({
options.set_count(50);
grilo.tracker.query(
query,
- [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST],
+ [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST,
Grl.METADATA_KEY_CREATION_DATE],
options,
Lang.bind(this, callback, null));
},
@@ -95,7 +95,7 @@ const Grilo = new Lang.Class({
options.set_flags (Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY);
grilo.tracker.query(
query,
- [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST],
+ [Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_ARTIST,
Grl.METADATA_KEY_CREATION_DATE],
options,
Lang.bind(this, callback, null));
},
diff --git a/src/query.js b/src/query.js
index 7bd4e17..b63f9bf 100644
--- a/src/query.js
+++ b/src/query.js
@@ -20,13 +20,13 @@
const Tracker = imports.gi.Tracker;
-const album = 'SELECT DISTINCT rdf:type(?album) tracker:id(?album) as id (SELECT nmm:artistName(?artist)
WHERE { ?album nmm:albumArtist ?artist } LIMIT 1) AS artist nie:title(?album) as title nie:title(?album) as
album tracker:coalesce( (SELECT GROUP_CONCAT(nmm:artistName(?artist), ",") WHERE { ?album nmm:albumArtist
?artist }), (SELECT GROUP_CONCAT((SELECT nmm:artistName(nmm:performer(?_12)) as perf WHERE { ?_12
nmm:musicAlbum ?album } GROUP BY ?perf), ",") as album_performer WHERE { }) ) as author
xsd:integer(tracker:coalesce(nmm:albumTrackCount(?album), (SELECT COUNT(?_1) WHERE { ?_1 nmm:musicAlbum
?album; tracker:available "true" }))) as childcount (SELECT fn:year-from-dateTime(?c) WHERE { ?_2
nmm:musicAlbum ?album; nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as publishing-date { ?album
a nmm:MusicAlbum FILTER (EXISTS { ?_3 nmm:musicAlbum ?album; tracker:available "true" }) } ORDER BY
nie:title(?album) ?author ?albumyear';
+const album = 'SELECT DISTINCT rdf:type(?album) tracker:id(?album) as id (SELECT nmm:artistName(?artist)
WHERE { ?album nmm:albumArtist ?artist } LIMIT 1) AS artist nie:title(?album) as title nie:title(?album) as
album tracker:coalesce( (SELECT GROUP_CONCAT(nmm:artistName(?artist), ",") WHERE { ?album nmm:albumArtist
?artist }), (SELECT GROUP_CONCAT((SELECT nmm:artistName(nmm:performer(?_12)) as perf WHERE { ?_12
nmm:musicAlbum ?album } GROUP BY ?perf), ",") as album_performer WHERE { }) ) as author
xsd:integer(tracker:coalesce(nmm:albumTrackCount(?album), (SELECT COUNT(?_1) WHERE { ?_1 nmm:musicAlbum
?album; tracker:available "true" }))) as childcount (SELECT fn:year-from-dateTime(?c) WHERE { ?_2
nmm:musicAlbum ?album; nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as creation-date { ?album a
nmm:MusicAlbum FILTER (EXISTS { ?_3 nmm:musicAlbum ?album; tracker:available "true" }) } ORDER BY
nie:title(?album) ?author ?albumyear';
-const artist = 'SELECT DISTINCT rdf:type(?album) tracker:id(?album) as id (SELECT nmm:artistName(?artist)
WHERE { ?album nmm:albumArtist ?artist } LIMIT 1) AS artist nie:title(?album) as title nie:title(?album) as
album tracker:coalesce( (SELECT GROUP_CONCAT(nmm:artistName(?artist), ",") WHERE { ?album nmm:albumArtist
?artist }), (SELECT GROUP_CONCAT((SELECT nmm:artistName(nmm:performer(?_12)) as perf WHERE { ?_12
nmm:musicAlbum ?album } GROUP BY ?perf), ",") as album_performer WHERE { }) ) as author
xsd:integer(tracker:coalesce(nmm:albumTrackCount(?album), (SELECT COUNT(?_1) WHERE { ?_1 nmm:musicAlbum
?album; tracker:available "true" }))) as childcount (SELECT fn:year-from-dateTime(?c) WHERE { ?_2
nmm:musicAlbum ?album; nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as publishing-date { ?album
a nmm:MusicAlbum FILTER (EXISTS { ?_3 nmm:musicAlbum ?album; tracker:available "true" }) } ORDER BY ?author
?albumyear nie:title(?album)';
+const artist = 'SELECT DISTINCT rdf:type(?album) tracker:id(?album) as id (SELECT nmm:artistName(?artist)
WHERE { ?album nmm:albumArtist ?artist } LIMIT 1) AS artist nie:title(?album) as title nie:title(?album) as
album tracker:coalesce( (SELECT GROUP_CONCAT(nmm:artistName(?artist), ",") WHERE { ?album nmm:albumArtist
?artist }), (SELECT GROUP_CONCAT((SELECT nmm:artistName(nmm:performer(?_12)) as perf WHERE { ?_12
nmm:musicAlbum ?album } GROUP BY ?perf), ",") as album_performer WHERE { }) ) as author
xsd:integer(tracker:coalesce(nmm:albumTrackCount(?album), (SELECT COUNT(?_1) WHERE { ?_1 nmm:musicAlbum
?album; tracker:available "true" }))) as childcount (SELECT fn:year-from-dateTime(?c) WHERE { ?_2
nmm:musicAlbum ?album; nie:contentCreated ?c; tracker:available "true" } LIMIT 1) as creation-date { ?album a
nmm:MusicAlbum FILTER (EXISTS { ?_3 nmm:musicAlbum ?album; tracker:available "true" }) } ORDER BY ?author
?albumyear nie:title(?album)';
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 } 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_count = 'SELECT COUNT(?song) AS childcount WHERE { ?song a nmm:MusicPiece }';
diff --git a/src/view.js b/src/view.js
index 4b149f5..1734a80 100644
--- a/src/view.js
+++ b/src/view.js
@@ -200,8 +200,8 @@ const ViewContainer = new Lang.Class({
},
_addItem: function(source, param, item) {
- print (item.get_title() + "\n");
if (item != null) {
+ print (item.get_title() + "\n");
this._offset += 1;
let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
let icon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, this._iconHeight, this._iconWidth,
true);
@@ -400,6 +400,7 @@ const Artists = new Lang.Class({
_init: function(header_bar, player) {
this.parent("Artists", header_bar);
+ this.player = player;
this._artists = {};
this._artistAlbumsWidget = new Gtk.VBox();
this.view.set_view_type(Gd.MainViewType.LIST);
@@ -442,7 +443,7 @@ const Artists = new Lang.Class({
var iter = this._model.get_iter (path)[1];
var artist = this._model.get_value (iter, 0);
var albums = this._artists[artist.toLowerCase()]["albums"]
- var artistAlbums = new Widgets.ArtistAlbums(artist, albums);
+ var artistAlbums = new Widgets.ArtistAlbums(artist, albums, this.player);
this._artistAlbumsWidget.pack_start(artistAlbums, true, true, 0)
//this._artistAlbumsWidget.update(artist, albums);
},
diff --git a/src/widgets.js b/src/widgets.js
index 68be254..104d735 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -51,6 +51,9 @@ const AlbumWidget = new Lang.Class({
GObject.TYPE_OBJECT,
GObject.TYPE_BOOLEAN
]);
+ this.ui = new Gtk.Builder();
+ this.ui.add_from_resource('/org/gnome/music/AlbumWidget.ui');
+ this.model = this.ui.get_object("AlbumWidget_model");
this.view = new Gd.MainView({
shadow_type: Gtk.ShadowType.NONE
@@ -66,108 +69,17 @@ const AlbumWidget = new Lang.Class({
})
);
-
-
- this.player.connect('song-changed', Lang.bind(this,
- function(widget, id) {
- // Highlight currently played song as bold
- let iter = this.model.get_iter_from_string(id.toString())[1];
- let item = this.model.get_value(iter, 5);
- let title = "<b>" + item.get_title() + "</b>";
- this.model.set_value(iter, 0, title);
- // Display now playing icon
- this.model.set_value(iter, 3, true);
-
- // Make all previous songs shadowed
- for (let i = 0; i < id; i++){
- let iter = this.model.get_iter_from_string(i.toString())[1];
- let item = this.model.get_value(iter, 5);
- let title = "<span color='grey'>" + item.get_title() + "</span>";
- this.model.set_value(iter, 0, title);
- this.model.set_value(iter, 3, false);
- }
-
- //Remove markup from the following songs
- let i = parseInt(id) + 1;
- while(this.model.get_iter_from_string(i.toString())[0]) {
- let iter = this.model.get_iter_from_string(i.toString())[1];
- let item = this.model.get_value(iter, 5);
- this.model.set_value(iter, 0, item.get_title());
- this.model.set_value(iter, 3, false);
- i++;
- }
- return true;
- }
- ));
-
- this.cover = new Gtk.Image();
- this.vbox = new Gtk.VBox();
- this.title_label = new Gtk.Label({label : ""});
- this.artist_label = new Gtk.Label({label : ""});
- this.running_length = 0;
- this.released_label = new Gtk.Label()
- this.released_label.set_markup ("<span color='grey'>Released</span>");
- this.running_length_label = new Gtk.Label({});
- this.running_length_label.set_markup ("<span color='grey'>Running Length</span>");
- this.released_label_info = new Gtk.Label({label: "----"});
- this.running_length_label_info = new Gtk.Label({label: "--:--"});
- this.released_label.set_alignment(1.0, 0.5)
- this.running_length_label.set_alignment(1.0, 0.5)
- this.released_label_info.set_alignment(0.0, 0.5)
- this.running_length_label_info.set_alignment(0.0, 0.5)
-
this.parent();
- this.hbox.set_homogeneous(true);
- this.vbox.set_homogeneous(false);
- this.scrolledWindow.set_policy(
- Gtk.PolicyType.NEVER,
- Gtk.PolicyType.AUTOMATIC);
-
- var vbox = new Gtk.VBox()
- var hbox = new Gtk.Box()
- hbox.homogeneous = true
- var child_view = this.view.get_children()[0];
+
+ let hbox = this.ui.get_object("box3");
+ let child_view = this.view.get_children()[0];
this.view.remove(child_view)
hbox.pack_start(child_view, true, true, 0)
- hbox.pack_start(new Gtk.Label(), true, true, 0)
-
- vbox.pack_start(new Gtk.Label(), false, false, 24)
- vbox.pack_start(hbox, true, true, 0)
- this.scrolledWindow.add(vbox);
-
- this.infobox = new Gtk.Box()
- this.infobox.homogeneous = true;
- this.infobox.spacing = 36
- var box = new Gtk.VBox();
- box.pack_start (this.released_label, false, false, 0)
- box.pack_start (this.running_length_label, false, false, 0)
- this.infobox.pack_start(box, true, true, 0)
- box = new Gtk.VBox();
- box.pack_start (this.released_label_info, false, false, 0)
- box.pack_start (this.running_length_label_info, false, false, 0)
- this.infobox.pack_start(box, true, true, 0)
-
- this.vbox.pack_start (new Gtk.Label({label:""}), false, false, 24);
- this.vbox.pack_start (this.cover, false, false, 0);
-
- let artistBox = new Gtk.VBox();
- artistBox.set_spacing(6);
- artistBox.pack_start (this.title_label, false, false, 0);
- artistBox.pack_start (this.artist_label, false, false, 0);
-
- this.vbox.pack_start (artistBox, false, false, 24);
- this.vbox.pack_start(this.infobox, false, false, 0);
-
- let hbox = new Gtk.Box();
- hbox.pack_start(new Gtk.Label(), true, true, 0);
- hbox.pack_end(this.vbox, false, false, 0);
- this.hbox.pack_start (hbox, true, true, 32);
- this.hbox.pack_start (this.scrolledWindow, true, true, 0);
-
- this.get_style_context ().add_class ("view");
- this.get_style_context ().add_class ("content-view");
- this.add(this.hbox);
+
+ this.add(this.ui.get_object("AlbumWidget"));
this._addListRenderers();
+ this.get_style_context().add_class("view");
+ this.get_style_context().add_class("content-view");
this.show_all ();
},
@@ -178,7 +90,7 @@ const AlbumWidget = new Lang.Class({
var cells = cols[0].get_cells()
cells[2].visible = false
cells[1].visible = false
-
+
let nowPlayingSymbolRenderer = new Gtk.CellRendererPixbuf({ xpad: 0 });
let path = "/usr/share/icons/gnome/scalable/actions/media-playback-start-symbolic.svg";
nowPlayingSymbolRenderer.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 16, true);
@@ -219,17 +131,17 @@ const AlbumWidget = new Lang.Class({
time = minutes + ":" + seconds;
durationRenderer.text = time;
}));
-
},
update: function (artist, album, item) {
var pixbuf = albumArtCache.lookup (256, artist, item.get_string(Grl.METADATA_KEY_ALBUM));
- let released_date = item.get_publication_date();
- if (released_date != null) {
- this.released_label_info.set_text(released_date.get_year().toString());
- } else {
- this.released_label_info.set_text("----");
- }
+ let released_date = item.get_publication_date();
+ 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()
var tracks = [];
@@ -243,7 +155,8 @@ const AlbumWidget = new Lang.Class({
this.model.set(iter,
[0, 1, 2, 3, 4, 5],
[ track.get_title(), "", "", false, pixbuf, track ]);
- this.running_length_label_info.set_text((parseInt(duration/60) + 1) + " min");
+ this.ui.get_object("running_length_label_info").set_text(
+ (parseInt(duration/60) + 1) + " min");
}
}));
@@ -254,40 +167,100 @@ const AlbumWidget = 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, 256, true);
}
- this.cover.set_from_pixbuf (pixbuf);
+ this.ui.get_object("cover").set_from_pixbuf (pixbuf);
this.setArtistLabel(artist);
this.setTitleLabel(album);
+ this.setReleasedLabel(item.get_creation_date().get_year());
+
+ this.player.connect('song-changed', Lang.bind(this,
+ function(widget, id) {
+ // Highlight currently played song as bold
+ let iter = this.model.get_iter_from_string(id.toString())[1];
+ let item = this.model.get_value(iter, 5);
+ let title = "<b>" + item.get_title() + "</b>";
+ this.model.set_value(iter, 0, title);
+ // Display now playing icon
+ this.model.set_value(iter, 3, true);
+
+ // Make all previous songs shadowed
+ for (let i = 0; i < id; i++){
+ let iter = this.model.get_iter_from_string(i.toString())[1];
+ let item = this.model.get_value(iter, 5);
+ let title = "<span color='grey'>" + item.get_title() + "</span>";
+ this.model.set_value(iter, 0, title);
+ this.model.set_value(iter, 3, false);
+ }
+
+ //Remove markup from the following songs
+ let i = parseInt(id) + 1;
+ while(this.model.get_iter_from_string(i.toString())[0]) {
+ let iter = this.model.get_iter_from_string(i.toString())[1];
+ let item = this.model.get_value(iter, 5);
+ this.model.set_value(iter, 0, item.get_title());
+ this.model.set_value(iter, 3, false);
+ i++;
+ }
+ return true;
+ }
+ ));
},
setArtistLabel: function(artist) {
- this.artist_label.set_markup("<b><span size='large' color='grey'>" + artist + "</span></b>");
+ this.ui.get_object("artist_label").set_markup(
+ "<b><span size='large' color='grey'>" + artist + "</span></b>");
},
setTitleLabel: function(title) {
- this.title_label.set_markup("<b><span size='large'>" + title + "</span></b>");
+ 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(
+ "<b><span color='grey'>" + year + "</span></b>");
+ },
});
-
const ArtistAlbums = new Lang.Class({
Name: "ArtistAlbumsWidget",
Extends: Gtk.VBox,
- _init: function (artist, albums) {
+ _init: function (artist, albums, player) {
+ this.player = player
this.artist = artist
this.albums = albums
this.parent();
+ this.ui = new Gtk.Builder();
+ this.ui.add_from_resource('/org/gnome/music/ArtistAlbumsWidget.ui');
this.set_border_width(24)
- this.label = new Gtk.Label()
- this.label.set_markup("<b>" + this.artist + "</b>")
- this.label.set_alignment(0.0, 0.5)
- this.pack_start(this.label, false, false, 0)
- this.pack_start(new Gtk.HSeparator(), false, false, 12)
- for (var i=0; i < albums.length; i++)
- this.pack_start(new ArtistAlbumWidget(artist, albums[i]), false, false, 9);
+ this.ui.get_object("artist").set_label(this.artist)
+ var tracks = [];
+ var widgets = [];
+ for (var i=0; i < albums.length; i++) {
+ let widget = new ArtistAlbumWidget(artist, albums[i], this.player, tracks)
+ this.pack_start(widget, false, false, 9);
+ widgets.push(widget);
+ }
this.show_all();
+ this.player.setPlaylist(tracks);
+ this.player.setCurrentTrack(tracks[0]);
+
+ this.player.connect('song-changed', Lang.bind(this,
+ function(widget, id) {
+ let origin = tracks[id].origin;
+ let iter = tracks[id].iterator;
+ origin.setPlayingSong(iter);
+
+ //Remove markup from other albums
+ for (let i in widgets) {
+ let albumwidget = widgets[i];
+ if (albumwidget != origin) {
+ albumwidget.setPlayingSong(-1);
+ }
+ }
+ }
+ ));
},
});
@@ -295,36 +268,90 @@ const ArtistAlbumWidget = new Lang.Class({
Name: "ArtistAlbumWidget",
Extends: Gtk.HBox,
- _init: function (artist, album) {
+ _init: function (artist, album, player, tracks) {
this.parent();
+ this.player = player;
this.album = album;
- this.cover = new Gtk.Image();
- this.title = new Gtk.Label();
- this.title.set_ellipsize(2);
+
+ this.ui = new Gtk.Builder();
+ this.ui.add_from_resource('/org/gnome/music/ArtistAlbumWidget.ui');
+ this.model = this.ui.get_object("liststore1");
+
var pixbuf = albumArtCache.lookup (128, artist, album.get_title());
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, 128, true);
}
- this.cover.set_from_pixbuf (pixbuf);
- this.pack_start(this.cover, false, false, 0)
- var vbox = new Gtk.VBox()
- this.pack_start(vbox, true, true, 32)
- this.title.set_markup("<span color='grey'><b>" + album.get_title() + "</b></span>")
- var tracks = [];
+ this.ui.get_object("cover").set_from_pixbuf(pixbuf);
+ this.ui.get_object("title").set_label(album.get_title());
+ if (album.get_creation_date()) {
+ this.ui.get_object("year").set_markup(
+ "<span color='grey'>(" + album.get_creation_date().get_year() + ")</span>");
+ }
+
grilo.getAlbumSongs(album.get_id(), Lang.bind(this, function (source, prefs, track) {
if (track != null) {
tracks.push(track);
- let released_date = album.get_publication_date();
- if (released_date != null) {
- this.title.set_markup("<span color='grey'><b>" + album.get_title() + "</b> (" +
released_date.get_year().toString() + ")</span>")
- } else {
- this.title.set_markup("<span color='grey'><b>" + album.get_title() + "</b></span>")
- }
+ 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 ]);
}
}));
- this.title.set_alignment(0.0, 0.5)
- vbox.pack_start(this.title, false, false, 0)
- this.show_all()
+
+ 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, 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];
+ let item = this.model.get_value(new_iter, 5);
+ this.model.set_value(new_iter, 0, item.get_title());
+ this.model.set_value(new_iter, 3, false);
+ while(this.model.iter_next(new_iter)){
+ let item = this.model.get_value(new_iter, 5);
+ this.model.set_value(new_iter, 0, item.get_title());
+ this.model.set_value(new_iter, 3, false);
+ }
+ } else {
+ // Highlight currently played song as bold
+ if (!iter)
+ return
+ let item = this.model.get_value(iter, 5);
+ let title = "<b>" + item.get_title() + "</b>";
+ this.model.set_value(iter, 0, title);
+ // Display now playing icon
+ this.model.set_value(iter, 3, true);
+
+ // Make all previous songs shadowed
+ let prev_iter = iter;
+ while(this.model.iter_previous(prev_iter)){
+ let item = this.model.get_value(prev_iter, 5);
+ let title = "<span color='grey'>" + item.get_title() + "</span>";
+ this.model.set_value(prev_iter, 0, title);
+ this.model.set_value(prev_iter, 3, false);
+ }
+
+ //Remove markup from the following songs
+ let next_iter = iter;
+ while(this.model.iter_next(next_iter)){
+ let item = this.model.get_value(next_iter, 5);
+ this.model.set_value(next_iter, 0, item.get_title());
+ this.model.set_value(next_iter, 3, false);
+ }
+ }
},
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]