From 7536fcdc9c7643d7e72fbe43565955bcab8f2b9e Mon Sep 17 00:00:00 2001 From: Lauren Lagarde Date: Thu, 11 Dec 2025 21:08:06 -0600 Subject: [PATCH 1/3] Automatically load and save application preferences found in hamburger menu --- resources/meson.build | 8 ++++++++ resources/resources.xml.in | 1 + resources/wdisplays.gschema.xml | 14 ++++++++++++++ src/main.c | 17 +++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 resources/wdisplays.gschema.xml diff --git a/resources/meson.build b/resources/meson.build index 0cc2f81..81dadee 100644 --- a/resources/meson.build +++ b/resources/meson.build @@ -48,3 +48,11 @@ install_data( output: '@0@.desktop'.format(meson.project_name()), configuration: conf), install_dir: get_option('datadir') / 'applications') + +settings_schemas = [ 'wdisplays.gschema.xml' ] +gschema_dir = get_option('prefix') / get_option('datadir') / 'glib-2.0' / 'schemas' +install_data(settings_schemas, install_dir: gschema_dir) + +gnome.post_install( + glib_compile_schemas: true +) diff --git a/resources/resources.xml.in b/resources/resources.xml.in index 4bed4b2..31c3eee 100644 --- a/resources/resources.xml.in +++ b/resources/resources.xml.in @@ -3,6 +3,7 @@ wdisplays.ui head.ui + wdisplays.gschema.xml style.css diff --git a/resources/wdisplays.gschema.xml b/resources/wdisplays.gschema.xml new file mode 100644 index 0000000..bf27deb --- /dev/null +++ b/resources/wdisplays.gschema.xml @@ -0,0 +1,14 @@ + + + + + false + + + true + + + true + + + diff --git a/src/main.c b/src/main.c index 2484a63..973332d 100644 --- a/src/main.c +++ b/src/main.c @@ -858,6 +858,10 @@ static void info_bar_animation_done(GObject *object, GParamSpec *pspec, gpointer static void auto_apply_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; + + GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); + g_settings_set_boolean(settings, "auto-apply", g_variant_get_boolean(param)); + state->autoapply = g_variant_get_boolean(param); g_simple_action_set_state(action, param); } @@ -874,6 +878,10 @@ static gboolean redraw_canvas(GtkWidget *widget, GdkFrameClock *frame_clock, gpo static void capture_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; + + GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); + g_settings_set_boolean(settings, "capture-screens", g_variant_get_boolean(param)); + state->capture = g_variant_get_boolean(param); g_simple_action_set_state(action, param); update_tick_callback(state); @@ -881,6 +889,10 @@ static void capture_selected(GSimpleAction *action, GVariant *param, gpointer da static void overlay_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; + + GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); + g_settings_set_boolean(settings, "show-overlay", g_variant_get_boolean(param)); + state->show_overlay = g_variant_get_boolean(param); g_simple_action_set_state(action, param); @@ -1019,6 +1031,11 @@ static void activate(GtkApplication* app, gpointer user_data) { g_signal_connect(action, "activate", G_CALLBACK(zoom_in), state); g_action_map_add_action(G_ACTION_MAP(main_actions), G_ACTION(action)); + GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); + state->autoapply = g_settings_get_boolean(settings, "auto-apply"); + state->capture = g_settings_get_boolean(settings, "capture-screens"); + state->show_overlay = g_settings_get_boolean(settings, "show-overlay"); + action = g_simple_action_new_stateful("auto-apply", NULL, g_variant_new_boolean(state->autoapply)); g_signal_connect(action, "change-state", G_CALLBACK(auto_apply_selected), state); From 3701a7cd3a52d799d9b6104148a6e7c6ac24c009 Mon Sep 17 00:00:00 2001 From: Lauren Lagarde Date: Mon, 19 Jan 2026 16:51:49 -0600 Subject: [PATCH 2/3] Add license to .reuse/dep5 --- .reuse/dep5 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.reuse/dep5 b/.reuse/dep5 index f40f818..882bb4c 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -27,3 +27,7 @@ License: MIT Files: protocol/wlr-screencopy-unstable-v1.xml Copyright: 2018 Simon Ser License: MIT + +Files: resources/wdisplays.gschema.xml +Copyright: 2026 Lauren Lagarde +License: MIT From d03af89d59bd6b94343d871659108ba4b7c56fa0 Mon Sep 17 00:00:00 2001 From: Mars-Wave <57585293+Mars-Wave@users.noreply.github.com> Date: Wed, 21 Jan 2026 20:54:22 +0100 Subject: [PATCH 3/3] Share one GSettings and survive a missing schema --- resources/meson.build | 6 +++--- resources/resources.xml.in | 1 - resources/wdisplays.gschema.xml | 2 +- src/main.c | 35 ++++++++++++++++++--------------- src/wdisplays.h | 2 ++ 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/resources/meson.build b/resources/meson.build index 81dadee..40e79ea 100644 --- a/resources/meson.build +++ b/resources/meson.build @@ -49,9 +49,9 @@ install_data( configuration: conf), install_dir: get_option('datadir') / 'applications') -settings_schemas = [ 'wdisplays.gschema.xml' ] -gschema_dir = get_option('prefix') / get_option('datadir') / 'glib-2.0' / 'schemas' -install_data(settings_schemas, install_dir: gschema_dir) +install_data('wdisplays.gschema.xml', + rename: '@0@.gschema.xml'.format(meson.project_name()), + install_dir: get_option('datadir') / 'glib-2.0' / 'schemas') gnome.post_install( glib_compile_schemas: true diff --git a/resources/resources.xml.in b/resources/resources.xml.in index 31c3eee..4bed4b2 100644 --- a/resources/resources.xml.in +++ b/resources/resources.xml.in @@ -3,7 +3,6 @@ wdisplays.ui head.ui - wdisplays.gschema.xml style.css diff --git a/resources/wdisplays.gschema.xml b/resources/wdisplays.gschema.xml index bf27deb..176072c 100644 --- a/resources/wdisplays.gschema.xml +++ b/resources/wdisplays.gschema.xml @@ -1,6 +1,6 @@ - + false diff --git a/src/main.c b/src/main.c index 973332d..176731d 100644 --- a/src/main.c +++ b/src/main.c @@ -418,6 +418,7 @@ static void cleanup(GtkWidget *window, gpointer data) { g_object_unref(state->grab_cursor); g_object_unref(state->grabbing_cursor); g_object_unref(state->move_cursor); + g_clear_object(&state->settings); wd_state_destroy(state); } @@ -858,10 +859,9 @@ static void info_bar_animation_done(GObject *object, GParamSpec *pspec, gpointer static void auto_apply_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; - - GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); - g_settings_set_boolean(settings, "auto-apply", g_variant_get_boolean(param)); - + if (state->settings != NULL) { + g_settings_set_boolean(state->settings, "auto-apply", g_variant_get_boolean(param)); + } state->autoapply = g_variant_get_boolean(param); g_simple_action_set_state(action, param); } @@ -878,10 +878,9 @@ static gboolean redraw_canvas(GtkWidget *widget, GdkFrameClock *frame_clock, gpo static void capture_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; - - GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); - g_settings_set_boolean(settings, "capture-screens", g_variant_get_boolean(param)); - + if (state->settings != NULL) { + g_settings_set_boolean(state->settings, "capture-screens", g_variant_get_boolean(param)); + } state->capture = g_variant_get_boolean(param); g_simple_action_set_state(action, param); update_tick_callback(state); @@ -889,10 +888,9 @@ static void capture_selected(GSimpleAction *action, GVariant *param, gpointer da static void overlay_selected(GSimpleAction *action, GVariant *param, gpointer data) { struct wd_state *state = data; - - GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); - g_settings_set_boolean(settings, "show-overlay", g_variant_get_boolean(param)); - + if (state->settings != NULL) { + g_settings_set_boolean(state->settings, "show-overlay", g_variant_get_boolean(param)); + } state->show_overlay = g_variant_get_boolean(param); g_simple_action_set_state(action, param); @@ -1031,10 +1029,15 @@ static void activate(GtkApplication* app, gpointer user_data) { g_signal_connect(action, "activate", G_CALLBACK(zoom_in), state); g_action_map_add_action(G_ACTION_MAP(main_actions), G_ACTION(action)); - GSettings *settings = g_settings_new("com.github.artizirk.wdisplays"); - state->autoapply = g_settings_get_boolean(settings, "auto-apply"); - state->capture = g_settings_get_boolean(settings, "capture-screens"); - state->show_overlay = g_settings_get_boolean(settings, "show-overlay"); + GSettingsSchemaSource *schemas = g_settings_schema_source_get_default(); + g_autoptr(GSettingsSchema) schema = schemas == NULL ? NULL : + g_settings_schema_source_lookup(schemas, WDISPLAYS_APP_ID, TRUE); + if (schema != NULL) { + state->settings = g_settings_new(WDISPLAYS_APP_ID); + state->autoapply = g_settings_get_boolean(state->settings, "auto-apply"); + state->capture = g_settings_get_boolean(state->settings, "capture-screens"); + state->show_overlay = g_settings_get_boolean(state->settings, "show-overlay"); + } action = g_simple_action_new_stateful("auto-apply", NULL, g_variant_new_boolean(state->autoapply)); diff --git a/src/wdisplays.h b/src/wdisplays.h index 4824017..0e7a3c6 100644 --- a/src/wdisplays.h +++ b/src/wdisplays.h @@ -215,6 +215,8 @@ struct wd_state { GtkWidget *info_label; GtkWidget *menu_button; + GSettings *settings; + GdkCursor *grab_cursor; GdkCursor *grabbing_cursor; GdkCursor *move_cursor;