Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-14-2023, 01:29 PM   #211
Nicolas F
Groupie
Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.
 
Posts: 161
Karma: 1842
Join Date: Jan 2016
Device: Kobo Glo HD
Quote:
Originally Posted by thiago.eec View Post
Yes. Using get_icons('icon.png', PLUGIN_NAME) works.

You need this too:
..\resources\images\PLUGIN_NAME\icon-for-dark-theme.png
..\resources\images\PLUGIN_NAME\icon-for-light-theme.png
Yes that's what I am doing
It works for me with your plugin Check books but it's not working with @JimmXinu plugin for example.

If someone has the time to check does light and dark theming work with calibre example plugin? https://calibre-ebook.com/downloads/...emo_plugin.zip

Sorry I don't get why I can't get it to work...

And to make things more complicated, I saw that in FanFicFare code, the comments say :
Code:
        # For theme creators, use:
        # FanFicFare/images/icon.png
        # (optionally)
        # FanFicFare/images/icon-for-dark-theme.png
        # FanFicFare/images/icon-for-light-theme.png
But I can use indifferently FanFicFare/images/icon.png or FanFicFare/icon.png and it works but FanFicFare/images/icon-for-dark-theme.png or FanFicFare/icon-for-dark-theme.png doesn't for me.
Nicolas F is offline   Reply With Quote
Old 09-14-2023, 02:19 PM   #212
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,218
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by thiago.eec View Post
Yes. Using get_icons('icon.png', PLUGIN_NAME) works.

You need this too:
..\resources\images\PLUGIN_NAME\icon-for-dark-theme.png
..\resources\images\PLUGIN_NAME\icon-for-light-theme.png

Sorry. My mistake. This does not work here!

I forgot I had another call to my custom get_icon() function when rebuilding menus.
thiago.eec is offline   Reply With Quote
Old 09-14-2023, 02:51 PM   #213
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,993
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
The last time I remember discussing this, Kovid said:
Quote:
Originally Posted by kovidgoyal View Post
https://manual.calibre-ebook.com/cus...me-for-calibre

and yes for-dark vs for-light only work with themes.
Themes as in published themes, not personalized files in resources dir.

As mentioned, thiago.eec put extra code in Check Books to allow for light/dark themed icons in the resources dir that my plugins don't have.

And honestly, IMO, that's not code that should be in every plugin.
JimmXinu is offline   Reply With Quote
Old 09-14-2023, 03:20 PM   #214
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,218
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by JimmXinu View Post
And honestly, IMO, that's not code that should be in every plugin.
I wouldn't say it should be in every plugin. To me, it's just a question of flexibility and giving the user a choice. Since no theme that I know of have this implemented yet, the added code allows the user to choose icons for dark and light theme.

Besides, it's harmless for those who does not need it.
thiago.eec is offline   Reply With Quote
Old 09-14-2023, 05:06 PM   #215
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,993
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
I'm not saying you shouldn't, I'm just saying I'm not. :-)
JimmXinu is offline   Reply With Quote
Old 09-14-2023, 10:18 PM   #216
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
As far as I recall, get_icon() uses QIcon.ic() which is what the rest of calibre uses ad that supports light/dark variants automatically. If it isnt working then it will require investigation.
kovidgoyal is online now   Reply With Quote
Old 09-14-2023, 10:57 PM   #217
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,993
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
That's what Nicolas F was reporting.
Quote:
Originally Posted by Nicolas F View Post
I tried to create icons in the "resources\images\Name of the plugin" folder but it works when I use icon.png but if I use icon-for-dark-theme.png or icon-for-light-theme.png the icon doesn't show up in calibre.
I see the same thing--icon.png works in the resources dir on disk, icon-for-dark-theme.png or icon-for-light-theme.png.

From what I see, '-for-X-theme' is implemented in calibre/utils/rcc/__init__.py, not in QIcon.

