[gnome-shell/wip/aggregate-menu: 11/36] 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: 11/36] status: Add new brightness slider widget
- Date: Wed, 29 May 2013 20:17:11 +0000 (UTC)
commit dffa5aa170aaca14aa21132779cafe417e6c4fab
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 | 70 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 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..a66d8d4
--- /dev/null
+++ b/js/ui/status/brightness.js
@@ -0,0 +1,70 @@
+// -*- 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='u' 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.section = new PopupMenu.PopupMenuSection();
+ this._item = new PopupMenu.PopupBaseMenuItem({ activate: false });
+
+ this._actor = new St.BoxLayout({ style_class: 'popup-slider-icon-menu-item' });
+
+ this._slider = new Slider.Slider(0);
+ this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
+
+ this._actor.add(new St.Icon({ icon_name: 'display-brightness-symbolic', icon_size: 16 }));
+ this._actor.add(this._slider.actor, { expand: true });
+ this._actor.add(new St.Icon({ icon_name: 'display-brightness-symbolic', icon_size: 16 }));
+
+ this._item.addActor(this._actor, { span: -1, expand: true });
+ this.section.addMenuItem(this._item);
+
+ this._updateBrightness();
+ },
+
+ _sliderChanged: function(slider, value) {
+ let percent = value * 100;
+ this._proxy.Brightness = percent;
+ },
+
+ _updateBrightness: function() {
+ let visible = this._proxy.Brightness >= 0;
+ this.section.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.section);
+ },
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]