lookingGlass: Don't use a signal callback on 'paint' to draw the border
Instead, use a ClutterEffect, the proper API that has existed for since 1.0. The 'paint' signal will go away for Clutter 2.0. https://bugzilla.gnome.org/show_bug.cgi?id=679464
This commit is contained in:
parent
4448b65a18
commit
a1837dde68
@ -465,29 +465,31 @@ const ObjInspector = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addBorderPaintHook(actor) {
|
const RedBorderEffect = new Lang.Class({
|
||||||
let signalId = actor.connect_after('paint',
|
Name: 'RedBorderEffect',
|
||||||
function () {
|
Extends: Clutter.Effect,
|
||||||
let color = new Cogl.Color();
|
|
||||||
color.init_from_4ub(0xff, 0, 0, 0xc4);
|
|
||||||
Cogl.set_source_color(color);
|
|
||||||
|
|
||||||
let geom = actor.get_allocation_geometry();
|
vfunc_paint: function() {
|
||||||
let width = 2;
|
let actor = this.get_actor();
|
||||||
|
actor.continue_paint();
|
||||||
|
|
||||||
// clockwise order
|
let color = new Cogl.Color();
|
||||||
Cogl.rectangle(0, 0, geom.width, width);
|
color.init_from_4ub(0xff, 0, 0, 0xc4);
|
||||||
Cogl.rectangle(geom.width - width, width,
|
Cogl.set_source_color(color);
|
||||||
geom.width, geom.height);
|
|
||||||
Cogl.rectangle(0, geom.height,
|
|
||||||
geom.width - width, geom.height - width);
|
|
||||||
Cogl.rectangle(0, geom.height - width,
|
|
||||||
width, width);
|
|
||||||
});
|
|
||||||
|
|
||||||
actor.queue_redraw();
|
let geom = actor.get_allocation_geometry();
|
||||||
return signalId;
|
let width = 2;
|
||||||
}
|
|
||||||
|
// clockwise order
|
||||||
|
Cogl.rectangle(0, 0, geom.width, width);
|
||||||
|
Cogl.rectangle(geom.width - width, width,
|
||||||
|
geom.width, geom.height);
|
||||||
|
Cogl.rectangle(0, geom.height,
|
||||||
|
geom.width - width, geom.height - width);
|
||||||
|
Cogl.rectangle(0, geom.height - width,
|
||||||
|
width, width);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const Inspector = new Lang.Class({
|
const Inspector = new Lang.Class({
|
||||||
Name: 'Inspector',
|
Name: 'Inspector',
|
||||||
@ -507,7 +509,7 @@ const Inspector = new Lang.Class({
|
|||||||
eventHandler.add(this._displayText, { expand: true });
|
eventHandler.add(this._displayText, { expand: true });
|
||||||
|
|
||||||
this._borderPaintTarget = null;
|
this._borderPaintTarget = null;
|
||||||
this._borderPaintId = null;
|
this._redBorderEffect = new RedBorderEffect();
|
||||||
eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
|
eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
|
eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
|
||||||
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
|
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
|
||||||
@ -552,7 +554,7 @@ const Inspector = new Lang.Class({
|
|||||||
|
|
||||||
_onDestroy: function() {
|
_onDestroy: function() {
|
||||||
if (this._borderPaintTarget != null)
|
if (this._borderPaintTarget != null)
|
||||||
this._borderPaintTarget.disconnect(this._borderPaintId);
|
this._borderPaintTarget.remove_effect(this._redBorderEffect);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onKeyPressEvent: function (actor, event) {
|
_onKeyPressEvent: function (actor, event) {
|
||||||
@ -625,9 +627,10 @@ const Inspector = new Lang.Class({
|
|||||||
|
|
||||||
if (this._borderPaintTarget != this._target) {
|
if (this._borderPaintTarget != this._target) {
|
||||||
if (this._borderPaintTarget != null)
|
if (this._borderPaintTarget != null)
|
||||||
this._borderPaintTarget.disconnect(this._borderPaintId);
|
this._borderPaintTarget.remove_effect(this._redBorderEffect);
|
||||||
this._borderPaintTarget = this._target;
|
this._borderPaintTarget = this._target;
|
||||||
this._borderPaintId = addBorderPaintHook(this._target);
|
if (this._borderPaintTarget != null)
|
||||||
|
this._borderPaintTarget.add_effect(this._redBorderEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -821,8 +824,7 @@ const LookingGlass = new Lang.Class({
|
|||||||
|
|
||||||
_init : function() {
|
_init : function() {
|
||||||
this._borderPaintTarget = null;
|
this._borderPaintTarget = null;
|
||||||
this._borderPaintId = 0;
|
this._redBorderEffect = new RedBorderEffect();
|
||||||
this._borderDestroyId = 0;
|
|
||||||
|
|
||||||
this._open = false;
|
this._open = false;
|
||||||
|
|
||||||
@ -959,23 +961,22 @@ const LookingGlass = new Lang.Class({
|
|||||||
+ 'font-family: "' + fontDesc.get_family() + '";';
|
+ 'font-family: "' + fontDesc.get_family() + '";';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setBorderPaintTarget: function(obj) {
|
||||||
|
if (this._borderPaintTarget != null)
|
||||||
|
this._borderPaintTarget.remove_effect(this._redBorderEffect);
|
||||||
|
this._borderPaintTarget = obj;
|
||||||
|
if (this._borderPaintTarget != null)
|
||||||
|
this._borderPaintTarget.add_effect(this._redBorderEffect);
|
||||||
|
},
|
||||||
|
|
||||||
_pushResult: function(command, obj) {
|
_pushResult: function(command, obj) {
|
||||||
let index = this._results.length + this._offset;
|
let index = this._results.length + this._offset;
|
||||||
let result = new Result('>>> ' + command, obj, index);
|
let result = new Result('>>> ' + command, obj, index);
|
||||||
this._results.push(result);
|
this._results.push(result);
|
||||||
this._resultsArea.add(result.actor);
|
this._resultsArea.add(result.actor);
|
||||||
if (this._borderPaintTarget != null) {
|
if (obj instanceof Clutter.Actor)
|
||||||
this._borderPaintTarget.disconnect(this._borderPaintId);
|
this._setBorderPaintTarget(obj);
|
||||||
this._borderPaintTarget = null;
|
|
||||||
}
|
|
||||||
if (obj instanceof Clutter.Actor) {
|
|
||||||
this._borderPaintTarget = obj;
|
|
||||||
this._borderPaintId = addBorderPaintHook(obj);
|
|
||||||
this._borderDestroyId = obj.connect('destroy', Lang.bind(this, function () {
|
|
||||||
this._borderDestroyId = 0;
|
|
||||||
this._borderPaintTarget = null;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
let children = this._resultsArea.get_children();
|
let children = this._resultsArea.get_children();
|
||||||
if (children.length > this._maxItems) {
|
if (children.length > this._maxItems) {
|
||||||
this._results.shift();
|
this._results.shift();
|
||||||
@ -1156,11 +1157,7 @@ const LookingGlass = new Lang.Class({
|
|||||||
this._open = false;
|
this._open = false;
|
||||||
Tweener.removeTweens(this.actor);
|
Tweener.removeTweens(this.actor);
|
||||||
|
|
||||||
if (this._borderPaintTarget != null) {
|
this._setBorderPaintTarget(null);
|
||||||
this._borderPaintTarget.disconnect(this._borderPaintId);
|
|
||||||
this._borderPaintTarget.disconnect(this._borderDestroyId);
|
|
||||||
this._borderPaintTarget = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Main.popModal(this._entry);
|
Main.popModal(this._entry);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user