-
Notifications
You must be signed in to change notification settings - Fork 634
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
Implement loading custom css in the GTK app #4200
Conversation
- use ArrayListUnmanaged - read the stylesheet file using zig api - use proper css_provider_load_ function depending on the GTK version
- initialize custom_css_providers using a default value - remove usage of buffered reader - document maximum file size - handle exceptions explicitly
/// Prepend a ? character to the file path to suppress errors if the file does | ||
/// not exist. If you want to include a file that begins with a literal ? | ||
/// character, surround the file path in double quotes ("). | ||
@"gtk-custom-css": RepeatablePath = .{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was doing some testing and I had a crash if I didn't explicitly specify an absolute path to the custom CSS file, so for some reason the paths are not being expanded properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3811 should fix expansion not sure about the crash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3811 should fix expansion not sure about the crash
The crash is specifically because we have an assert in place to check for non-absolute paths. And #3811 won't fix it because I wasn't using a ~
, just a plain filename --gtk-custom-css=custom.css
. RepeatablePath
should resolve that relative to Ghostty's config dir I thought but it obviously didn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think that I figured out my problem, if you specify --background-image=custom.css
on the CLI, Ghostty tries to resolve that based on the $PWD
. If it can't be resolved, I think that the code leaves it as is without any warnings and then we eventually get a panic. So that's not a blocker for this (even though Mitchell has already merged this).
Closes #4089
Gave it a shot and implemented the custom css loading.
My general idea is to use a provider for each stylesheet the user wants to load and then when the config changes unload them and create new providers.
A separate provider has to be used for each stylesheet the user wants to load, since when the provider loads the css it clears all the previously loaded styles, so in effect we cannot use one provider to load multiple stylesheets, but maybe there is a better way to overcome this limitation which I'm not seeing.