touchy: replace deprecated font and colour overrides with CSS#4133
Conversation
|
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? |
Let me have closer look at it. But it wouldn't be before Wednesday unfortunately. |
|
Sorry I forgot that... |
|
That's ok, wouldn't have passed the CI anyhow on Wednesday... |
|
I thought it like this d5bd26e but then you need to have the font duplicated in the CSS: So I guess it's a matter of taste. One makes the code shorter the other is better style I guess. Both is okay for me. But If we keep your version I would rename the |
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.
The default dro_font "FreeMono 10 Pitch Bold 16" parses to the Pango family "FreeMono 10 Pitch". The preference font buttons use use-font=True, so GtkFontButton renders its label in that font and emits the family as unquoted CSS, which GTK rejects with "Junk at end of value for font-family" (the parse warning in LinuxCNC#4068). "FreeMono 10 Pitch" is not a real family (Pango already fell back to monospace), so drop the legacy "10 Pitch" token and default to "FreeMono Bold 16". On a fresh profile this clears the warning.
Per review on LinuxCNC#4133: a more descriptive name for the helper that adds a style class once. No behavior change.
f20057e to
aada117
Compare
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.