apprt/gtk: only show config reload toast if app config changes

This resolves the toast showing up every time the surface config changes
which can be relatively frequent under certain circumstances such as
theme changes.
This commit is contained in:
Mitchell Hashimoto
2024-11-25 15:12:14 -08:00
parent b2db1a8df6
commit a39aa7e89d

View File

@ -462,7 +462,7 @@ pub fn performAction(
.equalize_splits => self.equalizeSplits(target),
.goto_split => self.gotoSplit(target, value),
.open_config => try configpkg.edit.open(self.core_app.alloc),
.config_change => self.configChange(value.config),
.config_change => self.configChange(target, value.config),
.reload_config => try self.reloadConfig(target, value),
.inspector => self.controlInspector(target, value),
.desktop_notification => self.showDesktopNotification(target, value),
@ -818,19 +818,33 @@ fn showDesktopNotification(
c.g_application_send_notification(g_app, n.body.ptr, notification);
}
fn configChange(self: *App, new_config: *const Config) void {
fn configChange(
self: *App,
target: apprt.Target,
new_config: *const Config,
) void {
_ = new_config;
switch (target) {
// We don't do anything for surface config change events. There
// is nothing to sync with regards to a surface today.
.surface => {},
.app => {
self.syncConfigChanges() catch |err| {
log.warn("error handling configuration changes err={}", .{err});
};
// App changes needs to show a toast that our configuration
// has reloaded.
if (adwaita.enabled(&self.config)) {
if (self.core_app.focusedSurface()) |core_surface| {
const surface = core_surface.rt_surface;
if (surface.container.window()) |window| window.onConfigReloaded();
}
}
},
}
}
pub fn reloadConfig(