diff --git a/area.js b/area.js
index 9d0e897..569ee4b 100644
--- a/area.js
+++ b/area.js
@@ -1105,8 +1105,9 @@ var DrawingArea = new Lang.Class({
},
// Used by the menu.
- getSvgContentForJson(json) {
+ getSvgContentsForJson(json) {
let elements = [];
+ let elementsContent = '';
elements.push(...JSON.parse(json.contents).map(object => {
if (object.color)
@@ -1117,16 +1118,21 @@ var DrawingArea = new Lang.Class({
object.image = new Files.Image(object.image);
return new Elements.DrawingElement(object);
}));
-
- let size = Math.min(this.monitor.width, this.monitor.height);
- let [x, y] = [(this.monitor.width - size) / 2, (this.monitor.height - size) / 2];
+ elements.forEach(element => elementsContent += element.buildSVG('transparent'));
let prefixes = 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"';
- let content = `";
- return content;
+ let getGiconSvgContent = () => {
+ let size = Math.min(this.monitor.width, this.monitor.height);
+ let [x, y] = [(this.monitor.width - size) / 2, (this.monitor.height - size) / 2];
+ return ``;
+ };
+
+ let getImageSvgContent = () => {
+ return ``;
+ };
+
+ return [getGiconSvgContent, getImageSvgContent];
},
saveAsSvg: function() {
diff --git a/files.js b/files.js
index d2eca2a..2442ac7 100644
--- a/files.js
+++ b/files.js
@@ -406,14 +406,15 @@ var Json = new Lang.Class({
this._contents = contents;
},
- createGicon: function(svgContent) {
- this.svgBytes = new GLib.Bytes(svgContent);
- this.gicon = Gio.BytesIcon.new(this.svgBytes);
+ addSvgContents: function(getGiconSvgContent, getImageSvgContent) {
+ let giconSvgBytes = new GLib.Bytes(getGiconSvgContent());
+ this.gicon = Gio.BytesIcon.new(giconSvgBytes);
+ this.getImageSvgBytes = () => new GLib.Bytes(getImageSvgContent());
},
get image() {
if (!this._image)
- this._image = new ImageFromJson({ bytes: this.svgBytes, gicon: this.gicon, displayName: this.displayName });
+ this._image = new ImageFromJson({ bytes: this.getImageSvgBytes(), gicon: this.gicon, displayName: this.displayName });
return this._image;
}
diff --git a/menu.js b/menu.js
index 7609692..4e51df1 100644
--- a/menu.js
+++ b/menu.js
@@ -599,10 +599,8 @@ var DrawingMenu = new Lang.Class({
_populateOpenDrawingSubMenu: function() {
this.openDrawingSubMenu.removeAll();
Files.Jsons.getSorted().forEach(json => {
- if (!json.gicon) {
- let svgContent = this.area.getSvgContentForJson(json);
- json.createGicon(svgContent);
- }
+ if (!json.gicon)
+ json.addSvgContents(...this.area.getSvgContentsForJson(json));
let subItem = this.openDrawingSubMenu.addAction(`${String(json)}`, () => {
this.area.loadJson(json);