Created new Mixer, PanelItem and Settings.
[AdvancedVolumeMixer.git] / widget.js
blob034e0236368fa29e9cc9a743f04eda343fa69954
1 // vi: et sw=2 fileencoding=utf8
2 //
4 const Mainloop = imports.mainloop;
5 const St = imports.gi.St;
6 const PopupMenu = imports.ui.popupMenu;
7 const Slider = imports.ui.slider;
8 const Pango = imports.gi.Pango;
9 const GLib = imports.gi.GLib;
10 const Gio = imports.gi.Gio;
11 const Lang = imports.lang;
13 const Volume = imports.ui.status.volume;
16 const AppOutputStreamSlider = new Lang.Class({
17   Name: "AppOutputStreamSlider",
18   Extends: Volume.StreamSlider,
20   _init: function(control) {
21     log("AppOutputStreamSlider");
23     this._control = control;
24     this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
26     this._slider = new Slider.Slider(0);
27     this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
28     this._slider.connect('drag-end', Lang.bind(this, this._notifyVolumeChange));
30     this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
31     this.item.actor.add(this._icon);
32     this.item.actor.add(this._slider.actor, { expand: true });
33     this.item.actor.connect('button-press-event', Lang.bind(this, function(actor, event) {
34         this._slider.startDragging(event);
35     }));
36     this.item.actor.connect('key-press-event', Lang.bind(this, function(actor, event) {
37         return this._slider.onKeyPressEvent(actor, event);
38     }));
39   },
41   _updateSliderIcon: function() {
42     if (this._stream) {
43       log("_updateSliderIcon:");
44       log(this._stream.get_gicon());
45       this._icon.gicon = this._stream.get_gicon();
46     } else {
47       this._icon.icon_name = (this._hasHeadphones ?
48                               'audio-headphones-symbolic' :
49                               'audio-speakers-symbolic');
50     }
51   },
53   _connectStream: function(stream) {
54     this._mutedChangedId = stream.connect('notify::is-muted', Lang.bind(this, this._updateVolume));
55     this._volumeChangedId = stream.connect('notify::volume', Lang.bind(this, this._updateVolume));
56     this._icon.gicon = stream.get_gicon();
57   },
59 });