Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: eonpatapon/gnome-shell-extensions-mediaplayer
...
head fork: flatzo/gnome-shell-extensions-mediaplayer
compare: userRating
Checking mergeability… Don't worry, you can still create the pull request.
  • 14 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
24 po/fr.po
@@ -3,8 +3,8 @@ msgstr ""
"Project-Id-Version: gnome-shell-extension-mediaplayer\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-03-31 11:21+0200\n"
-"PO-Revision-Date: 2012-02-09 13:26+0100\n"
-"Last-Translator: Jean-Philippe Braun <eon@patapon.info>\n"
+"PO-Revision-Date: 2012-05-01 20:02-0500\n"
+"Last-Translator: Charles Brière <charlesbriere.flatzo@gmail.com>\n"
"Language-Team: Jean-Philippe Braun <eon@patapon.info>\n"
"Language: French\n"
"MIME-Version: 1.0\n"
@@ -60,11 +60,8 @@ msgid "Allow to start the default media player"
msgstr "Permettre de lancer le lecteur multimédia par défaut"
#: ../src/prefs.js:35
-msgid ""
-"Runs the default mediaplayer by clicking on the media player status icon."
-msgstr ""
-"Lance le lecteur multimédia par défaut en cliquant sur l'icone de "
-"l'extension."
+msgid "Runs the default mediaplayer by clicking on the media player status icon."
+msgstr "Lance le lecteur multimédia par défaut en cliquant sur l'icone de l'extension."
#: ../src/prefs.js:36
msgid "Show the media player volume slider"
@@ -84,6 +81,13 @@ msgstr "Taille de la pochette de l'album"
#: ../src/prefs.js:42
msgid "The size of the cover displayed in the menu. Default is 80px width."
-msgstr ""
-"La taille de la pochette affichée dans le menu. La largeur par défaut est de "
-"80px."
+msgstr "La taille de la pochette affichée dans le menu. La largeur par défaut est de 80px."
+
+#: ../src/prefs/js:39
+msgid "Display song rating"
+msgstr "Afficher le classement de la chanson"
+
+#: ../src/prefs/js:40
+msgid "Display the currently playing song's rating on a 0 to 5 scale"
+msgstr "Afficher le classement de la chanson en lecture sur une échelle de 0 à 5"
+
View
2  src/Makefile.am
@@ -1,6 +1,6 @@
include ../include.mk
-dist_extension_DATA = extension.js widget.js dbus.js lib.js prefs.js stylesheet.css
+dist_extension_DATA = extension.js widget.js dbus.js lib.js prefs.js stylesheet.css
nodist_extension_DATA = metadata.json
EXTRA_DIST = metadata.json.in
View
26 src/extension.js
@@ -37,6 +37,7 @@ const MEDIAPLAYER_POSITION_KEY = 'position';
const MEDIAPLAYER_PLAYLISTS_KEY = 'playlists';
const MEDIAPLAYER_COVER_SIZE = 'coversize';
const MEDIAPLAYER_RUN_DEFAULT = 'rundefault';
+const MEDIAPLAYER_RATING_KEY = 'rating';
const FADE_ANIMATION_TIME = 0.16;
@@ -125,7 +126,18 @@ const Player = new Lang.Class({
this._settings.connect("changed::" + MEDIAPLAYER_COVER_SIZE, Lang.bind(this, function() {
this.coverSize = this._settings.get_int(MEDIAPLAYER_COVER_SIZE);
}));
-
+ this.showRating = this._settings.get_boolean(MEDIAPLAYER_RATING_KEY);
+ this._settings.connect("changed::" + MEDIAPLAYER_RATING_KEY, Lang.bind(this, function() {
+ if (this._settings.get_boolean(MEDIAPLAYER_RATING_KEY)) {
+ this.showRating = true;
+ this.trackRating.showRating();
+ }
+ else {
+ this.showRating = false;
+ this.trackRating.hideRating();
+
+ }
+ }));
let genericIcon = new St.Icon({icon_name: "audio-x-generic", icon_size: 16, icon_type: St.IconType.SYMBOLIC});
this.playerTitle = new Widget.TitleItem(this._identity, genericIcon, Lang.bind(this, function() { this._mediaServer.QuitRemote(); }));
@@ -140,11 +152,14 @@ const Player = new Lang.Class({
this.trackTitle = new Widget.TrackTitle(null, _('Unknown Title'), 'track-title');
this.trackArtist = new Widget.TrackTitle(_("by"), _('Unknown Artist'), 'track-artist');
this.trackAlbum = new Widget.TrackTitle(_("from"), _('Unknown Album'), 'track-album');
+ this.trackRating = new Widget.TrackRating(_("rating"), 0, 'track-rating');
this.trackBox = new Widget.TrackBox(this.trackCoverContainer);
this.trackBox._infos.add(this.trackTitle.box, {row: 0, col: 1, y_expand: false});
this.trackBox._infos.add(this.trackArtist.box, {row: 1, col: 1, y_expand: false});
this.trackBox._infos.add(this.trackAlbum.box, {row: 2, col: 1, y_expand: false});
+ this.trackBox._infos.add(this.trackRating.box, {row: 3, col: 1, y_expand: false});
+ this.trackRating.hideRating();
this.addMenuItem(this.trackBox);
@@ -357,6 +372,13 @@ const Player = new Lang.Class({
if (metadata["mpris:trackid"]) {
this.trackObj = metadata["mpris:trackid"].unpack();
}
+ if (this.showRating) {
+ if (metadata["xesam:userRating"]) {
+ this.trackRating.setValue(metadata["xesam:userRating"].deep_unpack());
+ }
+ else
+ this.trackRating.setValue(0);
+ }
let animate = false;
if (metadata["mpris:artUrl"]) {
@@ -495,6 +517,8 @@ const Player = new Lang.Class({
this._volume.actor.show();
if (this.showPosition && this.supportPosition)
this._position.actor.show();
+ if (this.showRating)
+ this.trackRating.showRating();
}
else {
if (this.trackBox.box.get_stage() && this.trackBox.box.opacity == 255) {
View
5 src/org.gnome.shell.extensions.mediaplayer.gschema.xml.in
@@ -30,5 +30,10 @@
<_summary>Allow to start the default media player</_summary>
<_description>Starts the default mediaplayer by clicking on the media player status icon.</_description>
</key>
+ <key type="b" name="rating">
+ <default>false</default>
+ <_summary>Display song rating</_summary>
+ <_description>Display the currently playing song's rating on a 0 to 5 scale</_description>
+ </key>
</schema>
</schemalist>
View
4 src/prefs.js
@@ -35,7 +35,9 @@ function init() {
help: _("Runs the default mediaplayer by clicking on the media player status icon.")},
volume: {label: _("Show the media player volume slider")},
position: {label: _("Show the media player position slider")},
- playlists: {label: _("Show media player playlists")}
+ playlists: {label: _("Show media player playlists")},
+ rating: {label: _("Display song rating"),
+ help: _("Display the currently playing song's rating on a 0 to 5 scale")}
};
settings_range = {
coversize: {label: _("Album cover size"),
View
13 src/stylesheet.css
@@ -9,6 +9,13 @@
padding: 2px;
}
+.button-star {
+ padding: 0px;
+ margin: 0px;
+ height: 20px;
+ width:20px;
+}
+
.status-icon {
icon-size: 10px;
}
@@ -39,6 +46,12 @@
font-size: 0.9em;
}
+.track-rating {
+ border: 0px;
+ padding: 0px;
+ margin: 0px;
+}
+
.menu-icon {
icon-size: 1.14em;
padding-right: .4em;
View
72 src/widget.js
@@ -182,6 +182,78 @@ TitleItem.prototype = {
}
}
+
+function TrackRating() {
+ this._init.apply(this, arguments);
+}
+
+TrackRating.prototype = {
+ _init: function(prepend, value, style) {
+ this.box = new St.Table({style_class: style});
+
+ this._starredIcon = new Array();
+ this._nonStarredIcon = new Array();
+ this._starButton = new Array();
+ for(i=0; i < 5; i++) {
+ // Create starred icons
+ this._starredIcon[i] = new St.Icon({
+ style_class: 'button-star',
+ icon_size: 20,
+ icon_type: St.IconType.SYMBOLIC,
+ icon_name: 'starred'
+ });
+ // Create non-starred icons
+ this._nonStarredIcon[i] = new St.Icon({
+ style_class: 'button-star',
+ icon_size: 20,
+ icon_type: St.IconType.SYMBOLIC,
+ icon_name: 'non-starred'
+ });
+ // Create the button with starred icon
+ this._starButton[i] = new St.Button({
+ style_class: 'button-star',
+ x_align: St.Align.START,
+ y_align: St.Align.START,
+ child: this._starredIcon[i]
+
+ });
+ // Put the button in the table
+ this.box.add(this._starButton[i], {row: 0, col: i + 2});
+ }
+
+ this.setValue(value);
+ },
+
+ setValue: function(value) {
+
+ for (i = 0; i < 5; i++) {
+ this._starButton[i].set_child(this._starredIcon[i]);
+ }
+
+ if (value < 0.2)
+ this._starButton[0].set_child(this._nonStarredIcon[0]);
+ if (value < 0.4)
+ this._starButton[1].set_child(this._nonStarredIcon[1]);
+ if (value < 0.6)
+ this._starButton[2].set_child(this._nonStarredIcon[2]);
+ if (value < 0.8)
+ this._starButton[3].set_child(this._nonStarredIcon[3]);
+ if (value < 1.0)
+ this._starButton[4].set_child(this._nonStarredIcon[4]);
+
+ },
+ showRating: function() {
+ for (i = 0; i < 5; i++) {
+ this._starButton[i].show();
+ }
+ },
+ hideRating: function() {
+ for (i = 0; i < 5; i++) {
+ this._starButton[i].hide();
+ }
+ }
+}
+
function PlaylistItem() {
this._init.apply(this, arguments);
}

No commit comments for this range

Something went wrong with that request. Please try again.