Example #1
0
	def __init__(self, ui, tool=None):
		Dialog.__init__(self, ui, _('Edit Custom Tool')) # T: Dialog title
		self.set_help(':Help:Custom Tools')
		self.vbox.set_spacing(12)

		if tool:
			name = tool.name
			comment = tool.comment
			execcmd = tool.execcmd
			readonly = tool.isreadonly
			toolbar = tool.showintoolbar
		else:
			name = ''
			comment = ''
			execcmd = ''
			readonly = False
			toolbar = False

		self.add_form((
			('Name', 'string', _('Name')), # T: Input in "Edit Custom Tool" dialog
			('Comment', 'string', _('Description')), # T: Input in "Edit Custom Tool" dialog
			('X-Zim-ExecTool', 'string', _('Command')), # T: Input in "Edit Custom Tool" dialog
		), {
			'Name': name,
			'Comment': comment,
			'X-Zim-ExecTool': execcmd,
		}, trigger_response=False)

		# FIXME need ui builder to take care of this as well
		self.iconbutton = IconChooserButton(stock=gtk.STOCK_EXECUTE)
		if tool and tool.icon and tool.icon != gtk.STOCK_EXECUTE:
			try:
				self.iconbutton.set_file(File(tool.icon))
			except Exception, error:
				logger.exception('Could not load: %s', tool.icon)
Example #2
0
    def __init__(self, ui, tool=None):
        Dialog.__init__(self, ui, _('Edit Custom Tool')) # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.vbox.set_spacing(12)

        if tool:
            name = tool.name
            comment = tool.comment
            execcmd = tool.execcmd
            readonly = tool.isreadonly
            toolbar = tool.showintoolbar
        else:
            name = ''
            comment = ''
            execcmd = ''
            readonly = False
            toolbar = False

        self.add_form((
            ('Name', 'string', _('Name')), # T: Input in "Edit Custom Tool" dialog
            ('Comment', 'string', _('Description')), # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ExecTool', 'string', _('Command')), # T: Input in "Edit Custom Tool" dialog
        ), {
            'Name': name,
            'Comment': comment,
            'X-Zim-ExecTool': execcmd,
        }, trigger_response=False)

        # FIXME need ui builder to take care of this as well
        self.iconbutton = IconChooserButton(stock=gtk.STOCK_EXECUTE)
        if tool and tool.icon and tool.icon != gtk.STOCK_EXECUTE:
            try:
                self.iconbutton.set_file(File(tool.icon))
            except Exception, error:
                logger.exception('Could not load: %s', tool.icon)
