[gnome-sound-recorder] recorder to return Recording Obj on stop
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] recorder to return Recording Obj on stop
- Date: Sat, 6 Jun 2020 07:04:36 +0000 (UTC)
commit 03bf4757e3a0515db6f3ed9a6136b6329480cff5
Author: Kavan Mevada <kavanmevada gmail com>
Date: Fri Jun 5 23:59:17 2020 +0530
recorder to return Recording Obj on stop
src/mainWindow.js | 7 +------
src/recorder.js | 42 ++++++++++++++----------------------------
2 files changed, 15 insertions(+), 34 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 3b394d8..e968bb4 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -24,7 +24,6 @@ const Handy = imports.gi.Handy;
const Utils = imports.utils;
const RecordingList = imports.recordingList.RecordingList;
-const Recording = imports.recording.Recording;
const Row = imports.row.Row;
const RowState = imports.row.RowState;
const Player = imports.player.Player;
@@ -97,11 +96,7 @@ var MainWindow = GObject.registerClass({
onRecordStop() {
this._recorder.stop();
-
- let fileUri = this._recorder.initialFileName;
- let recordedFile = Gio.file_new_for_path(fileUri);
- let recording = new Recording(recordedFile);
- this._recordingList.insert(0, recording);
+ this._recordingList.insert(0, this._recorder.recording);
this.wave.endDrawing();
this.wave = null;
diff --git a/src/recorder.js b/src/recorder.js
index c982269..8772340 100644
--- a/src/recorder.js
+++ b/src/recorder.js
@@ -22,6 +22,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gst = imports.gi.Gst;
const GstPbutils = imports.gi.GstPbutils;
+const Recording = imports.recording.Recording;
const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
@@ -99,12 +100,17 @@ var Recorder = new GObject.registerClass({
start() {
this.baseTime = 0;
- this._buildFileName = new BuildFileName();
- this.initialFileName = this._buildFileName.buildInitialFilename();
- let localDateTime = this._buildFileName.getOrigin();
- this.gstreamerDateTime = Gst.DateTime.new_from_g_date_time(localDateTime);
- if (this.initialFileName === -1)
+ const dir = Gio.Application.get_default().saveDir;
+ const dateTime = GLib.DateTime.new_now_local();
+ /* Translators: ""Recording from %F %A at %T"" is the default name assigned to a file created
+ by the application (for example, "Recording from 2020-03-11 Wednesday at 19:43:05"). */
+ const clipName = dateTime.format(_('Recording from %F %A at %T'));
+ const clip = dir.get_child_for_display_name(clipName);
+ const fileUri = clip.get_path();
+ this.file = Gio.file_new_for_path(fileUri);
+
+ if (fileUri === -1)
log('Unable to create Recordings directory.')
@@ -117,7 +123,7 @@ var Recorder = new GObject.registerClass({
this.ebin.set_property('profile', this._getProfile());
- this.filesink.set_property('location', this.initialFileName);
+ this.filesink.set_property('location', fileUri);
this.level.link(this.ebin);
this.ebin.link(this.filesink);
@@ -143,6 +149,8 @@ var Recorder = new GObject.registerClass({
this.recordBus.remove_watch();
this.recordBus = null;
}
+
+ return new Recording(this.file);
}
_onMessageReceived(message) {
@@ -241,25 +249,3 @@ var Recorder = new GObject.registerClass({
}
});
-
-const BuildFileName = class BuildFileName {
- buildInitialFilename() {
- var dir = Gio.Application.get_default().saveDir;
- this.dateTime = GLib.DateTime.new_now_local();
- /* Translators: ""Recording from %F %A at %T"" is the default name assigned to a file created
- by the application (for example, "Recording from 2020-03-11 Wednesday at 19:43:05"). */
- var clipName = this.dateTime.format(_('Recording from %F %A at %T'));
- this.clip = dir.get_child_for_display_name(clipName);
- var file = this.clip.get_path();
- return file;
- }
-
- getTitle() {
- return this.clip;
- }
-
- getOrigin() {
- return this.dateTime;
- }
-};
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]