LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.77k stars 1.14k forks source link

gmoccapy: add setting for G-code theme (GtkSourceView) #2811

Closed hansu closed 8 months ago

hansu commented 8 months ago

Adds a setting to Gmoccapy for setting the GtkSourceView theme to avoid problems with dark themes.

Related to: https://forum.linuxcnc.org/gmoccapy/50636-can-i-change-the-colors-scheme-in-the-gcode-editor and https://forum.linuxcnc.org/gmoccapy/51124-gmocappy-defects-in-release-2-9-2

I hope everybody is fine with the name "G-code Theme" because I think a user would not know what is meant with GtkSourceView :) grafik

Sigma1912 commented 8 months ago

Nice, thanks.

You may also want to adjust the high-lighting for the currently executing line in the gcode window: https://forum.linuxcnc.org/gmoccapy/50636-can-i-change-the-colors-scheme-in-the-gcode-editor#285585

hansu commented 8 months ago

Nice, thanks.

You may also want to adjust the high-lighting for the currently executing line in the gcode window: https://forum.linuxcnc.org/gmoccapy/50636-can-i-change-the-colors-scheme-in-the-gcode-editor#285585

That would be a bit too much of settings. I think the best would be to retrieve this color from the GtkSourceView theme, but I couldn't find a solution to get this color from which is defined in /usr/share/gtksourceview-3.0/styles/<style>.xml. Instead I used style.get_background_color(Gtk.StateFlags.SELECTED) which is better than a fixed color I think. Better would be that HAL_Sourceview handles the current line as selection and so automatically uses the same colors which are defined for a selected line in the theme.

Sigma1912 commented 8 months ago

I didn't mean that it should be user adjustable but that it should be changed to something more readable so what you did is just fine. I guess you could use 'line number' if you wanted the current line to be different from the 'selected line'

Sigma1912 commented 8 months ago

I guess you could use 'line number' if you wanted the current line to be different from the 'selected line'

Ah, for that we would need to access the color scheme in the xml which you have already tried.

hansu commented 8 months ago

Ah, for that we would need to access the color scheme in the xml which you have already tried.

exactly

hansu commented 8 months ago

I didn't mean that it should be user adjustable but that it should be changed to something more readable so what you did is just fine.

Have you also tested this version?

Sigma1912 commented 8 months ago

I have just finished testing your last two commits:
gmoccapy: add setting for G-code theme (GtkSourceView) gtksourceview: apply selection color from theme

Works fine for me. Thanks for your work!

hansu commented 8 months ago

Okay then let's use this for now