Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anduchs committed Nov 12, 2013
0 parents commit 54ef771
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*~
66 changes: 66 additions & 0 deletions extension.js
@@ -0,0 +1,66 @@
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._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...
item = new PopupMenu.PopupMenuItem('Connecting...');
this.menu.addMenuItem(item);
},

_updateDefaultSink: function () {
this.label.set_text(this._control.get_default_sink().get_description());
},

_updateSinkList: function () {
this.menu.removeAll();

sinklist = this._control.get_sinks();
control = this._control;

for (i = 0; i < sinklist.length; i++) {
sink = sinklist[i];
item = new PopupMenu.PopupMenuItem(sink.get_description());
item.connect('activate', Lang.bind(sink, function() {
control.set_default_sink(this);
}));
this.menu.addMenuItem(item);
}
},
});

let audioOutputSubMenu = null;

function init() {
}

function enable() {
if (audioOutputSubMenu != null)
return;
audioOutputSubMenu = new AudioOutputSubMenu();
Main.panel.statusArea.aggregateMenu._volume.menu.addMenuItem(audioOutputSubMenu);
}

function disable() {
audioOutputSubMenu.destroy();
audioOutputSubMenu = null;
}
9 changes: 9 additions & 0 deletions metadata.json
@@ -0,0 +1,9 @@
{
"shell-version": [
"3.10"
],
"uuid": "audio-output-switcher@anduchs",
"name": "Audio Output Switcher",
"description": "Adds a switch for choosing audio output to the system menu.",
"url": "http://github.com/anduchs/audio-output-switcher"
}

0 comments on commit 54ef771

Please sign in to comment.