touchy: replace deprecated font and colour overrides with CSS#4133
touchy: replace deprecated font and colour overrides with CSS#4133grandixximo wants to merge 1 commit into
Conversation
GTK deprecated Gtk.Widget.override_font() and modify_fg() in 3.16. Touchy used them throughout setfont() to set every display font and the per-coordinate DRO text colours, logging deprecation warnings. Tag the widgets with style classes once and drive the fonts and colours from a single GtkCssProvider on the screen, rebuilt whenever a font or colour preference changes. A Pango font description is translated to CSS font properties and stored colours are normalised through Gdk.RGBA. The rendered result is unchanged. The modify_bg() calls in filechooser, listing and mdi are a separate selection-highlight pattern and are left for a follow-up.
|
I would suggest to add property "name" to the widgets in the touchy.glade file and then add a block where all CSS styles are defined like I did in Gmoccapy: linuxcnc/src/emc/usr_intf/gmoccapy/gmoccapy.glade Line 1899 in 106519f linuxcnc/src/emc/usr_intf/gmoccapy/gmoccapy.py Lines 154 to 157 in 106519f This would not require so many changes in the touchy.py file I guess. BUT for that the touchy.glade must first be converted to Gtk3. I tried this yesterday, but the result was not satisfactory - all the button were smaller and did not fill the space so I postponed that for the moment... |
|
Thanks Hans. I looked at the gmoccapy approach and it's clean for fixed styling. The difference in touchy is that its four display fonts (control, DRO, error, listing) and the DRO text colours are user preferences: set on the Preferences tab, saved to The tagging itself reuses the font-group lists I agree the proper end state is a full GTK3 glade with the styling defined there, but that's the larger conversion you hit the button-sizing trouble with, so I scoped this PR to just removing the deprecated calls on the current glade. The rendered result is unchanged (verified the fonts and the rel/abs/dtg DRO colours). Happy to go whichever way you and the maintainers prefer. |
|
As far as I can see
Unfortunately I don't think we have a maintainer currently. |
hansu
left a comment
There was a problem hiding this comment.
Just mark it here as "changes needed" to keep the overview =)
| w = self.wTree.get_object(i) | ||
| if w: | ||
| w.override_font(self.control_font) | ||
| self._tag(w, "touchy_control") |
There was a problem hiding this comment.
Move to name property in glade file (after merge of #4135)
|
Agreed on the order. I tested #4135 in a sim container and it renders correctly in GTK3 (the status grid is tidy now). At default Sans 18 it is still wider than a small screen until #4131's fitting is applied on top, which lines up with your 718x596, so #4135 then #4131 then #4133 makes sense. For #4133 I'll move the widget identification into the glade as |
|
@hansu before I commit a large diff, one snag with moving the tags into the glade as A widget has a single self._tag(w, "touchy_dro") # font, always
self._tag(w, "touchy_rel") # colour, only if non-default
Two options:
I lean to B for maintainability, but happy to do C if you would rather see control/listing declared in the glade. Which do you prefer? |
GTK deprecated
Gtk.Widget.override_font()andmodify_fg()in 3.16. Touchy uses them throughoutsetfont()to set every display font and the per-coordinate DRO text colours, so it logs deprecation warnings.This tags the widgets with style classes once and drives the fonts and colours from a single
GtkCssProvideron the screen, rebuilt whenever a font or colour preference changes. A Pango font description is translated to CSS font properties, and stored colours are normalised throughGdk.RGBA. The rendered result is unchanged.Tested with the ui-smoke touchy tests and by hand: the fonts render identically (buttons, DRO, tab labels, handwheel), and the per-coordinate DRO colours still apply (verified with rel/abs/dtg set to blue/red/green).
The
modify_bg()calls infilechooser,listingandmdiare a separate selection-highlight pattern and left for a follow-up.