mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More work on edit book plugin interface
This commit is contained in:
parent
cc05dee17e
commit
60a346f565
@ -743,6 +743,8 @@ class ViewerPlugin(Plugin): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class EditBookToolPlugin(Plugin): # {{{
|
class EditBookToolPlugin(Plugin): # {{{
|
||||||
pass
|
|
||||||
|
minimum_calibre_version = (1, 45, 0)
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -70,9 +70,14 @@ def in_thread_job(func):
|
|||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
_boss = None
|
||||||
|
def get_boss():
|
||||||
|
return _boss
|
||||||
|
|
||||||
class Boss(QObject):
|
class Boss(QObject):
|
||||||
|
|
||||||
def __init__(self, parent, notify=None):
|
def __init__(self, parent, notify=None):
|
||||||
|
global _boss
|
||||||
QObject.__init__(self, parent)
|
QObject.__init__(self, parent)
|
||||||
self.global_undo = GlobalUndoHistory()
|
self.global_undo = GlobalUndoHistory()
|
||||||
self.container_count = 0
|
self.container_count = 0
|
||||||
@ -82,6 +87,7 @@ class Boss(QObject):
|
|||||||
self.doing_terminal_save = False
|
self.doing_terminal_save = False
|
||||||
self.ignore_preview_to_editor_sync = False
|
self.ignore_preview_to_editor_sync = False
|
||||||
setup_cssutils_serialization()
|
setup_cssutils_serialization()
|
||||||
|
_boss = self
|
||||||
|
|
||||||
def __call__(self, gui):
|
def __call__(self, gui):
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
|
41
src/calibre/gui2/tweak_book/plugin.py
Normal file
41
src/calibre/gui2/tweak_book/plugin.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import,
|
||||||
|
print_function)
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
from calibre.gui2.tweak_book.boss import get_boss
|
||||||
|
|
||||||
|
class Tool(object):
|
||||||
|
|
||||||
|
#: Set this to a unique name it will be used as a key
|
||||||
|
name = None
|
||||||
|
|
||||||
|
#: If True the user can choose to place this tool in the plugins toolbar
|
||||||
|
allowed_in_toolbar = True
|
||||||
|
|
||||||
|
#: If True the user can choose to place this tool in the plugins menu
|
||||||
|
allowed_in_menu = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boss(self):
|
||||||
|
' The :class:`calibre.gui2.tweak_book.boss.Boss` object. Used to control the user interface. '
|
||||||
|
return get_boss()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gui(self):
|
||||||
|
' The main window of the user interface '
|
||||||
|
return self.boss.gui
|
||||||
|
|
||||||
|
def create_action(self, for_toolbar=True):
|
||||||
|
'''
|
||||||
|
Create a QAction that will be added to either the plugins toolbar or
|
||||||
|
the plugins menu depending on ``for_toolbar``. For example::
|
||||||
|
|
||||||
|
def create_action(self, for_toolbar):
|
||||||
|
ac = QAction(
|
||||||
|
'''
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user