X Tutup
Skip to content

Implement Dynamic GTK Theme Reloading and Monitoring#3605

Open
sabrehagen wants to merge 1 commit intonicotine-plus:masterfrom
sabrehagen:master
Open

Implement Dynamic GTK Theme Reloading and Monitoring#3605
sabrehagen wants to merge 1 commit intonicotine-plus:masterfrom
sabrehagen:master

Conversation

@sabrehagen
Copy link

@sabrehagen sabrehagen commented Jan 9, 2026

Hello,

I am entirely unfamiliar with the nicotine-plus codebase, and largely the python language entirely.

I developed these changes entirely using OpenAI 5.2 to allow soulseek to re-render the UI when I update my gtk theme using pywal. I have tested interactively and all works well.

I submit this code for your review as the project maintainer, and if you believe this concept would be useful for all users of nicotine-plus, I would appreciate feedback on the code such that it may be brought in line with the existing codebase standard, so that it may be merged.

Thank you for your time in review, and for any feedback!

Summary of changes: These enhancements improve the application's ability to dynamically update themes.

  • Added GLOBAL_CSS_PROVIDER for centralized CSS management
  • Refactored CSS loading with _load_global_css and reload_global_css functions
  • Introduced theme file monitoring to automatically detect and respond to changes in GTK theme CSS files
  • Developed functions _get_theme_search_roots and _get_theme_css_files to identify and manage theme CSS file paths
  • Implemented _queue_theme_reload and _reload_theme_assets to handle scheduled theme reloading
  • Established file monitoring mechanisms with _on_theme_file_changed and _clear_theme_file_monitors
  • Initiated theme file monitoring in start_theme_file_monitoring and connected theme name changes to _on_theme_name_changed for seamless updates
  • Enhanced logging for better tracking of theme-related events

- Added `GLOBAL_CSS_PROVIDER` for centralized CSS management
- Refactored CSS loading with `_load_global_css` and `reload_global_css` functions
- Introduced theme file monitoring to automatically detect and respond to changes in GTK theme CSS files
- Developed functions `_get_theme_search_roots` and `_get_theme_css_files` to identify and manage theme CSS file paths
- Implemented `_queue_theme_reload` and `_reload_theme_assets` to handle scheduled theme reloading
- Established file monitoring mechanisms with `_on_theme_file_changed` and `_clear_theme_file_monitors`
- Initiated theme file monitoring in `start_theme_file_monitoring` and connected theme name changes to `_on_theme_name_changed` for seamless updates
- Enhanced logging for better tracking of theme-related events

These enhancements improve the application's ability to dynamically update themes, providing a more responsive and user-friendly experience.
@mathiascode
Copy link
Member

Thanks for opening a PR. I'm not sure how pywal works, but is there a different way to reload the GTK theme, e.g. by changing the active theme to another one and back? I would rather not carry custom code for theme reloading in Nicotine+, since it feels like something that should live in GTK.

@slook slook added the wontfix label Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup