Skip to content
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

rework custom stylesheet loading #692

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

deltragon
Copy link
Collaborator

Description

Previously, the stylesheet was copied to the user's .config dir, and this was then loaded as a style (with priority "application").
The user could alter this stylesheet directly.
This stylesheet was called "safeeyes_styles.css".

Now, we split the stylesheets into two:

  • The system stylesheet, which is directly loaded with priority "application".
  • The user's stylesheet, if it exists, which is loaded from the .config dir with priority "user", overriding both the system stylesheet and any themes the user might have.
    This is now called "safeeyes_custom_styles.css".

This means in the future, we can simply add new default styles to the system stylesheet without breaking the user. Additionally, any styles loaded with a higher priority than "application" (eg. certain GTK themes, see #687), can now be overridden by the user's stylesheet.

We also check if the old path ("safeeyes_styles.css") contains an old default stylesheet. If it does, we delete it.
If it (likely) contains a customized stylesheet, don't delete it, but warn the user that they should use "safeeyes_custom_styles.css" instead now.

@archisman-panigrahi
Copy link
Collaborator

It fails to run with the following error

python3 -m safeeyes
Traceback (most recent call last):
  File "/home/archisman/SafeEyes-style-priorities/safeeyes/safeeyes.py", line 108, in do_startup
    self._initialize_styles()
  File "/home/archisman/SafeEyes-style-priorities/safeeyes/safeeyes.py", line 169, in _initialize_styles
    utility.load_css_file(
TypeError: load_css_file() missing 1 required positional argument: 'priority'
Traceback (most recent call last):
  File "/home/archisman/SafeEyes-style-priorities/safeeyes/safeeyes.py", line 154, in do_activate
    if self.plugins_manager.needs_retry():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'needs_retry'

Previously, the stylesheet was copied to the user's .config dir, and
this was then loaded as a style (with priority "application").
The user could alter this stylesheet directly.
This stylesheet was called "safeeyes_styles.css".

Now, we split the stylesheets into two:
- The system stylesheet, which is directly loaded with priority
  "application".
- The user's stylesheet, if it exists, which is loaded from the .config
  dir with priority "user", overriding both the system stylesheet and
  any themes the user might have.
  This is now called "safeeyes_custom_styles.css".

This means in the future, we can simply add new default styles to the
system stylesheet without breaking the user. Additionally, any styles
loaded with a higher priority than "application" (eg. certain GTK
themes, see slgobinath#687), can now
be overridden by the user's stylesheet.

We also check if the old path ("safeeyes_styles.css") contains an old
default stylesheet. If it does, we delete it.
If it (likely) contains a customized stylesheet, don't delete it, but
warn the user that they should use "safeeyes_custom_styles.css" instead
now.
@deltragon
Copy link
Collaborator Author

Thanks, I moved the function around and didn't check it... Should be fixed now.

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.

2 participants