Merge pull request #765 from JakeStanger/fix/style-reload

fix: not properly redrawing on style reload
This commit is contained in:
Jake Stanger 2024-11-05 13:10:12 +00:00 committed by GitHub
commit 3cd2fce333
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -143,7 +143,7 @@ impl Ipc {
} }
Command::LoadCss { path } => { Command::LoadCss { path } => {
if path.exists() { if path.exists() {
load_css(path); load_css(path, application.clone());
Response::Ok Response::Ok
} else { } else {
Response::error("File not found") Response::error("File not found")

View File

@ -179,7 +179,7 @@ impl Ironbar {
); );
if style_path.exists() { if style_path.exists() {
load_css(style_path); load_css(style_path, app.clone());
} }
let (tx, rx) = mpsc::channel(); let (tx, rx) = mpsc::channel();

View File

@ -1,8 +1,8 @@
use crate::{glib_recv_mpsc, spawn, try_send}; use crate::{glib_recv_mpsc, spawn, try_send};
use color_eyre::{Help, Report}; use color_eyre::{Help, Report};
use gtk::ffi::GTK_STYLE_PROVIDER_PRIORITY_USER; use gtk::ffi::GTK_STYLE_PROVIDER_PRIORITY_USER;
use gtk::prelude::CssProviderExt; use gtk::prelude::*;
use gtk::{gdk, gio, CssProvider, StyleContext}; use gtk::{gdk, gio, Application, CssProvider, StyleContext};
use notify::event::ModifyKind; use notify::event::ModifyKind;
use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Result, Watcher}; use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Result, Watcher};
use std::env; use std::env;
@ -17,7 +17,7 @@ use tracing::{debug, error, info};
/// ///
/// Installs a file watcher and reloads CSS when /// Installs a file watcher and reloads CSS when
/// write changes are detected on the file. /// write changes are detected on the file.
pub fn load_css(style_path: PathBuf) { pub fn load_css(style_path: PathBuf, application: Application) {
// file watcher requires absolute path // file watcher requires absolute path
let style_path = if style_path.is_absolute() { let style_path = if style_path.is_absolute() {
style_path style_path
@ -80,6 +80,10 @@ pub fn load_css(style_path: PathBuf) {
.suggestion("Check the CSS file for errors") .suggestion("Check the CSS file for errors")
.suggestion("GTK CSS uses a subset of the full CSS spec and many properties are not available. Ensure you are not using any unsupported property.") .suggestion("GTK CSS uses a subset of the full CSS spec and many properties are not available. Ensure you are not using any unsupported property.")
); );
} else {
for win in application.windows() {
win.queue_draw();
}
} }
}); });
} }