Skip to content
Closed
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
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gtk_dep = dependency('gtk+-3.0')
handy_dep = dependency('libhandy-1', version: '>=1.0')
wingpanel_dep = dependency('wingpanel')
wingpanel_indicatorsdir = wingpanel_dep.get_pkgconfig_variable('indicatorsdir', define_variable: ['libdir', libdir])
portal_dep = dependency('libportal')

subdir('data')
subdir('po')
Expand Down
37 changes: 37 additions & 0 deletions src/PopoverWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class QuickSettings.PopoverWidget : Gtk.Box {
};
settings_button.get_style_context ().add_class ("circular");

var screenshot_button = new Gtk.Button.from_icon_name ("accessories-screenshot-tool-symbolic") {
tooltip_text = _("Take Screenshot…")
};
screenshot_button.get_style_context ().add_class ("circular");

var session_box = new SessionBox (server_type) {
halign = END,
hexpand = true,
Expand All @@ -60,6 +65,7 @@ public class QuickSettings.PopoverWidget : Gtk.Box {

var bottom_box = new Gtk.Box (HORIZONTAL, 0);
bottom_box.add (settings_button);
bottom_box.add (screenshot_button);
bottom_box.add (session_box);
bottom_box.get_style_context ().add_class ("togglebox");

Expand All @@ -73,6 +79,7 @@ public class QuickSettings.PopoverWidget : Gtk.Box {

if (server_type == GREETER) {
bottom_box.remove (settings_button);
bottom_box.remove (screenshot_button);
}

setup_accounts_services.begin ((obj, res) => {
Expand Down Expand Up @@ -109,6 +116,36 @@ public class QuickSettings.PopoverWidget : Gtk.Box {
}
});

screenshot_button.clicked.connect (() => {
popover.popdown ();

var portal = new Xdp.Portal ();
portal.take_screenshot.begin (null, INTERACTIVE, null, (obj, res) => {
try {
var file_uri = portal.take_screenshot.end (res);

var file_icon = new FileIcon (File.new_for_uri (file_uri));

var folder_dir = Environment.get_user_special_dir (PICTURES) + "%c".printf (Path.DIR_SEPARATOR) + _("Screenshots");

var readable_path = folder_dir.replace (Environment.get_home_dir () + "%c".printf (Path.DIR_SEPARATOR), "");

var notification = new Notification (_("Screenshot taken"));
// notification.add_button (
// _("Open"),
// Action.print_detailed_name ("app.open", new Variant ("s", file_uri))
// );
notification.set_body (_("Saved to “%s”").printf (readable_path));
notification.set_icon (file_icon);
notification.set_priority (LOW);

GLib.Application.get_default ().send_notification ("screenshot", notification);
} catch (Error e) {
critical (e.message);
}
});
});

var applications_settings = new Settings ("org.gnome.desktop.a11y.applications");
applications_settings.bind ("screen-keyboard-enabled", onscreen_keyboard, "active", DEFAULT);
applications_settings.bind ("screen-reader-enabled", screen_reader, "active", DEFAULT);
Expand Down
3 changes: 2 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ shared_module(
granite_dep,
gtk_dep,
handy_dep,
wingpanel_dep
wingpanel_dep,
portal_dep
],
install: true,
install_dir : wingpanel_indicatorsdir
Expand Down