[sushi] mainWindow: respect close button placement preference



commit 824eba62bf3d1aaff40dc36425ed534bfc50fbbb
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jun 19 09:04:56 2019 -0700

    mainWindow: respect close button placement preference
    
    Instead of always setting our own decoration layout, tweak the one
    provided by GTK to remove the actions that we don't support.
    
    https://gitlab.gnome.org/GNOME/sushi/issues/14

 src/ui/mainWindow.js | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/ui/mainWindow.js b/src/ui/mainWindow.js
index c78d1f3..5e7adae 100644
--- a/src/ui/mainWindow.js
+++ b/src/ui/mainWindow.js
@@ -58,6 +58,22 @@ const Embed = GObject.registerClass(class Embed extends Gtk.Overlay {
     }
 });
 
+function _getDecorationLayout() {
+    function _isSupported(name) {
+        // We don't support maximize and minimize
+        return ['menu', 'close'].includes(name);
+    }
+
+    let settings = Gtk.Settings.get_default();
+    let decorationLayout = settings.gtk_decoration_layout;
+    let [lhs, rhs] = decorationLayout.split(':');
+
+    let leftGroup = lhs.split(',').filter(_isSupported);
+    let rightGroup = rhs.split(',').filter(_isSupported);
+
+    return [leftGroup.join(','), rightGroup.join(',')].join(':');
+};
+
 var MainWindow = GObject.registerClass(class MainWindow extends Gtk.Window {
     _init(application) {
         this._renderer = null;
@@ -74,8 +90,7 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.Window {
                       application: application });
 
         this._titlebar = new Gtk.HeaderBar({ show_close_button: true,
-                                             // don't support maximize and minimize
-                                             decoration_layout: 'menu:close' });
+                                             decoration_layout: _getDecorationLayout() });
         this.set_titlebar(this._titlebar);
 
         this._openButton = new Gtk.Button();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]