johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.42k stars 295 forks source link

Fix Gtk.Popover select translate and save state select language. #1399

Closed keygenqt closed 1 month ago

keygenqt commented 2 months ago

my_gif

Added saving of language selection for translation, it is very inconvenient to select a new translation language each time. In addition to this, there is a bug related to Gtk.Popover & select (after selecting a language, the window can only be closed with focus on select, I have not yet figured out how to overcome this, it looks like a gtk bug).

If it is possible to save the state in the application without using localStorage, I will be glad if you tell me.

marsaif commented 2 months ago

thank you so much for adding this feature

johnfactotum commented 2 months ago

Using localStorage is okay (in theory using GSettings would be better but probably not worth the trouble).

But I would like to prevent it from leaking into other contexts, if possible (preferably each tool should have a separate origin). That's mainly why I haven't gotten around to fixing this. I think I attempted to set a different origin by setting the URL to foliate:selection-tool... but apparently that doesn't work.

But maybe it doesn't matter. But perhaps it should at least use a different URI scheme, to separate it from the main foliate: scheme.

keygenqt commented 2 months ago

my_gif

Now that's ok. I don't really understand GJS, as I understand the problem Gtk.Popover + Gtk.DropDown/select is not new https://gitlab.gnome.org/GNOME/gtk/-/issues/5568. I fixed Popover by replacing select with buttons and add saving via localStorage. Maybe I didn't do everything perfectly, but it works =)

johnfactotum commented 1 month ago

So in the end I decided to fix it myself with 02c5727abde5f40695f4ecd3d6b3dbb300d09b92. It uses GSettings instead of localStorage.

As for language selection, the main layout is the same as before: image

But now it's possible to filter the languages: image