2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2009-08-02 07:46:01 +00:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2011-02-10 19:35:33 +00:00
|
|
|
const Cogl = imports.gi.Cogl;
|
2010-05-15 16:43:56 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
2009-08-02 07:46:01 +00:00
|
|
|
const Gio = imports.gi.Gio;
|
2011-04-20 16:41:22 +00:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2011-09-06 15:35:16 +00:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-08-02 07:46:01 +00:00
|
|
|
const Pango = imports.gi.Pango;
|
2009-09-10 05:38:13 +00:00
|
|
|
const St = imports.gi.St;
|
2009-08-02 07:46:01 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Mainloop = imports.mainloop;
|
2012-07-12 23:59:52 +00:00
|
|
|
const System = imports.system;
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-02-13 16:43:32 +00:00
|
|
|
const History = imports.misc.history;
|
2009-10-28 22:05:34 +00:00
|
|
|
const ExtensionSystem = imports.ui.extensionSystem;
|
2012-01-31 01:58:29 +00:00
|
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
2011-10-11 22:38:24 +00:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
2009-08-02 07:46:01 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
const Main = imports.ui.main;
|
2011-10-29 08:20:49 +00:00
|
|
|
const JsParse = imports.misc.jsParse;
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 22:24:10 +00:00
|
|
|
const CHEVRON = '>>> ';
|
|
|
|
|
2009-09-10 05:38:13 +00:00
|
|
|
/* Imports...feel free to add here as needed */
|
2010-05-13 19:46:04 +00:00
|
|
|
var commandHeader = 'const Clutter = imports.gi.Clutter; ' +
|
|
|
|
'const GLib = imports.gi.GLib; ' +
|
|
|
|
'const Gtk = imports.gi.Gtk; ' +
|
|
|
|
'const Mainloop = imports.mainloop; ' +
|
|
|
|
'const Meta = imports.gi.Meta; ' +
|
|
|
|
'const Shell = imports.gi.Shell; ' +
|
2011-02-26 14:25:39 +00:00
|
|
|
'const Tp = imports.gi.TelepathyGLib; ' +
|
2010-05-13 19:46:04 +00:00
|
|
|
'const Main = imports.ui.main; ' +
|
|
|
|
'const Lang = imports.lang; ' +
|
|
|
|
'const Tweener = imports.ui.tweener; ' +
|
2009-08-02 07:46:01 +00:00
|
|
|
/* Utility functions...we should probably be able to use these
|
|
|
|
* in the shell core code too. */
|
2010-05-13 19:46:04 +00:00
|
|
|
'const stage = global.stage; ' +
|
2009-08-02 07:46:01 +00:00
|
|
|
/* Special lookingGlass functions */
|
2012-12-26 03:16:39 +00:00
|
|
|
'const inspect = Lang.bind(Main.lookingGlass, Main.lookingGlass.inspect); ' +
|
2012-05-30 00:36:45 +00:00
|
|
|
'const it = Main.lookingGlass.getIt(); ' +
|
2010-05-13 19:46:04 +00:00
|
|
|
'const r = Lang.bind(Main.lookingGlass, Main.lookingGlass.getResult); ';
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-02-13 16:43:32 +00:00
|
|
|
const HISTORY_KEY = 'looking-glass-history';
|
2011-10-29 08:20:49 +00:00
|
|
|
// Time between tabs for them to count as a double-tab event
|
|
|
|
const AUTO_COMPLETE_DOUBLE_TAB_DELAY = 500;
|
|
|
|
const AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION = 0.2;
|
|
|
|
const AUTO_COMPLETE_GLOBAL_KEYWORDS = _getAutoCompleteGlobalKeywords();
|
|
|
|
|
|
|
|
function _getAutoCompleteGlobalKeywords() {
|
|
|
|
const keywords = ['true', 'false', 'null', 'new'];
|
|
|
|
// Don't add the private properties of window (i.e., ones starting with '_')
|
|
|
|
const windowProperties = Object.getOwnPropertyNames(window).filter(function(a){ return a.charAt(0) != '_' });
|
|
|
|
const headerProperties = JsParse.getDeclaredConstants(commandHeader);
|
|
|
|
|
|
|
|
return keywords.concat(windowProperties).concat(headerProperties);
|
|
|
|
}
|
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const AutoComplete = new Lang.Class({
|
|
|
|
Name: 'AutoComplete',
|
2011-10-29 08:20:49 +00:00
|
|
|
|
|
|
|
_init: function(entry) {
|
|
|
|
this._entry = entry;
|
|
|
|
this._entry.connect('key-press-event', Lang.bind(this, this._entryKeyPressEvent));
|
|
|
|
this._lastTabTime = global.get_current_time();
|
|
|
|
},
|
|
|
|
|
|
|
|
_processCompletionRequest: function(event) {
|
|
|
|
if (event.completions.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Unique match = go ahead and complete; multiple matches + single tab = complete the common starting string;
|
|
|
|
// multiple matches + double tab = emit a suggest event with all possible options
|
|
|
|
if (event.completions.length == 1) {
|
|
|
|
this.additionalCompletionText(event.completions[0], event.attrHead);
|
|
|
|
this.emit('completion', { completion: event.completions[0], type: 'whole-word' });
|
|
|
|
} else if (event.completions.length > 1 && event.tabType === 'single') {
|
|
|
|
let commonPrefix = JsParse.getCommonPrefix(event.completions);
|
|
|
|
|
|
|
|
if (commonPrefix.length > 0) {
|
|
|
|
this.additionalCompletionText(commonPrefix, event.attrHead);
|
|
|
|
this.emit('completion', { completion: commonPrefix, type: 'prefix' });
|
|
|
|
this.emit('suggest', { completions: event.completions});
|
|
|
|
}
|
|
|
|
} else if (event.completions.length > 1 && event.tabType === 'double') {
|
|
|
|
this.emit('suggest', { completions: event.completions});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_entryKeyPressEvent: function(actor, event) {
|
|
|
|
let cursorPos = this._entry.clutter_text.get_cursor_position();
|
|
|
|
let text = this._entry.get_text();
|
|
|
|
if (cursorPos != -1) {
|
|
|
|
text = text.slice(0, cursorPos);
|
|
|
|
}
|
|
|
|
if (event.get_key_symbol() == Clutter.Tab) {
|
|
|
|
let [completions, attrHead] = JsParse.getCompletions(text, commandHeader, AUTO_COMPLETE_GLOBAL_KEYWORDS);
|
|
|
|
let currTime = global.get_current_time();
|
|
|
|
if ((currTime - this._lastTabTime) < AUTO_COMPLETE_DOUBLE_TAB_DELAY) {
|
|
|
|
this._processCompletionRequest({ tabType: 'double',
|
|
|
|
completions: completions,
|
|
|
|
attrHead: attrHead });
|
|
|
|
} else {
|
|
|
|
this._processCompletionRequest({ tabType: 'single',
|
|
|
|
completions: completions,
|
|
|
|
attrHead: attrHead });
|
|
|
|
}
|
|
|
|
this._lastTabTime = currTime;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Insert characters of text not already included in head at cursor position. i.e., if text="abc" and head="a",
|
|
|
|
// the string "bc" will be appended to this._entry
|
|
|
|
additionalCompletionText: function(text, head) {
|
|
|
|
let additionalCompletionText = text.slice(head.length);
|
|
|
|
let cursorPos = this._entry.clutter_text.get_cursor_position();
|
|
|
|
|
|
|
|
this._entry.clutter_text.insert_text(additionalCompletionText, cursorPos);
|
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2011-10-29 08:20:49 +00:00
|
|
|
Signals.addSignalMethods(AutoComplete.prototype);
|
|
|
|
|
2011-02-13 16:43:32 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Notebook = new Lang.Class({
|
|
|
|
Name: 'Notebook',
|
2009-08-04 13:49:03 +00:00
|
|
|
|
|
|
|
_init: function() {
|
2009-09-10 05:38:13 +00:00
|
|
|
this.actor = new St.BoxLayout({ vertical: true });
|
2009-08-04 13:49:03 +00:00
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
this.tabControls = new St.BoxLayout({ style_class: 'labels' });
|
2009-08-04 13:49:03 +00:00
|
|
|
|
|
|
|
this._selectedIndex = -1;
|
|
|
|
this._tabs = [];
|
|
|
|
},
|
|
|
|
|
|
|
|
appendPage: function(name, child) {
|
2010-05-15 16:43:56 +00:00
|
|
|
let labelBox = new St.BoxLayout({ style_class: 'notebook-tab',
|
|
|
|
reactive: true,
|
|
|
|
track_hover: true });
|
2009-10-27 17:27:00 +00:00
|
|
|
let label = new St.Button({ label: name });
|
|
|
|
label.connect('clicked', Lang.bind(this, function () {
|
2009-08-04 13:49:03 +00:00
|
|
|
this.selectChild(child);
|
|
|
|
return true;
|
|
|
|
}));
|
2009-09-10 05:38:13 +00:00
|
|
|
labelBox.add(label, { expand: true });
|
2009-10-27 17:27:00 +00:00
|
|
|
this.tabControls.add(labelBox);
|
2009-09-10 05:38:13 +00:00
|
|
|
|
|
|
|
let scrollview = new St.ScrollView({ x_fill: true, y_fill: true });
|
|
|
|
scrollview.get_hscroll_bar().hide();
|
|
|
|
scrollview.add_actor(child);
|
|
|
|
|
2009-10-09 00:11:45 +00:00
|
|
|
let tabData = { child: child,
|
|
|
|
labelBox: labelBox,
|
2009-10-27 17:27:00 +00:00
|
|
|
label: label,
|
2009-10-09 00:11:45 +00:00
|
|
|
scrollView: scrollview,
|
|
|
|
_scrollToBottom: false };
|
|
|
|
this._tabs.push(tabData);
|
2009-09-10 05:38:13 +00:00
|
|
|
scrollview.hide();
|
|
|
|
this.actor.add(scrollview, { expand: true });
|
|
|
|
|
2009-10-09 00:11:45 +00:00
|
|
|
let vAdjust = scrollview.vscroll.adjustment;
|
|
|
|
vAdjust.connect('changed', Lang.bind(this, function () { this._onAdjustScopeChanged(tabData); }));
|
|
|
|
vAdjust.connect('notify::value', Lang.bind(this, function() { this._onAdjustValueChanged(tabData); }));
|
|
|
|
|
2009-08-04 13:49:03 +00:00
|
|
|
if (this._selectedIndex == -1)
|
|
|
|
this.selectIndex(0);
|
|
|
|
},
|
|
|
|
|
|
|
|
_unselect: function() {
|
|
|
|
if (this._selectedIndex < 0)
|
|
|
|
return;
|
2009-10-09 00:11:45 +00:00
|
|
|
let tabData = this._tabs[this._selectedIndex];
|
2010-03-19 15:37:04 +00:00
|
|
|
tabData.labelBox.remove_style_pseudo_class('selected');
|
2009-10-09 00:11:45 +00:00
|
|
|
tabData.scrollView.hide();
|
2009-08-04 13:49:03 +00:00
|
|
|
this._selectedIndex = -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
selectIndex: function(index) {
|
|
|
|
if (index == this._selectedIndex)
|
|
|
|
return;
|
|
|
|
if (index < 0) {
|
2011-04-20 16:41:22 +00:00
|
|
|
this._unselect();
|
2009-08-04 13:49:03 +00:00
|
|
|
this.emit('selection', null);
|
|
|
|
return;
|
|
|
|
}
|
2011-04-20 16:41:22 +00:00
|
|
|
|
|
|
|
// Focus the new tab before unmapping the old one
|
2009-10-09 00:11:45 +00:00
|
|
|
let tabData = this._tabs[index];
|
2011-04-20 16:41:22 +00:00
|
|
|
if (!tabData.scrollView.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false))
|
|
|
|
this.actor.grab_key_focus();
|
|
|
|
|
|
|
|
this._unselect();
|
|
|
|
|
2010-03-19 15:37:04 +00:00
|
|
|
tabData.labelBox.add_style_pseudo_class('selected');
|
2009-10-09 00:11:45 +00:00
|
|
|
tabData.scrollView.show();
|
2009-08-04 13:49:03 +00:00
|
|
|
this._selectedIndex = index;
|
2009-10-09 00:11:45 +00:00
|
|
|
this.emit('selection', tabData.child);
|
2009-08-04 13:49:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
selectChild: function(child) {
|
|
|
|
if (child == null)
|
|
|
|
this.selectIndex(-1);
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < this._tabs.length; i++) {
|
2009-10-09 00:11:45 +00:00
|
|
|
let tabData = this._tabs[i];
|
|
|
|
if (tabData.child == child) {
|
2009-08-04 13:49:03 +00:00
|
|
|
this.selectIndex(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-09 00:11:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
scrollToBottom: function(index) {
|
|
|
|
let tabData = this._tabs[index];
|
|
|
|
tabData._scrollToBottom = true;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_onAdjustValueChanged: function (tabData) {
|
|
|
|
let vAdjust = tabData.scrollView.vscroll.adjustment;
|
|
|
|
if (vAdjust.value < (vAdjust.upper - vAdjust.lower - 0.5))
|
|
|
|
tabData._scrolltoBottom = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onAdjustScopeChanged: function (tabData) {
|
|
|
|
if (!tabData._scrollToBottom)
|
|
|
|
return;
|
|
|
|
let vAdjust = tabData.scrollView.vscroll.adjustment;
|
|
|
|
vAdjust.value = vAdjust.upper - vAdjust.page_size;
|
2011-10-21 05:23:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
nextTab: function() {
|
|
|
|
let nextIndex = this._selectedIndex;
|
|
|
|
if (nextIndex < this._tabs.length - 1) {
|
|
|
|
++nextIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.selectIndex(nextIndex);
|
|
|
|
},
|
|
|
|
|
|
|
|
prevTab: function() {
|
|
|
|
let prevIndex = this._selectedIndex;
|
|
|
|
if (prevIndex > 0) {
|
|
|
|
--prevIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.selectIndex(prevIndex);
|
2009-08-04 13:49:03 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-04 13:49:03 +00:00
|
|
|
Signals.addSignalMethods(Notebook.prototype);
|
|
|
|
|
2010-05-15 16:43:56 +00:00
|
|
|
function objectToString(o) {
|
|
|
|
if (typeof(o) == typeof(objectToString)) {
|
|
|
|
// special case this since the default is way, way too verbose
|
2011-09-30 21:30:47 +00:00
|
|
|
return '<js function>';
|
2010-05-15 16:43:56 +00:00
|
|
|
} else {
|
2011-10-04 20:50:51 +00:00
|
|
|
return '' + o;
|
2010-05-15 16:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 16:07:14 +00:00
|
|
|
const ObjLink = new Lang.Class({
|
|
|
|
Name: 'ObjLink',
|
2010-05-15 16:43:56 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
_init: function(lookingGlass, o, title) {
|
2010-05-15 16:43:56 +00:00
|
|
|
let text;
|
|
|
|
if (title)
|
|
|
|
text = title;
|
|
|
|
else
|
|
|
|
text = objectToString(o);
|
|
|
|
text = GLib.markup_escape_text(text, -1);
|
|
|
|
this._obj = o;
|
2011-11-20 16:07:14 +00:00
|
|
|
|
2012-07-14 22:49:06 +00:00
|
|
|
this.actor = new St.Button({ reactive: true,
|
|
|
|
track_hover: true,
|
|
|
|
style_class: 'shell-link',
|
|
|
|
label: text });
|
2010-05-15 16:43:56 +00:00
|
|
|
this.actor.get_child().single_line_mode = true;
|
|
|
|
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
2012-07-14 23:29:55 +00:00
|
|
|
|
|
|
|
this._lookingGlass = lookingGlass;
|
2010-05-15 16:43:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onClicked: function (link) {
|
2012-07-14 23:29:55 +00:00
|
|
|
this._lookingGlass.inspectObject(this._obj, this.actor);
|
2010-05-15 16:43:56 +00:00
|
|
|
}
|
2011-11-20 16:07:14 +00:00
|
|
|
});
|
2010-05-15 16:43:56 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Result = new Lang.Class({
|
|
|
|
Name: 'Result',
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
_init: function(lookingGlass, command, o, index) {
|
2009-08-02 07:46:01 +00:00
|
|
|
this.index = index;
|
|
|
|
this.o = o;
|
|
|
|
|
2010-03-31 20:40:32 +00:00
|
|
|
this.actor = new St.BoxLayout({ vertical: true });
|
2012-07-14 23:29:55 +00:00
|
|
|
this._lookingGlass = lookingGlass;
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2009-09-10 05:38:13 +00:00
|
|
|
let cmdTxt = new St.Label({ text: command });
|
2010-05-15 16:43:56 +00:00
|
|
|
cmdTxt.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
2010-03-31 20:40:32 +00:00
|
|
|
this.actor.add(cmdTxt);
|
2010-05-15 16:43:56 +00:00
|
|
|
let box = new St.BoxLayout({});
|
|
|
|
this.actor.add(box);
|
|
|
|
let resultTxt = new St.Label({ text: 'r(' + index + ') = ' });
|
|
|
|
resultTxt.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
|
|
|
box.add(resultTxt);
|
2012-07-14 23:29:55 +00:00
|
|
|
let objLink = new ObjLink(this._lookingGlass, o);
|
2010-05-15 16:43:56 +00:00
|
|
|
box.add(objLink.actor);
|
|
|
|
let line = new Clutter.Rectangle({ name: 'Separator' });
|
2010-05-13 19:46:04 +00:00
|
|
|
let padBin = new St.Bin({ name: 'Separator', x_fill: true, y_fill: true });
|
2009-09-10 05:38:13 +00:00
|
|
|
padBin.add_actor(line);
|
2010-03-31 20:40:32 +00:00
|
|
|
this.actor.add(padBin);
|
2009-08-02 07:46:01 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const WindowList = new Lang.Class({
|
|
|
|
Name: 'WindowList',
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
_init: function(lookingGlass) {
|
2010-05-13 19:46:04 +00:00
|
|
|
this.actor = new St.BoxLayout({ name: 'Windows', vertical: true, style: 'spacing: 8px' });
|
2010-04-20 18:57:31 +00:00
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
|
|
|
this._updateId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._updateWindowList));
|
2011-07-13 16:34:31 +00:00
|
|
|
global.display.connect('window-created', Lang.bind(this, this._updateWindowList));
|
2010-04-20 18:57:31 +00:00
|
|
|
tracker.connect('tracked-windows-changed', Lang.bind(this, this._updateWindowList));
|
2012-07-14 23:29:55 +00:00
|
|
|
|
|
|
|
this._lookingGlass = lookingGlass;
|
2009-08-02 07:46:01 +00:00
|
|
|
},
|
|
|
|
|
2010-04-20 18:57:31 +00:00
|
|
|
_updateWindowList: function() {
|
2012-05-30 00:36:45 +00:00
|
|
|
this.actor.destroy_all_children();
|
2010-10-19 18:55:43 +00:00
|
|
|
let windows = global.get_window_actors();
|
2010-04-20 18:57:31 +00:00
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
let metaWindow = windows[i].metaWindow;
|
2010-05-30 20:48:41 +00:00
|
|
|
// Avoid multiple connections
|
|
|
|
if (!metaWindow._lookingGlassManaged) {
|
|
|
|
metaWindow.connect('unmanaged', Lang.bind(this, this._updateWindowList));
|
|
|
|
metaWindow._lookingGlassManaged = true;
|
|
|
|
}
|
2010-04-20 18:57:31 +00:00
|
|
|
let box = new St.BoxLayout({ vertical: true });
|
|
|
|
this.actor.add(box);
|
2012-07-14 23:29:55 +00:00
|
|
|
let windowLink = new ObjLink(this._lookingGlass, metaWindow, metaWindow.title);
|
2010-05-15 16:43:56 +00:00
|
|
|
box.add(windowLink.actor, { x_align: St.Align.START, x_fill: false });
|
2010-04-20 18:57:31 +00:00
|
|
|
let propsBox = new St.BoxLayout({ vertical: true, style: 'padding-left: 6px;' });
|
|
|
|
box.add(propsBox);
|
2010-05-13 19:46:04 +00:00
|
|
|
propsBox.add(new St.Label({ text: 'wmclass: ' + metaWindow.get_wm_class() }));
|
2010-04-20 18:57:31 +00:00
|
|
|
let app = tracker.get_window_app(metaWindow);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 17:35:01 +00:00
|
|
|
if (app != null && !app.is_window_backed()) {
|
2010-04-20 18:57:31 +00:00
|
|
|
let icon = app.create_icon_texture(22);
|
|
|
|
let propBox = new St.BoxLayout({ style: 'spacing: 6px; ' });
|
|
|
|
propsBox.add(propBox);
|
2010-05-15 16:43:56 +00:00
|
|
|
propBox.add(new St.Label({ text: 'app: ' }), { y_fill: false });
|
2012-07-14 23:29:55 +00:00
|
|
|
let appLink = new ObjLink(this._lookingGlass, app, app.get_id());
|
2010-05-15 16:43:56 +00:00
|
|
|
propBox.add(appLink.actor, { y_fill: false });
|
|
|
|
propBox.add(icon, { y_fill: false });
|
2010-04-20 18:57:31 +00:00
|
|
|
} else {
|
2010-05-13 19:46:04 +00:00
|
|
|
propsBox.add(new St.Label({ text: '<untracked>' }));
|
2010-04-20 18:57:31 +00:00
|
|
|
}
|
2009-08-02 07:46:01 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2010-04-20 18:57:31 +00:00
|
|
|
Signals.addSignalMethods(WindowList.prototype);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const ObjInspector = new Lang.Class({
|
|
|
|
Name: 'ObjInspector',
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
_init: function(lookingGlass) {
|
2010-05-15 16:43:56 +00:00
|
|
|
this._obj = null;
|
|
|
|
this._previousObj = null;
|
2009-08-02 07:46:01 +00:00
|
|
|
|
|
|
|
this._parentList = [];
|
|
|
|
|
2012-09-05 19:23:54 +00:00
|
|
|
this.actor = new St.ScrollView({ pivot_point: new Clutter.Point({ x: 0.5, y: 0.5 }),
|
|
|
|
x_fill: true, y_fill: true });
|
2010-05-15 16:43:56 +00:00
|
|
|
this.actor.get_hscroll_bar().hide();
|
|
|
|
this._container = new St.BoxLayout({ name: 'LookingGlassPropertyInspector',
|
|
|
|
style_class: 'lg-dialog',
|
|
|
|
vertical: true });
|
|
|
|
this.actor.add_actor(this._container);
|
2012-07-14 23:29:55 +00:00
|
|
|
|
|
|
|
this._lookingGlass = lookingGlass;
|
2009-08-02 07:46:01 +00:00
|
|
|
},
|
|
|
|
|
2010-05-15 16:43:56 +00:00
|
|
|
selectObject: function(obj, skipPrevious) {
|
|
|
|
if (!skipPrevious)
|
|
|
|
this._previousObj = this._obj;
|
|
|
|
else
|
|
|
|
this._previousObj = null;
|
|
|
|
this._obj = obj;
|
|
|
|
|
2012-05-30 00:36:45 +00:00
|
|
|
this._container.destroy_all_children();
|
2010-05-15 16:43:56 +00:00
|
|
|
|
|
|
|
let hbox = new St.BoxLayout({ style_class: 'lg-obj-inspector-title' });
|
|
|
|
this._container.add_actor(hbox);
|
|
|
|
let label = new St.Label({ text: 'Inspecting: %s: %s'.format(typeof(obj),
|
|
|
|
objectToString(obj)) });
|
|
|
|
label.single_line_mode = true;
|
|
|
|
hbox.add(label, { expand: true, y_fill: false });
|
|
|
|
let button = new St.Button({ label: 'Insert', style_class: 'lg-obj-inspector-button' });
|
|
|
|
button.connect('clicked', Lang.bind(this, this._onInsert));
|
|
|
|
hbox.add(button);
|
|
|
|
|
|
|
|
if (this._previousObj != null) {
|
|
|
|
button = new St.Button({ label: 'Back', style_class: 'lg-obj-inspector-button' });
|
|
|
|
button.connect('clicked', Lang.bind(this, this._onBack));
|
|
|
|
hbox.add(button);
|
|
|
|
}
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2010-05-15 16:43:56 +00:00
|
|
|
button = new St.Button({ style_class: 'window-close' });
|
|
|
|
button.connect('clicked', Lang.bind(this, this.close));
|
|
|
|
hbox.add(button);
|
|
|
|
if (typeof(obj) == typeof({})) {
|
2012-03-30 15:15:33 +00:00
|
|
|
let properties = [];
|
2010-05-15 16:43:56 +00:00
|
|
|
for (let propName in obj) {
|
2012-03-30 15:15:33 +00:00
|
|
|
properties.push(propName);
|
|
|
|
}
|
|
|
|
properties.sort();
|
|
|
|
|
|
|
|
for (let i = 0; i < properties.length; i++) {
|
|
|
|
let propName = properties[i];
|
2010-05-15 16:43:56 +00:00
|
|
|
let valueStr;
|
|
|
|
let link;
|
|
|
|
try {
|
|
|
|
let prop = obj[propName];
|
2012-07-14 23:29:55 +00:00
|
|
|
link = new ObjLink(this._lookingGlass, prop).actor;
|
2010-05-15 16:43:56 +00:00
|
|
|
} catch (e) {
|
|
|
|
link = new St.Label({ text: '<error>' });
|
|
|
|
}
|
|
|
|
let hbox = new St.BoxLayout();
|
2011-09-30 21:30:47 +00:00
|
|
|
let propText = propName + ': ' + valueStr;
|
2010-05-15 16:43:56 +00:00
|
|
|
hbox.add(new St.Label({ text: propName + ': ' }));
|
|
|
|
hbox.add(link);
|
|
|
|
this._container.add_actor(hbox);
|
2009-08-02 07:46:01 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-15 16:43:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
open: function(sourceActor) {
|
|
|
|
if (this._open)
|
|
|
|
return;
|
|
|
|
this._previousObj = null;
|
|
|
|
this._open = true;
|
|
|
|
this.actor.show();
|
|
|
|
if (sourceActor) {
|
|
|
|
this.actor.set_scale(0, 0);
|
|
|
|
Tweener.addTween(this.actor, { scale_x: 1, scale_y: 1,
|
2011-09-30 21:30:47 +00:00
|
|
|
transition: 'easeOutQuad',
|
2010-05-15 16:43:56 +00:00
|
|
|
time: 0.2 });
|
|
|
|
} else {
|
|
|
|
this.actor.set_scale(1, 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
close: function() {
|
|
|
|
if (!this._open)
|
|
|
|
return;
|
|
|
|
this._open = false;
|
|
|
|
this.actor.hide();
|
|
|
|
this._previousObj = null;
|
|
|
|
this._obj = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onInsert: function() {
|
|
|
|
let obj = this._obj;
|
|
|
|
this.close();
|
2012-07-14 23:29:55 +00:00
|
|
|
this._lookingGlass.insertObject(obj);
|
2010-05-15 16:43:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onBack: function() {
|
|
|
|
this.selectObject(this._previousObj, true);
|
2009-08-02 07:46:01 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-06-21 18:42:33 +00:00
|
|
|
const RedBorderEffect = new Lang.Class({
|
|
|
|
Name: 'RedBorderEffect',
|
|
|
|
Extends: Clutter.Effect,
|
|
|
|
|
|
|
|
vfunc_paint: function() {
|
|
|
|
let actor = this.get_actor();
|
|
|
|
actor.continue_paint();
|
|
|
|
|
|
|
|
let color = new Cogl.Color();
|
|
|
|
color.init_from_4ub(0xff, 0, 0, 0xc4);
|
|
|
|
Cogl.set_source_color(color);
|
|
|
|
|
|
|
|
let geom = actor.get_allocation_geometry();
|
|
|
|
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);
|
|
|
|
},
|
|
|
|
});
|
2011-02-10 19:35:33 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Inspector = new Lang.Class({
|
|
|
|
Name: 'Inspector',
|
2009-08-04 13:49:03 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
_init: function(lookingGlass) {
|
2010-07-21 15:50:58 +00:00
|
|
|
let container = new Shell.GenericContainer({ width: 0,
|
|
|
|
height: 0 });
|
|
|
|
container.connect('allocate', Lang.bind(this, this._allocate));
|
|
|
|
Main.uiGroup.add_actor(container);
|
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
let eventHandler = new St.BoxLayout({ name: 'LookingGlassDialog',
|
2009-09-10 05:38:13 +00:00
|
|
|
vertical: false,
|
|
|
|
reactive: true });
|
2010-07-21 15:08:15 +00:00
|
|
|
this._eventHandler = eventHandler;
|
2010-07-21 15:50:58 +00:00
|
|
|
container.add_actor(eventHandler);
|
2010-07-21 15:08:15 +00:00
|
|
|
this._displayText = new St.Label();
|
|
|
|
eventHandler.add(this._displayText, { expand: true });
|
2009-08-04 13:49:03 +00:00
|
|
|
|
2010-07-21 15:37:08 +00:00
|
|
|
eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
|
2010-07-21 15:08:15 +00:00
|
|
|
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
|
2010-07-21 15:29:05 +00:00
|
|
|
eventHandler.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
2010-07-21 15:08:15 +00:00
|
|
|
eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
|
2009-08-04 13:49:03 +00:00
|
|
|
Clutter.grab_pointer(eventHandler);
|
2010-07-21 15:37:08 +00:00
|
|
|
Clutter.grab_keyboard(eventHandler);
|
2010-07-21 15:29:05 +00:00
|
|
|
|
|
|
|
// this._target is the actor currently shown by the inspector.
|
|
|
|
// this._pointerTarget is the actor directly under the pointer.
|
|
|
|
// Normally these are the same, but if you use the scroll wheel
|
|
|
|
// to drill down, they'll diverge until you either scroll back
|
|
|
|
// out, or move the pointer outside of _pointerTarget.
|
|
|
|
this._target = null;
|
|
|
|
this._pointerTarget = null;
|
2012-07-14 23:29:55 +00:00
|
|
|
|
|
|
|
this._lookingGlass = lookingGlass;
|
2010-07-21 15:29:05 +00:00
|
|
|
},
|
|
|
|
|
2010-07-21 15:50:58 +00:00
|
|
|
_allocate: function(actor, box, flags) {
|
2011-01-11 20:14:16 +00:00
|
|
|
if (!this._eventHandler)
|
|
|
|
return;
|
|
|
|
|
2011-06-13 13:54:05 +00:00
|
|
|
let primary = Main.layoutManager.primaryMonitor;
|
2010-07-21 15:50:58 +00:00
|
|
|
|
|
|
|
let [minWidth, minHeight, natWidth, natHeight] =
|
|
|
|
this._eventHandler.get_preferred_size();
|
|
|
|
|
|
|
|
let childBox = new Clutter.ActorBox();
|
|
|
|
childBox.x1 = primary.x + Math.floor((primary.width - natWidth) / 2);
|
|
|
|
childBox.x2 = childBox.x1 + natWidth;
|
|
|
|
childBox.y1 = primary.y + Math.floor((primary.height - natHeight) / 2);
|
|
|
|
childBox.y2 = childBox.y1 + natHeight;
|
|
|
|
this._eventHandler.allocate(childBox, flags);
|
|
|
|
},
|
|
|
|
|
2010-07-21 15:29:05 +00:00
|
|
|
_close: function() {
|
2012-07-24 18:11:17 +00:00
|
|
|
Clutter.ungrab_pointer();
|
|
|
|
Clutter.ungrab_keyboard();
|
2010-07-21 15:29:05 +00:00
|
|
|
this._eventHandler.destroy();
|
2011-01-11 20:14:16 +00:00
|
|
|
this._eventHandler = null;
|
2010-07-21 15:29:05 +00:00
|
|
|
this.emit('closed');
|
2010-07-21 15:08:15 +00:00
|
|
|
},
|
|
|
|
|
2010-07-21 15:37:08 +00:00
|
|
|
_onKeyPressEvent: function (actor, event) {
|
|
|
|
if (event.get_key_symbol() == Clutter.Escape)
|
|
|
|
this._close();
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2010-07-21 15:08:15 +00:00
|
|
|
_onButtonPressEvent: function (actor, event) {
|
2010-07-21 15:29:05 +00:00
|
|
|
if (this._target) {
|
|
|
|
let [stageX, stageY] = event.get_coords();
|
|
|
|
this.emit('target', this._target, stageX, stageY);
|
|
|
|
}
|
|
|
|
this._close();
|
|
|
|
return true;
|
|
|
|
},
|
2010-07-21 15:08:15 +00:00
|
|
|
|
2010-07-21 15:29:05 +00:00
|
|
|
_onScrollEvent: function (actor, event) {
|
|
|
|
switch (event.get_scroll_direction()) {
|
|
|
|
case Clutter.ScrollDirection.UP:
|
|
|
|
// select parent
|
|
|
|
let parent = this._target.get_parent();
|
|
|
|
if (parent != null) {
|
|
|
|
this._target = parent;
|
|
|
|
this._update(event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Clutter.ScrollDirection.DOWN:
|
|
|
|
// select child
|
|
|
|
if (this._target != this._pointerTarget) {
|
|
|
|
let child = this._pointerTarget;
|
|
|
|
while (child) {
|
|
|
|
let parent = child.get_parent();
|
|
|
|
if (parent == this._target)
|
|
|
|
break;
|
|
|
|
child = parent;
|
|
|
|
}
|
|
|
|
if (child) {
|
|
|
|
this._target = child;
|
|
|
|
this._update(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-07-21 15:08:15 +00:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onMotionEvent: function (actor, event) {
|
2010-07-21 15:29:05 +00:00
|
|
|
this._update(event);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_update: function(event) {
|
2010-07-21 15:08:15 +00:00
|
|
|
let [stageX, stageY] = event.get_coords();
|
|
|
|
let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
|
|
|
|
stageX,
|
|
|
|
stageY);
|
2010-07-21 15:29:05 +00:00
|
|
|
|
|
|
|
if (target != this._pointerTarget)
|
|
|
|
this._target = target;
|
|
|
|
this._pointerTarget = target;
|
|
|
|
|
2010-07-21 15:08:15 +00:00
|
|
|
let position = '[inspect x: ' + stageX + ' y: ' + stageY + ']';
|
|
|
|
this._displayText.text = '';
|
2010-07-21 15:29:05 +00:00
|
|
|
this._displayText.text = position + ' ' + this._target;
|
2011-02-10 19:35:33 +00:00
|
|
|
|
2012-07-14 23:30:47 +00:00
|
|
|
this._lookingGlass.setBorderPaintTarget(this._target);
|
2009-08-04 13:49:03 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-04 13:49:03 +00:00
|
|
|
|
|
|
|
Signals.addSignalMethods(Inspector.prototype);
|
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Memory = new Lang.Class({
|
|
|
|
Name: 'Memory',
|
2011-05-20 19:50:54 +00:00
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this.actor = new St.BoxLayout({ vertical: true });
|
|
|
|
this._glibc_uordblks = new St.Label();
|
|
|
|
this.actor.add(this._glibc_uordblks);
|
|
|
|
|
|
|
|
this._js_bytes = new St.Label();
|
|
|
|
this.actor.add(this._js_bytes);
|
|
|
|
|
|
|
|
this._gjs_boxed = new St.Label();
|
|
|
|
this.actor.add(this._gjs_boxed);
|
|
|
|
|
|
|
|
this._gjs_gobject = new St.Label();
|
|
|
|
this.actor.add(this._gjs_gobject);
|
|
|
|
|
|
|
|
this._gjs_function = new St.Label();
|
|
|
|
this.actor.add(this._gjs_function);
|
|
|
|
|
|
|
|
this._gjs_closure = new St.Label();
|
|
|
|
this.actor.add(this._gjs_closure);
|
|
|
|
|
2011-09-15 23:36:07 +00:00
|
|
|
this._last_gc_seconds_ago = new St.Label();
|
|
|
|
this.actor.add(this._last_gc_seconds_ago);
|
|
|
|
|
2011-05-20 19:50:54 +00:00
|
|
|
this._gcbutton = new St.Button({ label: 'Full GC',
|
|
|
|
style_class: 'lg-obj-inspector-button' });
|
2012-07-12 23:59:52 +00:00
|
|
|
this._gcbutton.connect('clicked', Lang.bind(this, function () { System.gc(); this._renderText(); }));
|
2011-05-20 19:50:54 +00:00
|
|
|
this.actor.add(this._gcbutton, { x_align: St.Align.START,
|
|
|
|
x_fill: false });
|
|
|
|
|
|
|
|
this.actor.connect('notify::mapped', Lang.bind(this, this._renderText));
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderText: function() {
|
|
|
|
if (!this.actor.mapped)
|
|
|
|
return;
|
|
|
|
let memInfo = global.get_memory_info();
|
|
|
|
this._glibc_uordblks.text = 'glibc_uordblks: ' + memInfo.glibc_uordblks;
|
|
|
|
this._js_bytes.text = 'js bytes: ' + memInfo.js_bytes;
|
|
|
|
this._gjs_boxed.text = 'gjs_boxed: ' + memInfo.gjs_boxed;
|
|
|
|
this._gjs_gobject.text = 'gjs_gobject: ' + memInfo.gjs_gobject;
|
|
|
|
this._gjs_function.text = 'gjs_function: ' + memInfo.gjs_function;
|
|
|
|
this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure;
|
2011-09-15 23:36:07 +00:00
|
|
|
this._last_gc_seconds_ago.text = 'last_gc_seconds_ago: ' + memInfo.last_gc_seconds_ago;
|
2011-05-20 19:50:54 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2011-05-20 19:50:54 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Extensions = new Lang.Class({
|
|
|
|
Name: 'Extensions',
|
2009-10-28 22:05:34 +00:00
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this.actor = new St.BoxLayout({ vertical: true,
|
|
|
|
name: 'lookingGlassExtensions' });
|
|
|
|
this._noExtensions = new St.Label({ style_class: 'lg-extensions-none',
|
|
|
|
text: _("No extensions installed") });
|
2011-06-11 04:21:35 +00:00
|
|
|
this._numExtensions = 0;
|
2009-10-28 22:05:34 +00:00
|
|
|
this._extensionsList = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'lg-extensions-list' });
|
2011-06-11 04:21:35 +00:00
|
|
|
this._extensionsList.add(this._noExtensions);
|
2009-10-28 22:05:34 +00:00
|
|
|
this.actor.add(this._extensionsList);
|
2011-06-11 04:21:35 +00:00
|
|
|
|
2012-01-31 01:58:29 +00:00
|
|
|
for (let uuid in ExtensionUtils.extensions)
|
2011-06-11 04:21:35 +00:00
|
|
|
this._loadExtension(null, uuid);
|
|
|
|
|
|
|
|
ExtensionSystem.connect('extension-loaded',
|
|
|
|
Lang.bind(this, this._loadExtension));
|
2009-10-28 22:05:34 +00:00
|
|
|
},
|
|
|
|
|
2011-06-11 04:21:35 +00:00
|
|
|
_loadExtension: function(o, uuid) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = ExtensionUtils.extensions[uuid];
|
2011-06-11 04:21:35 +00:00
|
|
|
// There can be cases where we create dummy extension metadata
|
|
|
|
// that's not really a proper extension. Don't bother with these.
|
2012-01-31 01:58:29 +00:00
|
|
|
if (!extension.metadata.name)
|
2011-06-11 04:21:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
let extensionDisplay = this._createExtensionDisplay(extension);
|
|
|
|
if (this._numExtensions == 0)
|
|
|
|
this._extensionsList.remove_actor(this._noExtensions);
|
|
|
|
|
|
|
|
this._numExtensions ++;
|
|
|
|
this._extensionsList.add(extensionDisplay);
|
2009-10-28 22:05:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onViewSource: function (actor) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = actor._extension;
|
|
|
|
let uri = extension.dir.get_uri();
|
2009-10-28 22:05:34 +00:00
|
|
|
Gio.app_info_launch_default_for_uri(uri, global.create_app_launch_context());
|
2012-07-14 23:29:55 +00:00
|
|
|
this._lookingGlass.close();
|
2009-10-28 22:05:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onWebPage: function (actor) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = actor._extension;
|
|
|
|
Gio.app_info_launch_default_for_uri(extension.metadata.url, global.create_app_launch_context());
|
2012-07-14 23:29:55 +00:00
|
|
|
this._lookingGlass.close();
|
2009-10-28 22:05:34 +00:00
|
|
|
},
|
|
|
|
|
2011-09-30 07:58:44 +00:00
|
|
|
_onViewErrors: function (actor) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = actor._extension;
|
2011-09-30 07:58:44 +00:00
|
|
|
let shouldShow = !actor._isShowing;
|
|
|
|
|
|
|
|
if (shouldShow) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let errors = extension.errors;
|
2011-09-30 07:58:44 +00:00
|
|
|
let errorDisplay = new St.BoxLayout({ vertical: true });
|
|
|
|
if (errors && errors.length) {
|
|
|
|
for (let i = 0; i < errors.length; i ++)
|
|
|
|
errorDisplay.add(new St.Label({ text: errors[i] }));
|
|
|
|
} else {
|
|
|
|
/* Translators: argument is an extension UUID. */
|
2012-02-08 17:59:02 +00:00
|
|
|
let message = _("%s has not emitted any errors.").format(extension.uuid);
|
2011-09-30 07:58:44 +00:00
|
|
|
errorDisplay.add(new St.Label({ text: message }));
|
|
|
|
}
|
|
|
|
|
|
|
|
actor._errorDisplay = errorDisplay;
|
|
|
|
actor._parentBox.add(errorDisplay);
|
|
|
|
actor.label = _("Hide Errors");
|
|
|
|
} else {
|
|
|
|
actor._errorDisplay.destroy();
|
|
|
|
actor._errorDisplay = null;
|
|
|
|
actor.label = _("Show Errors");
|
|
|
|
}
|
|
|
|
|
|
|
|
actor._isShowing = shouldShow;
|
|
|
|
},
|
|
|
|
|
2009-10-28 22:05:34 +00:00
|
|
|
_stateToString: function(extensionState) {
|
|
|
|
switch (extensionState) {
|
|
|
|
case ExtensionSystem.ExtensionState.ENABLED:
|
|
|
|
return _("Enabled");
|
|
|
|
case ExtensionSystem.ExtensionState.DISABLED:
|
2011-10-25 18:38:25 +00:00
|
|
|
case ExtensionSystem.ExtensionState.INITIALIZED:
|
2009-10-28 22:05:34 +00:00
|
|
|
return _("Disabled");
|
|
|
|
case ExtensionSystem.ExtensionState.ERROR:
|
|
|
|
return _("Error");
|
|
|
|
case ExtensionSystem.ExtensionState.OUT_OF_DATE:
|
|
|
|
return _("Out of date");
|
2011-06-28 02:27:56 +00:00
|
|
|
case ExtensionSystem.ExtensionState.DOWNLOADING:
|
|
|
|
return _("Downloading");
|
2009-10-28 22:05:34 +00:00
|
|
|
}
|
2010-05-13 19:46:04 +00:00
|
|
|
return 'Unknown'; // Not translated, shouldn't appear
|
2009-10-28 22:05:34 +00:00
|
|
|
},
|
|
|
|
|
2012-01-31 01:58:29 +00:00
|
|
|
_createExtensionDisplay: function(extension) {
|
2009-10-28 22:05:34 +00:00
|
|
|
let box = new St.BoxLayout({ style_class: 'lg-extension', vertical: true });
|
|
|
|
let name = new St.Label({ style_class: 'lg-extension-name',
|
2012-01-31 01:58:29 +00:00
|
|
|
text: extension.metadata.name });
|
2009-10-28 22:05:34 +00:00
|
|
|
box.add(name, { expand: true });
|
|
|
|
let description = new St.Label({ style_class: 'lg-extension-description',
|
2012-01-31 01:58:29 +00:00
|
|
|
text: extension.metadata.description || 'No description' });
|
2009-10-28 22:05:34 +00:00
|
|
|
box.add(description, { expand: true });
|
|
|
|
|
2011-09-29 16:34:46 +00:00
|
|
|
let metaBox = new St.BoxLayout({ style_class: 'lg-extension-meta' });
|
2009-10-28 22:05:34 +00:00
|
|
|
box.add(metaBox);
|
2012-01-31 01:58:29 +00:00
|
|
|
let stateString = this._stateToString(extension.state);
|
2009-10-28 22:05:34 +00:00
|
|
|
let state = new St.Label({ style_class: 'lg-extension-state',
|
2012-01-31 01:58:29 +00:00
|
|
|
text: this._stateToString(extension.state) });
|
2011-09-29 16:34:46 +00:00
|
|
|
metaBox.add(state);
|
2009-10-28 22:05:34 +00:00
|
|
|
|
2012-07-14 22:49:06 +00:00
|
|
|
let viewsource = new St.Button({ reactive: true,
|
|
|
|
track_hover: true,
|
|
|
|
style_class: 'shell-link',
|
|
|
|
label: _("View Source") });
|
|
|
|
viewsource._extension = extension;
|
|
|
|
viewsource.connect('clicked', Lang.bind(this, this._onViewSource));
|
|
|
|
metaBox.add(viewsource);
|
2009-10-28 22:05:34 +00:00
|
|
|
|
2012-01-31 01:58:29 +00:00
|
|
|
if (extension.metadata.url) {
|
2012-07-14 22:49:06 +00:00
|
|
|
let webpage = new St.Button({ reactive: true,
|
|
|
|
track_hover: true,
|
|
|
|
style_class: 'shell-link',
|
|
|
|
label: _("Web Page") });
|
|
|
|
webpage._extension = extension;
|
|
|
|
webpage.connect('clicked', Lang.bind(this, this._onWebPage));
|
|
|
|
metaBox.add(webpage);
|
2009-10-28 22:05:34 +00:00
|
|
|
}
|
|
|
|
|
2012-07-14 22:49:06 +00:00
|
|
|
let viewerrors = new St.Button({ reactive: true,
|
|
|
|
track_hover: true,
|
|
|
|
style_class: 'shell-link',
|
|
|
|
label: _("Show Errors") });
|
|
|
|
viewerrors._extension = extension;
|
|
|
|
viewerrors._parentBox = box;
|
|
|
|
viewerrors._isShowing = false;
|
|
|
|
viewerrors.connect('clicked', Lang.bind(this, this._onViewErrors));
|
|
|
|
metaBox.add(viewerrors);
|
2011-09-30 07:58:44 +00:00
|
|
|
|
2009-10-28 22:05:34 +00:00
|
|
|
return box;
|
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-10-28 22:05:34 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const LookingGlass = new Lang.Class({
|
|
|
|
Name: 'LookingGlass',
|
2009-08-02 07:46:01 +00:00
|
|
|
|
|
|
|
_init : function() {
|
2009-11-11 18:12:55 +00:00
|
|
|
this._borderPaintTarget = null;
|
2012-06-21 18:42:33 +00:00
|
|
|
this._redBorderEffect = new RedBorderEffect();
|
2009-11-11 18:12:55 +00:00
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
this._open = false;
|
|
|
|
|
|
|
|
this._offset = 0;
|
|
|
|
this._results = [];
|
|
|
|
|
2009-09-10 05:38:13 +00:00
|
|
|
// Sort of magic, but...eh.
|
|
|
|
this._maxItems = 150;
|
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
this.actor = new St.BoxLayout({ name: 'LookingGlassDialog',
|
2010-05-15 16:43:56 +00:00
|
|
|
style_class: 'lg-dialog',
|
2009-09-10 05:38:13 +00:00
|
|
|
vertical: true,
|
2011-11-22 18:28:23 +00:00
|
|
|
visible: false,
|
|
|
|
reactive: true });
|
2010-11-03 17:30:08 +00:00
|
|
|
this.actor.connect('key-press-event', Lang.bind(this, this._globalKeyPressEvent));
|
2010-11-30 18:11:11 +00:00
|
|
|
|
|
|
|
this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
|
|
|
this._interfaceSettings.connect('changed::monospace-font-name',
|
|
|
|
Lang.bind(this, this._updateFont));
|
2009-09-22 00:13:00 +00:00
|
|
|
this._updateFont();
|
|
|
|
|
2011-09-06 15:35:16 +00:00
|
|
|
// We want it to appear to slide out from underneath the panel
|
|
|
|
Main.layoutManager.panelBox.add_actor(this.actor);
|
|
|
|
this.actor.lower_bottom();
|
|
|
|
Main.layoutManager.panelBox.connect('allocation-changed',
|
|
|
|
Lang.bind(this, this._queueResize));
|
|
|
|
Main.layoutManager.keyboardBox.connect('allocation-changed',
|
|
|
|
Lang.bind(this, this._queueResize));
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
this._objInspector = new ObjInspector(this);
|
2010-05-15 16:43:56 +00:00
|
|
|
Main.uiGroup.add_actor(this._objInspector.actor);
|
|
|
|
this._objInspector.actor.hide();
|
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
let toolbar = new St.BoxLayout({ name: 'Toolbar' });
|
2009-09-10 05:38:13 +00:00
|
|
|
this.actor.add_actor(toolbar);
|
2010-11-02 22:33:22 +00:00
|
|
|
let inspectIcon = new St.Icon({ icon_name: 'gtk-color-picker',
|
|
|
|
icon_size: 24 });
|
2009-09-10 05:38:13 +00:00
|
|
|
toolbar.add_actor(inspectIcon);
|
2009-08-02 07:46:01 +00:00
|
|
|
inspectIcon.reactive = true;
|
|
|
|
inspectIcon.connect('button-press-event', Lang.bind(this, function () {
|
2012-07-14 23:29:55 +00:00
|
|
|
let inspector = new Inspector(this);
|
2009-08-04 13:49:03 +00:00
|
|
|
inspector.connect('target', Lang.bind(this, function(i, target, stageX, stageY) {
|
2012-12-26 03:16:39 +00:00
|
|
|
this._pushResult('inspect(' + Math.round(stageX) + ', ' + Math.round(stageY) + ')', target);
|
2009-08-04 13:49:03 +00:00
|
|
|
}));
|
|
|
|
inspector.connect('closed', Lang.bind(this, function() {
|
2009-08-02 07:46:01 +00:00
|
|
|
this.actor.show();
|
|
|
|
global.stage.set_key_focus(this._entry);
|
|
|
|
}));
|
|
|
|
this.actor.hide();
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
|
2009-08-04 13:49:03 +00:00
|
|
|
let notebook = new Notebook();
|
2009-10-09 00:11:45 +00:00
|
|
|
this._notebook = notebook;
|
2009-09-10 05:38:13 +00:00
|
|
|
this.actor.add(notebook.actor, { expand: true });
|
|
|
|
|
|
|
|
let emptyBox = new St.Bin();
|
|
|
|
toolbar.add(emptyBox, { expand: true });
|
|
|
|
toolbar.add_actor(notebook.tabControls);
|
2009-08-04 13:49:03 +00:00
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
this._evalBox = new St.BoxLayout({ name: 'EvalBox', vertical: true });
|
2009-08-04 13:49:03 +00:00
|
|
|
notebook.appendPage('Evaluator', this._evalBox);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
this._resultsArea = new St.BoxLayout({ name: 'ResultsArea', vertical: true });
|
2009-09-10 05:38:13 +00:00
|
|
|
this._evalBox.add(this._resultsArea, { expand: true });
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-10-29 08:20:49 +00:00
|
|
|
this._entryArea = new St.BoxLayout({ name: 'EntryArea' });
|
|
|
|
this._evalBox.add_actor(this._entryArea);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 22:24:10 +00:00
|
|
|
let label = new St.Label({ text: CHEVRON });
|
2011-10-29 08:20:49 +00:00
|
|
|
this._entryArea.add(label);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-04-20 16:41:22 +00:00
|
|
|
this._entry = new St.Entry({ can_focus: true });
|
2011-10-11 22:38:24 +00:00
|
|
|
ShellEntry.addContextMenu(this._entry);
|
2011-10-29 08:20:49 +00:00
|
|
|
this._entryArea.add(this._entry, { expand: true });
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2012-07-14 23:29:55 +00:00
|
|
|
this._windowList = new WindowList(this);
|
2010-04-20 18:57:31 +00:00
|
|
|
notebook.appendPage('Windows', this._windowList.actor);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2011-05-20 19:50:54 +00:00
|
|
|
this._memory = new Memory();
|
|
|
|
notebook.appendPage('Memory', this._memory.actor);
|
|
|
|
|
2009-10-28 22:05:34 +00:00
|
|
|
this._extensions = new Extensions();
|
|
|
|
notebook.appendPage('Extensions', this._extensions.actor);
|
|
|
|
|
2009-09-10 05:38:13 +00:00
|
|
|
this._entry.clutter_text.connect('activate', Lang.bind(this, function (o, e) {
|
2011-10-29 08:20:49 +00:00
|
|
|
// Hide any completions we are currently showing
|
|
|
|
this._hideCompletions();
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
let text = o.get_text();
|
|
|
|
// Ensure we don't get newlines in the command; the history file is
|
|
|
|
// newline-separated.
|
|
|
|
text.replace('\n', ' ');
|
2009-08-04 05:37:54 +00:00
|
|
|
// Strip leading and trailing whitespace
|
2010-05-13 19:46:04 +00:00
|
|
|
text = text.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
2009-08-04 05:37:54 +00:00
|
|
|
if (text == '')
|
|
|
|
return true;
|
2009-08-02 07:46:01 +00:00
|
|
|
this._evaluate(text);
|
|
|
|
return true;
|
|
|
|
}));
|
2011-02-13 16:43:32 +00:00
|
|
|
|
2011-02-28 17:22:12 +00:00
|
|
|
this._history = new History.HistoryManager({ gsettingsKey: HISTORY_KEY,
|
|
|
|
entry: this._entry.clutter_text });
|
2011-09-06 15:35:16 +00:00
|
|
|
|
2011-10-29 08:20:49 +00:00
|
|
|
this._autoComplete = new AutoComplete(this._entry);
|
|
|
|
this._autoComplete.connect('suggest', Lang.bind(this, function(a,e) {
|
|
|
|
this._showCompletions(e.completions);
|
|
|
|
}));
|
|
|
|
// If a completion is completed unambiguously, the currently-displayed completion
|
|
|
|
// suggestions become irrelevant.
|
|
|
|
this._autoComplete.connect('completion', Lang.bind(this, function(a,e) {
|
|
|
|
if (e.type == 'whole-word')
|
|
|
|
this._hideCompletions();
|
|
|
|
}));
|
|
|
|
|
2011-09-06 15:35:16 +00:00
|
|
|
this._resize();
|
2009-08-02 07:46:01 +00:00
|
|
|
},
|
|
|
|
|
2009-09-22 00:13:00 +00:00
|
|
|
_updateFont: function() {
|
2010-11-30 18:11:11 +00:00
|
|
|
let fontName = this._interfaceSettings.get_string('monospace-font-name');
|
2009-09-22 00:13:00 +00:00
|
|
|
// This is mishandled by the scanner - should by Pango.FontDescription_from_string(fontName);
|
|
|
|
// https://bugzilla.gnome.org/show_bug.cgi?id=595889
|
2010-09-08 13:35:33 +00:00
|
|
|
let fontDesc = Pango.font_description_from_string(fontName);
|
2009-09-22 00:13:00 +00:00
|
|
|
// We ignore everything but size and style; you'd be crazy to set your system-wide
|
|
|
|
// monospace font to be bold/oblique/etc. Could easily be added here.
|
|
|
|
this.actor.style =
|
|
|
|
'font-size: ' + fontDesc.get_size() / 1024. + (fontDesc.get_size_is_absolute() ? 'px' : 'pt') + ';'
|
|
|
|
+ 'font-family: "' + fontDesc.get_family() + '";';
|
|
|
|
},
|
|
|
|
|
2012-07-14 23:30:47 +00:00
|
|
|
setBorderPaintTarget: function(obj) {
|
2012-06-21 18:42:33 +00:00
|
|
|
if (this._borderPaintTarget != null)
|
|
|
|
this._borderPaintTarget.remove_effect(this._redBorderEffect);
|
|
|
|
this._borderPaintTarget = obj;
|
|
|
|
if (this._borderPaintTarget != null)
|
|
|
|
this._borderPaintTarget.add_effect(this._redBorderEffect);
|
|
|
|
},
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
_pushResult: function(command, obj) {
|
|
|
|
let index = this._results.length + this._offset;
|
2012-07-14 23:29:55 +00:00
|
|
|
let result = new Result(this, CHEVRON + command, obj, index);
|
2009-08-02 07:46:01 +00:00
|
|
|
this._results.push(result);
|
2010-03-31 20:40:32 +00:00
|
|
|
this._resultsArea.add(result.actor);
|
2012-06-21 18:42:33 +00:00
|
|
|
if (obj instanceof Clutter.Actor)
|
2012-07-14 23:30:47 +00:00
|
|
|
this.setBorderPaintTarget(obj);
|
2012-06-21 18:42:33 +00:00
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
let children = this._resultsArea.get_children();
|
|
|
|
if (children.length > this._maxItems) {
|
|
|
|
this._results.shift();
|
|
|
|
children[0].destroy();
|
|
|
|
this._offset++;
|
|
|
|
}
|
|
|
|
this._it = obj;
|
2009-10-09 00:11:45 +00:00
|
|
|
|
|
|
|
// Scroll to bottom
|
|
|
|
this._notebook.scrollToBottom(0);
|
2009-08-02 07:46:01 +00:00
|
|
|
},
|
|
|
|
|
2011-10-29 08:20:49 +00:00
|
|
|
_showCompletions: function(completions) {
|
|
|
|
if (!this._completionActor) {
|
|
|
|
let actor = new St.BoxLayout({ vertical: true });
|
|
|
|
|
|
|
|
this._completionText = new St.Label({ name: 'LookingGlassAutoCompletionText', style_class: 'lg-completions-text' });
|
|
|
|
this._completionText.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
|
|
|
this._completionText.clutter_text.line_wrap = true;
|
|
|
|
actor.add(this._completionText);
|
|
|
|
|
|
|
|
let line = new Clutter.Rectangle();
|
|
|
|
let padBin = new St.Bin({ x_fill: true, y_fill: true });
|
|
|
|
padBin.add_actor(line);
|
|
|
|
actor.add(padBin);
|
|
|
|
|
|
|
|
this._completionActor = actor;
|
2012-02-13 20:27:16 +00:00
|
|
|
this._evalBox.insert_child_below(this._completionActor, this._entryArea);
|
2011-10-29 08:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._completionText.set_text(completions.join(', '));
|
|
|
|
|
|
|
|
// Setting the height to -1 allows us to get its actual preferred height rather than
|
|
|
|
// whatever was last given in set_height by Tweener.
|
|
|
|
this._completionActor.set_height(-1);
|
|
|
|
let [minHeight, naturalHeight] = this._completionText.get_preferred_height(this._resultsArea.get_width());
|
|
|
|
|
|
|
|
// Don't reanimate if we are already visible
|
|
|
|
if (this._completionActor.visible) {
|
|
|
|
this._completionActor.height = naturalHeight;
|
|
|
|
} else {
|
|
|
|
this._completionActor.show();
|
|
|
|
Tweener.removeTweens(this._completionActor);
|
|
|
|
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / St.get_slow_down_factor(),
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
height: naturalHeight,
|
|
|
|
opacity: 255
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_hideCompletions: function() {
|
|
|
|
if (this._completionActor) {
|
|
|
|
Tweener.removeTweens(this._completionActor);
|
|
|
|
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / St.get_slow_down_factor(),
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
height: 0,
|
|
|
|
opacity: 0,
|
|
|
|
onComplete: Lang.bind(this, function () {
|
|
|
|
this._completionActor.hide();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
_evaluate : function(command) {
|
2011-02-13 16:43:32 +00:00
|
|
|
this._history.addItem(command);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
|
|
|
let fullCmd = commandHeader + command;
|
|
|
|
|
|
|
|
let resultObj;
|
|
|
|
try {
|
|
|
|
resultObj = eval(fullCmd);
|
|
|
|
} catch (e) {
|
2010-05-13 19:46:04 +00:00
|
|
|
resultObj = '<exception ' + e + '>';
|
2009-08-02 07:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._pushResult(command, resultObj);
|
|
|
|
this._entry.text = '';
|
|
|
|
},
|
|
|
|
|
2012-12-26 03:16:39 +00:00
|
|
|
inspect: function(x, y) {
|
|
|
|
return global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
|
|
|
|
},
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
getIt: function () {
|
|
|
|
return this._it;
|
|
|
|
},
|
|
|
|
|
|
|
|
getResult: function(idx) {
|
|
|
|
return this._results[idx - this._offset].o;
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
|
|
|
if (this._open)
|
|
|
|
this.close();
|
|
|
|
else
|
|
|
|
this.open();
|
|
|
|
},
|
|
|
|
|
2011-09-06 15:35:16 +00:00
|
|
|
_queueResize: function() {
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
|
|
|
|
Lang.bind(this, function () { this._resize(); }));
|
|
|
|
},
|
|
|
|
|
|
|
|
_resize: function() {
|
2011-06-13 13:54:05 +00:00
|
|
|
let primary = Main.layoutManager.primaryMonitor;
|
2009-08-25 19:23:53 +00:00
|
|
|
let myWidth = primary.width * 0.7;
|
2011-09-06 15:35:16 +00:00
|
|
|
let availableHeight = primary.height - Main.layoutManager.keyboardBox.height;
|
|
|
|
let myHeight = Math.min(primary.height * 0.7, availableHeight * 0.9);
|
|
|
|
this.actor.x = (primary.width - myWidth) / 2;
|
|
|
|
this._hiddenY = this.actor.get_parent().height - myHeight - 4; // -4 to hide the top corners
|
2009-08-02 07:46:01 +00:00
|
|
|
this._targetY = this._hiddenY + myHeight;
|
|
|
|
this.actor.y = this._hiddenY;
|
|
|
|
this.actor.width = myWidth;
|
|
|
|
this.actor.height = myHeight;
|
2010-05-15 16:43:56 +00:00
|
|
|
this._objInspector.actor.set_size(Math.floor(myWidth * 0.8), Math.floor(myHeight * 0.8));
|
2012-09-05 19:23:54 +00:00
|
|
|
this._objInspector.actor.set_position(primary.x + this.actor.x + Math.floor(myWidth * 0.1),
|
|
|
|
primary.y + this._targetY + Math.floor(myHeight * 0.1));
|
2009-08-02 07:46:01 +00:00
|
|
|
},
|
|
|
|
|
2010-05-15 16:43:56 +00:00
|
|
|
insertObject: function(obj) {
|
|
|
|
this._pushResult('<insert>', obj);
|
|
|
|
},
|
|
|
|
|
|
|
|
inspectObject: function(obj, sourceActor) {
|
|
|
|
this._objInspector.open(sourceActor);
|
|
|
|
this._objInspector.selectObject(obj);
|
|
|
|
},
|
|
|
|
|
2009-12-18 20:22:58 +00:00
|
|
|
// Handle key events which are relevant for all tabs of the LookingGlass
|
|
|
|
_globalKeyPressEvent : function(actor, event) {
|
|
|
|
let symbol = event.get_key_symbol();
|
2012-02-28 16:01:48 +00:00
|
|
|
let modifierState = event.get_state();
|
2009-12-18 20:22:58 +00:00
|
|
|
if (symbol == Clutter.Escape) {
|
2010-05-15 16:43:56 +00:00
|
|
|
if (this._objInspector.actor.visible) {
|
|
|
|
this._objInspector.close();
|
|
|
|
} else {
|
|
|
|
this.close();
|
|
|
|
}
|
2009-12-18 20:22:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-21 05:23:08 +00:00
|
|
|
// Ctrl+PgUp and Ctrl+PgDown switches tabs in the notebook view
|
|
|
|
if (modifierState & Clutter.ModifierType.CONTROL_MASK) {
|
|
|
|
if (symbol == Clutter.KEY_Page_Up) {
|
|
|
|
this._notebook.prevTab();
|
|
|
|
} else if (symbol == Clutter.KEY_Page_Down) {
|
|
|
|
this._notebook.nextTab();
|
|
|
|
}
|
|
|
|
}
|
2009-12-18 20:22:58 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
open : function() {
|
|
|
|
if (this._open)
|
|
|
|
return;
|
|
|
|
|
2012-12-12 13:14:13 +00:00
|
|
|
if (!Main.pushModal(this._entry, { keybindingMode: Shell.KeyBindingMode.LOOKING_GLASS }))
|
2009-09-16 15:37:51 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-20 16:41:22 +00:00
|
|
|
this._notebook.selectIndex(0);
|
2009-08-02 07:46:01 +00:00
|
|
|
this.actor.show();
|
|
|
|
this._open = true;
|
2011-02-13 16:43:32 +00:00
|
|
|
this._history.lastItem();
|
2009-08-02 07:46:01 +00:00
|
|
|
|
|
|
|
Tweener.removeTweens(this.actor);
|
|
|
|
|
2010-11-09 19:37:32 +00:00
|
|
|
// We inverse compensate for the slow-down so you can change the factor
|
|
|
|
// through LookingGlass without long waits.
|
|
|
|
Tweener.addTween(this.actor, { time: 0.5 / St.get_slow_down_factor(),
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad',
|
2009-08-02 07:46:01 +00:00
|
|
|
y: this._targetY
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
close : function() {
|
|
|
|
if (!this._open)
|
|
|
|
return;
|
|
|
|
|
2010-05-15 16:43:56 +00:00
|
|
|
this._objInspector.actor.hide();
|
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
this._open = false;
|
|
|
|
Tweener.removeTweens(this.actor);
|
|
|
|
|
2012-07-14 23:30:47 +00:00
|
|
|
this.setBorderPaintTarget(null);
|
2009-11-11 18:12:55 +00:00
|
|
|
|
2010-11-03 17:30:08 +00:00
|
|
|
Main.popModal(this._entry);
|
2009-08-02 07:46:01 +00:00
|
|
|
|
2010-11-09 19:37:32 +00:00
|
|
|
Tweener.addTween(this.actor, { time: 0.5 / St.get_slow_down_factor(),
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad',
|
2009-08-02 07:46:01 +00:00
|
|
|
y: this._hiddenY,
|
|
|
|
onComplete: Lang.bind(this, function () {
|
|
|
|
this.actor.hide();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-02 07:46:01 +00:00
|
|
|
Signals.addSignalMethods(LookingGlass.prototype);
|