[sushi] mainWindow: use GTK client side decorations
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] mainWindow: use GTK client side decorations
- Date: Sat, 27 Jun 2015 03:11:19 +0000 (UTC)
commit f48315d723de01ef8a4926d23991d76831858ecc
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Jun 26 18:49:37 2015 -0700
mainWindow: use GTK client side decorations
Instead of creating our own custom client side decoration with Clutter,
use GTK's machinery now that it's available.
configure.ac | 2 -
data/Makefile.am | 13 +----
data/org.gnome.sushi.gschema.xml.in | 9 ---
src/js/ui/mainWindow.js | 111 +++++------------------------------
src/libsushi/sushi-utils.c | 60 -------------------
src/libsushi/sushi-utils.h | 1 -
src/resources/gtk-style.css | 23 +++++---
7 files changed, 31 insertions(+), 188 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 58f7068..49d70bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,8 +41,6 @@ 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 728097c..3236290 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -5,19 +5,10 @@ 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) \
- $(gsettingsschema_in_files)
+ $(service_in_files)
CLEANFILES = \
- $(service_DATA) \
- $(gsettings_SCHEMAS)
+ $(service_DATA)
-include $(top_srcdir)/git.mk
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index a251340..f7bb582 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -24,6 +24,7 @@
*/
const Clutter = imports.gi.Clutter;
+const ClutterGdk = imports.gi.ClutterGdk;
const Gdk = imports.gi.Gdk;
const GdkX11 = imports.gi.GdkX11;
const Gio = imports.gi.Gio;
@@ -66,18 +67,14 @@ const MainWindow = new Lang.Class({
},
_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: !this._clientDecorated,
- hasResizeGrip: false,
skipPagerHint: true,
skipTaskbarHint: true,
windowPosition: Gtk.WindowPosition.CENTER,
gravity: Gdk.Gravity.CENTER,
application: this._application });
+ this._titlebar = new Gtk.HeaderBar({ show_close_button: true });
+ this._gtkWindow.set_titlebar(this._titlebar);
let screen = Gdk.Screen.get_default();
this._gtkWindow.set_visual(screen.get_rgba_visual());
@@ -143,16 +140,11 @@ const MainWindow = new Lang.Class({
if (this._background)
return;
- 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 = new Clutter.Actor();
+ this._background.set_background_color(new Clutter.Color({ red: 0,
+ green: 0,
+ blue: 0,
+ alpha: 255 }));
this._background.set_opacity(Constants.VIEW_BACKGROUND_OPACITY);
this._mainLayout.add(this._background, Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
@@ -182,6 +174,7 @@ const MainWindow = new Lang.Class({
},
_onButtonPressEvent : function(actor, event) {
+ let stageWin = ClutterGdk.get_stage_window(this._stage);
let win_coords = event.get_coords();
if ((event.get_source() == this._toolbarActor) ||
@@ -195,9 +188,8 @@ const MainWindow = new Lang.Class({
return false;
}
- let root_coords =
- this._gtkWindow.get_window().get_root_coords(win_coords[0],
- win_coords[1]);
+ let root_coords = stageWin.get_root_coords(win_coords[0],
+ win_coords[1]);
this._gtkWindow.begin_move_drag(event.get_button(),
root_coords[0],
@@ -220,10 +212,9 @@ const MainWindow = new Lang.Class({
_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 - yPadding;
+ let availableHeight = this._isFullScreen ? screenSize[1] : Constants.VIEW_MAX_H -
Constants.VIEW_PADDING_Y;
let textureSize = this._renderer.getSizeForAllocation([availableWidth, availableHeight],
this._isFullScreen);
@@ -233,14 +224,13 @@ const MainWindow = new Lang.Class({
_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 - yPadding)) {
+ textureSize[1] < (Constants.VIEW_MIN - Constants.VIEW_PADDING_Y)) {
windowSize = [ Constants.VIEW_MIN, Constants.VIEW_MIN ];
} else if (!this._isFullScreen) {
windowSize = [ windowSize[0] + 2 * Constants.VIEW_PADDING_X,
- windowSize[1] + yPadding ];
+ windowSize[1] + Constants.VIEW_PADDING_Y ];
}
return windowSize;
@@ -366,11 +356,6 @@ const MainWindow = new Lang.Class({
time: 0.15,
transition: 'easeOutQuad'
});
- Tweener.addTween(this._titleGroup,
- { opacity: 255,
- time: 0.15,
- transition: 'easeOutQuad'
- });
},
_exitFullScreen : function() {
@@ -411,7 +396,7 @@ const MainWindow = new Lang.Class({
this._background = null;
this._createSolidBackground();
- /* Fade in everything but the title */
+ /* Fade in everything */
Tweener.addTween(this._mainGroup,
{ opacity: 255,
time: 0.15,
@@ -462,11 +447,6 @@ const MainWindow = new Lang.Class({
/* quickly fade out everything,
* and then fullscreen the (empty) window.
*/
- Tweener.addTween(this._titleGroup,
- { opacity: 0,
- time: 0.10,
- transition: 'easeOutQuad'
- });
Tweener.addTween(this._mainGroup,
{ opacity: 0,
time: 0.10,
@@ -544,63 +524,6 @@ const MainWindow = new Lang.Class({
return false;
},
-
- /**************************************************************************
- ************************ titlebar helpers ********************************
- **************************************************************************/
- _createTitle : function() {
- if (this._titleGroup) {
- this._titleGroup.raise_top();
- return;
- }
-
- this._titleGroupLayout = new Clutter.BoxLayout();
- this._titleGroup = new Clutter.Box({ layout_manager: this._titleGroupLayout });
- this._stage.add_actor(this._titleGroup);
-
- this._titleGroup.add_constraint(
- 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: 2 });
- this._titleLabel.get_style_context().add_class('np-decoration');
-
- this._titleLabel.show();
- this._titleActor = new GtkClutter.Actor({ contents: this._titleLabel });
- Utils.alphaGtkWidget(this._titleActor.get_widget());
-
- this._quitButton =
- new Gtk.Button({ image: new Gtk.Image ({ icon_size: Gtk.IconSize.MENU,
- icon_name: 'window-close-symbolic' })});
- this._quitButton.get_style_context().add_class('np-decoration');
- this._quitButton.show();
-
- this._quitButton.connect('clicked',
- Lang.bind(this,
- this._clearAndQuit));
-
- this._quitActor = new GtkClutter.Actor({ contents: this._quitButton });
- Utils.alphaGtkWidget(this._quitActor.get_widget());
- this._quitActor.set_reactive(true);
-
- let hidden = new Clutter.Actor();
- let size = this._quitButton.get_preferred_size()[1];
- hidden.set_size(size.width, size.height);
-
- this._titleGroupLayout.pack(hidden, false, false, false,
- Clutter.BoxAlignment.START, Clutter.BoxAlignment.START);
- this._titleGroupLayout.pack(this._titleActor, true, true, false,
- Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
- this._titleGroupLayout.pack(this._quitActor, false, false, false,
- Clutter.BoxAlignment.END, Clutter.BoxAlignment.START);
- },
-
/**************************************************************************
*********************** Window move/fade helpers *************************
**************************************************************************/
@@ -630,15 +553,11 @@ const MainWindow = new Lang.Class({
this._createRenderer(file);
this._createTexture();
this._createToolbar();
- this._createTitle();
this._gtkWindow.show_all();
},
setTitle : function(label) {
- if (this._clientDecorated)
- this._titleLabel.set_label(label);
-
this._gtkWindow.set_title(label);
},
diff --git a/src/libsushi/sushi-utils.c b/src/libsushi/sushi-utils.c
index 7139dc5..e3e054d 100644
--- a/src/libsushi/sushi-utils.c
+++ b/src/libsushi/sushi-utils.c
@@ -27,66 +27,6 @@
#include <gdk/gdkx.h>
-static void
-_cairo_round_rectangle (cairo_t *cr,
- gdouble x,
- gdouble y,
- gdouble w,
- gdouble h,
- gdouble radius)
-{
- g_return_if_fail (cr != NULL);
-
- if (radius < 0.0001)
- {
- cairo_rectangle (cr, x, y, w, h);
- return;
- }
-
- cairo_move_to (cr, x+radius, y);
- cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
- cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, G_PI * 0.5);
- cairo_arc (cr, x+radius, y+h-radius, radius, G_PI * 0.5, G_PI);
- cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5);
-}
-
-static void
-rounded_background_draw_cb (ClutterCairoTexture *texture,
- cairo_t *cr)
-{
- ClutterActorBox allocation;
-
- clutter_actor_get_allocation_box (CLUTTER_ACTOR (texture), &allocation);
- clutter_cairo_texture_clear (CLUTTER_CAIRO_TEXTURE (texture));
-
- _cairo_round_rectangle (cr, allocation.x1, allocation.y1,
- allocation.x2 - allocation.x1,
- allocation.y2 - allocation.y1,
- 6.0);
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
-
- cairo_fill (cr);
-}
-
-/**
- * sushi_create_rounded_background:
- *
- * Returns: (transfer none): a #ClutterActor
- */
-ClutterActor *
-sushi_create_rounded_background (void)
-{
- ClutterActor *retval;
-
- retval = clutter_cairo_texture_new (1, 1);
- clutter_cairo_texture_set_auto_resize (CLUTTER_CAIRO_TEXTURE (retval), TRUE);
-
- g_signal_connect (retval, "draw",
- G_CALLBACK (rounded_background_draw_cb), NULL);
-
- return retval;
-}
-
/**
* sushi_create_foreign_window:
* @xid:
diff --git a/src/libsushi/sushi-utils.h b/src/libsushi/sushi-utils.h
index f78a35e..21c6c26 100644
--- a/src/libsushi/sushi-utils.h
+++ b/src/libsushi/sushi-utils.h
@@ -32,7 +32,6 @@
G_BEGIN_DECLS
-ClutterActor * sushi_create_rounded_background (void);
GdkWindow * sushi_create_foreign_window (guint xid);
gchar ** sushi_query_supported_document_types (void);
diff --git a/src/resources/gtk-style.css b/src/resources/gtk-style.css
index 587aae7..cca73b7 100644
--- a/src/resources/gtk-style.css
+++ b/src/resources/gtk-style.css
@@ -31,25 +31,25 @@ SushiFontWidget {
background-color: shade (@np_bg_color, 1.70);
}
-.np-decoration {
- font: bold;
+.titlebar {
+ background-color: black;
+ background-image: none;
+ box-shadow: none;
+ border: none;
}
-.np-decoration.button {
+.titlebar .button {
background-image: none;
- padding: 4px;
border-image: none;
border-style: none;
border-radius: 0;
border-width: 0;
- background-color: alpha (#000, 0.0);
-
- -GtkWidget-focus-line-width: 0;
+ background-color: transparent;
box-shadow: none;
}
-.np-decoration.button:hover {
+.titlebar .button:hover {
background-image: -gtk-gradient(linear,
left top,
left bottom,
@@ -58,7 +58,7 @@ SushiFontWidget {
to(alpha(@np_bg_color, 0.0)));
}
-.np-decoration.button:hover:active {
+.titlebar .button:hover:active {
background-image: -gtk-gradient(linear,
left top,
left bottom,
@@ -66,3 +66,8 @@ SushiFontWidget {
color-stop(0.50, @np_bg_color),
to(alpha(@np_bg_color, 0.0)));
}
+
+.window-frame {
+ box-shadow: none;
+ margin: 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]