Compare commits
No commits in common. "de67f202a8c29bf626248d314e09cf42c4e0324a" and "d46e341448731b2eebf0c56a7926b5890476b10a" have entirely different histories.
de67f202a8
...
d46e341448
3 changed files with 17 additions and 42 deletions
11
oml/api.py
11
oml/api.py
|
|
@ -40,8 +40,6 @@ def selectFolder(data):
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
path = stdout.decode('utf-8').strip()
|
path = stdout.decode('utf-8').strip()
|
||||||
if path == 'None':
|
|
||||||
path = None
|
|
||||||
return {
|
return {
|
||||||
'path': path
|
'path': path
|
||||||
}
|
}
|
||||||
|
|
@ -62,18 +60,12 @@ def selectFile(data):
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
path = stdout.decode('utf-8').strip()
|
path = stdout.decode('utf-8').strip()
|
||||||
if path == 'None':
|
|
||||||
path = None
|
|
||||||
return {
|
return {
|
||||||
'path': path
|
'path': path
|
||||||
}
|
}
|
||||||
actions.register(selectFile, cache=False)
|
actions.register(selectFile, cache=False)
|
||||||
|
|
||||||
def short_home(path):
|
|
||||||
home = os.path.expanduser('~')
|
|
||||||
if path and path.startswith(home):
|
|
||||||
path = path.replace(home, '~')
|
|
||||||
return path
|
|
||||||
|
|
||||||
def autocompleteFolder(data):
|
def autocompleteFolder(data):
|
||||||
'''
|
'''
|
||||||
|
|
@ -100,7 +92,6 @@ def autocompleteFolder(data):
|
||||||
folders = [path] + folders
|
folders = [path] + folders
|
||||||
else:
|
else:
|
||||||
folders = []
|
folders = []
|
||||||
folders = [short_home(f) for f in folders]
|
|
||||||
return {
|
return {
|
||||||
'items': ox.sorted_strings(folders)
|
'items': ox.sorted_strings(folders)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,9 @@ class GtkUI:
|
||||||
class TkUI:
|
class TkUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.root = Tk(className="Open Media Library")
|
self.root = Tk(className="Open Media Library")
|
||||||
#png = os.path.join(os.path.dirname(os.path.abspath('__file__')), 'static', 'png', 'oml.png')
|
png = os.path.join(os.path.dirname(os.path.abspath('__file__')), 'static', 'png', 'oml.png')
|
||||||
#icon = PhotoImage(file=png)
|
icon = PhotoImage(file=png)
|
||||||
#self.root.tk.call('wm', 'iconphoto', self.root._w, icon)
|
self.root.tk.call('wm', 'iconphoto', self.root._w, icon)
|
||||||
self.root.withdraw() # hiding tkinter window
|
self.root.withdraw() # hiding tkinter window
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
self.root.lift()
|
self.root.lift()
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,26 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
oml.ui.selectFolder = function(options, self) {
|
oml.ui.selectFolder = function(options, self) {
|
||||||
var inputOptions = {
|
options.width = options.width - options.labelWidth
|
||||||
style: options.style,
|
options = Ox.extend({
|
||||||
placeholder: options.placeholder,
|
title: '...',
|
||||||
width: options.width - options.labelWidth - 4,
|
textAlign: 'left'
|
||||||
value: options.title,
|
}, options);
|
||||||
autocomplete: function(value, callback) {
|
var $button = Ox.Button(options, self).bindEvent({
|
||||||
oml.api.autocompleteFolder({path: value}, function(result) {
|
|
||||||
callback(result.data.items);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
autocompleteSelect: true,
|
|
||||||
changeOnKeypress: true,
|
|
||||||
},
|
|
||||||
buttonOptions = {
|
|
||||||
overlap: 'left',
|
|
||||||
tooltip: Ox._('Select Folder'),
|
|
||||||
style: options.style,
|
|
||||||
title: 'directory',
|
|
||||||
type: 'image'
|
|
||||||
};
|
|
||||||
var $button = Ox.Button(buttonOptions).bindEvent({
|
|
||||||
click: function(event) {
|
click: function(event) {
|
||||||
oml.api.selectFolder({
|
oml.api.selectFolder({
|
||||||
base: $input.value()
|
base: $button.value()
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
if (result.data.path) {
|
if (result.data.path) {
|
||||||
$input.value(result.data.path);
|
$button.value(result.data.path);
|
||||||
that.triggerEvent('change', result.data.path);
|
$button.options({
|
||||||
|
title: result.data.path
|
||||||
|
});
|
||||||
|
$button.triggerEvent('change', result.data.path);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}).css({
|
|
||||||
'padding-left': '4px'
|
|
||||||
}),
|
}),
|
||||||
$input = Ox.Input(inputOptions),
|
|
||||||
that = Ox.FormElementGroup({
|
that = Ox.FormElementGroup({
|
||||||
id: options.id,
|
id: options.id,
|
||||||
elements: [
|
elements: [
|
||||||
|
|
@ -46,13 +31,12 @@ oml.ui.selectFolder = function(options, self) {
|
||||||
title: options.label,
|
title: options.label,
|
||||||
width: options.labelWidth
|
width: options.labelWidth
|
||||||
}),
|
}),
|
||||||
$input,
|
|
||||||
$button
|
$button
|
||||||
],
|
],
|
||||||
}, self);
|
}, self);
|
||||||
|
|
||||||
that.value = function() {
|
that.value = function() {
|
||||||
return $input.value()
|
return $button.value()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.title && options.title != '...') {
|
if (options.title && options.title != '...') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue