GwR EPUB/MOBI integration

This commit is contained in:
GRiker 2010-01-22 08:28:32 -07:00
commit 0fe72a4b42
22 changed files with 2777 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,62 @@
p.title {
margin-top:0em;
margin-bottom:1em;
text-align:center;
font-style:italic;
font-size:xx-large;
height:0px;
}
p.author {
margin-top:0em;
margin-bottom:0em;
text-align: left;
text-indent: 1em;
font-size:large;
}
p.tags {
margin-top:0em;
margin-bottom:0em;
text-align: left;
text-indent: 1em;
font-size:small;
}
p.description {
text-align:left;
font-style:italic;
margin-top: 0em;
}
p.letter_index {
font-size:x-large;
text-align:left;
margin-top:0px;
margin-bottom:0px;
}
p.author_index {
font-size:large;
text-align:left;
margin-top:0px;
margin-bottom:0px;
text-indent: 0em;
}
p.read_book {
text-align:left;
margin-top:0px;
margin-bottom:0px;
margin-left:2em;
text-indent:-2em;
}
p.unread_book {
text-align:left;
margin-top:0px;
margin-bottom:0px;
margin-left:2em;
text-indent:-2em;
}

View File

@ -421,8 +421,8 @@ from calibre.devices.binatone.driver import README
from calibre.devices.hanvon.driver import N516 from calibre.devices.hanvon.driver import N516
from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon
from calibre.library.catalog import CSV_XML from calibre.library.catalog import CSV_XML, EPUB_MOBI
plugins = [HTML2ZIP, PML2PMLZ, GoogleBooks, ISBNDB, Amazon, CSV_XML] plugins = [HTML2ZIP, PML2PMLZ, GoogleBooks, ISBNDB, Amazon, CSV_XML, EPUB_MOBI]
plugins += [ plugins += [
ComicInput, ComicInput,
EPUBInput, EPUBInput,

View File

@ -0,0 +1,45 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.gui2 import gprefs
from catalog_epub_mobi_ui import Ui_Form
from PyQt4.Qt import QWidget
class PluginWidget(QWidget,Ui_Form):
TITLE = _('EPUB/MOBI Options')
HELP = _('Options specific to')+' EPUB/MOBI '+_('output')
# Indicates whether this plugin wants its output synced to the connected device
sync_enabled = True
formats = set(['epub','mobi'])
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
def initialize(self, name):
self.name = name
# Restore options from last use here
print "gui2.catalog.catalog_epub_mobi:initialize(): need to restore options"
def options(self):
OPTION_FIELDS = ['exclude_genre','exclude_tags','read_tag','note_tag','output_profile']
# Save the current options
print "gui2.catalog.catalog_epub_mobi:options(): need to save options"
# Return a dictionary with current options
print "gui2.catalog.catalog_epub_mobi:options(): need to return options"
print "gui2.catalog.catalog_epub_mobi:options(): using hard-coded options"
opts_dict = {}
for opt in OPTION_FIELDS:
opts_dict[opt] = str(getattr(self,opt).text()).split(',')
return opts_dict

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>411</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>241</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Tags to exclude as genres (regex):</string>
</property>
<property name="textFormat">
<enum>Qt::LogText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>241</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>'Don't include this book' tag:</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>171</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Additional note tag prefix:</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>181</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Output profile:</string>
</property>
</widget>
<widget class="QLineEdit" name="exclude_genre">
<property name="geometry">
<rect>
<x>300</x>
<y>20</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Tooltip comment here"/>
</property>
<property name="text">
<string>\[[\w ]*\]</string>
</property>
</widget>
<widget class="QLineEdit" name="exclude_tags">
<property name="geometry">
<rect>
<x>300</x>
<y>50</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Tooltip comment here"/>
</property>
<property name="text">
<string>~</string>
</property>
</widget>
<widget class="QLineEdit" name="read_tag">
<property name="geometry">
<rect>
<x>300</x>
<y>80</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Tooltip comment here"/>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>241</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>'Mark this book as read' tag:</string>
</property>
</widget>
<widget class="QLineEdit" name="note_tag">
<property name="geometry">
<rect>
<x>300</x>
<y>110</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Tooltip comment here"/>
</property>
<property name="text">
<string>*</string>
</property>
</widget>
<widget class="QLineEdit" name="output_profile">
<property name="geometry">
<rect>
<x>300</x>
<y>140</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Tooltip comment here"/>
</property>
<property name="text">
<string>kindle2</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -42,6 +42,7 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, fmt_options,
opts, args = parser.parse_args() opts, args = parser.parse_args()
# Populate opts # Populate opts
opts.catalog_title = title
opts.ids = ids opts.ids = ids
opts.search_text = None opts.search_text = None
opts.sort_by = None opts.sort_by = None

View File

@ -17,7 +17,6 @@ from calibre.customize.ui import catalog_plugins
class Catalog(QDialog, Ui_Dialog): class Catalog(QDialog, Ui_Dialog):
''' Catalog Dialog builder''' ''' Catalog Dialog builder'''
widgets = []
def __init__(self, parent, dbspec, ids): def __init__(self, parent, dbspec, ids):
import re, cStringIO import re, cStringIO
@ -50,11 +49,12 @@ class Catalog(QDialog, Ui_Dialog):
name = plugin.name.lower().replace(' ', '_') name = plugin.name.lower().replace(' ', '_')
if type(plugin) in builtin_plugins: if type(plugin) in builtin_plugins:
#info("Adding widget for builtin Catalog plugin %s" % plugin.name) info("Adding widget for builtin Catalog plugin %s" % plugin.name)
try: try:
catalog_widget = __import__('calibre.gui2.catalog.'+name, catalog_widget = __import__('calibre.gui2.catalog.'+name,
fromlist=[1]) fromlist=[1])
pw = catalog_widget.PluginWidget() pw = catalog_widget.PluginWidget()
info("Initializing %s" % name)
pw.initialize(name) pw.initialize(name)
pw.ICON = I('forward.svg') pw.ICON = I('forward.svg')
self.widgets.append(pw) self.widgets.append(pw)

View File

@ -1092,6 +1092,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.library_view.model().refresh_ids(ids) self.library_view.model().refresh_ids(ids)
self.library_view.model().current_changed(self.library_view.currentIndex(), self.library_view.model().current_changed(self.library_view.currentIndex(),
self.library_view.currentIndex()) self.library_view.currentIndex())
if ids:
self.tags_view.recount()
def delete_all_but_selected_formats(self, *args): def delete_all_but_selected_formats(self, *args):
ids = self._get_selected_ids() ids = self._get_selected_ids()
@ -1113,6 +1115,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.library_view.model().refresh_ids(ids) self.library_view.model().refresh_ids(ids)
self.library_view.model().current_changed(self.library_view.currentIndex(), self.library_view.model().current_changed(self.library_view.currentIndex(),
self.library_view.currentIndex()) self.library_view.currentIndex())
if ids:
self.tags_view.recount()
def delete_covers(self, *args): def delete_covers(self, *args):
@ -1399,8 +1403,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.status_bar.showMessage(_('Catalog generated.'), 3000) self.status_bar.showMessage(_('Catalog generated.'), 3000)
self.sync_catalogs() self.sync_catalogs()
if job.fmt in ['CSV','XML']: if job.fmt in ['CSV','XML']:
export_dir = choose_dir(self, 'Export Catalog Directory', export_dir = choose_dir(self, _('Export Catalog Directory'),
'Select destination for %s.%s' % (job.catalog_title, job.fmt.lower())) _('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
if export_dir: if export_dir:
destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower())) destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower()))
shutil.copyfile(job.catalog_file_path, destination) shutil.copyfile(job.catalog_file_path, destination)

