[lookingGlass] Replace "Hierarchy" with the far more useful "Windows"

I debug the window list a lot more often than I debug actors.
This commit is contained in:
Colin Walters 2010-04-20 14:57:31 -04:00
parent 26c8227df5
commit cf0664fcc6

View File

@ -165,57 +165,49 @@ Result.prototype = {
} }
}; };
function ActorHierarchy() { function WindowList() {
this._init(); this._init();
} }
ActorHierarchy.prototype = { WindowList.prototype = {
_init : function () { _init : function () {
this._previousTarget = null; this.actor = new St.BoxLayout({ name: "Windows", vertical: true, style: "spacing: 8px" });
this._target = null; let display = global.screen.get_display();
let tracker = Shell.WindowTracker.get_default();
this._parentList = []; this._updateId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._updateWindowList));
display.connect('window-created', Lang.bind(this, this._updateWindowList));
this.actor = new St.BoxLayout({ name: "ActorHierarchy", vertical: true }); tracker.connect('tracked-windows-changed', Lang.bind(this, this._updateWindowList));
}, },
setTarget: function(actor) { _updateWindowList: function() {
this._previousTarget = this._target; this.actor.get_children().forEach(function (actor) { actor.destroy(); });
this.target = actor; let windows = global.get_windows();
let tracker = Shell.WindowTracker.get_default();
this.actor.get_children().forEach(function (child) { child.destroy(); }); for (let i = 0; i < windows.length; i++) {
let metaWindow = windows[i].metaWindow;
if (!(actor instanceof Clutter.Actor)) metaWindow.connect('unmanaged', Lang.bind(this, this._updateWindowList));
return; let box = new St.BoxLayout({ vertical: true });
this.actor.add(box);
if (this.target == null) let label = new Link.Link({ label: metaWindow.title, x_align: St.Align.START });
return; label.actor.connect('clicked', Lang.bind(this, function () { this.emit('selected', metaWindow); }));
box.add(label.actor);
this._parentList = []; let propsBox = new St.BoxLayout({ vertical: true, style: 'padding-left: 6px;' });
let parent = actor; box.add(propsBox);
while ((parent = parent.get_parent()) != null) { propsBox.add(new St.Label({ text: "wmclass: " + metaWindow.get_wm_class() }));
this._parentList.push(parent); let app = tracker.get_window_app(metaWindow);
if (app != null && !app.is_transient()) {
let link = new St.Label({ reactive: true, let icon = app.create_icon_texture(22);
text: "" + parent }); let propBox = new St.BoxLayout({ style: 'spacing: 6px; ' });
this.actor.add_actor(link); propsBox.add(propBox);
let parentTarget = parent; propBox.add(new St.Label({ text: "app: " + app.get_id() }), { y_align: St.Align.MIDDLE });
link.connect('button-press-event', Lang.bind(this, function () { propBox.add(icon, { y_align: St.Align.MIDDLE });
this._selectByActor(parentTarget); } else {
return true; propsBox.add(new St.Label({ text: "<untracked>" }));
})); }
} }
this.emit('selection', actor);
},
_selectByActor: function(actor) {
let idx = this._parentList.indexOf(actor);
let children = this.actor.get_children();
let link = children[idx];
this.emit('selection', actor);
} }
}; };
Signals.addSignalMethods(ActorHierarchy.prototype); Signals.addSignalMethods(WindowList.prototype);
function PropertyInspector() { function PropertyInspector() {
this._init(); this._init();
@ -492,7 +484,6 @@ LookingGlass.prototype = {
inspector.connect('target', Lang.bind(this, function(i, target, stageX, stageY) { inspector.connect('target', Lang.bind(this, function(i, target, stageX, stageY) {
this._pushResult('<inspect x:' + stageX + ' y:' + stageY + '>', this._pushResult('<inspect x:' + stageX + ' y:' + stageY + '>',
target); target);
this._hierarchy.setTarget(target);
})); }));
inspector.connect('closed', Lang.bind(this, function() { inspector.connect('closed', Lang.bind(this, function() {
this.actor.show(); this.actor.show();
@ -530,15 +521,15 @@ LookingGlass.prototype = {
})); }));
entryArea.add(this._entry, { expand: true }); entryArea.add(this._entry, { expand: true });
this._hierarchy = new ActorHierarchy();
notebook.appendPage('Hierarchy', this._hierarchy.actor);
this._propInspector = new PropertyInspector(); this._propInspector = new PropertyInspector();
notebook.appendPage('Properties', this._propInspector.actor); notebook.appendPage('Properties', this._propInspector.actor);
this._hierarchy.connect('selection', Lang.bind(this, function (h, actor) {
this._pushResult('<parent selection>', actor); this._windowList = new WindowList();
this._windowList.connect('selected', Lang.bind(this, function(list, window) {
notebook.selectIndex(0); notebook.selectIndex(0);
this._pushResult('<window selection>', window);
})); }));
notebook.appendPage('Windows', this._windowList.actor);
this._errorLog = new ErrorLog(); this._errorLog = new ErrorLog();
notebook.appendPage('Errors', this._errorLog.actor); notebook.appendPage('Errors', this._errorLog.actor);
@ -666,7 +657,6 @@ LookingGlass.prototype = {
} }
this._pushResult(command, resultObj); this._pushResult(command, resultObj);
this._hierarchy.setTarget(null);
this._entry.text = ''; this._entry.text = '';
}, },