Die*_*-MX 5 rhythmbox indicator-sound menu-bar
我喜欢 Spotify 的指示器菜单,只要应用程序打开它就会展开。我不喜欢总是显示所有按钮的 Rhythmbox。
当应用程序处于非活动状态时,我想隐藏 Rhythmbox 的 Rew/Play/FF 按钮。
感谢您的帮助。
声音指示器,无活动播放器(仅启动器,无控制按钮)
声音指示器,带有活动播放器(完全控制按钮)
与 14.04 具有相同的构建步骤。
关闭后从菜单中删除播放器
src/service.vala将菜单修改desktop为 HIDE_INACTIVE_PLAYERS。
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE|SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
Run Code Online (Sandbox Code Playgroud)
并修改src/sound-menu.valaadd_player 函数以删除_player_section(如果未运行并设置隐藏非活动状态)。
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);
Run Code Online (Sandbox Code Playgroud)关闭后从菜单中隐藏播放器控件(上一个/播放/下一个),仅保留其启动器
与 14.04 相同,没有变化。
下载构建依赖项和源代码
sudo apt-get build-dep indicator-sound
apt-get source indicator-sound
Run Code Online (Sandbox Code Playgroud)选择您想要的行为:
关闭后从菜单中删除播放器
修改src/service.vala为desktop菜单。
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
Run Code Online (Sandbox Code Playgroud)
我补充说,如果您想隐藏静音播放器的音量控制,| SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS您可以删除。SoundMenu.DisplayFlags.SHOW_MUTE |
关闭后从菜单中隐藏播放器控件(上一个/播放/下一个),仅保留其启动器
调整src/sound-menu.vala
在上一行的末尾HIDE_INACTIVE_PLAYERS_CONTROLS = 128添加新标志。,
public enum DisplayFlags {
NONE = 0,
SHOW_MUTE = 1,
HIDE_INACTIVE_PLAYERS = 2,
HIDE_PLAYERS = 4,
HIDE_INACTIVE_PLAYERS_CONTROLS = 128
}
Run Code Online (Sandbox Code Playgroud)添加bool hide_inactive_controls;变量来保存标志状态
bool hide_inactive;
bool hide_inactive_controls;
bool hide_players = false;
Run Code Online (Sandbox Code Playgroud)添加this.hide_inactive_controls =...行。将 SoundMenu 构造函数标志参数传递给其变量。
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);
Run Code Online (Sandbox Code Playgroud)添加if (player.is_running || !this.hide_inactive_controls) {和}。包装在菜单项中创建(上一个/播放/下一个)的指令。因此,仅当玩家正在运行或隐藏标志处于非活动状态时才会创建它们。
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);
}
Run Code Online (Sandbox Code Playgroud)添加if (this.hide_inactive_controls) {到下一个}。当玩家状态改变时强制重新创建玩家菜单部分is-running。
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);
});
Run Code Online (Sandbox Code Playgroud)最后,修改src/service.vala. 将我们新创建的标志添加| SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_CONTROLS到desktop菜单中。
this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_CONTROLS));
Run Code Online (Sandbox Code Playgroud)构建并安装
cd indicator-sound-12.10.2+14.04.20140313/
mkdir build
cd build/
cmake ..
make
sudo make install
Run Code Online (Sandbox Code Playgroud)现在,玩家关闭后就会消失。
下载构建依赖项和源代码
sudo apt-get build-dep indicator-sound
apt-get source indicator-sound
Run Code Online (Sandbox Code Playgroud)修改src/player-controller.vala,替换"rhythmbox.desktop"为"xrhythmbox.desktop"两次出现。(只是名称不同)
构建并安装
cd indicator-sound-0.8.5.0/
./configure
make
make install
Run Code Online (Sandbox Code Playgroud)注意:这是一个快速技巧,正确的方法可能是:
代替
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
this.app_info.get_id() == "rhythmbox.desktop");
Run Code Online (Sandbox Code Playgroud)
和
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
false);
Run Code Online (Sandbox Code Playgroud)和
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);
}
Run Code Online (Sandbox Code Playgroud)
和
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
true);
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
1036 次 |
| 最近记录: |