Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions data/gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id="io.elementary.portals.screenshot.capture-mode">
<value nick="all" value="0"/>
<value nick="window" value="1"/>
<value nick="area" value="2"/>
</enum>

<schema path="/io/elementary/portals/screenshot/" id="io.elementary.portals.screenshot">
<key name='last-capture-mode' enum='io.elementary.portals.screenshot.capture-mode'>
<default>"all"</default>
</key>
</schema>
</schemalist>
6 changes: 6 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
12 changes: 12 additions & 0 deletions data/portals.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
<update_contact>contact_at_elementary.io</update_contact>

<releases>
<release version="8.1.0" data="2025-12-12" urgency="medium">
<description>
<p>New Features:</p>
<ul>
<li>Updated translations</li>
</ul>
</description>
<issues>
<issue url="https://github.com/elementary/portals/issues/158">Remember Screenshot Type Choice</issue>
</issues>
</release>

<release version="8.0.4" data="2025-06-22" urgency="medium">
<description>
<p>Fixes a regression in 8.0.3 that happens with unreleased version of Granite</p>
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
37 changes: 17 additions & 20 deletions src/Screenshot/SetupDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -40,6 +40,16 @@ public class Screenshot.SetupDialog : Gtk.Window {
});
}

var settings = new Settings ("io.elementary.portals.screenshot");
settings.bind ("last-capture-mode", this, "screenshot-type", GET);

var type_action = settings.create_action ("last-capture-mode");

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
};
Expand All @@ -52,17 +62,12 @@ public class Screenshot.SetupDialog : Gtk.Window {
all_box.append (all_label);

var all = new Gtk.CheckButton () {
active = true,
action_name = "screenshot.last-capture-mode",
action_target = new Variant.string ("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
};
Expand All @@ -75,17 +80,13 @@ public class Screenshot.SetupDialog : Gtk.Window {
curr_box.append (curr_label);

var curr_window = new Gtk.CheckButton () {
action_name = "screenshot.last-capture-mode",
action_target = new Variant.string ("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
};
Expand All @@ -98,17 +99,13 @@ public class Screenshot.SetupDialog : Gtk.Window {
selection_box.append (selection_label);

var selection = new Gtk.CheckButton () {
action_name = "screenshot.last-capture-mode",
action_target = new Variant.string ("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
};
Expand Down