[console/zbrown/quick-ci-check: 2/3] schema: add setting to restore window size
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [console/zbrown/quick-ci-check: 2/3] schema: add setting to restore window size
- Date: Tue, 30 Aug 2022 23:58:26 +0000 (UTC)
commit 345e91d4823084df12fb418971e1bcedee6d2eec
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Thu Aug 11 12:24:49 2022 +0200
schema: add setting to restore window size
Enabled by default. If disabled we simply use the ≤42 behaviour.
Fix: https://gitlab.gnome.org/GNOME/console/-/issues/120
data/org.gnome.Console.gschema.xml.in | 6 ++++
src/kgx-settings.c | 53 +++++++++++++++++++++++++++++++++++
src/kgx-settings.h | 6 ++++
3 files changed, 65 insertions(+)
---
diff --git a/data/org.gnome.Console.gschema.xml.in b/data/org.gnome.Console.gschema.xml.in
index 8bf5d05..a62a7c7 100644
--- a/data/org.gnome.Console.gschema.xml.in
+++ b/data/org.gnome.Console.gschema.xml.in
@@ -21,5 +21,11 @@
<key name="scrollback-lines" type="x">
<default>10000</default>
</key>
+ <key name="last-window-size" type="(ii)">
+ <default>(-1, -1)</default>
+ </key>
+ <key name="restore-window-size" type="b">
+ <default>true</default>
+ </key>
</schema>
</schemalist>
diff --git a/src/kgx-settings.c b/src/kgx-settings.c
index 9a4c7eb..6f208e5 100644
--- a/src/kgx-settings.c
+++ b/src/kgx-settings.c
@@ -51,6 +51,8 @@
*/
#define MONOSPACE_FONT_KEY_NAME "monospace-font-name"
+#define RESTORE_SIZE_KEY "restore-window-size"
+#define LAST_SIZE_KEY "last-window-size"
struct _KgxSettings {
GObject parent_instance;
@@ -239,6 +241,17 @@ font_changed (GSettings *settings,
}
+static void
+restore_window_size_changed (GSettings *settings,
+ const char *key,
+ KgxSettings *self)
+{
+ if (!g_settings_get_boolean (self->settings, RESTORE_SIZE_KEY)) {
+ g_settings_set (self->settings, LAST_SIZE_KEY, "(ii)", -1, -1);
+ }
+}
+
+
static void
kgx_settings_init (KgxSettings *self)
{
@@ -253,6 +266,11 @@ kgx_settings_init (KgxSettings *self)
self, "scrollback-lines",
G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect (self->settings,
+ "changed::restore-window-size",
+ G_CALLBACK (restore_window_size_changed),
+ self);
+
self->desktop_interface = g_settings_new (DESKTOP_INTERFACE_SETTINGS_SCHEMA);
g_signal_connect (self->desktop_interface,
"changed::" MONOSPACE_FONT_KEY_NAME,
@@ -372,3 +390,38 @@ kgx_settings_set_scrollback (KgxSettings *self,
g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_SCROLLBACK_LINES]);
}
+
+
+void
+kgx_settings_get_size (KgxSettings *self,
+ int *width,
+ int *height)
+{
+ g_return_if_fail (KGX_IS_SETTINGS (self));
+ g_return_if_fail (width != NULL && height != NULL);
+
+ if (!g_settings_get_boolean (self->settings, RESTORE_SIZE_KEY)) {
+ *width = -1;
+ *height = -1;
+ return;
+ }
+
+ g_settings_get (self->settings, LAST_SIZE_KEY, "(ii)", width, height);
+}
+
+
+void
+kgx_settings_set_custom_size (KgxSettings *self,
+ int width,
+ int height)
+{
+ g_return_if_fail (KGX_IS_SETTINGS (self));
+
+ if (!g_settings_get_boolean (self->settings, RESTORE_SIZE_KEY)) {
+ return;
+ }
+
+ g_debug ("Store window size: %i×%i", width, height);
+
+ g_settings_set (self->settings, LAST_SIZE_KEY, "(ii)", width, height);
+}
diff --git a/src/kgx-settings.h b/src/kgx-settings.h
index 8c000c0..997088d 100644
--- a/src/kgx-settings.h
+++ b/src/kgx-settings.h
@@ -80,5 +80,11 @@ void kgx_settings_set_custom_shell (KgxSettings *self,
const char *const *shell);
void kgx_settings_set_scrollback (KgxSettings *self,
int64_t value);
+void kgx_settings_get_size (KgxSettings *self,
+ int *width,
+ int *height);
+void kgx_settings_set_custom_size (KgxSettings *self,
+ int width,
+ int height);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]