Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added button for closing the media player. #4

Open
wants to merge 6 commits into
base: gnome-3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 52 additions & 26 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,19 @@ MprisIndicator.prototype = {
this.menu_playback.add(this.menu_playback_buttons.playpause.actor, { expand: true, x_fill: false, x_align: St.Align.MIDDLE });
this.menu_playback.add(this.menu_playback_buttons.next.actor, { expand: true, x_fill: false, x_align: St.Align.END });

this.menu_player = new PopupMenu.PopupMenuItem("", { reactive: true, style_class: "menu-player" });
this.menu_player.connect("activate", Lang.bind(this, this.on_playermenu_clicked));
this.menu.addMenuItem(this.menu_player);
this.menu_player = new St.BoxLayout({name: "playerControls"});
this.menu.addActor(this.menu_player);

this.menu_player_buttons = {
"player": new PopupMenu.PopupMenuItem("", { reactive: true, style_class: "menu-player" }),
"quit": new PopupIconMenuItem("window-close", { reactive: true })
}

this.menu_player_buttons.player.connect("activate", Lang.bind(this, this.on_playermenu_clicked));
this.menu_player_buttons.quit.connect("activate", Lang.bind(this, this.on_playerquit_clicked));

this.menu_player.add(this.menu_player_buttons.player.actor, { expand: true, x_fill: false, x_align: St.Align.START });
this.menu_player.add(this.menu_player_buttons.quit.actor, { expand: false, x_fill: false, x_align: St.Align.END });

this.unbind_player();

Expand Down Expand Up @@ -200,11 +210,18 @@ MprisIndicator.prototype = {
if (this.mprisplayer2) this.mprisplayer2.RaiseRemote();
},

on_playerquit_clicked: function() {
if (this.mprisplayer2) {
this.menu.close(false); // Ugly hack
this.mprisplayer2.QuitRemote();
}
},

on_player_propertieschanged: function(properties) {
if ("Identity" in properties)
this.menu_player.label.set_text(properties["Identity"]);
this.menu_player_buttons.player.label.set_text(properties["Identity"]);
if ("CanRaise" in properties)
this.menu_player.actor.reactive = properties["CanRaise"];
this.menu_player_buttons.player.actor.reactive = properties["CanRaise"];
},

on_playback_propertieschanged: function(properties) {
Expand Down Expand Up @@ -233,6 +250,8 @@ MprisIndicator.prototype = {
this.on_player_propertieschanged(properties);
}
}));

this.menu_player_buttons.quit.actor.reactive = true;
this.menu_playback.show();
},

Expand Down Expand Up @@ -265,27 +284,34 @@ MprisIndicator.prototype = {

playback_status_changed: function(playback_status) {
this.playback_status = playback_status;
if (playback_status == PLAYBACKSTATUS_PAUSED) {
this.setIcon("media-playback-pause");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.actor.show();
} else if (playback_status == PLAYBACKSTATUS_PLAYING) {
this.setIcon("media-playback-start");
this.menu_playback_buttons.playpause.setIcon("media-playback-pause");
this.actor.show();
} else if (playback_status == PLAYBACKSTATUS_STOPPED) {
this.setIcon("media-playback-stop");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.actor.show();
} else {
for each (let b in this.menu_playback_buttons) {
b.actor.reactive = false;
}
this.setIcon("media-eject");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.menu_player.label.set_text(_("No player found"));
this.menu_player.actor.reactive = false;
if (HIDE_DISCONNECTED) this.actor.hide();
switch (playback_status) {
case PLAYBACKSTATUS_PAUSED:
this.setIcon("media-playback-pause");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.actor.show();
break;
case PLAYBACKSTATUS_PLAYING:
this.setIcon("media-playback-start");
this.menu_playback_buttons.playpause.setIcon("media-playback-pause");
this.actor.show();
break;
case PLAYBACKSTATUS_STOPPED:
this.setIcon("media-playback-stop");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.actor.show();
break;
default:
for each (let b in this.menu_playback_buttons) {
b.actor.reactive = false;
}
this.setIcon("media-eject");
this.menu_playback_buttons.playpause.setIcon("media-playback-start");
this.menu_player_buttons.player.label.set_text(_("No player found"));
this.menu_player_buttons.player.actor.reactive = false;
this.menu_player_buttons.quit.actor.reactive = false;
if (HIDE_DISCONNECTED)
this.actor.hide();
break;
}
}
};
Expand Down
Binary file modified MprisControl_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
What is MprisControl?
=====================

MprisControl is a gnome-shell extension that allows controling any MPRIS_
MprisControl is a gnome-shell extension that allows controlling any MPRIS_
compliant player with (literally) one click. The extension places an icon
on gnome-shell Main Panel which indicates playback status of currently running
media player. Middle-clicking the icon toggles play/pause. Left- or right-
-clicking shows menu with standard playback control buttons.
on gnome-shell Main Panel which indicates playback status of the currently
running media player. Middle-clicking the icon toggles play/pause. Scrolling
up/down on the icon skips to the previous/next track. Left- or right-clicking
shows a menu with standard playback control buttons.

.. _MPRIS: http://www.mpris.org/

Expand All @@ -17,12 +18,12 @@ Everybody loves screenshots, right?

Playing:

.. image:: http://img155.imageshack.us/img155/2687/mpriscontrolplaying2.png
.. image:: https://github.com/ojo/gnome-shell-extension-mpriscontrol/raw/gnome-3.2/MprisControl_playing2.png
:alt: MprisControl (playing)

Menu:

.. image:: http://img441.imageshack.us/img441/1195/mpriscontrolmenu.png
.. image:: https://github.com/ojo/gnome-shell-extension-mpriscontrol/raw/gnome-3.2/MprisControl_menu.png
:alt: MprisControl (menu)


Expand Down Expand Up @@ -68,4 +69,5 @@ This program is free software: you can redistribute it and/or modify it under th

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.