![]() |
#271 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
![]() |
![]() |
![]() |
#272 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Quote:
It occurs to me, however, that it may be a good idea for there to be such info passed to plugins. Maybe not at the individual file level, but I think there probably should be a way for a plugin to request/warn that an epub is in and unsaved state before continuing. I'm thinking of output/input plugins especially. With Kevin's new FolderOut plugin for instance, silently saving an OEBPS copy of an unsaved epub might cause unnecessary confusion. |
||
![]() |
![]() |
Advert | |
|
![]() |
#273 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 843
Karma: 3335974
Join Date: Jan 2017
Location: Poland
Device: Various
|
I was referring to the case that my validation plugin should work on the saved file (offset is calculated more precisely because command "save" places the code a bit differently).
That's why I wanted to add a check before running the plugin. Code:
If not saved: Show message "Save the file first" else: Run |
![]() |
![]() |
![]() |
#274 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
A validation plugin is not an edit plugin. It simply finds and reports errors from what is inside Sigil currently, that allows the user to easily visit each error after the plugin ends.
You validation plugin gets those file contents via the launcher interface code to prevent issues. There are a variety of interface calls to get a copy of the entire epub or specific types based on iterators. It should not be opening an external .epub file and trying to map errors inside to what is already inside Sigil. |
![]() |
![]() |
![]() |
#275 | |||
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 843
Karma: 3335974
Join Date: Jan 2017
Location: Poland
Device: Various
|
Quote:
Quote:
Quote:
Simply, my code is not perfect and if I knew that the epub file was saved, I would be happy with the current solution. But if it is not possible – I have to write a smarter plugin… By the way. I was compile my own version with support for 10 plugins. I do not have to constantly go to the menu. The icons help me to recognize the plugins without looking at the tooltip. ![]() |
|||
![]() |
![]() |
Advert | |
|
![]() |
#276 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Looks like fun! Perhaps we should allow the user to use their own icons for plugins. It is at least something to consider. Or perhaps allow each plugin author to include an icon file inside the plugin folder that is picked up by Sigil.
|
![]() |
![]() |
![]() |
#277 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I thought about that as well. Use the default unless there's an icon file present.
|
![]() |
![]() |
![]() |
#278 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
@DiapDealer,
We could change Sigil/src/Misc/Plugin.cpp to check for and load the icon file once on initial startup and then for the appropriate Qt action related to plugins in MainWindow use the setIcon to set the plugin's icon. We could require a 48x48 png and look in the root of the plugin folder for a file called plugin.png. Looks doable to me. What do you think? Or should we require a plugin.svg file and go for vector icons? |
![]() |
![]() |
![]() |
#279 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Vector graphics would probably scale better for all potential sizes (which can be increased/decreased by user preference for the main menu), but not being a graphics guy, I have no idea if an svg-only restriction would be a hardship or not.
|
![]() |
![]() |
![]() |
#280 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
So let’s go with plugin.png first with 48x48 and later on we can give preference to plugin.svg if it exists.
|
![]() |
![]() |
![]() |
#281 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Works for me!
|
![]() |
![]() |
![]() |
#282 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 843
Karma: 3335974
Join Date: Jan 2017
Location: Poland
Device: Various
|
Again me: Validate OPF and offset.
I found the issue that bothered me. bk.get_opf() -- is not perfect. Why? Result of bk.get_opf() is not current state of file .opf. This is state "what will the .opf file look like after saving" + missing two spaces before <metadata and </metadata> + missing four spaces before each <dc:… and <meta …. These missing spaces prevented me from calculating the offsets accurately. Code:
opf_data = bk.get_opf() opf_data = re.sub("<metadata"," <metadata",opf_data) opf_data = re.sub("<meta "," <meta ",opf_data) opf_data = re.sub("<dc:"," <dc:",opf_data) opf_data = re.sub("</metadata"," </metadata",opf_data) |
![]() |
![]() |
![]() |
#283 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Code:
opf_data = bk.readotherfile("OEBPS/content.opf") bk.get_opf() is performing some parsing/rebuilding of the various sections of the opf. Last edited by DiapDealer; 01-21-2018 at 04:44 PM. |
|
![]() |
![]() |
![]() |
#284 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
The opf obtained by bk.get_opf() is built on the fly to reflect whatever changes have been done in and by the plugin so far. The same is true inside Sigil as well. The opf is always kept in machine parseable format. Things like comments and whitespace are not kept as they will be rebuilt as files are added and removed. You should only use line offsets to report errors in the opf as whitespace is meaningless.
A validator should not be modifying anything and in that case doing as DiapDealer said in his post above will give you the original opf that was present when the plugin was started. As soon as a plugin modifies something that impacts the opf, even this function will return the built on the fly version of the opf. Last edited by KevinH; 01-21-2018 at 04:45 PM. |
![]() |
![]() |
![]() |
#285 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 843
Karma: 3335974
Join Date: Jan 2017
Location: Poland
Device: Various
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loading Plugin in development | Sladd | Development | 6 | 06-17-2014 06:57 PM |
Question for plugin development gurus | DiapDealer | Plugins | 2 | 02-04-2012 11:33 PM |
DR800 Plugin development for DR800/DR1000 | yuri_b | iRex Developer's Corner | 0 | 09-18-2010 09:46 AM |
Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
Calibre plugin development - Newbie problems | minstrel | Plugins | 5 | 04-12-2009 12:44 PM |