aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gsr-window.c
diff options
context:
space:
mode:
authorTrung Lê <8@tle.id.au>2026-06-10 11:46:52 +1000
committerGitHub <noreply@github.com>2026-06-10 11:46:52 +1000
commitf51ba1bf936ae5085ba604b76bbca18e79554dfe (patch)
tree8584adb5c971446eedd3959ac6fdaea86953e74d /src/gsr-window.c
parent3d6435e45cc4b760afa10ddf96a1c542817c0fe1 (diff)
parenta646f86c232ecbc0d1875ef2b83a165760127699 (diff)
Merge pull request #8 from runlevel5/feature/notification-open-folder
feat: click the saved-recording notification to open its folder
Diffstat (limited to 'src/gsr-window.c')
-rw-r--r--src/gsr-window.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gsr-window.c b/src/gsr-window.c
index fe7a55e..6620b59 100644
--- a/src/gsr-window.c
+++ b/src/gsr-window.c
@@ -133,8 +133,9 @@ on_notification_withdraw(gpointer user_data)
* case so the user still sees them.
*/
static void
-send_notification(GsrWindow *self, const char *title,
- const char *body, GNotificationPriority priority)
+send_notification_full(GsrWindow *self, const char *title,
+ const char *body, GNotificationPriority priority,
+ const char *open_file_path)
{
GtkApplication *app = GTK_APPLICATION(
gtk_window_get_application(GTK_WINDOW(self)));
@@ -153,6 +154,11 @@ send_notification(GsrWindow *self, const char *title,
g_notification_set_priority(notif, effective);
+ /* Clicking the notification reveals the saved file in the file manager */
+ if (open_file_path && *open_file_path)
+ g_notification_set_default_action_and_target(notif,
+ "app.open-folder", "s", open_file_path);
+
/* Cancel any pending withdrawal timer, then send */
if (self->showing_notification) {
g_application_withdraw_notification(G_APPLICATION(app),
@@ -171,9 +177,22 @@ send_notification(GsrWindow *self, const char *title,
/* ── In-app toast ── */
AdwToast *toast = adw_toast_new(body);
adw_toast_set_timeout(toast, (effective >= G_NOTIFICATION_PRIORITY_URGENT) ? 10 : 3);
+ if (open_file_path && *open_file_path) {
+ adw_toast_set_button_label(toast, "Open Folder");
+ adw_toast_set_action_name(toast, "app.open-folder");
+ adw_toast_set_action_target_value(toast,
+ g_variant_new_string(open_file_path));
+ }
adw_toast_overlay_add_toast(self->toast_overlay, toast);
}
+static void
+send_notification(GsrWindow *self, const char *title,
+ const char *body, GNotificationPriority priority)
+{
+ send_notification_full(self, title, body, priority, NULL);
+}
+
/* ── Container compatibility fix ─────────────────────────────────── */
static const char *
@@ -553,8 +572,8 @@ handle_child_death(GsrWindow *self, int exit_status)
if (gsr_config_page_get_notify_saved(self->config_page)) {
char *msg = g_strdup_printf("Recording saved to %s",
self->record_filename);
- send_notification(self, "GPU Screen Recorder", msg,
- G_NOTIFICATION_PRIORITY_NORMAL);
+ send_notification_full(self, "GPU Screen Recorder", msg,
+ G_NOTIFICATION_PRIORITY_NORMAL, self->record_filename);
g_free(msg);
}
} else if (gsr_config_page_get_notify_stopped(self->config_page)) {
@@ -1114,8 +1133,8 @@ gsr_window_stop_process(GsrWindow *self, gboolean *already_dead)
if (gsr_config_page_get_notify_saved(self->config_page)) {
char *msg = g_strdup_printf("Recording saved to %s",
self->record_filename);
- send_notification(self, "GPU Screen Recorder", msg,
- G_NOTIFICATION_PRIORITY_NORMAL);
+ send_notification_full(self, "GPU Screen Recorder", msg,
+ G_NOTIFICATION_PRIORITY_NORMAL, self->record_filename);
g_free(msg);
}
} else if (gsr_config_page_get_notify_stopped(self->config_page)) {