Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-10-2011, 05:59 PM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Specifying a default search when switching libraries from a plugin

In the "View Manager" plugin a user requested the ability for the plugin to apply the "last used view" when Calibre starts up/switches libraries. Applying columns (which Calibre does anyway) and sort orders (which Calibre doesn't) works fine.

However in the plugin (in my initialization_complete) if I call self.gui.apply_named_search_restriction or self.gui.saved_search.saved_search_selected to either apply a restriction or apply a saved search, these appear to be cleared by code later in the startup/library switch process.

Is there some signal perhaps that I could connect to from my plugin to know when the Calibre gui is initialized to a point where it would allow me to apply search restrictions or searches? Both at startup and when libraries are switched?

Last edited by kiwidude; 04-10-2011 at 06:59 PM. Reason: Changed thread title
kiwidude is offline   Reply With Quote
Old 04-10-2011, 06:31 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
As far as I can tell, there is no code that runs after initialization_complete (see for yourself the relevant code is at the end of the initialize method in gui2.ui)

Maybe charles will know why the search boxes are being reset.
kovidgoyal is offline   Reply With Quote
Advert
Old 04-10-2011, 06:38 PM   #3
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Hmmm... ok, thx Kovid - I'll do some debugging to try to figure it out since this isn't what you expected.
kiwidude is offline   Reply With Quote
Old 04-10-2011, 06:47 PM   #4
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Ok, this explains one of them.

When switching libraries, look at lines 452 onwards in ui.py

First it calls the plugin library_changed method
Then it clears the search restrictions and saved searches in 455-457.
I can't see any obvious events or anything I could hook into after that point.

As for Calibre startup, I have found that I can actually apply a saved search, but not a search restriction. I'll see if I can find why on that one out too...

EDIT: Ok, I don't know what I did wrong previously but I can now apply searches AND restrictions from my plugin at startup. It is ONLY when switching libraries, for the reasons stated above that I cannot apply from library_changed.

Any alternative suggestions?

Last edited by kiwidude; 04-10-2011 at 06:59 PM. Reason: Update findings
kiwidude is offline   Reply With Quote
Old 04-10-2011, 07:23 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Fixed it for you
kovidgoyal is offline   Reply With Quote
Advert
Old 04-10-2011, 07:42 PM   #6
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Thanks
kiwidude is offline   Reply With Quote
Old 04-11-2011, 08:29 AM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I think that the plugin should check that the 'restriction at startup' preference is empty before permitting a different one to be used. If it doesn't, then there will be confusion about which one wins, and why.
chaley is offline   Reply With Quote
Old 04-11-2011, 11:11 AM   #8
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
I'm on the fence over that one. I've made the whole "remember and apply last view" behaviour an optional thing. I think it could get a little more confusing if I allowed Calibre to override it in some cases. For instance I don't let the Calibre "sort columns at startup" tweak override sorting. So for consistency I don't think startup restrictions should have precedence either? If a user is into both using restrictions and using views, I consider it "highly likely" that they will configure the restriction into the view, in which case there is no conflict anyways.

It's a good point though that I will mention in the front page of the plugin to explain that behaviour.
kiwidude is offline   Reply With Quote
Old 04-11-2011, 11:40 AM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I agree that they shouldn't have precedence. What I am suggesting is that you warn the user and (possibly) clear the startup restriction.

The restriction differs from the sort tweak in that the startup restriction is in preferences, making it more likely that it will be changed.

What I am trying to avoid is bug reports/complaints saying something to the effect of "I set a restriction and it is being ignored." Such a report will be impossible to debug. If the view plugin hassles the user, then at least there is a chance that the user will figure out what is happening.

BTW: for the same reason you might also want to hassle the user if a startup sort list is set that is different from the one in the view. I am less worried about this one, though, because tweaks are a bit harder to find and set.
chaley is offline   Reply With Quote
Old 04-11-2011, 11:55 AM   #10
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Thanks for the clarification. I will need to think about where I would warn them. Because in each view it is entirely optional whether to specify sort columns and restrictions. So whether applying a view "overrides" the tweak/preferences set depends on whether they requested their view to touch those things. I think popping up a dialog to tell them when they startup or switch libraries would be a bit irritating. Maybe I should just put some informational text on the dialog next to the checkbox which enables such views to be applied.
kiwidude is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
K3 - change default google search jetfin Kindle Developer's Corner 29 11-12-2011 06:48 AM
change default search action Sachiko Kindle Developer's Corner 0 02-20-2011 11:16 AM
Fictionwise Browser Search Plugin Zero9 Deals and Resources (No Self-Promotion or Affiliate Links) 17 07-27-2009 03:15 PM
eReader.com Browser Search Plugin Zero9 Deals and Resources (No Self-Promotion or Affiliate Links) 0 07-24-2009 09:44 PM
BooksOnBoard Browser Search Plugin Zero9 Deals and Resources (No Self-Promotion or Affiliate Links) 10 07-24-2009 03:27 PM


All times are GMT -4. The time now is 11:28 PM.


MobileRead.com is a privately owned, operated and funded community.