From ce613f5d15ab9804e1b7710a7c4cb742a9f6d985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 2 Oct 2023 14:00:45 +0200 Subject: [PATCH] screenshot: Show a special error when screencast ran out of disk space Since we now propagate error types back to gnome-shell now, let's start with showing a special error message in case the disk ran out of space, which is probably the most typical error. Part-of: --- js/dbusServices/screencast/screencastService.js | 12 +++++++++--- js/misc/dbusErrors.js | 1 + js/ui/screenshot.js | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/js/dbusServices/screencast/screencastService.js b/js/dbusServices/screencast/screencastService.js index b87443e08..9a4479424 100644 --- a/js/dbusServices/screencast/screencastService.js +++ b/js/dbusServices/screencast/screencastService.js @@ -363,9 +363,15 @@ class Recorder extends Signals.EventEmitter { case PipelineState.PLAYING: case PipelineState.FLUSHING: { const [error] = message.parse_error(); - this._handleFatalPipelineError( - `GStreamer error while in state ${this._pipelineState}: ${error.message}`, - ScreencastErrors, ScreencastError.PIPELINE_ERROR); + + if (error.matches(Gst.ResourceError, Gst.ResourceError.NO_SPACE_LEFT)) { + this._handleFatalPipelineError('Out of disk space', + ScreencastErrors, ScreencastError.OUT_OF_DISK_SPACE); + } else { + this._handleFatalPipelineError( + `GStreamer error while in state ${this._pipelineState}: ${error.message}`, + ScreencastErrors, ScreencastError.PIPELINE_ERROR); + } break; } diff --git a/js/misc/dbusErrors.js b/js/misc/dbusErrors.js index ff84f3140..6f4f80b51 100644 --- a/js/misc/dbusErrors.js +++ b/js/misc/dbusErrors.js @@ -51,6 +51,7 @@ export const ScreencastError = { ALREADY_RECORDING: 3, RECORDER_ERROR: 4, SERVICE_CRASH: 5, + OUT_OF_DISK_SPACE: 6, }; export const ScreencastErrors = registerErrorDomain('Screencast', ScreencastError); diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 7480f89dc..fecc4584d 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -2039,7 +2039,14 @@ export const ScreenshotUI = GObject.registerClass({ // Translators: notification title. this._showNotification(_('Screencast failed to start')); break; + case ScreencastPhase.RECORDING: + if (error.matches(ScreencastErrors, ScreencastError.OUT_OF_DISK_SPACE)) { + // Translators: notification title. + this._showNotification(_('Screencast ended: Out of disk space')); + return; + } + // Translators: notification title. this._showNotification(_('Screencast ended unexpectedly')); break;