zaz-favorites/source/ZAZFavorites.py

66 lines
1.8 KiB
Python

import uno
import unohelper
from com.sun.star.task import XJobExecutor
import main
ID_EXTENSION = 'net.elmau.zaz.Favorites'
SERVICE = ('com.sun.star.task.Job',)
class ZAZFavorites(unohelper.Base, XJobExecutor):
def __init__(self, ctx):
self.ctx = ctx
def trigger(self, args):
main.ID_EXTENSION = ID_EXTENSION
main.run(args, __file__)
return
def _create_dialog(self):
columns = (
{'Title': _('File Name'), 'MaxWidth': 120},
{'Title': 'X', 'HorizontalAlign': 1, 'Resizeable': False, 'ColumnWidth': 10},
{'Title': '', 'Resizeable': False, 'ColumnWidth': 0},
)
args = {
'Type': 'Grid',
'Name': 'grid',
'Width': 140,
'Height': 110,
'ShowRowHeader': True,
'Columns': columns
}
dlg.add_control(args)
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
args = {
'Type': 'Button',
'Name': 'button_save',
'Label': _('~Save'),
'ImageURL': app.join(self.IMAGES, 'save.png'),
'ImagePosition': 1,
'Width': 60,
'Height': 15,
}
dlg.add_control(args)
dlg.button_add.center()
dlg.grid.move(dlg.button_add)
dlg.grid.center()
dlg.button_save.move(dlg.grid)
dlg.button_save.center()
return dlg
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(ZAZFavorites, ID_EXTENSION, SERVICE)