From b6b010929bbac6d2136bffc76c826e576a0db7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 13 Dec 2025 10:54:01 -0800 Subject: [PATCH 1/4] Screenshot/SetupDialog: use Action for type --- src/Screenshot/SetupDialog.vala | 41 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Screenshot/SetupDialog.vala b/src/Screenshot/SetupDialog.vala index 6acebc06..ea5f5f50 100644 --- a/src/Screenshot/SetupDialog.vala +++ b/src/Screenshot/SetupDialog.vala @@ -14,7 +14,7 @@ public class Screenshot.SetupDialog : Gtk.Window { public string parent_window { get; construct; } - public ScreenshotType screenshot_type { get; private set; default = ScreenshotType.ALL; } + public ScreenshotType screenshot_type { get; set; default = ALL; } public bool grab_pointer { get; private set; default = false; } public bool redact_text { get; private set; default = false; } public int delay { get; private set; default = 0; } @@ -40,6 +40,20 @@ public class Screenshot.SetupDialog : Gtk.Window { }); } + var type_action = new SimpleAction.stateful ("type", VariantType.UINT32, new Variant.uint32 (screenshot_type)); + type_action.activate.connect ((parameter) => { + screenshot_type = (ScreenshotType) parameter.get_uint32 (); + }); + + notify ["screenshot-type"].connect (() => { + type_action.set_state (new Variant.uint32 (screenshot_type)); + }); + + var action_group = new SimpleActionGroup (); + action_group.add_action (type_action); + + insert_action_group ("screenshot", action_group); + all_image = new Gtk.Image.from_icon_name ("grab-screen-symbolic") { icon_size = LARGE }; @@ -52,17 +66,12 @@ public class Screenshot.SetupDialog : Gtk.Window { all_box.append (all_label); var all = new Gtk.CheckButton () { - active = true, + action_name = "screenshot.type", + action_target = new Variant.uint32 (ScreenshotType.ALL), child = all_box }; all.add_css_class ("image-button"); - all.toggled.connect (() => { - if (all.active) { - screenshot_type = ScreenshotType.ALL; - } - }); - var curr_image = new Gtk.Image.from_icon_name ("grab-window-symbolic") { icon_size = LARGE }; @@ -75,17 +84,13 @@ public class Screenshot.SetupDialog : Gtk.Window { curr_box.append (curr_label); var curr_window = new Gtk.CheckButton () { + action_name = "screenshot.type", + action_target = new Variant.uint32 (ScreenshotType.WINDOW), child = curr_box, group = all }; curr_window.add_css_class ("image-button"); - curr_window.toggled.connect (() => { - if (curr_window.active) { - screenshot_type = ScreenshotType.WINDOW; - } - }); - var selection_image = new Gtk.Image.from_icon_name ("grab-area-symbolic") { icon_size = LARGE }; @@ -98,17 +103,13 @@ public class Screenshot.SetupDialog : Gtk.Window { selection_box.append (selection_label); var selection = new Gtk.CheckButton () { + action_name = "screenshot.type", + action_target = new Variant.uint32 (ScreenshotType.AREA), child = selection_box, group = all }; selection.add_css_class ("image-button"); - selection.toggled.connect (() => { - if (selection.active) { - screenshot_type = ScreenshotType.AREA; - } - }); - var pointer_switch = new Gtk.Switch () { halign = START }; From 736ae13e88fd30ef43c64a3548b092296887f88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 13 Dec 2025 11:09:15 -0800 Subject: [PATCH 2/4] Remember screenshot type --- data/gschema.xml | 14 ++++++++++++++ data/meson.build | 6 ++++++ meson.build | 4 ++++ src/Screenshot/SetupDialog.vala | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 data/gschema.xml diff --git a/data/gschema.xml b/data/gschema.xml new file mode 100644 index 00000000..7f4ce4e0 --- /dev/null +++ b/data/gschema.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + "all" + + + diff --git a/data/meson.build b/data/meson.build index e596191d..f3653654 100644 --- a/data/meson.build +++ b/data/meson.build @@ -37,3 +37,9 @@ icon_res = gnome.compile_resources( 'screenshot-icon-resources', 'gresource.xml' ) + +install_data( + 'gschema.xml', + install_dir: get_option('datadir') / 'glib-2.0' / 'schemas', + rename: meson.project_name() + '.gschema.xml' +) diff --git a/meson.build b/meson.build index 6e8cb672..1fe653ab 100644 --- a/meson.build +++ b/meson.build @@ -48,3 +48,7 @@ conf_data.set_quoted('VERSION', meson.project_version()) subdir('data') subdir('po') subdir('src') + +gnome.post_install ( + glib_compile_schemas: true +) diff --git a/src/Screenshot/SetupDialog.vala b/src/Screenshot/SetupDialog.vala index ea5f5f50..2a9ed968 100644 --- a/src/Screenshot/SetupDialog.vala +++ b/src/Screenshot/SetupDialog.vala @@ -40,6 +40,9 @@ public class Screenshot.SetupDialog : Gtk.Window { }); } + var settings = new Settings ("io.elementary.portals.screenshot"); + settings.bind ("last-capture-mode", this, "screenshot-type", DEFAULT); + var type_action = new SimpleAction.stateful ("type", VariantType.UINT32, new Variant.uint32 (screenshot_type)); type_action.activate.connect ((parameter) => { screenshot_type = (ScreenshotType) parameter.get_uint32 (); From 7bac5444bb5147cb9361fd16f4b28f3597e61d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 13 Dec 2025 11:12:24 -0800 Subject: [PATCH 3/4] Replace with settings action --- src/Screenshot/SetupDialog.vala | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Screenshot/SetupDialog.vala b/src/Screenshot/SetupDialog.vala index 2a9ed968..4aafb92e 100644 --- a/src/Screenshot/SetupDialog.vala +++ b/src/Screenshot/SetupDialog.vala @@ -41,16 +41,9 @@ public class Screenshot.SetupDialog : Gtk.Window { } var settings = new Settings ("io.elementary.portals.screenshot"); - settings.bind ("last-capture-mode", this, "screenshot-type", DEFAULT); + settings.bind ("last-capture-mode", this, "screenshot-type", GET); - var type_action = new SimpleAction.stateful ("type", VariantType.UINT32, new Variant.uint32 (screenshot_type)); - type_action.activate.connect ((parameter) => { - screenshot_type = (ScreenshotType) parameter.get_uint32 (); - }); - - notify ["screenshot-type"].connect (() => { - type_action.set_state (new Variant.uint32 (screenshot_type)); - }); + var type_action = settings.create_action ("last-capture-mode"); var action_group = new SimpleActionGroup (); action_group.add_action (type_action); @@ -69,8 +62,8 @@ public class Screenshot.SetupDialog : Gtk.Window { all_box.append (all_label); var all = new Gtk.CheckButton () { - action_name = "screenshot.type", - action_target = new Variant.uint32 (ScreenshotType.ALL), + action_name = "screenshot.last-capture-mode", + action_target = new Variant.string ("all"), child = all_box }; all.add_css_class ("image-button"); @@ -87,8 +80,8 @@ public class Screenshot.SetupDialog : Gtk.Window { curr_box.append (curr_label); var curr_window = new Gtk.CheckButton () { - action_name = "screenshot.type", - action_target = new Variant.uint32 (ScreenshotType.WINDOW), + action_name = "screenshot.last-capture-mode", + action_target = new Variant.string ("window"), child = curr_box, group = all }; @@ -106,8 +99,8 @@ public class Screenshot.SetupDialog : Gtk.Window { selection_box.append (selection_label); var selection = new Gtk.CheckButton () { - action_name = "screenshot.type", - action_target = new Variant.uint32 (ScreenshotType.AREA), + action_name = "screenshot.last-capture-mode", + action_target = new Variant.string ("area"), child = selection_box, group = all }; From 3a8567de1847afb614b3a99dd201945d65148571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 13 Dec 2025 11:14:18 -0800 Subject: [PATCH 4/4] Add metainfo --- data/portals.metainfo.xml.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/portals.metainfo.xml.in b/data/portals.metainfo.xml.in index 7b900d2f..d1846cd0 100644 --- a/data/portals.metainfo.xml.in +++ b/data/portals.metainfo.xml.in @@ -26,6 +26,18 @@ contact_at_elementary.io + + +

New Features:

+
    +
  • Updated translations
  • +
+
+ + Remember Screenshot Type Choice + +
+

Fixes a regression in 8.0.3 that happens with unreleased version of Granite