Sound indicator, with no active player (launchers only, no control buttons)

Sound indicator, with active player (full control buttons)

15.10
Have same build steps as 14.04.
Remove player from menu after close
Modify src/service.vala
for desktop
menu to HIDE_INACTIVE_PLAYERS.
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE|SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
And modify src/sound-menu.vala
for add_player function to remove_player_section if it is not running & hide inactive is set.
public void add_player (MediaPlayer player) {
if (this.notify_handlers.contains (player))
return;
if (player.is_running || !this.hide_inactive)
this.insert_player_section (player);
else
this.remove_player_section (player);
this.update_playlists (player);
Hide player controls (Prev/Play/Next) from menu after close, keep only its launcher
Same as 14.04, no change.
14.04
Download build dependencies and source
sudo apt-get build-dep indicator-sound
apt-get source indicator-sound
Choose the behavior you want:
Remove player from menu after close
Modify src/service.vala
for desktop
menu.
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
I added | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS
, You can remove SoundMenu.DisplayFlags.SHOW_MUTE |
if you want hide volume control with muted players.
Hide player controls (Prev/Play/Next) from menu after close, keep only its launcher
Modify src/sound-menu.vala
Add new flag HIDE_INACTIVE_PLAYERS_CONTROLS = 128
with ,
in end of previous line.
public enum DisplayFlags {
NONE = 0,
SHOW_MUTE = 1,
HIDE_INACTIVE_PLAYERS = 2,
HIDE_PLAYERS = 4,
HIDE_INACTIVE_PLAYERS_CONTROLS = 128
}
Add bool hide_inactive_controls;
variable to hold flag status
bool hide_inactive;
bool hide_inactive_controls;
bool hide_players = false;
Add this.hide_inactive_controls =...
line. to pass SoundMenu constructor flag parameter to its variable.
this.hide_inactive = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS) != 0;
this.hide_inactive_controls = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS_CONTROLS) != 0;
this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal);
Add if (player.is_running || !this.hide_inactive_controls) {
and }
. to wrap instructions which create (prev/play/next) in menu item. So they are not created only if player is running or hide flag is inactive.
if (player.is_running || !this.hide_inactive_controls) {
var playback_item = new MenuItem (null, null);
playback_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.playback-item");
playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id);
playback_item.set_attribute ("x-canonical-next-action", "s", "indicator.next." + player.id);
playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id);
section.append_item (playback_item);
}
Add if (this.hide_inactive_controls) {
to next }
. To force player menu section recreation when player is-running
state changes.
var handler_id = player.notify["is-running"].connect ( () => {
if (this.hide_inactive) {
if (player.is_running) {
this.insert_player_section (player);
}
else {
this.remove_player_section (player);
}
}
if (this.hide_inactive_controls) {
this.remove_player_section (player);
this.insert_player_section (player);
}
this.update_playlists (player);
});
Finally, modify src/service.vala
. Add our new created flag | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_CONTROLS
to desktop
menu.
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_CONTROLS));
Build and install
cd indicator-sound-12.10.2+14.04.20140313/
mkdir build
cd build/
cmake ..
make
sudo make install
Now, the players will disappear after closing them.
12.04
Download build dependencies and source
sudo apt-get build-dep indicator-sound
apt-get source indicator-sound
Modify src/player-controller.vala
, Replace "rhythmbox.desktop"
with "xrhythmbox.desktop"
in the two occurrences. (just different name)
Build and install
cd indicator-sound-0.8.5.0/
./configure
make
make install
Note: That was a quick trick, the correct way may be:
Replace
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
this.app_info.get_id() == "rhythmbox.desktop");
with
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
false);
and
if (this.app_info.get_id() == "rhythmbox.desktop"){
TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
transport.handle_cached_action();
}
else{
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
true);
}
with
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
true);
indicator-sound
). I would really want to see this reopened. – user Jul 04 '15 at 01:27