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

Port to GTK3/Xfce 4.16 #63

Merged
merged 1 commit into from
Jan 7, 2021
Merged

Port to GTK3/Xfce 4.16 #63

merged 1 commit into from
Jan 7, 2021

Conversation

ad1217
Copy link
Contributor

@ad1217 ad1217 commented Dec 25, 2020

  • Switch libxfce4ui and libxfce4panel to version 2
  • use X-XFCE-API 2.0 in desktop file
  • change GdkColor to GdkRGBA
  • replace xfce/panel specific functions with new GTK3 equivalents

I have not tested this extensively, but it seems to work okay on Arch with Xfce 4.16. I haven't written much C recently and never really learned GTK, so no guarantees on the sanity of any of this.

- Switch libxfce4ui and libxfce4panel to version 2
- use X-XFCE-API 2.0 in desktop file
- change GdkColor to GdkRGBA
- replace xfce/panel specific functions with new GTK3 equivalents
@ad1217 ad1217 changed the title Port to GTK3 Port to GTK3/Xfce 4.16 Dec 26, 2020
Copy link
Owner

@denesb denesb left a comment

Choose a reason for hiding this comment

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

I have some questions, otherwise looks good to me.

guint16 green_component = gdkcolor->green >> 8;
guint16 blue_component = gdkcolor->blue >> 8;
// convert the GdkRGBA components to 8 bit ints
guint8 red_component = gdkrgba->red * 255;
Copy link
Owner

Choose a reason for hiding this comment

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

* 255 is not equivalent to >> 8, is this a difference between the two APIs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! GdkRGBA stores its components in floats of range 0.0 to 1.0. Multiplying and dividing by 255 (max of a uint8) converts to/from 8 bit ints, whereas shifts will do interesting (incorrect) things.

I also have a branch (https://github.com/ad1217/xfce4-i3-workspaces-plugin/tree/gtk3-css) which I wrote last night that does away with this part entirely in favor of CSS styling, which seems to be the preferred method for GTK3 and simplifies a lot of the color-related code.

Choose a reason for hiding this comment

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

Your branch works for me in Arch. I've not noticed any bugs, just that only the text is coloured, rather than the coloured boxes as in the original. If you're planning to maintain this package for the future, is it beyond your scope to add a few features? It would be nice to be able to change the font and customise the background, border, and text colours for each workspace type, to make it look like the native i3 bar. Otherwise I'm just happy that functionality is restored, thanks!

Copy link
Owner

Choose a reason for hiding this comment

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

@ad1217 I'm going to merge this branch as-is, and you can submit your CSS branch as a follow-up (if you want to).

// convert back to floats in range 0.0 to 1.0
gdkrgba->red = red_component / 255.0;
gdkrgba->green = green_component / 255.0;
gdkrgba->blue = blue_component / 255.0;
Copy link
Owner

Choose a reason for hiding this comment

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

/ 255.0 is not equivalent to << 8. You need to use 256 to get the same result, but what is wrong with using shifts?

@denesb denesb merged commit baec90d into denesb:master Jan 7, 2021
@ad1217 ad1217 deleted the gtk3 branch January 7, 2021 06:39
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.

4 participants