diff options
| author | Trung Lê <8@tle.id.au> | 2026-06-10 11:24:16 +1000 |
|---|---|---|
| committer | Trung Lê <8@tle.id.au> | 2026-06-10 11:32:32 +1000 |
| commit | 9576fada7bb0262dda68735fd49eafe2d7d9d537 (patch) | |
| tree | ada97270f61a9a5a045ee293d64d8057f0fb3403 /src/gsr-window.c | |
| parent | 3d6435e45cc4b760afa10ddf96a1c542817c0fe1 (diff) | |
feat: open the saved recording's folder when its notification is clicked
The "Recording saved to <path>" desktop notification is now clickable:
activating it opens the default file manager at the file's containing folder
(and highlights the file where the file manager supports it).
- Add an app.open-folder action (string target = file path) that uses
GtkFileLauncher.open_containing_folder() — portal-backed, so it works on
both X11 and Wayland.
- The saved-recording GNotification sets that action as its default action,
and the in-app AdwToast gains a matching "Open Folder" button.
send_notification() gains a send_notification_full() variant carrying the
optional path; all other notifications are unchanged.
Diffstat (limited to 'src/gsr-window.c')
| -rw-r--r-- | src/gsr-window.c | 31 |
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)) { |
