diff --git a/files/ZAZFavorites_v0.6.0.oxt b/files/ZAZFavorites_v0.6.0.oxt index a2f70d7..303d707 100644 Binary files a/files/ZAZFavorites_v0.6.0.oxt and b/files/ZAZFavorites_v0.6.0.oxt differ diff --git a/source/images/delete.png b/source/images/delete.png deleted file mode 100644 index 7652e03..0000000 Binary files a/source/images/delete.png and /dev/null differ diff --git a/source/pythonpath/main.py b/source/pythonpath/main.py index b5d47b2..8698af5 100644 --- a/source/pythonpath/main.py +++ b/source/pythonpath/main.py @@ -5,7 +5,8 @@ import easymacro as app ID_EXTENSION = '' _ = None -# ~ cmd = 'service:' + ID_EXTENSION + '?' + +PREFIX = 'fav' class Controllers(object): @@ -35,37 +36,43 @@ class Controllers(object): @app.catch_exception def button_save_action(self, event): - msg = _('Want you save your favorites?') + msg = _('Want you save your favorites files?') if not app.question(msg, self.TITLE): return - base = 'service:net.elmau.zaz.Favorites?{}' - paths = [] + # ~ cmd = 'service:' + ID_EXTENSION + '?' + base = f'service:{ID_EXTENSION}?{{}}' + # ~ paths = [] submenus = [] - for row in range(self.d.grid.rows): - label = '{}. {}'.format(row + 1, self.d.grid[0, row]) - path = self.d.grid[2, row] - paths.append(path) - path = app._path_url(path) - sm = {'Label': label, 'CommandURL': base.format(path)} - submenus.append(sm) - sm = {'Label': '-'} - submenus.append(sm) - sm = {'Label': _('Favorites...'), 'CommandURL': base.format('config')} - submenus.append(sm) + for path in self.paths: + pass + # ~ for row in range(self.d.grid.row_count): + # ~ name = self.d.grid[0, row] + # ~ path = self.d.grid[2, row] - command = 'menu.zaz.favorites' - data = { - 'Label': 'Favorites', - 'CommandURL': command, - 'After': '.uno:RecentFileList', - 'Submenu': submenus, - } + # ~ label = '{}. {}'.format(row + 1, name) + # ~ paths.append(path) + # ~ path = app._path_url(path) + # ~ sm = {'Label': label, 'CommandURL': base.format(path)} + # ~ submenus.append(sm) + # ~ sm = {'Label': '-'} + # ~ submenus.append(sm) + # ~ sm = {'Label': _('Favorites...'), 'CommandURL': base.format('config')} + # ~ submenus.append(sm) - for doc_type in ('main', 'calc', 'writer'): - app.remove_menu(doc_type, 'File', command) - app.insert_menu(doc_type, 'File', **data) - app.set_config('paths', paths) + # ~ command = 'menu.zaz.favorites' + # ~ data = { + # ~ 'Label': 'Favorites', + # ~ 'CommandURL': command, + # ~ 'After': '.uno:RecentFileList', + # ~ 'Submenu': submenus, + # ~ } + + # ~ for doc_type in ('main', 'calc', 'writer'): + # ~ app.remove_menu(doc_type, 'File', command) + # ~ app.insert_menu(doc_type, 'File', **data) + + app.set_config('paths', self.paths, PREFIX) self.d.close(1) msg = _('Favorites saved correctly') @@ -104,15 +111,18 @@ class Controllers(object): def _config(): dlg = _create_dialog() + path_img = app.paths.join(dlg.path, 'images/delete.svg') + image = app.paths.image(path_img) - # ~ dlg.grid.set_column_image(1, app.join(self.IMAGES, 'delete.png')) - # ~ paths = app.get_config('paths', []) - # ~ for path in paths: - # ~ p, filename, n, e = app.get_info_path(path) - # ~ dlg.grid.add_row((filename, '', path)) - # ~ dlg.grid.set_cell_tooltip(0, dlg.grid.rows-1, p) - # ~ dlg.events.paths = paths + paths = app.get_config('paths', prefix=PREFIX) + for i, path in enumerate(paths): + p = app.paths(path) + dlg.grid.add_row((p.file_name, image, path)) + dlg.grid.set_cell_tooltip(0, i, p.path) + if paths: + dlg.grid.sort(0) + dlg.events.paths = paths dlg.open() return