diff --git a/README.md b/README.md index 92d7465..2946484 100644 --- a/README.md +++ b/README.md @@ -23,14 +23,13 @@ to install the extension in your home directory. A Shell reload is required - + + True + False + 0 + in + + + True + False + none + + + 100 + True + True + + + True + False + 12 + 12 + 32 + 32 + + + True + False + Clock location + 0 + + + 0 + 0 + + + + + True + False + center + + Natural + Left of status menu + Right of status menu + + + + 1 + 0 + + + + + + + + + + + + + + False + True + 2 + diff --git a/panel.js b/panel.js index 618c227..675414c 100644 --- a/panel.js +++ b/panel.js @@ -21,6 +21,9 @@ * Code to re-anchor the panel was taken from Thoma5 BottomPanel: * https://github.com/Thoma5/gnome-shell-extension-bottompanel * + * Pattern for moving clock based on Frippery Move Clock by R M Yorston + * http://frippery.org/extensions/ + * * Some code was also adapted from the upstream Gnome Shell source code. */ @@ -74,6 +77,7 @@ const taskbarPanel = new Lang.Class({ this._oldRightBoxStyle = this.panel._rightBox.get_style(); this._setTraySize(this._dtpSettings.get_int('tray-size')); this._setLeftBoxSize(this._dtpSettings.get_int('tray-size')); + this._setClockLocation(this._dtpSettings.get_string('location-clock')); this.panel.actor.add_style_class_name("popup-menu"); @@ -106,6 +110,13 @@ const taskbarPanel = new Lang.Class({ Lang.bind(this, function() { Main.overview.dashIconSize = this.taskbar.iconSize; }) + ], + [ + this.panel._rightBox, + 'actor-added', + Lang.bind(this, function() { + this._setClockLocation(this._dtpSettings.get_string('location-clock')); + }) ] ); @@ -135,6 +146,7 @@ const taskbarPanel = new Lang.Class({ Main.overview._panelGhost.set_height(this._oldPanelHeight); this._setTraySize(0); this._setLeftBoxSize(0); + this._setClockLocation("NATURAL"); this.panel.actor.remove_style_class_name("popup-menu"); this.appMenu = null; @@ -163,6 +175,10 @@ const taskbarPanel = new Lang.Class({ this._dtpSettings.connect('changed::leftbox-size', Lang.bind(this, function() { this._setLeftBoxSize(this._dtpSettings.get_int('leftbox-size')); })); + + this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() { + this._setClockLocation(this._dtpSettings.get_string('location-clock')); + })); }, _allocate: function(actor, box, flags) { @@ -246,5 +262,41 @@ const taskbarPanel = new Lang.Class({ _setLeftBoxSize: function(size) { size ? this.panel._leftBox.set_style("font-size: " + size + "px;" + (this._oldLeftBoxStyle || "")) : this.panel._leftBox.set_style(this._oldLeftBoxStyle); + }, + + _setClockLocation: function(loc) { + let centerBox = this.panel._centerBox; + let rightBox = this.panel._rightBox; + let dateMenu = this.panel.statusArea['dateMenu']; + let statusMenu = this.panel.statusArea['aggregateMenu']; + + if(loc == "NATURAL") { + // only move the clock back if it's in the right box + if ( rightBox.get_children().indexOf(dateMenu.container) != -1 ) { + rightBox.remove_actor(dateMenu.container); + centerBox.add_actor(dateMenu.container); + } + } else { + // if clock is in left box, remove it and add to right + if ( centerBox.get_children().indexOf(dateMenu.container) != -1 ) { + centerBox.remove_actor(dateMenu.container); + rightBox.insert_child_at_index(dateMenu.container, 0); + } + + // then, move to its new location + switch(loc) { + case "STATUSLEFT": + if(statusMenu) + rightBox.set_child_below_sibling(dateMenu.container, statusMenu.container); + break; + case "STATUSRIGHT": + if(statusMenu) + rightBox.set_child_above_sibling(dateMenu.container, statusMenu.container); + break; + default: + break; + } + + } } }); \ No newline at end of file diff --git a/prefs.js b/prefs.js index 4b52aea..8b41d04 100644 --- a/prefs.js +++ b/prefs.js @@ -84,6 +84,11 @@ const Settings = new Lang.Class({ } + this._builder.get_object('location_clock_combo').set_active_id(this._settings.get_string('location-clock')); + this._builder.get_object('location_clock_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('location-clock', widget.get_active_id()); + })); + // size options let panel_size_scale = this._builder.get_object('panel_size_scale'); panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length-1], DEFAULT_PANEL_SIZES[0]); 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 50f5515..ff6deaa 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -25,6 +25,11 @@ Panel size Set the size of the panel. + + "STATUSRIGHT" + Location of the clock + Set the location of the clock on the taskbar + true Show applications button