[gnome-shell/wip/message-tray-menu: 19/20] status: Add new brightness slider widget
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/message-tray-menu: 19/20] status: Add new brightness slider widget
- Date: Wed, 24 Apr 2013 20:14:39 +0000 (UTC)
commit a701a661911ac084a6095c2ec80df36c7d837e03
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/panel.js | 2 +
js/ui/status/brightness.js | 72 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index 57f42db..acd0545 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -85,6 +85,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/network.js \
ui/status/power.js \
diff --git a/js/ui/panel.js b/js/ui/panel.js
index cd78afa..a614dc1 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -932,12 +932,14 @@ const AggregateMenu = new Lang.Class({
let network = new imports.ui.status.network.Indicator();
let volume = new imports.ui.status.volume.Indicator();
+ let brightness = new imports.ui.status.brightness.Indicator();
let userMenu = new imports.ui.userMenu.UserMenuButton();
this._indicators.add_child(network.indicators);
this._indicators.add_child(volume.indicators);
this.menu.addMenuItem(volume.menu);
+ this.menu.addMenuItem(brightness.menu);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addMenuItem(userMenu.menu);
},
diff --git a/js/ui/status/brightness.js b/js/ui/status/brightness.js
new file mode 100644
index 0000000..92d3770
--- /dev/null
+++ b/js/ui/status/brightness.js
@@ -0,0 +1,72 @@
+// -*- 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: 'slider-icon-menu-item' });
+
+ this._slider = new Slider.Slider(0);
+ this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
+
+ this._actor.add_child(new St.Icon({ icon_name: 'display-brightness-symbolic', icon_size: 16 }));
+ this._actor.add_child(this._slider.actor);
+ this._actor.add_child(new St.Icon({ icon_name: 'display-brightness-symbolic', icon_size: 16 }));
+
+ this._item.addActor(this._actor);
+ this.section.addMenuItem(this._item);
+
+ this._updateBrightness();
+ },
+
+ _updateVisibility: function() {
+ let visible = this._shouldBeVisible();
+ this.section.actor.visible = visible;
+ },
+
+ _sliderChanged: function(slider, value) {
+ let percent = value * 100;
+ this._proxy.Brightness = percent;
+ },
+
+ _updateBrightness: function() {
+ this._slider.setValue(this._proxy.Brightness);
+ },
+});
+
+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]