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 09-03-2011, 06:18 PM   #31
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 Kovid, that now works. I think I have the code changes figured out for my "static" menu plugins now, obviously I will have to wait for the next Calibre release before I can get someone to verify it.

Next on the list I need to work through the dynamic based ones like Search the Internet, where I have the extra complication of unregistering shortcuts for actions that no longer exist when the menu is rebuilt. What could possibly go wrong...
kiwidude is offline   Reply With Quote
Old 09-04-2011, 02:21 PM   #32
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
The keyboard shortcut plugin upgrade mission slowly continues. So far I have managed to upgrade eight plugins which are all the non dynamic menus based ones (the "easy" cases), and that is all working fine.

However on my way to attempting a dynamic menu, I tried to start with Quality Check. In this plugin, it is possible for the users to decide which menu items will appear on the menu. So to do things "properly" I need to cover for the situation where a user assigns a keyboard shortcut to a menu item, and then chooses to "hide" that menu item without them removing their shortcut first.

So in this situation, I thought it might be as "simple" as calling gui.keyboard.unregister_shortcut for each menu item that the user is hiding when they click ok on the configuration dialog. That part of the code I have working, though it is a little messy as you can see below from this extract:
Code:
                kb = self.plugin_action.gui.keyboard
                # Need to manually construct the menu name because at this point I have
                # no action at all as I am not creating them
                unique_name = '%s : menu action : %s'%(self.plugin_action.unique_name, menu_key)
                # Have to check for existence (same applies to replace_action call)
                if unique_name in kb.shortcuts:
                    kb.unregister_shortcut(unique_name)
This works ok, however then when I try to go into Preferences->Keyboard, I always get this error:
Code:
calibre, version 0.8.17
ERROR: Unhandled exception: <b>KeyError</b>:u'Interface Action: Quality Check (Quality Check) : menu action : check_covers'

Traceback (most recent call last):
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\preferences\main.py", line 282, in show_plugin
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\preferences\keyboard.py", line 27, in initialize
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 615, in initialize
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 179, in __init__
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 178, in <dictcomp>
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 178, in <lambda>
KeyError: u'Interface Action: Quality Check (Quality Check) : menu action : check_covers'
Where check_covers is the unique_name I associated with the menu that I have called unregister_shortcut() method with a few moments before.

Now for this particular plugin I could just store the actions in a dictionary, creating them only once etc. However I believe the error I see is going to come up for plugins where that is not an option, so better to figure it all out now...
kiwidude is offline   Reply With Quote
Advert
Old 09-04-2011, 02:56 PM   #33
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 (I think) and added a function menu_action_unique_name
kovidgoyal is offline   Reply With Quote
Old 09-04-2011, 03:30 PM   #34
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 Kovid, that solved that one. Unfortunately I found another scenario which means I need to rethink my whole approach again - and revisit all the plugins I thought I had done so far. Darn it.

I see I hit 2000 posts, what was life like before Calibre took it over?
kiwidude is offline   Reply With Quote
Old 09-04-2011, 04:42 PM   #35
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
Quote:
Originally Posted by kiwidude View Post
I see I hit 2000 posts, what was life like before Calibre took it over?
Far less hectic
kovidgoyal is offline   Reply With Quote
Advert
Old 09-24-2011, 12:14 PM   #36
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
Hi Kovid,

I’ve been sitting here for over an hour experimenting trying to work out the cause of an issue and finally figured out the symptoms at least.

When my menu text that I pass into create_menu_action() starts with numeric digits (rather than alphabetic characters), AND if I have a triggered=xxx value assigned, then while everything works correctly, when I close Calibre it is taking around 30 seconds to actually exit the process (Win 7).

The text I am trying to display in the menu is “450(w) x 680(h)”
  • If I do not assign a triggered action to that menu item, it works fine.
  • If I set shortcut=False, it works fine
  • If I rename my menu item text to start with alphabetic characters, it works fine – ie. “New size: 450(w) x 680(h)”
Any ideas? The fact that setting shortcut=False alone avoids the problem implies it lies with some kind of interaction with the menu code. All the rest of my code is the same as other plugins. So I start calibre, click on the menu to drop it down (no need to click any items on it) then exit calibre. The main window closes immediately, but the process appears to take at least 30 secs to exit. As soon as I do one of those alternate workarounds above (of which only the third is workable albeit cosmetically undesired) then calibre exits in it's usual second or so.
kiwidude is offline   Reply With Quote
Old 09-24-2011, 12:20 PM   #37
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
That's weird, I can't think of anything that could cause that. Setting one of the builtin actions' menu items to 450(w) x 680(h) doesn't make any difference to shutdown times for me. Maybe prefix your menu item with Size:
kovidgoyal is offline   Reply With Quote
Old 09-24-2011, 12:25 PM   #38
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
Thx Kovid - you are right, it is very weird. Sadly, it seems that it was just a lucky fluke that renaming the text worked a couple of times in a row - that has now stopped working for me.

Back to the drawing board... sigh..
kiwidude is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre keyboard shortcuts? Clytie Calibre 29 08-25-2019 03:51 AM
K3 keyboard shortcuts et al btobw Amazon Kindle 25 10-15-2011 09:43 AM
Keyboard shortcuts VenturingSoul enTourage Archive 1 04-15-2010 10:21 PM
keyboard shortcuts? tashiegirl Calibre 5 04-12-2010 09:25 PM
Keyboard Shortcuts malkie13 Calibre 2 02-08-2009 03:21 PM


All times are GMT -4. The time now is 03:26 AM.


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