Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use notification instead of toast #13

Merged
merged 4 commits into from
Jan 7, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Open folder as notification action
meisenzahl committed Jan 7, 2022
commit fdcf6ca5a8892d3cf2dc81a7f7e8efefb31c7860
14 changes: 14 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -55,6 +55,20 @@ public class Application : Gtk.Application {
settings.notify["zoom"].connect (() => {
font.size = (int) (_default_font.size * settings.zoom / 100.0);
});

var show_codecard_folder = new SimpleAction ("show-codecard-folder", null);
show_codecard_folder.activate.connect (() => {
var uri = "file://" + Utils.get_codecard_folder ();
AppInfo.launch_default_for_uri_async.begin (uri, null, null, (obj, res) => {
try {
AppInfo.launch_default_for_uri_async.end (res);
} catch (Error e) {
critical (e.message);
}
});
});

add_action (show_codecard_folder);
}

public Models.Font font {
6 changes: 2 additions & 4 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
@@ -312,10 +312,7 @@ public class MainWindow : Hdy.Window {

string file_name = "Codecard from %s.png".printf (date_time);

var path = Path.build_filename (
Environment.get_user_special_dir (UserDirectory.PICTURES),
Constants.APP_NAME
);
var path = Utils.get_codecard_folder ();

DirUtils.create_with_parents (path, 0755);

@@ -328,6 +325,7 @@ public class MainWindow : Hdy.Window {

var notification = new Notification (title);
notification.set_body (_("Saved to %s and copied to clipboard").printf (Utils.replace_home_with_tilde (path)));
notification.set_default_action ("app.show-codecard-folder");
app.send_notification (Constants.APP_ID, notification);

saving = false;
7 changes: 7 additions & 0 deletions src/Utils.vala
Original file line number Diff line number Diff line change
@@ -27,4 +27,11 @@ namespace Utils {
return path;
}
}

public string get_codecard_folder () {
return Path.build_filename (
Environment.get_user_special_dir (UserDirectory.PICTURES),
Constants.APP_NAME
);
}
}