From c28bfb46e4c920085f4188c274a73ef51148ba2b Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 24 May 2019 20:41:55 -0400 Subject: [PATCH] Add setting to specify close button and header position --- Settings.ui | 101 ++++++++++++++---- prefs.js | 19 ++++ ...shell.extensions.dash-to-panel.gschema.xml | 15 +-- windowPreview.js | 28 +++-- 4 files changed, 127 insertions(+), 36 deletions(-) diff --git a/Settings.ui b/Settings.ui index add7730..542239d 100644 --- a/Settings.ui +++ b/Settings.ui @@ -2357,7 +2357,7 @@ True False True - Middle click to close window + Middle click on the preview to close the window True 0 @@ -2378,25 +2378,6 @@ 0 - - - True - False - True - Middle click on the preview to close the window. - True - 40 - 0 - - - - 0 - 1 - 2 - - @@ -2492,6 +2473,86 @@ + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Close button and header position + 0 + + + False + True + 0 + + + + + True + False + 32 + + + Bottom + True + True + False + center + center + True + True + + + + False + True + 1 + + + + + Top + True + True + False + center + center + bottom + True + preview_title_position_bottom_button + + + + False + True + 2 + + + + + False + True + 1 + + + + + + True diff --git a/prefs.js b/prefs.js index 37ad7ec..4bc8bd1 100644 --- a/prefs.js +++ b/prefs.js @@ -990,6 +990,15 @@ const Settings = new Lang.Class({ 'active', Gio.SettingsBindFlags.DEFAULT); + switch (this._settings.get_string('window-preview-title-position')) { + case 'BOTTOM': + this._builder.get_object('preview_title_position_bottom_button').set_active(true); + break; + case 'TOP': + this._builder.get_object('preview_title_position_top_button').set_active(true); + break; + } + this._builder.get_object('grid_preview_title_font_color_colorbutton').connect('notify::color', Lang.bind(this, function (button) { let rgba = button.get_rgba(); let css = rgba.to_string(); @@ -1632,6 +1641,16 @@ const Settings = new Lang.Class({ this._settings.set_string('dot-position', "TOP"); }, + preview_title_position_bottom_button_toggled_cb: function(button) { + if (button.get_active()) + this._settings.set_string('window-preview-title-position', 'BOTTOM'); + }, + + preview_title_position_top_button_toggled_cb: function(button) { + if (button.get_active()) + this._settings.set_string('window-preview-title-position', 'TOP'); + }, + panel_size_scale_format_value_cb: function(scale, value) { return value+ ' px'; }, 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 f44ada9..8b0730e 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -44,11 +44,7 @@ - - - - - + @@ -65,7 +61,7 @@ - + 'BOTTOM' Panel position Panel is shown on the Bottom or Top of the screen. @@ -75,7 +71,7 @@ Panel size Set the size of the panel. - + 'BOTTOM' Dot position Running indicators are shown on the Bottom or Top of the screen. @@ -410,6 +406,11 @@ Display title in preview Display window title in preview + + 'TOP' + Title position + Position of the window title, close button and icon in preview. + "#dddddd" Window previews title font color diff --git a/windowPreview.js b/windowPreview.js index d2fc89f..1a9cab7 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -46,6 +46,7 @@ const PEEK_INDEX_PROP = '_dtpPeekInitialIndex'; var headerHeight = 0; var isLeftButtons = false; +var isTopHeader = true; var scaleFactor = 1; var animationTime = 0; @@ -331,6 +332,7 @@ var PreviewMenu = Utils.defineClass({ _refreshGlobals: function() { isLeftButtons = Meta.prefs_get_button_layout().left_buttons.indexOf(Meta.ButtonFunction.CLOSE) >= 0; + isTopHeader = this._dtpSettings.get_string('window-preview-title-position') == 'TOP'; scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; headerHeight = this._dtpSettings.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; animationTime = this._dtpSettings.get_int('window-preview-animation-time') * .001; @@ -555,12 +557,16 @@ var Preview = Utils.defineClass({ this.animatingOut = false; let [previewBinWidth, previewBinHeight] = this._getBinSize(); - this._previewBin = new St.Widget({ layout_manager: new Clutter.BinLayout() }); - this._previewBin.set_style('padding: ' + this._padding + 'px;'); - this._previewBin.set_size(previewBinWidth, previewBinHeight); - let closeButton = new St.Button({ style_class: 'window-close', accessible_name: 'Close window' }); + this._previewBin = new St.Widget({ + layout_manager: new Clutter.BinLayout(), + y_align: Clutter.ActorAlign[!isTopHeader ? 'START' : 'END'], + y_expand: true, + style: 'padding: ' + this._padding + 'px;' + }); + this._previewBin.set_size(previewBinWidth, previewBinHeight); + if (Config.PACKAGE_VERSION >= '3.31.9') { closeButton.add_actor(new St.Icon({ icon_name: 'window-close-symbolic' })); } @@ -570,7 +576,7 @@ var Preview = Utils.defineClass({ opacity: 0, x_expand: true, y_expand: true, x_align: Clutter.ActorAlign[isLeftButtons ? 'START' : 'END'], - y_align: Clutter.ActorAlign.START + y_align: Clutter.ActorAlign[isTopHeader ? 'START' : 'END'] }); this._closeButtonBin.add_child(closeButton); @@ -578,7 +584,7 @@ var Preview = Utils.defineClass({ if (headerHeight) { let headerBox = new St.Widget({ layout_manager: new Clutter.BoxLayout(), - y_align: Clutter.ActorAlign.START, + y_align: Clutter.ActorAlign[isTopHeader ? 'START' : 'END'], y_expand: true, style: this._getBackgroundColor(HEADER_COLOR_OFFSET, .8) }); @@ -594,8 +600,6 @@ var Preview = Utils.defineClass({ headerBox.insert_child_at_index(this._windowTitle, isLeftButtons ? 1 : 2); this.add_child(headerBox); - - this._previewBin.set_position(0, headerHeight); } closeButton.connect('clicked', () => this._onCloseBtnClick()); @@ -615,7 +619,13 @@ var Preview = Utils.defineClass({ let closeButtonBorderRadius = ''; if (!headerHeight) { - closeButtonBorderRadius = 'border-radius: ' + (isLeftButtons ? '0 0 4px 0;' : '0 0 0 4px;'); + closeButtonBorderRadius = 'border-radius: '; + + if (isTopHeader) { + closeButtonBorderRadius += (isLeftButtons ? '0 0 4px 0;' : '0 0 0 4px;'); + } else { + closeButtonBorderRadius += (isLeftButtons ? '0 4px 0 0;' : '4px 0 0 0;'); + } } this._closeButtonBin.set_style(