diff --git a/Settings.ui b/Settings.ui index 8d11049..cd4f188 100644 --- a/Settings.ui +++ b/Settings.ui @@ -2166,6 +2166,77 @@ 2 + + + True + False + 0 + in + + + True + False + none + + + 100 + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + 32 + + + True + False + True + Taskbar position + 0 + + + 0 + 0 + + + + + True + False + center + + Left panel + Centered in monitor + Centered in center panel + + + + 1 + 0 + + + + + + + + + + + + + + False + True + 3 + + diff --git a/panel.js b/panel.js index 6cbfa5b..61f215e 100644 --- a/panel.js +++ b/panel.js @@ -55,11 +55,21 @@ var dtpPanel = new Lang.Class({ _init: function(settings) { this._dtpSettings = settings; this.panelStyle = new PanelStyle.dtpPanelStyle(settings); + //rebuild panel when taskar-position change + this._dtpSettings.connect('changed::taskbar-position', Lang.bind(this, function() { + this.disable(); + this.enable(); + })); }, enable : function() { this.panel = Main.panel; - this.container = this.panel._leftBox; + //choose the leftBox or the centerBox to build taskbar + if (this._dtpSettings.get_string('taskbar-position') == 'LEFTPANEL') { + this.container = this.panel._leftBox; + } else { + this.container = this.panel._centerBox; + } this.appMenu = this.panel.statusArea.appMenu; this.panelBox = Main.layoutManager.panelBox; @@ -328,29 +338,41 @@ var dtpPanel = new Lang.Class({ let [centerMinWidth, centerNaturalWidth] = this.panel._centerBox.get_preferred_width(-1); let [rightMinWidth, rightNaturalWidth] = this.panel._rightBox.get_preferred_width(-1); - let sideWidth = allocWidth - rightNaturalWidth - centerNaturalWidth; + //I use ctb and cim variables to make diff reading easier. This must be replaced by if loups. + let taskbarPosition = this._dtpSettings.get_string('taskbar-position'); + let ctb = (taskbarPosition != 'LEFTPANEL'); // ctb: centered taskbar + let cim = (taskbarPosition == 'CENTEREDMONITOR'); // cim: centered in monitor + + let sideWidth, leftSideWidth, rightSideWidth; + if(ctb && !cim) { + leftSideWidth = (allocWidth - centerNaturalWidth + leftNaturalWidth - rightNaturalWidth) / 2; + rightSideWidth = (allocWidth - centerNaturalWidth - leftNaturalWidth + rightNaturalWidth) / 2; + sideWidth = 0; + } else { + sideWidth = leftSideWidth = rightSideWidth = (!ctb)*(allocWidth - rightNaturalWidth - centerNaturalWidth) + ctb*((allocWidth - centerNaturalWidth) / 2); + } let childBox = new Clutter.ActorBox(); childBox.y1 = 0; childBox.y2 = allocHeight; if (this.panel.actor.get_text_direction() == Clutter.TextDirection.RTL) { - childBox.x1 = allocWidth - Math.min(Math.floor(sideWidth), leftNaturalWidth); + childBox.x1 = allocWidth - ctb*leftNaturalWidth - (!ctb)*sideWidth; childBox.x2 = allocWidth; } else { childBox.x1 = 0; - childBox.x2 = sideWidth; + childBox.x2 = ctb*leftNaturalWidth + (!ctb)*sideWidth; } this.panel._leftBox.allocate(childBox, flags, true); childBox.y1 = 0; childBox.y2 = allocHeight; if (this.panel.actor.get_text_direction() == Clutter.TextDirection.RTL) { - childBox.x1 = rightNaturalWidth; - childBox.x2 = childBox.x1 + centerNaturalWidth; + childBox.x1 = allocWidth - ctb*(allocWidth - Math.max(rightNaturalWidth, rightSideWidth)) - (!ctb)*(childBox.x1 + centerNaturalWidth); + childBox.x2 = allocWidth - ctb*(Math.max(leftNaturalWidth, leftSideWidth)) - (!ctb)*(allocWidth - centerNaturalWidth - rightNaturalWidth); } else { - childBox.x1 = allocWidth - centerNaturalWidth - rightNaturalWidth; - childBox.x2 = childBox.x1 + centerNaturalWidth; + childBox.x1 = ctb*(Math.max(leftNaturalWidth, leftSideWidth)) + (!ctb)*(allocWidth - centerNaturalWidth - rightNaturalWidth); + childBox.x2 = ctb*(allocWidth - Math.max(rightNaturalWidth, rightSideWidth)) + (!ctb)*(childBox.x1 + centerNaturalWidth); } this.panel._centerBox.allocate(childBox, flags, true); diff --git a/prefs.js b/prefs.js index 90aacd3..1015512 100644 --- a/prefs.js +++ b/prefs.js @@ -201,6 +201,10 @@ const Settings = new Lang.Class({ this._builder.get_object('location_clock_combo').connect('changed', Lang.bind (this, function(widget) { this._settings.set_string('location-clock', widget.get_active_id()); })); + this._builder.get_object('taskbar_position_combo').set_active_id(this._settings.get_string('taskbar-position')); + this._builder.get_object('taskbar_position_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('taskbar-position', widget.get_active_id()); + })); // size options let panel_size_scale = this._builder.get_object('panel_size_scale'); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 7f8e32f..8605f33 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -22,6 +22,11 @@ + + + + + @@ -132,6 +137,11 @@ Location of the clock Set the location of the clock on the taskbar + + 'LEFTPANEL' + Position of the taskbar + Set the position of the taskbar on the panel + true Show applications button