Skip to content

Conversation

@lobre
Copy link
Contributor

@lobre lobre commented Nov 9, 2025

Hey,

I have tried to answer my self-created issue:

#1659

As a sum-up, I have added a new syntax-highlighting GSettings key plus a toggle under Preferences -> Interface so users who prefer monochrome editing can disable highlighting globally while leaving the existing language picker active for commenting, Markdown shortcuts, etc.

The SourceView simply toggles Gtk.SourceBuffer.highlight_syntax, so search hits and other non-language effects keep working, and the language dropdown now says "Document language" to better reflect its broader role.

Happy to adjust any of this if you think there is a better way to expose the preference, or if there is anything with the implementation.

@lobre
Copy link
Contributor Author

lobre commented Nov 9, 2025

Also, I see that the build fails, but I am not sure if it has anything to do with my changes.

@jeremypw
Copy link
Collaborator

jeremypw commented Nov 9, 2025

Funnily enough I just started work on this. I have pushed work for info. Your PR looks more elegant but does it listen to changes in the setting?

@jeremypw
Copy link
Collaborator

jeremypw commented Nov 9, 2025

There seems to be an issue with Flatpak CI. Not sure why - it doesn't seem to be associated with the project code though. I can build a Flatpak OK locally so I am ignoring it for now.

@jeremypw
Copy link
Collaborator

jeremypw commented Nov 9, 2025

I'll let you complete your PR as you started first and look like you're on the right lines.

@lobre
Copy link
Contributor Author

lobre commented Nov 9, 2025

I guess it is all I have :)

It already picks up live preference changes.

See src/Widgets/SourceView.vala:129-130:

restore_settings ();
settings.changed.connect (restore_settings);

So, restore_settings seems to reapply all editor settings to the view. The first line calls it once, so the brand-new buffer adopts the current preferences. The second line is connecting the changed signal from settings to that same method, so every time any GSettings key under /io/elementary/code/settings/ changes, restore_settings() runs again.

I have tested the implementation on my current build, and it works for me.

@jeremypw
Copy link
Collaborator

@lobre You are right. The problem with this function I've noticed is that all the settings are restored when any one of them changes. Also there are several places around the code base where different classes monitor specific settings which this function also monitors so things get called twice. I think that for this PR we can leave things as they are but we probably need to have a review of settings handling at some point. It would seem restore settings () should only be called when there is a need to refresh all the settings (if there is one) while different widgets should handle specific settings that affect them. That can be left for another PR though.

Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

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

Works as expected - lets go!

@jeremypw jeremypw merged commit bd59edd into elementary:master Nov 10, 2025
4 of 6 checks passed
@jeremypw jeremypw added this to the 8.2 milestone Nov 10, 2025
@lobre
Copy link
Contributor Author

lobre commented Nov 10, 2025

I think that for this PR we can leave things as they are but we probably need to have a review of settings handling at some point.

Makes sense effectively, thank you again for the merge!

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.

Add an option in Preferences to disable syntax highlighting globally

2 participants