Add setting to specify close button and header position

This commit is contained in:
Charles Gagnon
2019-05-24 20:41:55 -04:00
parent d2b969d157
commit c28bfb46e4
4 changed files with 127 additions and 36 deletions

View File

@@ -2357,7 +2357,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Middle click to close window</property>
<property name="label" translatable="yes">Middle click on the preview to close the window</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
@@ -2378,25 +2378,6 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="preview_middle_click_close_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Middle click on the preview to close the window.</property>
<property name="wrap">True</property>
<property name="max_width_chars">40</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
@@ -2492,6 +2473,86 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listbox_preview_title_position">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox" id="preview_title_position_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="spacing">32</property>
<child>
<object class="GtkLabel" id="preview_title_position_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Close button and header position</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="preview_title_position_butttons_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkRadioButton" id="preview_title_position_bottom_button">
<property name="label" translatable="yes">Bottom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="preview_title_position_bottom_button_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="preview_title_position_top_button">
<property name="label" translatable="yes">Top</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">preview_title_position_bottom_button</property>
<signal name="toggled" handler="preview_title_position_top_button_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listbox_preview_show_title">
<property name="visible">True</property>

View File

@@ -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';
},

View File

@@ -44,11 +44,7 @@
</enum>
<!-- this is mean to Match StSide. LEFT and RIGHT actual position in reversed in
rtl languages -->
<enum id='org.gnome.shell.extensions.dash-to-panel.panelPosition'>
<value value='0' nick='BOTTOM'/>
<value value='1' nick='TOP'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.dotPosition'>
<enum id='org.gnome.shell.extensions.dash-to-panel.position'>
<value value='0' nick='BOTTOM'/>
<value value='1' nick='TOP'/>
</enum>
@@ -65,7 +61,7 @@
<value value='4' nick='bolder'/>
</enum>
<schema path="/org/gnome/shell/extensions/dash-to-panel/" id="org.gnome.shell.extensions.dash-to-panel">
<key name="panel-position" enum="org.gnome.shell.extensions.dash-to-panel.panelPosition">
<key name="panel-position" enum="org.gnome.shell.extensions.dash-to-panel.position">
<default>'BOTTOM'</default>
<summary>Panel position</summary>
<description>Panel is shown on the Bottom or Top of the screen.</description>
@@ -75,7 +71,7 @@
<summary>Panel size</summary>
<description>Set the size of the panel.</description>
</key>
<key name="dot-position" enum="org.gnome.shell.extensions.dash-to-panel.dotPosition">
<key name="dot-position" enum="org.gnome.shell.extensions.dash-to-panel.position">
<default>'BOTTOM'</default>
<summary>Dot position</summary>
<description>Running indicators are shown on the Bottom or Top of the screen.</description>
@@ -410,6 +406,11 @@
<summary>Display title in preview</summary>
<description>Display window title in preview</description>
</key>
<key name="window-preview-title-position" enum="org.gnome.shell.extensions.dash-to-panel.position">
<default>'TOP'</default>
<summary>Title position</summary>
<description>Position of the window title, close button and icon in preview.</description>
</key>
<key type="s" name="window-preview-title-font-color">
<default>"#dddddd"</default>
<summary>Window previews title font color</summary>

View File

@@ -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(