From 0d4e4fe54e520c006a4eaddd1d5cd6377b85857b Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Sat, 28 Dec 2024 12:49:08 +0100 Subject: [PATCH] Save and restore main window state Closes #62 --- .gitignore | 3 ++ Makefile | 3 +- build.rs | 23 +++++++++++++ flatpak/de.swsnr.turnon.Devel.yaml | 3 ++ resources/de.swsnr.turnon.metainfo.xml.in | 4 +++ resources/ui/turnon-application-window.blp | 2 -- resources/ui/turnon-application-window.ui | 2 -- schemas/de.swsnr.turnon.gschema.xml | 16 +++++++++ src/app/widgets/application_window.rs | 39 ++++++++++++++++++++-- src/config.rs | 21 ++++++++++++ 10 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 schemas/de.swsnr.turnon.gschema.xml diff --git a/.gitignore b/.gitignore index c30e3d5..a9f5e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ # Compiled gettext catalogs /po/*.mo + +# Compiled schemas +/schemas/gschemas.compiled diff --git a/Makefile b/Makefile index 6eb9f94..d34b0db 100644 --- a/Makefile +++ b/Makefile @@ -74,4 +74,5 @@ devel: sed -i '/de.swsnr.turnon.Devel/! s/de\.swsnr\.turnon/de.swsnr.turnon.Devel/g' \ src/config.rs \ resources/de.swsnr.turnon.metainfo.xml.in de.swsnr.turnon.desktop.in \ - dbus-1/de.swsnr.turnon.service de.swsnr.turnon.search-provider.ini + dbus-1/de.swsnr.turnon.service de.swsnr.turnon.search-provider.ini \ + schemas/de.swsnr.turnon.gschema.xml diff --git a/build.rs b/build.rs index 707ad35..cedeac4 100644 --- a/build.rs +++ b/build.rs @@ -153,11 +153,34 @@ pub fn compile_resources>(source_dirs: &[P], gresource: &str, tar } } +fn compile_schemas() { + let schemas: Vec = glob::glob("schemas/*.gschema.xml") + .unwrap() + .collect::>() + .unwrap(); + for schema in schemas { + println!("cargo:rerun-if-changed={}", schema.display()); + } + + let output = Command::new("glib-compile-schemas") + .args(["--strict", "schemas"]) + .output() + .unwrap(); + + assert!( + output.status.success(), + "glib-compile-schemas failed with exit status {} and stderr:\n{}", + output.status, + String::from_utf8_lossy(&output.stderr) + ); +} + fn main() { // Compile blueprints and msgfmt our metainfo template first, as these are // inputs to resource compilation. compile_blueprint(); msgfmt(); + compile_schemas(); compile_resources( &["resources"], "resources/resources.gresource.xml", diff --git a/flatpak/de.swsnr.turnon.Devel.yaml b/flatpak/de.swsnr.turnon.Devel.yaml index edd4286..1e534f4 100644 --- a/flatpak/de.swsnr.turnon.Devel.yaml +++ b/flatpak/de.swsnr.turnon.Devel.yaml @@ -39,3 +39,6 @@ modules: - install -Dm0644 resources/de.swsnr.turnon.metainfo.xml /app/share/metainfo/de.swsnr.turnon.Devel.metainfo.xml - install -Dm0644 dbus-1/de.swsnr.turnon.service /app/share/dbus-1/services/de.swsnr.turnon.Devel.service - install -Dm0644 de.swsnr.turnon.search-provider.ini /app/share/gnome-shell/search-providers/de.swsnr.turnon.Devel.search-provider.ini + # Install settings and compile them + - install -Dm0644 schemas/de.swsnr.turnon.gschema.xml /app/share/glib-2.0/schemas/de.swsnr.turnon.Devel.gschema.xml + - glib-compile-schemas --strict /app/share/glib-2.0/schemas diff --git a/resources/de.swsnr.turnon.metainfo.xml.in b/resources/de.swsnr.turnon.metainfo.xml.in index 756a31c..3835ee3 100644 --- a/resources/de.swsnr.turnon.metainfo.xml.in +++ b/resources/de.swsnr.turnon.metainfo.xml.in @@ -33,8 +33,12 @@ +

Save and restore main window state.

Update translations.

+ + GH-62 + https://github.com/swsnr/turnon/releases/tag/next
diff --git a/resources/ui/turnon-application-window.blp b/resources/ui/turnon-application-window.blp index bb24f82..c4dc22f 100644 --- a/resources/ui/turnon-application-window.blp +++ b/resources/ui/turnon-application-window.blp @@ -6,8 +6,6 @@ using Gtk 4.0; using Adw 1; template $TurnOnApplicationWindow: Adw.ApplicationWindow { - default-width: 480; - default-height: 480; title: _('Turn On'); content: Adw.ToolbarView { diff --git a/resources/ui/turnon-application-window.ui b/resources/ui/turnon-application-window.ui index 8857385..3ee3ef2 100644 --- a/resources/ui/turnon-application-window.ui +++ b/resources/ui/turnon-application-window.ui @@ -7,8 +7,6 @@ corresponding .blp file and regenerate this file with blueprint-compiler.