Example #3
0
class EditCustomToolDialog(Dialog):

    def __init__(self, ui, tool=None):
        Dialog.__init__(self, ui, _('Edit Custom Tool')) # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.vbox.set_spacing(12)

        if tool:
            name = tool.name
            comment = tool.comment
            execcmd = tool.execcmd
            readonly = tool.isreadonly
            toolbar = tool.showintoolbar
        else:
            name = ''
            comment = ''
            execcmd = ''
            readonly = False
            toolbar = False

        self.add_form((
            ('Name', 'string', _('Name')), # T: Input in "Edit Custom Tool" dialog
            ('Comment', 'string', _('Description')), # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ExecTool', 'string', _('Command')), # T: Input in "Edit Custom Tool" dialog
        ), {
            'Name': name,
            'Comment': comment,
            'X-Zim-ExecTool': execcmd,
        }, trigger_response=False)

        # FIXME need ui builder to take care of this as well
        self.iconbutton = IconChooserButton(stock=gtk.STOCK_EXECUTE)
        if tool and tool.icon and tool.icon != gtk.STOCK_EXECUTE:
            try:
                self.iconbutton.set_file(File(tool.icon))
            except Exception, error:
                logger.exception('Could not load: %s', tool.icon)
        label = gtk.Label(_('Icon')+':') # T: Input in "Edit Custom Tool" dialog
        label.set_alignment(0.0, 0.5)
        hbox = gtk.HBox()
        i = self.form.get_property('n-rows')
        self.form.attach(label, 0,1, i,i+1, xoptions=0)
        self.form.attach(hbox, 1,2, i,i+1)
        hbox.pack_start(self.iconbutton, False)

        self.form.add_inputs((
            ('X-Zim-ReadOnly', 'bool', _('Command does not modify data')), # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ShowInToolBar', 'bool', _('Show in the toolbar')), # T: Input in "Edit Custom Tool" dialog
        ))
        self.form.update({
            'X-Zim-ReadOnly': readonly,
            'X-Zim-ShowInToolBar': toolbar,
        })

        self.add_help_text(_('''\
The following parameters will be substituted
in the command when it is executed:
<tt>
<b>%f</b> the page source as a temporary file
<b>%d</b> the attachment directory of the current page
<b>%s</b> the real page source file (if any)
<b>%n</b> the notebook location (file or folder)
<b>%D</b> the document root (if any)
<b>%t</b> the selected text or word under cursor
<b>%T</b> the selected text including wiki formatting
</tt>
''') ) # T: Short help text in "Edit Custom Tool" dialog. The "%" is literal - please include the html formatting
    def __init__(self, parent, tool=None):
        Dialog.__init__(self, parent, _('Edit Custom Tool'))  # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.vbox.set_spacing(12)

        if tool:
            name = tool.name
            comment = tool.comment
            execcmd = tool.execcmd
            readonly = tool.isreadonly
            toolbar = tool.showintoolbar
            replaceselection = tool.replaceselection
        else:
            name = ''
            comment = ''
            execcmd = ''
            readonly = False
            toolbar = False
            replaceselection = False

        self.add_form(
            (
                ('Name', 'string',
                 _('Name')),  # T: Input in "Edit Custom Tool" dialog
                ('Comment', 'string',
                 _('Description')),  # T: Input in "Edit Custom Tool" dialog
                ('X-Zim-ExecTool', 'string',
                 _('Command')),  # T: Input in "Edit Custom Tool" dialog
            ),
            {
                'Name': name,
                'Comment': comment,
                'X-Zim-ExecTool': execcmd,
            },
            trigger_response=False)

        # FIXME need ui builder to take care of this as well
        self.iconbutton = IconChooserButton(stock=Gtk.STOCK_EXECUTE)
        if tool and tool.icon and tool.icon != Gtk.STOCK_EXECUTE:
            try:
                self.iconbutton.set_file(File(tool.icon))
            except Exception as error:
                logger.exception('Could not load: %s', tool.icon)
        label = Gtk.Label(label=_('Icon') +
                          ':')  # T: Input in "Edit Custom Tool" dialog
        label.set_alignment(0.0, 0.5)
        hbox = Gtk.HBox()
        i = self.form.get_property('n-rows')
        self.form.attach(label, 0, 1, i, i + 1, xoptions=0)
        self.form.attach(hbox, 1, 2, i, i + 1)
        hbox.pack_start(self.iconbutton, False, True, 0)

        self.form.add_inputs((
            ('X-Zim-ReadOnly', 'bool', _('Command does not modify data')
             ),  # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ReplaceSelection', 'bool',
             _('Output should replace current selection')
             ),  # T: Input in "Edit Custom Tool" dialog
            #('X-Zim-ShowInToolBar', 'bool', _('Show in the toolbar')), # T: Input in "Edit Custom Tool" dialog
        ))
        self.form.update({
            'X-Zim-ReadOnly': readonly,
            'X-Zim-ReplaceSelection': replaceselection,
            #'X-Zim-ShowInToolBar': toolbar,
        })

        self.add_help_text(
            _('''\
The following parameters will be substituted
in the command when it is executed:
<tt>
<b>%f</b> the page source as a temporary file
<b>%d</b> the attachment directory of the current page
<b>%s</b> the real page source file (if any)
<b>%p</b> the page name
<b>%n</b> the notebook location (file or folder)
<b>%D</b> the document root (if any)
<b>%t</b> the selected text or word under cursor
<b>%T</b> the selected text including wiki formatting
</tt>
'''))  # T: Short help text in "Edit Custom Tool" dialog. The "%" is literal - please include the html formatting