diff --git a/oml/api.py b/oml/api.py index 32b31bc..32c1363 100644 --- a/oml/api.py +++ b/oml/api.py @@ -40,8 +40,6 @@ def selectFolder(data): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) stdout, stderr = p.communicate() path = stdout.decode('utf-8').strip() - if path == 'None': - path = None return { 'path': path } @@ -62,18 +60,12 @@ def selectFile(data): p = subprocess.Popen(cmd, stdout=subprocess.PIPE) stdout, stderr = p.communicate() path = stdout.decode('utf-8').strip() - if path == 'None': - path = None return { 'path': path } 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): ''' @@ -100,7 +92,6 @@ def autocompleteFolder(data): folders = [path] + folders else: folders = [] - folders = [short_home(f) for f in folders] return { 'items': ox.sorted_strings(folders) } diff --git a/oml/ui.py b/oml/ui.py index a15dfac..f9970bf 100644 --- a/oml/ui.py +++ b/oml/ui.py @@ -76,9 +76,9 @@ class GtkUI: class TkUI: def __init__(self): self.root = Tk(className="Open Media Library") - #png = os.path.join(os.path.dirname(os.path.abspath('__file__')), 'static', 'png', 'oml.png') - #icon = PhotoImage(file=png) - #self.root.tk.call('wm', 'iconphoto', self.root._w, icon) + png = os.path.join(os.path.dirname(os.path.abspath('__file__')), 'static', 'png', 'oml.png') + icon = PhotoImage(file=png) + self.root.tk.call('wm', 'iconphoto', self.root._w, icon) self.root.withdraw() # hiding tkinter window if sys.platform == 'darwin': self.root.lift() diff --git a/static/js/selectFolder.js b/static/js/selectFolder.js index b760643..f6a2cc8 100644 --- a/static/js/selectFolder.js +++ b/static/js/selectFolder.js @@ -1,41 +1,26 @@ 'use strict'; oml.ui.selectFolder = function(options, self) { - var inputOptions = { - style: options.style, - placeholder: options.placeholder, - width: options.width - options.labelWidth - 4, - value: options.title, - autocomplete: function(value, callback) { - 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({ + options.width = options.width - options.labelWidth + options = Ox.extend({ + title: '...', + textAlign: 'left' + }, options); + var $button = Ox.Button(options, self).bindEvent({ click: function(event) { oml.api.selectFolder({ - base: $input.value() + base: $button.value() }, function(result) { if (result.data.path) { - $input.value(result.data.path); - that.triggerEvent('change', result.data.path); + $button.value(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({ id: options.id, elements: [ @@ -46,13 +31,12 @@ oml.ui.selectFolder = function(options, self) { title: options.label, width: options.labelWidth }), - $input, $button ], }, self); that.value = function() { - return $input.value() + return $button.value() } if (options.title && options.title != '...') {