summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2023-03-12 19:42:56 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2023-03-12 20:37:30 +0100
commit45e742faadcc007cc06217ab3e04333dabc285b5 (patch)
treecbe70e817aea69e3a24e9946c428d46569cf0918
parent258d8d016f4b1dca38cf2d03b7faa0cb09f5496f (diff)
Remember the window dimensions with Gsettings.
-rw-r--r--Makefile.am2
-rw-r--r--cfg.mk4
-rw-r--r--configure.ac8
-rw-r--r--po/POTFILES.in1
-rw-r--r--settings/Makefile.am19
-rw-r--r--settings/eu.planete_kraus.Disfluid.gschema.xml.in38
-rw-r--r--src/adwaita/disfluid-window.c15
7 files changed, 84 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 8e51600..e59c036 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ noinst_LTLIBRARIES =
include_HEADERS =
check_PROGRAMS =
DISTCLEANFILES =
+CLEANFILES =
EXTRA_DIST = m4/gnulib-cache.m4 m4prog/gnulib-cache.m4
ACLOCAL_AMFLAGS = -I m4 -I m4prog
TESTS =
@@ -20,4 +21,5 @@ include %D%/include/Makefile.am
include %D%/src/Makefile.am
include %D%/icons/Makefile.am
include %D%/desktop/Makefile.am
+include %D%/settings/Makefile.am
include %D%/tests/Makefile.am
diff --git a/cfg.mk b/cfg.mk
index e47bea7..3a39e45 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1,8 +1,8 @@
old_NEWS_hash = f0fb7934a30c4e89f0468433bd9317c7
-_makefile_at_at_check_exceptions = ' && !/INTL_MACOSX_LIBS/'
+_makefile_at_at_check_exceptions = ' && !/INTL_MACOSX_LIBS/ && !/GSETTINGS_RULES/'
generated_files = $(srcdir)/lib/*.[ch]
-_gl_translatable_string_re ?= \b(N?_|gettext) *\([^)"]*("|$$)|translatable="yes"|^Comment=
+_gl_translatable_string_re ?= \b(N?_|gettext) *\([^)"]*("|$$)|translatable="yes"|^Comment=|<description>
.PHONY: push-updated-translations sc_git_authors_known sc_appstream_news_hash
diff --git a/configure.ac b/configure.ac
index 9250f3a..aca35a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,7 @@ glprog_INIT
AM_PROG_VALAC
AM_MISSING_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
AM_MISSING_PROG([CONVERT], [convert])
+GLIB_GSETTINGS
# Checks for libraries.
AM_GNU_GETTEXT([external])
@@ -67,10 +68,14 @@ AM_CONDITIONAL([SHLIBS_IN_BINDIR], [test "x$i_am_windows" = "xyes"])
case "$VERSION" in
*-*)
AC_SUBST([DISFLUID_IS_NIGHTLY], [yes])
+ AC_SUBST([DISFLUID_NIGHTLY_SUFFIX], [.Devel])
+ AC_SUBST([DISFLUID_NIGHTLY_SUFFIX_SLASH], [/Devel])
AC_DEFINE([DISFLUID_IS_NIGHTLY], [1], [Whether disfluid is built from a snapshot, as opposed to an official release.])
;;
*)
AC_SUBST([DISFLUID_IS_NIGHTLY], [no])
+ AC_SUBST([DISFLUID_NIGHTLY_SUFFIX], [])
+ AC_SUBST([DISFLUID_NIGHTLY_SUFFIX_SLASH], [])
AC_DEFINE([DISFLUID_IS_NIGHTLY], [0], [Whether disfluid is built from a snapshot, as opposed to an official release.])
;;
esac
@@ -81,5 +86,6 @@ AC_CONFIG_FILES([
Makefile
lib/Makefile libprog/Makefile
po/Makefile.in
- tests/libgnu/Makefile tests/libprog/Makefile])
+ tests/libgnu/Makefile tests/libprog/Makefile
+ settings/eu.planete_kraus.Disfluid.gschema.xml])
AC_OUTPUT
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4397e1f..5f2aa7c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,3 +6,4 @@ src/adwaita/disfluid-menus.c
src/libdisfluid/disfluid-authors.h
src/libdisfluid/disfluid-tests.h
src/libdisfluid/disfluid-version.h
+settings/eu.planete_kraus.Disfluid.gschema.xml.in
diff --git a/settings/Makefile.am b/settings/Makefile.am
new file mode 100644
index 0000000..2416181
--- /dev/null
+++ b/settings/Makefile.am
@@ -0,0 +1,19 @@
+gsettingsdir = ${datarootdir}/glib-2.0/schemas
+
+gsettings_DATA = \
+ %D%/eu.planete_kraus.Disfluid$(DISFLUID_NIGHTLY_SUFFIX).gschema.xml
+
+EXTRA_DIST += \
+ %D%/eu.planete_kraus.Disfluid.gschema.xml.in \
+ %D%/eu.planete_kraus.Disfluid.gschema.valid
+
+CLEANFILES += \
+ %D%/eu.planete_kraus.Disfluid.gschema.xml \
+ %D%/eu.planete_kraus.Disfluid.Devel.gschema.xml
+
+
+%D%/eu.planete_kraus.Disfluid.gschema.valid: %D%/eu.planete_kraus.Disfluid.gschema.xml.in
+ $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --strict --dry-run --schema-file=$(srcdir)/%D%/eu.planete_kraus.Disfluid.gschema.xml.in && touch $(srcdir)/%D%/eu.planete_kraus.Disfluid.gschema.valid
+
+%D%/eu.planete_kraus.Disfluid.Devel.gschema.xml: %D%/eu.planete_kraus.Disfluid.gschema.xml
+ $(AM_V_GEN) cp %D%/eu.planete_kraus.Disfluid.gschema.xml %D%/eu.planete_kraus.Disfluid.Devel.gschema.xml
diff --git a/settings/eu.planete_kraus.Disfluid.gschema.xml.in b/settings/eu.planete_kraus.Disfluid.gschema.xml.in
new file mode 100644
index 0000000..f8298ba
--- /dev/null
+++ b/settings/eu.planete_kraus.Disfluid.gschema.xml.in
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<schemalist>
+ <schema id="eu.planete_kraus.Disfluid@DISFLUID_NIGHTLY_SUFFIX@.State"
+ path="/eu/planete_kraus/Disfluid@DISFLUID_NIGHTLY_SUFFIX_SLASH@/State/">
+ <key name="width" type="i">
+ <default>640</default>
+ <summary>Main window width</summary>
+ <description>
+ Remember the width of the main window last time you closed the
+ application.
+ </description>
+ </key>
+ <key name="height" type="i">
+ <default>480</default>
+ <summary>Main window height</summary>
+ <description>
+ Remember the height of the main window last time you closed the
+ application.
+ </description>
+ </key>
+ <key name="is-maximized" type="b">
+ <default>false</default>
+ <summary>Whether the main window is maximized</summary>
+ <description>
+ Remember whether the main window was maximized last time you
+ closed the application.
+ </description>
+ </key>
+ <key name="is-fullscreen" type="b">
+ <default>false</default>
+ <summary>Whether the main window used the whole screen</summary>
+ <description>
+ Remember whether the main window used the whole screen last
+ time you closed the application.
+ </description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/adwaita/disfluid-window.c b/src/adwaita/disfluid-window.c
index d1943f5..8f9d87f 100644
--- a/src/adwaita/disfluid-window.c
+++ b/src/adwaita/disfluid-window.c
@@ -71,6 +71,21 @@ disfluid_adw_window_init (DisfluidAdwWindow * self)
gtk_box_append (GTK_BOX (content), header_bar);
gtk_box_append (GTK_BOX (content), main_page);
adw_application_window_set_content (ADW_APPLICATION_WINDOW (self), content);
+ char *settings_id;
+ if (asprintf (&settings_id, "%s.State", disfluid_adw_application_id ()) < 0)
+ {
+ abort ();
+ }
+ GSettings *settings = g_settings_new (settings_id);
+ free (settings_id);
+ g_settings_bind (settings, "width", self, "default-width",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "height", self, "default-height",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "is-maximized", self, "maximized",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "is-fullscreen", self, "fullscreened",
+ G_SETTINGS_BIND_DEFAULT);
}
GtkWidget *