File diff suppressed because it is too large Load Diff

View File

@ -194,7 +194,7 @@ You can insert the following two lines of code to start an interactive python se
When running from the command line, this will start an interactive python interpreter with access to all When running from the command line, this will start an interactive python interpreter with access to all
locally defined variables (variables in the local scope). The interactive prompt even has TAB completion locally defined variables (variables in the local scope). The interactive prompt even has TAB completion
for object properties and you can use the various python facilities for introspection, such as for object properties and you can use the various python facilities for introspection, such as
:function:`dir`, :function:`type`, :function:`repr`, etc. :func:`dir`, :func:`type`, :func:`repr`, etc.
Using print statements Using print statements
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
@ -204,4 +204,18 @@ terminal. For example, you can start the GUI from the terminal as::
calibre-debug -g calibre-debug -g
Executing arbitrary scripts in the calibre python environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The :command:`calibre-debug` command provides a couple of handy switches to execute your own
code, with access to the calibre modules::
calibre-debug -c "some python code"
is great for testing a little snippet of code on the command line. It works in the same way as the -c switch to the python interpreter::
calibre-debug -e myscript.py
can be used to execute your own python script. It works in the same way as passing the script to the python interpreter, except
that the calibre environment is fully initialized, so you can use all the calibre code in your script.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

