Dot not use stateObj

Remove `Me.stateObj.areaManager`.
It caused errors on extension updated from ego (`JS ERROR: TypeError: Me.stateObj.areaManager is undefined`).
This commit is contained in:
abakkk 2020-10-16 14:04:57 +02:00
parent e99927d985
commit e588728d3d
3 changed files with 21 additions and 10 deletions

View File

@ -123,13 +123,15 @@ var DrawingArea = new Lang.Class({
Name: `${UUID}-DrawingArea`,
Extends: St.Widget,
Signals: { 'show-osd': { param_types: [Gio.Icon.$gtype, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE, GObject.TYPE_BOOLEAN] },
'pointer-cursor-changed': { param_types: [GObject.TYPE_STRING] },
'update-action-mode': {},
'leave-drawing-mode': {} },
_init: function(params, monitor, helper, loadPersistent) {
_init: function(params, monitor, helper, areaManagerUtils, loadPersistent) {
this.parent({ style_class: 'draw-on-your-screen', name: params.name});
this.monitor = monitor;
this.helper = helper;
this.areaManagerUtils = areaManagerUtils;
this.layerContainer = new St.Widget({ width: monitor.width, height: monitor.height });
this.add_child(this.layerContainer);
@ -174,7 +176,7 @@ var DrawingArea = new Lang.Class({
get menu() {
if (!this._menu)
this._menu = new Menu.DrawingMenu(this, this.monitor, Tools);
this._menu = new Menu.DrawingMenu(this, this.monitor, Tools, this.areaManagerUtils);
return this._menu;
},
@ -903,7 +905,7 @@ var DrawingArea = new Lang.Class({
setPointerCursor: function(pointerCursorName) {
if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) {
this.currentPointerCursorName = pointerCursorName;
Me.stateObj.areaManager.setCursor(pointerCursorName);
this.emit('pointer-cursor-changed', pointerCursorName);
}
},
@ -1273,6 +1275,7 @@ var DrawingArea = new Lang.Class({
this.erase();
if (this._menu)
this._menu.disable();
delete this.areaManagerUtils;
},
updateActionMode: function() {

View File

@ -169,7 +169,13 @@ const AreaManager = new Lang.Class({
let monitor = this.monitors[i];
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
let loadPersistent = i == Main.layoutManager.primaryIndex && this.persistentOverRestarts;
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
// Some utils for the drawing area menus.
let areaManagerUtils = {
getHiddenList: () => this.hiddenList,
togglePanelAndDockOpacity: this.togglePanelAndDockOpacity.bind(this),
openPreferences: this.openPreferences.bind(this)
};
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, areaManagerUtils, loadPersistent);
Main.layoutManager._backgroundGroup.insert_child_above(area, Main.layoutManager._bgManagers[i].backgroundActor);
if (!this.onDesktop)
@ -179,6 +185,7 @@ const AreaManager = new Lang.Class({
area.set_size(monitor.width, monitor.height);
area.leaveDrawingHandler = area.connect('leave-drawing-mode', this.toggleDrawing.bind(this));
area.updateActionModeHandler = area.connect('update-action-mode', this.updateActionMode.bind(this));
area.pointerCursorChangedHandler = area.connect('pointer-cursor-changed', this.setCursor.bind(this));
area.showOsdHandler = area.connect('show-osd', this.showOsd.bind(this));
this.areas.push(area);
}
@ -361,7 +368,7 @@ const AreaManager = new Lang.Class({
if (source && source == global.display)
// Translators: "released" as the opposite of "grabbed"
this.showOsd(null, Files.Icons.UNGRAB, _("Keyboard and pointer released"), null, null, false);
this.setCursor('DEFAULT');
this.setCursor(null, 'DEFAULT');
this.activeArea.reactive = false;
this.removeInternalKeybindings();
} else {
@ -499,7 +506,7 @@ const AreaManager = new Lang.Class({
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
},
setCursor: function(cursorName) {
setCursor: function(sourceActor_, cursorName) {
// check display or screen (API changes)
if (global.display.set_cursor)
global.display.set_cursor(Meta.Cursor[cursorName]);

View File

@ -142,10 +142,11 @@ var DisplayStrings = {
var DrawingMenu = new Lang.Class({
Name: `${UUID}-DrawingMenu`,
_init: function(area, monitor, drawingTools) {
_init: function(area, monitor, drawingTools, areaManagerUtils) {
this.area = area;
this.monitor = monitor;
this.drawingTools = drawingTools;
this.areaManagerUtils = areaManagerUtils;
let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT;
this.menu = new PopupMenu.PopupMenu(Main.layoutManager.dummyCursor, 0.25, side);
@ -178,6 +179,7 @@ var DrawingMenu = new Lang.Class({
disable: function() {
delete this.area;
delete this.drawingTools;
delete this.areaManagerUtils;
this.menuManager.removeMenu(this.menu);
Main.layoutManager.uiGroup.remove_actor(this.menu.actor);
this.menu.destroy();
@ -279,8 +281,7 @@ var DrawingMenu = new Lang.Class({
imageSection.itemActivated = () => {};
this.imageSection = imageSection;
let areaManager = Me.stateObj.areaManager;
this._addSimpleSwitchItem(this.menu, getSummary('toggle-panel-and-dock-visibility'), !!areaManager.hiddenList, areaManager.togglePanelAndDockOpacity.bind(areaManager));
this._addSimpleSwitchItem(this.menu, getSummary('toggle-panel-and-dock-visibility'), !!this.areaManagerUtils.getHiddenList(), this.areaManagerUtils.togglePanelAndDockOpacity);
this._addSimpleSwitchItem(this.menu, getSummary('toggle-background'), this.area.hasBackground, this.area.toggleBackground.bind(this.area));
this._addSimpleSwitchItem(this.menu, getSummary('toggle-grid'), this.area.hasGrid, this.area.toggleGrid.bind(this.area));
this._addSimpleSwitchItem(this.menu, getSummary('toggle-square-area'), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area));
@ -294,7 +295,7 @@ var DrawingMenu = new Lang.Class({
groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-your-screen-menu-group-item' });
this.saveButton = new ActionButton(getSummary('save-as-json'), 'document-save-symbolic', this.area.saveAsJson.bind(this.area, false, this._onDrawingSaved.bind(this)), null);
this.svgButton = new ActionButton(getSummary('export-to-svg'), Files.Icons.DOCUMENT_EXPORT, this.area.exportToSvg.bind(this.area), null);
this.prefsButton = new ActionButton(getSummary('open-preferences'), 'document-page-setup-symbolic', areaManager.openPreferences.bind(areaManager), null);
this.prefsButton = new ActionButton(getSummary('open-preferences'), 'document-page-setup-symbolic', this.areaManagerUtils.openPreferences, null);
this.helpButton = new ActionButton(getSummary('toggle-help'), 'preferences-desktop-keyboard-shortcuts-symbolic', () => { this.close(); this.area.toggleHelp(); }, null);
getActor(groupItem).add_child(this.saveButton);
getActor(groupItem).add_child(this.svgButton);