Allow adding the "Manage Snippets" action to the toolbar, for easy access

This commit is contained in:
Kovid Goyal 2015-01-11 14:15:36 +05:30
parent 57eee6d2f7
commit 04dfbe41d4
5 changed files with 50 additions and 0 deletions

42
imgsrc/snippets.svg Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="128"
height="128"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-924.36218)"
id="layer1">
<text
x="6.9818249"
y="1031.5"
transform="scale(1.0074934,0.99256234)"
id="text2985"
xml:space="preserve"
style="font-size:119.50392914px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"><tspan
x="6.9818249"
y="1031.5"
id="tspan2987">{|}</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1353,6 +1353,10 @@ class Boss(QObject):
def insert_character(self): def insert_character(self):
self.gui.insert_char.show() self.gui.insert_char.show()
def manage_snippets(self):
from calibre.gui2.tweak_book.editor.snippets import UserSnippets
UserSnippets(self.gui).exec_()
# Shutdown {{{ # Shutdown {{{
def quit(self): def quit(self):

View File

@ -548,6 +548,7 @@ class UserSnippets(Dialog):
def __init__(self, parent=None): def __init__(self, parent=None):
Dialog.__init__(self, _('Create/Edit snippets'), 'snippet-editor', parent=parent) Dialog.__init__(self, _('Create/Edit snippets'), 'snippet-editor', parent=parent)
self.setWindowIcon(QIcon(I('snippets.png')))
def setup_ui(self): def setup_ui(self):
self.setWindowIcon(QIcon(I('modified.png'))) self.setWindowIcon(QIcon(I('modified.png')))

View File

@ -460,6 +460,9 @@ class Main(MainWindow):
'Split HTML file at multiple locations')) 'Split HTML file at multiple locations'))
self.action_compare_book = treg('diff.png', _('&Compare to another book'), self.boss.compare_book, 'compare-book', (), _( self.action_compare_book = treg('diff.png', _('&Compare to another book'), self.boss.compare_book, 'compare-book', (), _(
'Compare to another book')) 'Compare to another book'))
self.action_manage_snippets = treg(
'snippets.png', _('Manage &Snippets'), self.boss.manage_snippets, 'manage-snippets', (), _(
'Manage user created snippets'))
self.plugin_menu_actions = [] self.plugin_menu_actions = []