[gnome-shell/wip/aggregate-menu: 34/62] status: Add new brightness slider widget
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/aggregate-menu: 34/62] status: Add new brightness slider widget
- Date: Sun, 23 Jun 2013 00:16:34 +0000 (UTC)
commit fe389fe83ed3fafa02ab197d7baf4fc617a89415
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Apr 23 19:26:05 2013 -0400
status: Add new brightness slider widget
js/Makefile.am | 1 +
js/ui/status/brightness.js | 65 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index 604c834..c388d26 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -88,6 +88,7 @@ nobase_dist_js_DATA = \
ui/searchDisplay.js \
ui/shellDBus.js \
ui/status/accessibility.js \
+ ui/status/brightness.js \
ui/status/keyboard.js \
ui/status/lockScreenMenu.js \
ui/status/network.js \
diff --git a/js/ui/status/brightness.js b/js/ui/status/brightness.js
new file mode 100644
index 0000000..9721432
--- /dev/null
+++ b/js/ui/status/brightness.js
@@ -0,0 +1,65 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Clutter = imports.gi.Clutter;
+const Lang = imports.lang;
+const Gio = imports.gi.Gio;
+const St = imports.gi.St;
+const Signals = imports.signals;
+
+const PanelMenu = imports.ui.panelMenu;
+const PopupMenu = imports.ui.popupMenu;
+const Slider = imports.ui.slider;
+
+const BUS_NAME = 'org.gnome.SettingsDaemon.Power';
+const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power';
+
+const BrightnessInterface = <interface name="org.gnome.SettingsDaemon.Power.Screen">
+<property name='Brightness' type='i' access='readwrite'/>
+</interface>;
+
+const BrightnessProxy = Gio.DBusProxy.makeProxyWrapper(BrightnessInterface);
+
+const BrightnessSlider = new Lang.Class({
+ Name: 'BrightnessSlider',
+
+ _init: function(proxy) {
+ this._proxy = proxy;
+ this._proxy.connect('g-properties-changed', Lang.bind(this, this._updateBrightness));
+
+ this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
+
+ this._slider = new Slider.Slider(0);
+ this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
+
+ let icon = new St.Icon({ icon_name: 'display-brightness-symbolic',
+ style_class: 'popup-menu-icon' });
+ this.item.addActor(icon, { align: St.Align.MIDDLE });
+ this.item.addActor(this._slider.actor, { span: -1, expand: true });
+
+ this._updateBrightness();
+ },
+
+ _sliderChanged: function(slider, value) {
+ let percent = value * 100;
+ this._proxy.Brightness = percent;
+ },
+
+ _updateBrightness: function() {
+ let visible = this._proxy.Brightness >= 0;
+ this.item.actor.visible = visible;
+ if (visible)
+ this._slider.setValue(this._proxy.Brightness / 100.0);
+ },
+});
+
+const Indicator = new Lang.Class({
+ Name: 'BrightnessIndicator',
+ Extends: PanelMenu.SystemIndicator,
+
+ _init: function() {
+ this.parent('display-brightness-symbolic');
+ this._proxy = new BrightnessProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
+ this._brightnessSlider = new BrightnessSlider(this._proxy);
+ this.menu.addMenuItem(this._brightnessSlider.item);
+ },
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]