View File

@ -29,6 +29,7 @@ Sections
gui gui
news news
viewer
conversion conversion
metadata metadata
faq faq

View File

@ -0,0 +1,105 @@
.. include:: global.rst
.. _gui:
The E-book Viewer
=============================
|app| includes a built-in E-book viewer that can view all the major e-book formats.
The viewer is highly customizable and has many advanced features.
.. contents::
:depth: 1
:local:
Starting the viewer
--------------------
You can view any of the books in your |app| library by selecting the book and pressing the View button. This
will open up the book in the e-book viewer. You can also launch the viewer by itself, from the Start menu in windows
or using the command :command:`ebook-viewer` in Linux and OS X (you have to install the command line tools on OS X
first by going to Preferences->Advanced).
Navigating around an e-book
-----------------------------
.. |pni| image:: images/prev_next.png
.. |bookmi| image:: images/bookmark.png
.. |toci| image:: images/toc.png
.. |navposi| image:: images/nav_pos.png
.. |refmi| image:: images/ref_mode_button.png
You can "turn pages" in a book by using the :guilabel:`Page Next` and :guilabel:`Page Previous` buttons |pni|, or by pressing
the Page Down/Page Up keys. Unlike most e-book viewers, |app| does not force you to view books in paged mode. You can
scroll by amounts less than a page by using the scroll bar or various customizable keyboard shortcuts.
Bookmarks
^^^^^^^^^^^^
When you are in the middle of a book and close the viewer, it will remember where you stopped reading and return there
the next time you open the book. You can also set bookmarks in the book by using the Bookmark button |bookmi|. When viewing EPUB format
books, these bookmarks are actually saved in the EPUB file itself, so you can add bookmarks, then send the file to a friend and
when they open the file, they will be able to see your bookmarks.
Table of Contents
^^^^^^^^^^^^^^^^^^^^
If the book you are reading defines a Table of Contents, you can access it by pressing the Table of Contents button |toci|.
This will bring up a list of sections in the book and you can click on any of them to jump to that portion of the book.
Navigating by location
^^^^^^^^^^^^^^^^^^^^^^^^
E-books, unlike paper books have no concept of pages. Instead,
as you read through the book, you will notice that your position in the book is displayed in the upper left corner in a box
like this |navposi|. This is both your current position and the total length of the book. These numbers are independent of the screen size and font
size you are viewing the boko at, and they play a similar role to page numbers in paper books.
You can enter any number you like to go to the corresponding location in the book.
|app| also has a very handy
reference mode. You can turn it on by clicking the Reference Mode button |refmi|. Once you do this, every time you move your
mouse over a paragraph, calibre will display a unique number made up of the section and paragraph numbers.
.. image:: images/ref_mode.png
You can use this number to unambiguously refer to parts of the books when discussing it with friends or referring to it
in other works. You can enter these numbers in the box marked Go to at the top of the window to go to a particular
reference location.
If you click on links inside the e-book to take you to different parts of the book, like an endnote, you can use the back and forward buttons
in the top left corner to return to where you were. These button behave just like those in a web browser.
Customizing the look and feel of your reading experience
------------------------------------------------------------
.. |fontsizei| image:: images/font_size.png
.. |fsi| image:: images/full_screen.png
.. |prefbi| image:: images/pref_button.png
You can change font sizes on the fly by using the font size buttons |fontsizei|. You can also make the viewer full screen
by pressing the Full Screen button |fsi|. By clicking the Preferences button |prefbi|, you can change the default fonts used
by the viewer to ones you like as well as the default font size when the viewer starts up.
More advanced customization can be achieved by the User Stylesheet setting. This is a stylesheet you can set that will be applied
to every book. Using it you can do things like have white text on a black background, change paragraph styles, text justification, etc.
For examples if custom stylesheets used by |app|'s users, see `the forums <http://www.mobileread.com/forums/showthread.php?t=51500>`_.
Dictionary lookup
-------------------
You can lookup the meaning of words in the current book by right clicking on a word. |app| uses the publicly available dictionary
server at ``dict.org`` to lookup words. The definition is displayed in a small box at the bottom of the screen.
Copying text and images
-------------------------
You can select text and images by dragging the content with your mouse and then right click to copy to the clipboard.
The copied material can be pasted into another application as plain text and images.