[gnome-sound-recorder] Improve filename assignment
- From: Meg Ford (Margaret) <megford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] Improve filename assignment
- Date: Sun, 1 Feb 2015 20:39:05 +0000 (UTC)
commit cb49c83df59e8610d882815e76c6010cdcc0c1f1
Author: Meg Ford <megford gnome org>
Date: Sun Feb 1 14:24:59 2015 -0600
Improve filename assignment
Parse the names of the existing filenames, and add one if there
is a name with a > number. Else get the number from 0 + 1.
src/listview.js | 7 +++++++
src/record.js | 2 +-
2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/listview.js b/src/listview.js
index 3bce9ed..cc95abc 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -106,6 +106,13 @@ const Listview = new Lang.Class({
files.forEach(Lang.bind(this,
function(file) {
let returnedName = file.get_attribute_as_string("standard::display-name");
+ try {
+ let returnedNumber = parseInt(returnedName.split(" ")[1]);
+ if (returnedNumber > trackNumber)
+ trackNumber = returnedNumber;
+ } catch (e if e instanceof TypeError) {
+ // Don't handle the error
+ }
let finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
returnedName]);
let fileUri = GLib.filename_to_uri(finalFileName, null);
diff --git a/src/record.js b/src/record.js
index a9ef43a..697df3e 100644
--- a/src/record.js
+++ b/src/record.js
@@ -311,7 +311,7 @@ const BuildFileName = new Lang.Class({
let fileExtensionName = MainWindow.audioProfile.fileExtensionReturner();
let dir = Gio.Application.get_default().saveDir;
this.dateTime = GLib.DateTime.new_now_local();
- this.clipNumber = Listview.allFilesInfo.length + 1;
+ this.clipNumber = Listview.trackNumber + 1;
this.clipNumberString = this.clipNumber.toString();
/* Translators: ""Clip %d"" is the default name assigned to a file created
by the application (for example, "Clip 1"). */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]