draw.js -> area.js

This commit is contained in:
abakkk 2020-07-04 08:42:45 +02:00
parent ca96e76d12
commit 96efac1e3f
4 changed files with 20 additions and 24 deletions

View File

View File

@ -26,10 +26,6 @@ const Lang = imports.lang;
const Pango = imports.gi.Pango;
const PangoCairo = imports.gi.PangoCairo;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const reverseEnumeration = function(obj) {
let reversed = {};
Object.keys(obj).forEach(key => {

View File

@ -35,7 +35,7 @@ const PanelMenu = imports.ui.panelMenu;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
const Draw = Me.imports.draw;
const Area = Me.imports.area;
const Helper = Me.imports.helper;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
@ -157,7 +157,7 @@ var AreaManager = new Lang.Class({
let container = new St.Widget({ name: 'drawOnYourSreenContainer' + i });
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
let loadPersistent = i == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
let area = new Draw.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
container.add_child(area);
container.add_child(helper);
@ -191,16 +191,16 @@ var AreaManager = new Lang.Class({
'toggle-fill-rule': this.activeArea.toggleFillRule.bind(this.activeArea),
'toggle-dash' : this.activeArea.toggleDash.bind(this.activeArea),
'toggle-fill' : this.activeArea.toggleFill.bind(this.activeArea),
'select-none-shape': () => this.activeArea.selectTool(Draw.Tools.NONE),
'select-line-shape': () => this.activeArea.selectTool(Draw.Tools.LINE),
'select-ellipse-shape': () => this.activeArea.selectTool(Draw.Tools.ELLIPSE),
'select-rectangle-shape': () => this.activeArea.selectTool(Draw.Tools.RECTANGLE),
'select-text-shape': () => this.activeArea.selectTool(Draw.Tools.TEXT),
'select-polygon-shape': () => this.activeArea.selectTool(Draw.Tools.POLYGON),
'select-polyline-shape': () => this.activeArea.selectTool(Draw.Tools.POLYLINE),
'select-move-tool': () => this.activeArea.selectTool(Draw.Tools.MOVE),
'select-resize-tool': () => this.activeArea.selectTool(Draw.Tools.RESIZE),
'select-mirror-tool': () => this.activeArea.selectTool(Draw.Tools.MIRROR)
'select-none-shape': () => this.activeArea.selectTool(Area.Tools.NONE),
'select-line-shape': () => this.activeArea.selectTool(Area.Tools.LINE),
'select-ellipse-shape': () => this.activeArea.selectTool(Area.Tools.ELLIPSE),
'select-rectangle-shape': () => this.activeArea.selectTool(Area.Tools.RECTANGLE),
'select-text-shape': () => this.activeArea.selectTool(Area.Tools.TEXT),
'select-polygon-shape': () => this.activeArea.selectTool(Area.Tools.POLYGON),
'select-polyline-shape': () => this.activeArea.selectTool(Area.Tools.POLYLINE),
'select-move-tool': () => this.activeArea.selectTool(Area.Tools.MOVE),
'select-resize-tool': () => this.activeArea.selectTool(Area.Tools.RESIZE),
'select-mirror-tool': () => this.activeArea.selectTool(Area.Tools.MIRROR)
};
// available when writing

16
menu.js
View File

@ -36,7 +36,7 @@ const Slider = imports.ui.slider;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Draw = Me.imports.draw;
const Area = Me.imports.area;
const Elements = Me.imports.elements;
const Extension = Me.imports.extension;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
@ -154,7 +154,7 @@ var DrawingMenu = new Lang.Class({
this.menu.addAction(_("Smooth"), this.area.smoothLastElement.bind(this.area), 'format-text-strikethrough-symbolic');
this._addSeparator(this.menu);
this._addSubMenuItem(this.menu, 'document-edit-symbolic', Draw.ToolNames, this.area, 'currentTool', this._updateSectionVisibility.bind(this));
this._addSubMenuItem(this.menu, 'document-edit-symbolic', Area.ToolNames, this.area, 'currentTool', this._updateSectionVisibility.bind(this));
this._addColorSubMenuItem(this.menu);
this.fillItem = this._addSwitchItem(this.menu, _("Fill"), this.strokeIcon, this.fillIcon, this.area, 'fill', this._updateSectionVisibility.bind(this));
this.fillSection = new PopupMenu.PopupMenuSection();
@ -174,7 +174,7 @@ var DrawingMenu = new Lang.Class({
this.lineSection = lineSection;
let fontSection = new PopupMenu.PopupMenuSection();
let FontGenericNamesCopy = Object.create(Draw.FontGenericNames);
let FontGenericNamesCopy = Object.create(Area.FontGenericNames);
FontGenericNamesCopy[0] = this.area.currentThemeFontFamily;
this._addSubMenuItem(fontSection, 'font-x-generic-symbolic', FontGenericNamesCopy, this.area, 'currentFontGeneric');
this._addSubMenuItem(fontSection, 'format-text-bold-symbolic', Elements.FontWeightNames, this.area, 'currentFontWeight');
@ -204,7 +204,7 @@ var DrawingMenu = new Lang.Class({
},
_updateSectionVisibility: function() {
if (this.area.currentTool != Draw.Tools.TEXT) {
if (this.area.currentTool != Area.Tools.TEXT) {
this.lineSection.actor.show();
this.fontSection.actor.hide();
this.fillItem.setSensitive(true);
@ -320,9 +320,9 @@ var DrawingMenu = new Lang.Class({
subItem.label.get_clutter_text().set_use_markup(true);
// change the display order of tools
if (obj == Draw.ToolNames && i == Draw.Tools.POLYGON)
if (obj == Area.ToolNames && i == Area.Tools.POLYGON)
item.menu.moveMenuItem(subItem, 4);
else if (obj == Draw.ToolNames && i == Draw.Tools.POLYLINE)
else if (obj == Area.ToolNames && i == Area.Tools.POLYLINE)
item.menu.moveMenuItem(subItem, 5);
}
return GLib.SOURCE_REMOVE;
@ -394,7 +394,7 @@ var DrawingMenu = new Lang.Class({
_populateOpenDrawingSubMenu: function() {
this.openDrawingSubMenu.removeAll();
let jsonFiles = Draw.getJsonFiles();
let jsonFiles = Area.getJsonFiles();
jsonFiles.forEach(file => {
let item = this.openDrawingSubMenu.addAction(`<i>${file.displayName}</i>`, () => {
this.area.loadJson(file.name);
@ -450,7 +450,7 @@ var DrawingMenu = new Lang.Class({
_populateSaveDrawingSubMenu: function() {
this.saveDrawingSubMenu.removeAll();
let saveEntry = new DrawingMenuEntry({ initialTextGetter: Draw.getDateString,
let saveEntry = new DrawingMenuEntry({ initialTextGetter: Area.getDateString,
entryActivateCallback: (text) => {
this.area.saveAsJsonWithName(text);
this.saveDrawingSubMenu.toggle();