Add an initial version of a preferences dialog - #2261
Conversation
|
Great that you like the UI files 👍 If your solution for translations can be supported by GirCore we can try to upstream it or parts of it. There is already a ticket to improve the UI file translation situation but without any concrete idea yet: gircore/gir.core#1482 |
|
One option would be to extend the The other approach I've been looking at is just having Pinta use the native We already bundle libintl since it's used by GTK, libadwaita, etc, so using this is pretty reasonable and just requires a few bindings for the native functions. The |
|
I think you can already provide custom resource loaders so influencing the xml is already possible. Adding another configuration point inside it feels a little much to me. It sounds pretty great to use the gettext package. One idea which came to my mind is to just let the user use an attribute on assembly level like In this way if you call it everything gets setup automatically including language and subclass registration. |
|
Agreed, I think it should be doable as-is to provide a custom resource loader - it's just more work to implement the parsing. But IMO using the native gettext will probably be the easiest avenue for most users. Initializing gettext can involve some runtime configuration (e.g. to come up with the folder path that gettext should load from, or possibly changing the language-related env vars to override the default language selection), so my initial thinking was to just start with some straightforward bindings that mirror the C api before trying to come up with a higher-level utility? |
|
Yes this would be possible too. I suggested the attribute instead of an API because:
If I use an attribute and generate the code in the user project I don't need a new Nuget and it's more like a configuration. I don't know if there are lots of possibilities to use gettext? I thought it's always the same 3 calls in order and that's it. Do you know otherwise? |
|
Yeah it's a bit different not being a gobject-based library, although it's maybe not too different from the Cairo bindings which are mostly manual The initialization is pretty much always the same AFAIK, although for a library you would skip calling textdomain() which sets the global default |
|
Yeah you are right. I think having a new Nuget is probably the way to go. |
- Related to PR #2261, using the native gettext library is the simplest way to also support translations for .ui files - no additional work is needed since GTK already calls dgettext() for any translatable strings when loading the xml file - We already bundle libintl with Pinta (since it's required by GTK, libadwaita etc) so this doesn't require any additional packaging. I think the original motivation for using the managed Ngettext library was because we no longer had any bindings to gettext when porting to GTK3 - for GTK2 we used the Mono.Unix.Catalog wrapper for the native library - Several of the native methods are already wrapped via GLib and have bindings available (e.g. GLib.Functions.Dgettext()) so this just requires a couple custom bindings for functions like textdomain(). We previously already had one binding for bindtextdomain() to configure libadwaita's translation directory for the macOS app bundle
- Use the libadwaita preferences dialog, and define the layout using an xml .ui file to test out this process for the first time. - Move the color scheme preference into the dialog as a test. By adding an event when settings are modified, changes to the settings can be decoupled from the dialog itself - Add a Preferences menu item. Depending on the platform, this is in the application menu on macOS, or in the Edit menu for a menubar layout, or in the main menu when using a headerbar layout. - Also simplified logic around how the macOS app menu commands are registered, and fixed the keyboard shortcut dialog to use different shortcuts from the prefs dialog
8e9f222 to
5fbddb0
Compare
Description of Changes
Use the libadwaita preferences dialog, and define the layout using a
.uifile to test out this process for the first time (works quite well!).Move the color scheme preference into the dialog as a test. By adding an event when settings are modified, changes to the settings can be decoupled from the dialog itself
Add a Preferences menu item. Depending on the platform, this is in the application menu on macOS, or in the Edit menu for a menubar layout on other platforms, or in the main menu when using a headerbar layout.
TODO: figure out how to translate the .ui file. If we used the native gettext library for our translations this would just work automatically, so perhaps we should attempt to do this? Otherwise we need to implement a custom loader which translates the xml file using our
Translations.GetString()functionChecklist