Our discussion from last year:
Quote:
Originally Posted by JimmXinu View Post
Also, I'm trying to test -for-dark-theme and -for-light-theme file names on Cal6 portable by putting files in Calibre Settings\resources\images, but it doesn't appear to work?

I see in the calibre code that -for-dark-theme and -for-light-theme only appear in calibre/utils/rcc/__init__.py. Do they only work for imported icon themes?
Quote:
Originally Posted by kovidgoyal View Post
https://manual.calibre-ebook.com/cus...me-for-calibre

and yes for-dark vs for-light only work with themes.
JimmXinu is offline   Reply With Quote
Old 09-14-2023, 11:03 PM   #218
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes but compile_icon_dir_as_themes() is how themes are installed into calibre so it should work for any theme. And QIcon.ic() uses the output of compile_icon_dir_as_themes().
kovidgoyal is online now   Reply With Quote
Old 09-14-2023, 11:18 PM   #219
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,993
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Is there a step where Calibre automatically uses the old resources dir on disk to create a theme for custom icons?

Unless I misunderstand, that's the only way that code could apply to custom icons in the resources dir...
JimmXinu is offline   Reply With Quote
Old 09-14-2023, 11:42 PM   #220
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I thought this was about icons from themes not customised icons. IIRC, when loading from resources dir these are looked for via the overriden_icon_path() function
kovidgoyal is online now   Reply With Quote
Old 09-15-2023, 12:48 AM   #221
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,993
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Okay, I've taken a look at overriden_icon_path() in calibre/gui2/__init__.py. I think it's broken for plugins.

overriden_icon_path() is looking for -for-light/dark-theme files in override_items, which is built from looking for files in 'devices', 'mimetypes', 'plugins' dirs under resources/images.

Probably works fine for devices and mimetypes, but not for plugin custom icons.

Currently, plugin custom icons are under resources/images/<pluginname> for each plugin, not under resources/images/plugins. And just putting the pluginname dir under 'plugins' doesn't work because the code doesn't recurse.

Adding 'FanFicFare' to the 'devices', 'mimetypes', 'plugins' list works, but I don't know if adding all plugin names to that list is an appropriate solution.
JimmXinu is offline   Reply With Quote
Old 09-15-2023, 01:38 AM   #222
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...cb56c36ae9b121
kovidgoyal is online now   Reply With Quote
Old 09-15-2023, 04:23 AM   #223
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: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
This doesn't work for me, but perhaps I am doing something wrong.

My steps:
  1. I grabbed interface_demo.zip and built it. I see the 'sun' icon. It uses
    Code:
    icon = get_icons('images/icon.png', 'Interface Plugin Demo')
    to fetch the icon.
  2. I created a directory in my config 'resources\images\Interface Plugin Demo\images'.
  3. I put a different 'icon.png' into that directory. Running calibre, I see that different icon.
  4. I put 'icon-for-light-theme.png' in that directory and removed (renamed) 'icon.png'. I now see the default 'sun' icon.
Is this the expected behavior?
chaley is offline   Reply With Quote
Old 09-15-2023, 04:29 AM   #224
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It should be just

resources\images\Interface Plugin Demo\

no extra images sub-folder.
kovidgoyal is online now   Reply With Quote
Old 09-15-2023, 04:32 AM   #225
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: 45,393
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
that commit assumes images are in the plugin root which. I suppose adding support for an extra images sub-folder shouldnt be too bad.
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion for PI Devs BetterRed Plugins 11 09-27-2020 06:18 PM
Attn plugin devs: porting to python 3 kovidgoyal Plugins 129 06-16-2020 01:31 AM
Attention All Plugin Devs: Remove vestiges from python 2? KevinH Plugins 11 05-29-2020 03:16 PM
Plugin Devs: Should we include a License or COPYING file? KevinH Plugins 3 08-15-2017 01:09 PM
New Plugin Features in the upcoming Sigil 0.8.900 KevinH Plugins 6 09-14-2015 02:48 PM


All times are GMT -4. The time now is 12:20 AM.


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