From ea1e5a5210bbade987fb63b7f40dffe6d250d433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 7 Jun 2011 12:27:52 +0200 Subject: [PATCH] workspace: Make close button respect button_layout Make the close button in the overview follow the user preference for the window button layout. https://bugzilla.gnome.org/show_bug.cgi?id=620105 --- js/ui/workspace.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 1650e7fb6..9c1acd16b 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1,6 +1,7 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Clutter = imports.gi.Clutter; +const GConf = imports.gi.GConf; const Lang = imports.lang; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; @@ -27,6 +28,8 @@ const CLOSE_BUTTON_FADE_TIME = 0.1; const DRAGGING_WINDOW_OPACITY = 100; +const BUTTON_LAYOUT_KEY = '/desktop/gnome/shell/windows/button_layout'; + // Define a layout scheme for small window counts. For larger // counts we fall back to an algorithm. We need more schemes here // unless we have a really good algorithm. @@ -435,9 +438,20 @@ WindowOverlay.prototype = { let button = this.closeButton; let title = this.title; + let gconf = GConf.Client.get_default(); + let layout = gconf.get_string(BUTTON_LAYOUT_KEY); + let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL; + + let split = layout.split(":"); + let side; + if (split[0].indexOf("close") > -1) + side = rtl ? St.Side.RIGHT : St.Side.LEFT; + else + side = rtl ? St.Side.LEFT : St.Side.RIGHT; + let buttonX; let buttonY = cloneY - (button.height - button._overlap); - if (St.Widget.get_default_direction() == St.TextDirection.RTL) + if (side == St.Side.LEFT) buttonX = cloneX - (button.width - button._overlap); else buttonX = cloneX + (cloneWidth - button._overlap);