Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTK4] Migrate deprecated ColorChooser to ColorDialog #1629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptziegler
Copy link
Contributor

The Color Chooser has been moved to the GTK3 class and all references inside the GTK4 blocks have been updated to use the new API.

Note that the GTK4 API doesn't provide the means to set a custom palette, meaning that the colors specified with setRGBS(RGB[]) are effectively ignored.

@ptziegler
Copy link
Contributor Author

GTK3:

ColorDialog_gtk3

GTK4:

ColorDialog_gtk4

Comment on lines +163 to +161
// TODO The ColorDialog API doesn't support setting a custom palette
// See https://gitlab.gnome.org/GNOME/gtk/-/issues/5936
// > The new GtkColorDialog api doesn't have this feature atm. We might
// > want to bring it back, but judging from application use of color
// > choosers, setting custom palettes is not very popular.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably really bad. But as mentioned in the linked issue, as well as the documentation, there is simply no way to customize the palette.

Meaning this is probably something that would first have to be implemented, but I don't think my GTK knowledge is sufficient to do so. :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should merge this one as there is not much to be done from SWT side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I fear that contributing the palette customization directly to GTK is beyond my capabilities, so the current state has to suffice for now.

Copy link
Contributor

github-actions bot commented Nov 28, 2024

Test Results

   494 files  ±0     494 suites  ±0   9m 55s ⏱️ - 2m 7s
 4 333 tests ±0   4 320 ✅ ±0   13 💤 ±0  0 ❌ ±0 
16 574 runs  ±0  16 466 ✅ ±0  108 💤 ±0  0 ❌ ±0 

Results for commit f041bb4. ± Comparison against base commit 422f742.

♻️ This comment has been updated with latest results.

@ptziegler ptziegler marked this pull request as draft December 8, 2024 10:06
@akurtakov
Copy link
Member

Would you please rebase on master and remove the draft if you agree that it's time to get this one in.

The Color Chooser has been moved to the GTK3 class and all references
inside the GTK4 blocks have been updated to use the new API.

Note that the GTK4 API doesn't provide the means to set a custom
palette, meaning that the colors specified with setRGBS(RGB[]) are
effectively ignored.
@ptziegler ptziegler marked this pull request as ready for review January 30, 2025 19:24
@ptziegler
Copy link
Contributor Author

Would you please rebase on master and remove the draft if you agree that it's time to get this one in.

I only wanted to revisit the issue with the modal dialog but that has now been fixed. I don't see any (additional) warnings when trying out the snippets so I think this is done for now.

@akurtakov
Copy link
Member

akurtakov commented Jan 30, 2025

There is one fundamental problem - the gtk_color_dialog calls are guarded with if( GTK4) blocks but they are introduced in gtk 4.10 so these symbols will simply fail to load (hard crash) if swt is run on gtk 4.0-4.8.
I believe the ColorChooser API should stay in GTK class and be used till gtk 4.8. The ColorDialog API should be guarded using if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) blocks.

@akurtakov
Copy link
Member

Now I realize I missed the same problem in #1583 so we will have to redo it too.

@ptziegler
Copy link
Contributor Author

Now I realize I missed the same problem in #1583 so we will have to redo it too.

I was just about to ask about the Font/Dialog chooser. I can have a look at it over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants