[gnome-shell-extensions] Allow dock allows multiple positions in screen
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] Allow dock allows multiple positions in screen
- Date: Mon, 23 May 2011 20:44:07 +0000 (UTC)
commit 41d9b71b269804088936b8cc5320ba7c41f20845
Author: Marc Alcalà <marc alcala gmail com>
Date: Fri Apr 22 12:54:34 2011 +0200
Allow dock allows multiple positions in screen
Use GSettings to store configuration and make the dock position
customizabile. Currently, supported are left and right of the
primary monitor; more could be added in the future.
(Commit message edited by Giovanni Campagna)
https://bugzilla.gnome.org/show_bug.cgi?id=647394
Signed-off-by: Giovanni Campagna <gcampagna src gnome org>
extensions/dock/Makefile.am | 11 ++++
extensions/dock/extension.js | 53 +++++++++++++++++---
.../org.gnome.shell.extensions.dock.gschema.xml.in | 19 +++++++
3 files changed, 76 insertions(+), 7 deletions(-)
---
diff --git a/extensions/dock/Makefile.am b/extensions/dock/Makefile.am
index 2531858..41be99f 100644
--- a/extensions/dock/Makefile.am
+++ b/extensions/dock/Makefile.am
@@ -1,3 +1,14 @@
EXTENSION_ID = dock
include ../../extension.mk
+
+gschemas_in = org.gnome.shell.extensions.dock.gschema.xml.in
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
+
+ GSETTINGS_RULES@
+
+CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
+EXTRA_DIST += $(gschemas_in)
diff --git a/extensions/dock/extension.js b/extensions/dock/extension.js
index 8af0d3e..7018495 100644
--- a/extensions/dock/extension.js
+++ b/extensions/dock/extension.js
@@ -25,7 +25,19 @@ const AltTab = imports.ui.altTab;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
-const DOCKICON_SIZE = 48;
+// Settings
+const DOCK_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.dock';
+const DOCK_POSITION_KEY = 'position';
+const DOCK_SIZE_KEY = 'size';
+
+// Keep enums in sync with GSettings schemas
+const PositionMode = {
+ LEFT: 0,
+ RIGHT: 1
+};
+
+let position = PositionMode.RIGHT;
+let dockicon_size = 48;
const DND_RAISE_APP_TIMEOUT = 500;
function Dock() {
@@ -40,8 +52,16 @@ Dock.prototype = {
this._favorites = [];
+ // Load Settings
+ this._settings = new Gio.Settings({ schema: DOCK_SETTINGS_SCHEMA });
+ position = this._settings.get_enum(DOCK_POSITION_KEY);
+ dockicon_size = this._settings.get_int(DOCK_SIZE_KEY);
+ //global.log("POSITION: " + position);
+ //global.log("dockicon_size: " + dockicon_size);
+
+
this._spacing = 4;
- this._item_size = DOCKICON_SIZE;
+ this._item_size = dockicon_size;
this.actor = new St.BoxLayout({ name: 'dock', vertical: true, reactive: true });
@@ -119,8 +139,18 @@ Dock.prototype = {
let primary = global.get_primary_monitor();
let height = (icons)*(this._item_size + this._spacing) + 2*this._spacing;
- this.actor.set_size(this._item_size + 4*this._spacing, height);
- this.actor.set_position(primary.width-this._item_size-this._spacing-2, (primary.height-height)/2);
+ let width = (icons)*(this._item_size + this._spacing) + 2*this._spacing;
+
+ switch (position) {
+ case PositionMode.LEFT:
+ this.actor.set_size(this._item_size + 4*this._spacing, height);
+ this.actor.set_position(0-this._spacing-4, (primary.height-height)/2);
+ break;
+ case PositionMode.RIGHT:
+ default:
+ this.actor.set_size(this._item_size + 4*this._spacing, height);
+ this.actor.set_position(primary.width-this._item_size-this._spacing-2, (primary.height-height)/2);
+ }
},
_getPreferredWidth: function (grid, forHeight, alloc) {
@@ -141,6 +171,8 @@ Dock.prototype = {
let children = this._grid.get_children();
let x = box.x1 + this._spacing;
+ if (position == PositionMode.LEFT)
+ x = box.x1 + 2*this._spacing;
let y = box.y1 + this._spacing;
for (let i = 0; i < children.length; i++) {
@@ -191,9 +223,9 @@ DockIcon.prototype = {
x_fill: true,
y_fill: true });
this.actor._delegate = this;
- this.actor.set_size(DOCKICON_SIZE, DOCKICON_SIZE);
+ this.actor.set_size(dockicon_size, dockicon_size);
- this._icon = this.app.create_icon_texture(DOCKICON_SIZE);
+ this._icon = this.app.create_icon_texture(dockicon_size);
this.actor.set_child(this._icon);
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
@@ -371,7 +403,14 @@ DockIconMenu.prototype = {
__proto__: AppDisplay.AppIconMenu.prototype,
_init: function(source) {
- PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, St.Side.RIGHT, 0);
+ switch (position) {
+ case PositionMode.LEFT:
+ PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, St.Side.LEFT, 0);
+ break;
+ case PositionMode.RIGHT:
+ default:
+ PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, St.Side.RIGHT, 0);
+ }
this._source = source;
diff --git a/extensions/dock/org.gnome.shell.extensions.dock.gschema.xml.in b/extensions/dock/org.gnome.shell.extensions.dock.gschema.xml.in
new file mode 100644
index 0000000..d73cd69
--- /dev/null
+++ b/extensions/dock/org.gnome.shell.extensions.dock.gschema.xml.in
@@ -0,0 +1,19 @@
+<schemalist gettext-domain="gnome-shell-extensions">
+ <enum id='org.gnome.shell.extensions.dock.PositionMode'>
+ <value nick='left' value='0'/>
+ <value nick='right' value='1'/>
+ </enum>
+
+ <schema id="org.gnome.shell.extensions.dock" path="/org/gnome/shell/extensions/dock/">
+ <key name="position" enum="org.gnome.shell.extensions.dock.PositionMode">
+ <default>'right'</default>
+ <_summary>Position of the dock</_summary>
+ <_description>Sets the position of the dock in the screen. Allowed values are 'right' or 'left'</_description>
+ </key>
+ <key name="size" type="i">
+ <default>48</default>
+ <_summary>Icon size</_summary>
+ <_description>Sets icon size of the dock.</_description>
+ </key>
+ </schema>
+</schemalist>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]