This repository was archived by the owner on Jan 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathextension.js
More file actions
94 lines (77 loc) · 2.41 KB
/
Copy pathextension.js
File metadata and controls
94 lines (77 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const Lang = imports.lang;
const Main = imports.ui.main;
const PopupMenu = imports.ui.popupMenu;
const AudioOutputSubMenu = new Lang.Class({
Name: 'AudioOutputSubMenu',
Extends: PopupMenu.PopupSubMenuMenuItem,
_init: function() {
this.parent('Audio Output: Connecting...', true);
this._control = Main.panel.statusArea.aggregateMenu._volume._control;
this._controlSignal = this._control.connect('default-sink-changed', Lang.bind(this, function() {
this._updateDefaultSink();
}));
this._updateDefaultSink();
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
if (isOpen)
this._updateSinkList();
}));
//Unless there is at least one item here, no 'open' will be emitted...
let item = new PopupMenu.PopupMenuItem('Connecting...');
this.menu.addMenuItem(item);
},
_updateDefaultSink: function () {
defsink = this._control.get_default_sink();
//Unfortunately, Gvc neglects some pulse-devices, such as all "Monitor of ..."
if (defsink == null)
this.label.set_text("Other");
else
this.label.set_text(defsink.get_description());
},
_updateSinkList: function () {
this.menu.removeAll();
let defsink = this._control.get_default_sink();
let sinklist = this._control.get_sinks();
let control = this._control;
for (let i=0; i<sinklist.length; i++) {
let sink = sinklist[i];
if (sink === defsink)
continue;
let item = new PopupMenu.PopupMenuItem(sink.get_description());
item.connect('activate', Lang.bind(sink, function() {
control.set_default_sink(this);
}));
this.menu.addMenuItem(item);
}
if (sinklist.length == 0 ||
(sinklist.length == 1 && sinklist[0] === defsink)) {
item = new PopupMenu.PopupMenuItem("No more Devices");
this.menu.addMenuItem(item);
}
},
destroy: function() {
this._control.disconnect(this._controlSignal);
this.parent();
}
});
let audioOutputSubMenu = null;
function init() {
}
function enable() {
if (audioOutputSubMenu != null)
return;
audioOutputSubMenu = new AudioOutputSubMenu();
//Try to add the output-switcher right below the output slider...
let volMen = Main.panel.statusArea.aggregateMenu._volume._volumeMenu;
let items = volMen._getMenuItems();
let i = 0;
while (i < items.length)
if (items[i] === volMen._output.item)
break;
else
i++;
volMen.addMenuItem(audioOutputSubMenu, i+1);
}
function disable() {
audioOutputSubMenu.destroy();
audioOutputSubMenu = null;
}