fix menu item name and sensitivity stynchronization
This commit is contained in:
parent
408929848d
commit
80e2955f8c
8
area.js
8
area.js
|
|
@ -1074,7 +1074,7 @@ var DrawingArea = new Lang.Class({
|
|||
}
|
||||
},
|
||||
|
||||
_saveAsJson: function(name, notify) {
|
||||
_saveAsJson: function(name, notify, callback) {
|
||||
// stop drawing or writing
|
||||
if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.isWriting) {
|
||||
this._stopWriting();
|
||||
|
|
@ -1107,11 +1107,13 @@ var DrawingArea = new Lang.Class({
|
|||
this.jsonName = name;
|
||||
this.lastJsonContents = contents;
|
||||
}
|
||||
if (callback)
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
saveAsJsonWithName: function(name) {
|
||||
this._saveAsJson(name);
|
||||
saveAsJsonWithName: function(name, callback) {
|
||||
this._saveAsJson(name, false, callback);
|
||||
},
|
||||
|
||||
saveAsJson: function() {
|
||||
|
|
|
|||
10
menu.js
10
menu.js
|
|
@ -420,6 +420,7 @@ var DrawingMenu = new Lang.Class({
|
|||
_addOpenDrawingSubMenuItem: function(menu) {
|
||||
let item = new PopupMenu.PopupSubMenuMenuItem(_("Open drawing"), true);
|
||||
this.openDrawingSubMenuItem = item;
|
||||
this.openDrawingSubMenuItem.setSensitive(Boolean(Files.getJsons().length));
|
||||
this.openDrawingSubMenu = item.menu;
|
||||
item.icon.set_icon_name('document-open-symbolic');
|
||||
|
||||
|
|
@ -463,6 +464,7 @@ var DrawingMenu = new Lang.Class({
|
|||
deleteButton.connect('clicked', () => {
|
||||
json.delete();
|
||||
item.destroy();
|
||||
this.openDrawingSubMenuItem.setSensitive(!this.openDrawingSubMenu.isEmpty());
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -493,13 +495,17 @@ var DrawingMenu = new Lang.Class({
|
|||
this.saveDrawingSubMenuItem.setSensitive(this.area.elements.length > 0);
|
||||
},
|
||||
|
||||
_onDrawingSaved() {
|
||||
this._updateDrawingNameMenuItem();
|
||||
this.openDrawingSubMenuItem.setSensitive(true);
|
||||
},
|
||||
|
||||
_populateSaveDrawingSubMenu: function() {
|
||||
this.saveDrawingSubMenu.removeAll();
|
||||
let saveEntry = new DrawingMenuEntry({ initialTextGetter: Files.getDateString,
|
||||
entryActivateCallback: (text) => {
|
||||
this.area.saveAsJsonWithName(text);
|
||||
this.area.saveAsJsonWithName(text, this._onDrawingSaved.bind(this));
|
||||
this.saveDrawingSubMenu.toggle();
|
||||
this._updateDrawingNameMenuItem();
|
||||
},
|
||||
invalidStrings: [Me.metadata['persistent-file-name'], '/'],
|
||||
primaryIconName: 'insert-text' });
|
||||
|
|
|
|||
Loading…
Reference in New Issue