[sushi] main-window: add a preference to turn off client decorations
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] main-window: add a preference to turn off client decorations
- Date: Thu, 12 Apr 2012 14:39:27 +0000 (UTC)
commit d013e8d69e0b07c8c94e7d71c6c4c318e77e8870
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Apr 12 10:37:35 2012 -0400
main-window: add a preference to turn off client decorations
For environments that look different from gnome-shell, it might make
sense to just use the regular WM decorations for the Sushi window. Add a
gsetting option that allows this (disabled by default).
https://bugzilla.gnome.org/show_bug.cgi?id=667056
configure.ac | 2 ++
data/Makefile.am | 13 +++++++++++--
data/org.gnome.sushi.gschema.xml.in | 9 +++++++++
src/js/ui/mainWindow.js | 33 +++++++++++++++++++++++++++------
4 files changed, 49 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a5b70a..555e184 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,8 @@ AC_PROG_LIBTOOL
## don't rerun to this point if we abort
AC_CACHE_SAVE
+GLIB_GSETTINGS
+
GJS_JS_DIR=`$PKG_CONFIG --variable=datadir gjs-1.0`/gjs-1.0
AC_SUBST(GJS_JS_DIR)
diff --git a/data/Makefile.am b/data/Makefile.am
index b8f7915..843bd88 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,8 +7,17 @@ service_DATA = $(service_in_files:.service.in=.service)
org.gnome.Sushi.service: org.gnome.Sushi.service.in Makefile
$(AM_V_GEN) sed -e "s|\ bindir\@|$(bindir)|" $< > $@
+gsettingsschema_in_files = org.gnome.sushi.gschema.xml.in
+gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
+.PRECIOUS: $(gsettings_SCHEMAS)
+
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
EXTRA_DIST = \
- $(service_in_files)
+ $(service_in_files) \
+ $(gsettingsschema_in_files)
CLEANFILES = \
- $(service_DATA)
\ No newline at end of file
+ $(service_DATA) \
+ $(gsettings_SCHEMAS)
diff --git a/data/org.gnome.sushi.gschema.xml.in b/data/org.gnome.sushi.gschema.xml.in
new file mode 100644
index 0000000..f3d61ce
--- /dev/null
+++ b/data/org.gnome.sushi.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist gettext-domain="sushi">
+ <schema id="org.gnome.sushi" path="/org/gnome/sushi/">
+ <key name="client-decoration" type="b">
+ <default>true</default>
+ <_summary>Client decoration</_summary>
+ <_description>Whether the window draws WM decorations itself</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 46de067..e18a5dd 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -75,9 +75,12 @@ MainWindow.prototype = {
},
_createGtkWindow : function() {
+ this._settings = new Gio.Settings({ schema_id: 'org.gnome.sushi' });
+ this._clientDecorated = this._settings.get_boolean('client-decoration');
+
this._gtkWindow = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL,
focusOnMap: true,
- decorated: false,
+ decorated: !this._clientDecorated,
hasResizeGrip: false,
skipPagerHint: true,
skipTaskbarHint: true,
@@ -151,7 +154,16 @@ MainWindow.prototype = {
if (this._background)
return;
- this._background = Sushi.create_rounded_background();
+ if (this._clientDecorated) {
+ this._background = Sushi.create_rounded_background();
+ } else {
+ this._background = new Clutter.Rectangle();
+ this._background.set_color(new Clutter.Color({ red: 0,
+ green: 0,
+ blue: 0,
+ alpha: 255 }));
+ }
+
this._background.set_opacity(Constants.VIEW_BACKGROUND_OPACITY);
this._background.add_constraint(
new Clutter.BindConstraint({ source: this._stage,
@@ -223,9 +235,10 @@ MainWindow.prototype = {
_getTextureSize : function() {
let screenSize = [ this._gtkWindow.get_window().get_width(),
this._gtkWindow.get_window().get_height() ];
+ let yPadding = this._clientDecorated ? Constants.VIEW_PADDING_Y : 0;
let availableWidth = this._isFullScreen ? screenSize[0] : Constants.VIEW_MAX_W - 2 * Constants.VIEW_PADDING_X;
- let availableHeight = this._isFullScreen ? screenSize[1] : Constants.VIEW_MAX_H - Constants.VIEW_PADDING_Y;
+ let availableHeight = this._isFullScreen ? screenSize[1] : Constants.VIEW_MAX_H - yPadding;
let textureSize = this._renderer.getSizeForAllocation([availableWidth, availableHeight], this._isFullScreen);
@@ -235,13 +248,14 @@ MainWindow.prototype = {
_getWindowSize : function() {
let textureSize = this._getTextureSize();
let windowSize = textureSize;
+ let yPadding = this._clientDecorated ? Constants.VIEW_PADDING_Y : 0;
if (textureSize[0] < (Constants.VIEW_MIN - 2 * Constants.VIEW_PADDING_X) &&
- textureSize[1] < (Constants.VIEW_MIN - Constants.VIEW_PADDING_Y)) {
+ textureSize[1] < (Constants.VIEW_MIN - yPadding)) {
windowSize = [ Constants.VIEW_MIN, Constants.VIEW_MIN ];
} else if (!this._isFullScreen) {
windowSize = [ windowSize[0] + 2 * Constants.VIEW_PADDING_X,
- windowSize[1] + Constants.VIEW_PADDING_Y ];
+ windowSize[1] + yPadding ];
}
return windowSize;
@@ -576,6 +590,10 @@ MainWindow.prototype = {
new Clutter.BindConstraint({ source: this._stage,
coordinate: Clutter.BindCoordinate.WIDTH }));
+ // if we don't draw client decorations, just create an empty actor
+ if (!this._clientDecorated)
+ return;
+
this._titleLabel = new Gtk.Label({ label: "",
ellipsize: Pango.EllipsizeMode.END,
margin: 6 });
@@ -679,7 +697,10 @@ MainWindow.prototype = {
},
setTitle : function(label) {
- this._titleLabel.set_label(label);
+ if (this._clientDecorated)
+ this._titleLabel.set_label(label);
+
+ this._gtkWindow.set_title(label);
},
refreshSize : function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]