[polari] mainWindow: Respect gtk-decoration-layout property



commit 2884f69f76c0e0b7b42f2be55dc7f840710d42ea
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 9 12:37:10 2014 -0500

    mainWindow: Respect gtk-decoration-layout property
    
    GTK+ recently gained a setting to control the layout of headerbar
    decorations. It's a reasonable expectation that we respect it,
    even if the result may turn out horribly unbalanced (in particular
    when moving everything into the sidebar on the left) ...
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721889

 configure.ac                  |    2 +-
 data/resources/main-window.ui |    1 +
 src/mainWindow.js             |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ab201e5..a7904dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ GLIB_GSETTINGS
 PKG_CHECK_MODULES(POLARI,
                   gio-2.0 >= 2.39.0
                   gobject-introspection-1.0
-                  gtk+-3.0 >= 3.9.12
+                  gtk+-3.0 >= 3.11.5
                   telepathy-glib);
 
 AC_PATH_PROG([GJS_CONSOLE],[gjs-console],[no])
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index 443ab71..d03eb68 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -29,6 +29,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">False</property>
+            <property name="show_close_button">True</property>
             <style>
               <class name="polari-titlebar-left"/>
               <class name="titlebar"/>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 22e2c7d..47adcce 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -28,6 +28,7 @@ const MainWindow = new Lang.Class({
 
         this._room = null;
         this._settings = new Gio.Settings({ schema: 'org.gnome.polari' });
+        this._gtkSettings = Gtk.Settings.get_default();
 
         this._displayNameChangedId = 0;
         this._topicChangedId = 0;
@@ -56,6 +57,10 @@ const MainWindow = new Lang.Class({
 
         this._userListAction = app.lookup_action('user-list');
 
+        this._gtkSettings.connect('notify::gtk-decoration-layout',
+                                  Lang.bind(this, this._updateDecorations));
+        this._updateDecorations();
+
         this.window.connect_after('key-press-event', Lang.bind(this,
             function(w, event) {
                 let [, keyval] = event.get_keyval();
@@ -181,6 +186,22 @@ const MainWindow = new Lang.Class({
             });
     },
 
+    _updateDecorations: function() {
+        let layoutLeft = null;
+        let layoutRight = null;
+
+        let layout = this._gtkSettings.gtk_decoration_layout;
+        if (layout) {
+            let split = layout.split(':');
+
+            layoutLeft = split[0] + ':';
+            layoutRight = ':' + split[1];
+        }
+
+        this._titlebarLeft.set_decoration_layout(layoutLeft);
+        this._titlebarRight.set_decoration_layout(layoutRight);
+    },
+
     _activeRoomChanged: function(manager, room) {
         if (this._room) {
             this._room.disconnect(this._displayNameChangedId);


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