From aa69a9b2d5fec54714b5b238edfb9f7d2a79a8dc Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Tue, 25 Oct 2011 13:11:15 +0530
Subject: [PATCH 1/9] ...
---
src/calibre/gui2/preferences/sending.py | 3 +++
src/calibre/gui2/preferences/sending.ui | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/calibre/gui2/preferences/sending.py b/src/calibre/gui2/preferences/sending.py
index c6cc7da754..3fce5cb072 100644
--- a/src/calibre/gui2/preferences/sending.py
+++ b/src/calibre/gui2/preferences/sending.py
@@ -29,10 +29,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
(_('Only on send'), 'on_send'),
(_('Automatic management'), 'on_connect')]
r('manage_device_metadata', prefs, choices=choices)
+
if gui.device_manager.is_device_connected:
self.opt_manage_device_metadata.setEnabled(False)
self.opt_manage_device_metadata.setToolTip(
_('Cannot change metadata management while a device is connected'))
+ self.mm_label.setText('Metadata management (disabled while '
+ 'device connected)')
self.send_template.changed_signal.connect(self.changed_signal.emit)
diff --git a/src/calibre/gui2/preferences/sending.ui b/src/calibre/gui2/preferences/sending.ui
index 75b1899a3a..606934329e 100644
--- a/src/calibre/gui2/preferences/sending.ui
+++ b/src/calibre/gui2/preferences/sending.ui
@@ -15,7 +15,7 @@
-
-
+
0
From 30b78c37823b12905f4f5f28865ef5d88ea91779 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Tue, 25 Oct 2011 18:57:58 +0530
Subject: [PATCH 2/9] Fix #881332 (Updated metro-nl)
---
..._news_nl.png (PNG Image, 16x16 pixels).png | Bin 0 -> 712 bytes
recipes/metro_news_nl.recipe | 81 ++++++++++++++++--
2 files changed, 73 insertions(+), 8 deletions(-)
create mode 100644 recipes/icons/metro_news_nl.png (PNG Image, 16x16 pixels).png
diff --git a/recipes/icons/metro_news_nl.png (PNG Image, 16x16 pixels).png b/recipes/icons/metro_news_nl.png (PNG Image, 16x16 pixels).png
new file mode 100644
index 0000000000000000000000000000000000000000..3b692f6bacdf5044f9456b95cb3363a3bcc2ffda
GIT binary patch
literal 712
zcmV;(0yq7MP)LIbGK!YB_
zs7Rr}OeiC1J~RsrGu>=DcX4(xFUPZ;OAksQ)kFWc5B@(s`1lcU+VMX}uSo;}Nd(VB
zkpY0B!KpzI{{UnOJfD)1x-EZej?pZ{Vne>sLGNfRCP1zE1CS y{(h+;FhkW;9QK
zjV7oy$!hKEVb9Hn?fo7%w23QK6msFnurk9>IYs$0#fL`7+RbZ;^mYHGdW86B!AEr+lSfJ96%
ztxI2@qWjJ-Rh1s%dEPrd;tl#g`@Iui#?n%B<+~l;>B)lZJTNK%G!#Y4aY-6YO=(3=
zhFMbN+GF+GH`%jIStfl(u0FHcQK?}Wn&m)I04QXoF*H+ASaPA|ayS}Zl;X`TuFMQ`
z-=MqwL0f*_mgYOnLOiZdH#~m%3^YT7WrMR3UwFEtaPQMMy;TP)Pu8C)wC~Ke=4P5K
z6ip6ALaw5+9#20+ab+a~#CTvf;;KJuG#G6emgr1qZhp=e3KUpvYL=_qvp-Rzz0`JV
znWR9H6ms-n*nr;`m!$@0)v$kDmZhm^I3_CwT^dW%o2|CG8yEedDR624#HxIyjx>k2G3UKBWn731Rbcm3Bp+JfN#v( |\s)*
|]*>Tweet|]*>||)', re.DOTALL|re.IGNORECASE),lambda match: ''),
+ (re.compile(r'( |\s\s)+\s*', re.DOTALL|re.IGNORECASE),lambda match: ' '),
+ (re.compile(r'([\s>])([^\s>]+)(]+) />', re.DOTALL|re.IGNORECASE),
+ lambda match: match.group(1) + match.group(3) + '>' + match.group(2) + ''),
+ ]
+
+ def postprocess_html(self, soup, first):
+ for tag in soup.findAll(lambda tag: tag.name.lower()=='img' and tag.has_key('src')):
+ iurl = tag['src']
+ img = Image()
+ img.open(iurl)
+ #width, height = img.size
+ #print '***img is: ', iurl, '\n****width is: ', width, 'height is: ', height
+ pw = PixelWand()
+ img.trim(0)
+ img.save(iurl)
+ '''
+ #width, height = img.size
+ #print '***TRIMMED img width is: ', width, 'height is: ', height
+ left=0
+ top=0
+ border_color='#ffffff'
+ width, height = img.size
+ #print '***retrieved img width is: ', width, 'height is: ', height
+ height_correction = 1.17
+ canvas = create_canvas(width, height*height_correction,border_color)
+ canvas.compose(img, left, top)
+ #img = canvas
+ canvas.save(iurl)
+ #width, height = canvas.size
+ #print '***NEW img width is: ', width, 'height is: ', height
+ '''
+ return soup
+
feeds = [
(u'Binnenland', u'http://www.metronieuws.nl/rss.xml?c=1277377288-3'),
(u'Economie', u'http://www.metronieuws.nl/rss.xml?c=1278070988-0'),
(u'Den Haag', u'http://www.metronieuws.nl/rss.xml?c=1289013337-3'),
(u'Rotterdam', u'http://www.metronieuws.nl/rss.xml?c=1289013337-2'),
(u'Amsterdam', u'http://www.metronieuws.nl/rss.xml?c=1289013337-1'),
+ (u'Buitenland', u'http://www.metronieuws.nl/rss.xml?c=1277377288-4'),
(u'Columns', u'http://www.metronieuws.nl/rss.xml?c=1277377288-17'),
(u'Entertainment', u'http://www.metronieuws.nl/rss.xml?c=1277377288-2'),
(u'Dot', u'http://www.metronieuws.nl/rss.xml?c=1283166782-12'),
From 636576ac7d7b14a2139d7f10de2a240948327c8e Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 08:27:51 +0530
Subject: [PATCH 3/9] Add optional login to The Autralian
---
recipes/the_oz.recipe | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/recipes/the_oz.recipe b/recipes/the_oz.recipe
index 6a897589db..c431c56fe7 100644
--- a/recipes/the_oz.recipe
+++ b/recipes/the_oz.recipe
@@ -16,17 +16,12 @@ class DailyTelegraph(BasicNewsRecipe):
language = 'en_AU'
oldest_article = 2
+ needs_subscription = 'optional'
max_articles_per_feed = 30
remove_javascript = True
no_stylesheets = True
encoding = 'utf8'
- html2lrf_options = [
- '--comment' , description
- , '--category' , 'news, Australia'
- , '--publisher' , title
- ]
-
keep_only_tags = [dict(name='div', attrs={'id': 'story'})]
#remove_tags = [dict(name=['object','link'])]
@@ -67,6 +62,19 @@ class DailyTelegraph(BasicNewsRecipe):
(u'Commercial Property', u'http://feeds.news.com.au/public/rss/2.0/aus_business_commercial_property_708.xml'),
(u'Mining', u'http://feeds.news.com.au/public/rss/2.0/aus_business_mining_704.xml')]
+ def get_browser(self):
+ br = BasicNewsRecipe.get_browser(self)
+ if self.username and self.password:
+ br.open('http://www.theaustralian.com.au')
+ br.select_form(nr=0)
+ br['username'] = self.username
+ br['password'] = self.password
+ raw = br.submit().read()
+ if '>log out' not in raw.lower():
+ raise ValueError('Failed to log in to www.theaustralian.com.au'
+ ' are your username and password correct?')
+ return br
+
def get_article_url(self, article):
return article.id
@@ -76,14 +84,4 @@ class DailyTelegraph(BasicNewsRecipe):
#return br.geturl()
- def get_cover_url(self):
- href = 'http://www.theaustralian.news.com.au/'
-
- soup = self.index_to_soup(href)
- img = soup.find('img',alt ="AUS HP promo digital2")
- print img
- if img :
- cover_url = img['src']
-
- return cover_url
From 90bec1f133322b3d307c221da1e912c780b471d9 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 08:33:37 +0530
Subject: [PATCH 4/9] ...
---
recipes/the_oz.recipe | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/recipes/the_oz.recipe b/recipes/the_oz.recipe
index c431c56fe7..cffeb173da 100644
--- a/recipes/the_oz.recipe
+++ b/recipes/the_oz.recipe
@@ -12,7 +12,9 @@ from calibre.web.feeds.news import BasicNewsRecipe
class DailyTelegraph(BasicNewsRecipe):
title = u'The Australian'
__author__ = u'Matthew Briggs and Sujata Raman'
- description = u'National broadsheet newspaper from down under - colloquially known as The Oz'
+ description = (u'National broadsheet newspaper from down under - colloquially known as The Oz'
+ '. You will need to have a subscription to '
+ 'http://www.theaustralian.com.au to get full articles.')
language = 'en_AU'
oldest_article = 2
From f86b414c478f98565b62c68731f647d648ee7083 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 09:57:27 +0530
Subject: [PATCH 5/9] Preserve the set of selected books in the library view
when a device is connected
---
src/calibre/gui2/device.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py
index f3ee0e575e..5f13923ddf 100644
--- a/src/calibre/gui2/device.py
+++ b/src/calibre/gui2/device.py
@@ -850,15 +850,16 @@ class DeviceMixin(object): # {{{
self.refresh_ondevice()
device_signals.device_metadata_available.emit()
- def refresh_ondevice(self, reset_only = False):
+ def refresh_ondevice(self, reset_only=False):
'''
Force the library view to refresh, taking into consideration new
device books information
'''
- self.book_on_device(None, reset=True)
- if reset_only:
- return
- self.library_view.model().refresh_ondevice()
+ with self.library_view.preserve_selected_books:
+ self.book_on_device(None, reset=True)
+ if reset_only:
+ return
+ self.library_view.model().refresh_ondevice()
# }}}
From 27e73d54f34c7209c04937e8795bd51f1e3df7df Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 10:41:54 +0530
Subject: [PATCH 6/9] Make preserving of library view when device is
connected/books are sent to device more robust
---
src/calibre/gui2/device.py | 4 +--
src/calibre/gui2/library/views.py | 55 ++++++++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py
index 5f13923ddf..3c05805782 100644
--- a/src/calibre/gui2/device.py
+++ b/src/calibre/gui2/device.py
@@ -855,7 +855,7 @@ class DeviceMixin(object): # {{{
Force the library view to refresh, taking into consideration new
device books information
'''
- with self.library_view.preserve_selected_books:
+ with self.library_view.preserve_state():
self.book_on_device(None, reset=True)
if reset_only:
return
@@ -1320,7 +1320,7 @@ class DeviceMixin(object): # {{{
# If it does not, then do it here.
if not self.set_books_in_library(self.booklists(), reset=True, add_as_step_to_job=job):
self.upload_booklists(job)
- with self.library_view.preserve_selected_books:
+ with self.library_view.preserve_state():
self.book_on_device(None, reset=True)
self.refresh_ondevice()
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index 5a62b76c6b..f0f7a33c3c 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -40,7 +40,42 @@ class PreserveSelection(object): # {{{
def __exit__(self, *args):
current = self.view.get_selected_ids()
if not current:
- self.view.select_rows(self.selected_ids, using_ids=True)
+ self.view.select_rows(self.selected_ids, using_ids=True,
+ change_current=False, scroll=False)
+# }}}
+
+class PreserveViewState(object): # {{{
+
+ '''
+ Save the set of selected books at enter time. If at exit time there are no
+ selected books, restore the previous selection, the previous current index
+ and dont affect the scroll position.
+ '''
+
+ def __init__(self, view, preserve_hpos=True, preserve_vpos=True):
+ self.view = view
+ self.selected_ids = set()
+ self.current_id = None
+ self.preserve_hpos = preserve_hpos
+ self.preserve_vpos = preserve_vpos
+
+ def __enter__(self):
+ self.selected_ids = self.view.get_selected_ids()
+ self.current_id = self.view.current_id
+ self.vscroll = self.verticalScrollBar().value()
+ self.hscroll = self.horizontalScrollBar().value()
+
+ def __exit__(self, *args):
+ current = self.view.get_selected_ids()
+ if not current and self.selected_ids:
+ if self.current_id is not None:
+ self.view.current_id = self.current_id
+ self.view.select_rows(self.selected_ids, using_ids=True,
+ scroll=False, change_current=self.current_id is None)
+ if self.preserve_vpos:
+ self.verticalScrollBar().setValue(self.vscroll)
+ if self.preserve_hpos:
+ self.horizontalScrollBar().setValue(self.hscroll)
# }}}
class BooksView(QTableView): # {{{
@@ -105,6 +140,7 @@ class BooksView(QTableView): # {{{
self.setSortingEnabled(True)
self.selectionModel().currentRowChanged.connect(self._model.current_changed)
self.preserve_selected_books = PreserveSelection(self)
+ self.preserve_state = partial(PreserveViewState, self)
# {{{ Column Header setup
self.can_add_columns = True
@@ -788,6 +824,23 @@ class BooksView(QTableView): # {{{
ans.append(i)
return ans
+ @dynamic_property
+ def current_id(self):
+ def fget(self):
+ try:
+ return self.model().id(self.currentIndex())
+ except:
+ pass
+ return None
+ def fset(self, val):
+ if val is None: return
+ m = self.model()
+ for row in xrange(m.rowCount(QModelIndex())):
+ if m.id(row) == val:
+ self.set_current_row(row, select=False)
+ break
+ return property(fget=fget, fset=fset)
+
def close(self):
self._model.close()
From d4f07e39672ce3a6e8770d27efd8fdb749ef96a4 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 10:45:40 +0530
Subject: [PATCH 7/9] remove unused code
---
src/calibre/gui2/library/views.py | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index f0f7a33c3c..cb7e6754f0 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -23,27 +23,6 @@ from calibre.gui2.library import DEFAULT_SORT
from calibre.constants import filesystem_encoding
from calibre import force_unicode
-class PreserveSelection(object): # {{{
-
- '''
- Save the set of selected books at enter time. If at exit time there are no
- selected books, restore the previous selection.
- '''
-
- def __init__(self, view):
- self.view = view
- self.selected_ids = []
-
- def __enter__(self):
- self.selected_ids = self.view.get_selected_ids()
-
- def __exit__(self, *args):
- current = self.view.get_selected_ids()
- if not current:
- self.view.select_rows(self.selected_ids, using_ids=True,
- change_current=False, scroll=False)
-# }}}
-
class PreserveViewState(object): # {{{
'''
@@ -139,7 +118,6 @@ class BooksView(QTableView): # {{{
self.setSelectionBehavior(QAbstractItemView.SelectRows)
self.setSortingEnabled(True)
self.selectionModel().currentRowChanged.connect(self._model.current_changed)
- self.preserve_selected_books = PreserveSelection(self)
self.preserve_state = partial(PreserveViewState, self)
# {{{ Column Header setup
From 3631dceebbcf79fe544daa683ec5269c36f4a094 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 12:21:11 +0530
Subject: [PATCH 8/9] ...
---
src/calibre/gui2/library/views.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index cb7e6754f0..be7efa8e1c 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -37,12 +37,17 @@ class PreserveViewState(object): # {{{
self.current_id = None
self.preserve_hpos = preserve_hpos
self.preserve_vpos = preserve_vpos
+ self.vscroll = self.hscroll = 0
def __enter__(self):
- self.selected_ids = self.view.get_selected_ids()
- self.current_id = self.view.current_id
- self.vscroll = self.verticalScrollBar().value()
- self.hscroll = self.horizontalScrollBar().value()
+ try:
+ self.selected_ids = self.view.get_selected_ids()
+ self.current_id = self.view.current_id
+ self.vscroll = self.view.verticalScrollBar().value()
+ self.hscroll = self.view.horizontalScrollBar().value()
+ except:
+ import traceback
+ traceback.print_exc()
def __exit__(self, *args):
current = self.view.get_selected_ids()
From 7bf888bd61ed839e1829c2dccda33a39a432e3c4 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Wed, 26 Oct 2011 12:22:26 +0530
Subject: [PATCH 9/9] ...
---
src/calibre/gui2/library/views.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index be7efa8e1c..6d04cbd443 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -57,9 +57,9 @@ class PreserveViewState(object): # {{{
self.view.select_rows(self.selected_ids, using_ids=True,
scroll=False, change_current=self.current_id is None)
if self.preserve_vpos:
- self.verticalScrollBar().setValue(self.vscroll)
+ self.view.verticalScrollBar().setValue(self.vscroll)
if self.preserve_hpos:
- self.horizontalScrollBar().setValue(self.hscroll)
+ self.view.horizontalScrollBar().setValue(self.hscroll)
# }}}
class BooksView(QTableView): # {{{