mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactored external editor...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
150d8edcf0
commit
c987abac35
@ -156,7 +156,7 @@ chrome-app: $(APP_ZIP) $(CHROME_APP_BUILD_DIR)
|
|||||||
|
|
||||||
|
|
||||||
# nwjs win64
|
# nwjs win64
|
||||||
# XXX include exiftool...
|
# XXX include exiftool???
|
||||||
# XXX include scripts/utils???
|
# XXX include scripts/utils???
|
||||||
win64: $(APP_ZIP) $(WIN_BUILD_DIR)
|
win64: $(APP_ZIP) $(WIN_BUILD_DIR)
|
||||||
rm -rf $(WIN_BUILD_DIR)
|
rm -rf $(WIN_BUILD_DIR)
|
||||||
@ -169,7 +169,6 @@ win64: $(APP_ZIP) $(WIN_BUILD_DIR)
|
|||||||
chmod +x $(WIN_BUILD_DIR)/*.{exe,dll}
|
chmod +x $(WIN_BUILD_DIR)/*.{exe,dll}
|
||||||
cp -vR \
|
cp -vR \
|
||||||
$(NODE_DIR) $(WIN_BUILD_DIR)
|
$(NODE_DIR) $(WIN_BUILD_DIR)
|
||||||
# XXX is this correct???
|
|
||||||
cp -vR "`which exiftool`" $(WIN_BUILD_DIR)
|
cp -vR "`which exiftool`" $(WIN_BUILD_DIR)
|
||||||
# cleanup nwjs-sdk...
|
# cleanup nwjs-sdk...
|
||||||
rm -f $(WIN_BUILD_DIR)/nwsnapshot.exe \
|
rm -f $(WIN_BUILD_DIR)/nwsnapshot.exe \
|
||||||
|
|||||||
@ -7,6 +7,9 @@
|
|||||||
define(function(require){ var module = {}
|
define(function(require){ var module = {}
|
||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
if(typeof(process) != 'undefined'){
|
||||||
|
var pathlib = requirejs('path')
|
||||||
|
}
|
||||||
|
|
||||||
var actions = require('lib/actions')
|
var actions = require('lib/actions')
|
||||||
var features = require('lib/features')
|
var features = require('lib/features')
|
||||||
@ -154,6 +157,19 @@ var AppControlActions = actions.Actions({
|
|||||||
nw.Window.get().showDevTools &&
|
nw.Window.get().showDevTools &&
|
||||||
nw.Window.get().showDevTools()
|
nw.Window.get().showDevTools()
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// XXX should this be here???
|
||||||
|
showInFolder: ['File|Image/Show in folder',
|
||||||
|
function(image){
|
||||||
|
image = this.images[this.data.getImage(image)]
|
||||||
|
|
||||||
|
var base = image.base_path || this.location.path
|
||||||
|
var filename = image.path
|
||||||
|
|
||||||
|
path = pathlib.normalize(base + '/' + filename)
|
||||||
|
|
||||||
|
nw.Shell.showItemInFolder(path)
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ var ExternalEditorActions = actions.Actions({
|
|||||||
{
|
{
|
||||||
// NOTE: empty means use app name...
|
// NOTE: empty means use app name...
|
||||||
title: 'System default',
|
title: 'System default',
|
||||||
// NOTE: empty means system to select editor...
|
// NOTE: empty means system default editor...
|
||||||
path: '',
|
path: '',
|
||||||
// NOTE: empty is the same as '$TARGET'...
|
// NOTE: empty is the same as '$TARGET'...
|
||||||
arguments: '',
|
arguments: '',
|
||||||
@ -58,7 +58,7 @@ var ExternalEditorActions = actions.Actions({
|
|||||||
// ...irfanview for instance does not understand '/' in paths
|
// ...irfanview for instance does not understand '/' in paths
|
||||||
// while windows in general have no problem...
|
// while windows in general have no problem...
|
||||||
// XXX target is not yet used...
|
// XXX target is not yet used...
|
||||||
openInExtenalEditor: ['Edit/Open with external editor',
|
openInExtenalEditor: ['Edit|Image/Open with external editor',
|
||||||
function(editor, image, type){
|
function(editor, image, type){
|
||||||
editor = editor || 0
|
editor = editor || 0
|
||||||
editor = typeof(editor) == typeof('str') ?
|
editor = typeof(editor) == typeof('str') ?
|
||||||
@ -69,6 +69,7 @@ var ExternalEditorActions = actions.Actions({
|
|||||||
|
|
||||||
if(editor == null){
|
if(editor == null){
|
||||||
// XXX ERR???
|
// XXX ERR???
|
||||||
|
console.error('Unknown editor')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ var ExternalEditorActions = actions.Actions({
|
|||||||
var img = this.images[this.data.getImage(image)]
|
var img = this.images[this.data.getImage(image)]
|
||||||
|
|
||||||
if(img == null){
|
if(img == null){
|
||||||
|
console.error('No image data')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +94,7 @@ var ExternalEditorActions = actions.Actions({
|
|||||||
var full_path = img.base_path +'/'+ img.path
|
var full_path = img.base_path +'/'+ img.path
|
||||||
|
|
||||||
// XXX is this portable enough???
|
// XXX is this portable enough???
|
||||||
var path = requirejs('path')
|
full_path = pathlib.normalize(full_path)
|
||||||
full_path = path.normalize(full_path)
|
|
||||||
|
|
||||||
editor = editor
|
editor = editor
|
||||||
// XXX make '$' quotable....
|
// XXX make '$' quotable....
|
||||||
@ -128,12 +129,13 @@ module.ExternalEditor = core.ImageGridFeatures.Feature({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
var ExternalEditorUIActions = actions.Actions({
|
var ExternalEditorUIActions = actions.Actions({
|
||||||
// XXX empty title -- use app name without ext...
|
// XXX empty title -- use app name without ext...
|
||||||
externalEditorDialog: ['- Edit/',
|
externalEditorDialog: ['- Edit/',
|
||||||
function(editor){
|
widgets.makeUIDialog(function(editor){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
editor = editor || 0
|
editor = editor || 0
|
||||||
@ -158,12 +160,11 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
|
|
||||||
var editor_i = this.config['external-editors'].indexOf(editor)
|
var editor_i = this.config['external-editors'].indexOf(editor)
|
||||||
|
|
||||||
var o = overlay.Overlay(this.ribbons.viewer,
|
var dialog = browse.makeLister(null, function(_, make){
|
||||||
browse.makeLister(null, function(_, make){
|
|
||||||
make(['Title: ', function(){ return editor.title || '' }])
|
make(['Title: ', function(){ return editor.title || '' }])
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
widgets.makeEditableItem(o.client, $(this),
|
widgets.makeEditableItem(dialog, $(this),
|
||||||
$(this).find('.text').last(),
|
$(this).find('.text').last(),
|
||||||
function(_, text){ editor.title = text }) })
|
function(_, text){ editor.title = text }) })
|
||||||
|
|
||||||
@ -185,8 +186,8 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
|
|
||||||
b.close()
|
b.close()
|
||||||
|
|
||||||
o.client.update()
|
dialog.update()
|
||||||
.then(function(){ o.client.select(txt+path) })
|
.then(function(){ dialog.select(txt+path) })
|
||||||
}))
|
}))
|
||||||
.close(function(){
|
.close(function(){
|
||||||
// XXX
|
// XXX
|
||||||
@ -197,14 +198,14 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
widgets.makeEditableItem(o.client, $(this),
|
widgets.makeEditableItem(dialog, $(this),
|
||||||
$(this).find('.text').last(),
|
$(this).find('.text').last(),
|
||||||
function(_, text){ editor.path = text }) })
|
function(_, text){ editor.path = text }) })
|
||||||
|
|
||||||
make(['Arguments: ', function(){ return editor.arguments || '' }])
|
make(['Arguments: ', function(){ return editor.arguments || '' }])
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
widgets.makeEditableItem(o.client, $(this),
|
widgets.makeEditableItem(dialog, $(this),
|
||||||
$(this).find('.text').last(),
|
$(this).find('.text').last(),
|
||||||
function(_, text){ editor.arguments = text }) })
|
function(_, text){ editor.arguments = text }) })
|
||||||
|
|
||||||
@ -213,7 +214,7 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
return editor.target
|
return editor.target
|
||||||
|| that.config['external-editor-targets'][0] }])
|
|| that.config['external-editor-targets'][0] }])
|
||||||
.on('open',
|
.on('open',
|
||||||
widgets.makeNestedConfigListEditor(that, o,
|
widgets.makeNestedConfigListEditor(that, dialog.parent,
|
||||||
'external-editor-targets',
|
'external-editor-targets',
|
||||||
function(val){
|
function(val){
|
||||||
if(val == null){
|
if(val == null){
|
||||||
@ -243,18 +244,18 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
that.config['external-editors'] = editors.concat([editor])
|
that.config['external-editors'] = editors.concat([editor])
|
||||||
}
|
}
|
||||||
|
|
||||||
o.close()
|
dialog.parent.close()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}))
|
|
||||||
|
|
||||||
o.client.dom.addClass('metadata-view tail-action')
|
dialog.dom.addClass('metadata-view tail-action')
|
||||||
|
|
||||||
return o
|
return dialog
|
||||||
}],
|
})],
|
||||||
// XXX need to support $TARGET in args...
|
// XXX need to support $TARGET in args...
|
||||||
// ...append if not present...
|
// ...append if not present...
|
||||||
listExtenalEditors: ['Edit/List external editors',
|
listExtenalEditors: ['Edit|Image/Choose external editor...',
|
||||||
function(){
|
widgets.makeUIDialog(function(){
|
||||||
var that = this
|
var that = this
|
||||||
var closingPrevented = false
|
var closingPrevented = false
|
||||||
var editors = this.config['external-editors'] || []
|
var editors = this.config['external-editors'] || []
|
||||||
@ -269,16 +270,16 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
var to_remove = []
|
var to_remove = []
|
||||||
|
|
||||||
// build the dialog...
|
// build the dialog...
|
||||||
var o = overlay.Overlay(this.ribbons.viewer,
|
var dialog = browse.makeLister(null,
|
||||||
//browse.makeList(null, list, {
|
|
||||||
browse.makeLister(null,
|
|
||||||
function(_, make){
|
function(_, make){
|
||||||
|
|
||||||
editors
|
editors
|
||||||
.forEach(function(e, i){
|
.forEach(function(e, i){
|
||||||
make([function(){ return e.title || pathlib.basename(e.path)}])
|
make([function(){ return e.title || pathlib.basename(e.path)}])
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
that.openInExtenalEditor(i)
|
that.openInExtenalEditor(i)
|
||||||
})
|
})
|
||||||
|
.addClass(i == 0 ? 'selected' : '')
|
||||||
})
|
})
|
||||||
|
|
||||||
make(['Add new editor...'])
|
make(['Add new editor...'])
|
||||||
@ -300,11 +301,11 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
|
|
||||||
// is this the correct way to do this???
|
// is this the correct way to do this???
|
||||||
b.close()
|
b.close()
|
||||||
o.client.update()//.close()
|
dialog.update()//.close()
|
||||||
//that.listExtenalEditors()
|
//that.listExtenalEditors()
|
||||||
}))
|
}))
|
||||||
.close(function(){
|
.close(function(){
|
||||||
o.focus()
|
dialog.parent.focus()
|
||||||
})
|
})
|
||||||
return b
|
return b
|
||||||
})
|
})
|
||||||
@ -316,8 +317,8 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
['edit',
|
['edit',
|
||||||
function(p){
|
function(p){
|
||||||
that.externalEditorDialog(p)
|
that.externalEditorDialog(p)
|
||||||
.close(function(){
|
.on('close', function(){
|
||||||
o.client.update()
|
dialog.update()
|
||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
// move to top...
|
// move to top...
|
||||||
@ -380,11 +381,11 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
.open(function(evt){
|
.open(function(evt){
|
||||||
// close self if no dialog is triggered...
|
// close self if no dialog is triggered...
|
||||||
if(!closingPrevented){
|
if(!closingPrevented){
|
||||||
o.close()
|
dialog.parent.close()
|
||||||
}
|
}
|
||||||
closingPrevented = false
|
closingPrevented = false
|
||||||
}))
|
})
|
||||||
.close(function(){
|
.on('close', function(){
|
||||||
// remove elements marked for removal...
|
// remove elements marked for removal...
|
||||||
to_remove.forEach(function(e){
|
to_remove.forEach(function(e){
|
||||||
if(e == that.config['external-editor-default']){
|
if(e == that.config['external-editor-default']){
|
||||||
@ -396,11 +397,10 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
o.client.select(0)
|
dialog.dom.addClass('editor-list tail-action')
|
||||||
o.client.dom.addClass('editor-list tail-action')
|
|
||||||
|
|
||||||
return o
|
return dialog
|
||||||
}],
|
})],
|
||||||
})
|
})
|
||||||
|
|
||||||
var ExternalEditorUI =
|
var ExternalEditorUI =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user