screenshot: Don't pick up rubberband style from GTK

Selecting a screen area for a screenshot isn't the same as selecting
items in an icon view, so there's no strong rationale for picking
up the style from GTK. We stopped doing that for other elements like
tile previews long ago, so just use our own style here too.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/481
This commit is contained in:
Florian Müllner 2019-04-04 16:03:54 +02:00 committed by Florian Müllner
parent 4541fb9819
commit a5c75ff58b
2 changed files with 12 additions and 26 deletions

View File

@ -1142,6 +1142,12 @@ StScrollBar {
.ripple-box:rtl { border-radius: 0 0 0 52px; } // just a simple change to the border radius position .ripple-box:rtl { border-radius: 0 0 0 52px; } // just a simple change to the border radius position
// Rubberband for select-area screenshots
.select-area-rubberband {
background-color: transparentize($selected_bg_color,0.7);
border: 1px solid $selected_bg_color;
}
// not really top bar only // not really top bar only
.popup-menu-arrow { icon-size: 1.09em; } .popup-menu-arrow { icon-size: 1.09em; }
.popup-menu-icon { icon-size: 1.09em; } .popup-menu-icon { icon-size: 1.09em; }

View File

@ -1,6 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const { Clutter, Gio, GLib, Gtk, Meta, Shell, St } = imports.gi; const { Clutter, Gio, GLib, Meta, Shell, St } = imports.gi;
const Signals = imports.signals; const Signals = imports.signals;
const GrabHelper = imports.ui.grabHelper; const GrabHelper = imports.ui.grabHelper;
@ -227,8 +227,6 @@ var SelectArea = class {
this._lastY = 0; this._lastY = 0;
this._result = null; this._result = null;
this._initRubberbandColors();
this._group = new St.Widget({ visible: false, this._group = new St.Widget({ visible: false,
reactive: true, reactive: true,
x: 0, x: 0,
@ -248,10 +246,10 @@ var SelectArea = class {
coordinate: Clutter.BindCoordinate.ALL }); coordinate: Clutter.BindCoordinate.ALL });
this._group.add_constraint(constraint); this._group.add_constraint(constraint);
this._rubberband = new Clutter.Rectangle({ color: this._background, this._rubberband = new St.Widget({
has_border: true, style_class: 'select-area-rubberband',
border_width: 1, visible: false
border_color: this._border }); });
this._group.add_actor(this._rubberband); this._group.add_actor(this._rubberband);
} }
@ -265,25 +263,6 @@ var SelectArea = class {
this._group.visible = true; this._group.visible = true;
} }
_initRubberbandColors() {
function colorFromRGBA(rgba) {
return new Clutter.Color({ red: rgba.red * 255,
green: rgba.green * 255,
blue: rgba.blue * 255,
alpha: rgba.alpha * 255 });
}
let path = new Gtk.WidgetPath();
path.append_type(Gtk.IconView);
let context = new Gtk.StyleContext();
context.set_path(path);
context.add_class('rubberband');
this._background = colorFromRGBA(context.get_background_color(Gtk.StateFlags.NORMAL));
this._border = colorFromRGBA(context.get_border_color(Gtk.StateFlags.NORMAL));
}
_getGeometry() { _getGeometry() {
return { x: Math.min(this._startX, this._lastX), return { x: Math.min(this._startX, this._lastX),
y: Math.min(this._startY, this._lastY), y: Math.min(this._startY, this._lastY),
@ -302,6 +281,7 @@ var SelectArea = class {
this._rubberband.set_position(geometry.x, geometry.y); this._rubberband.set_position(geometry.x, geometry.y);
this._rubberband.set_size(geometry.width, geometry.height); this._rubberband.set_size(geometry.width, geometry.height);
this._rubberband.show();
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }