Commit b6ca7244 authored by Christopher Davis's avatar Christopher Davis

sound-recorder: Use var instead of let or const

As per #32, let/const are not appropriate for ES6 code,
and are replaced by let. While the code worked before, it's
not guaranteed to work in the future and thus has been updated.
parent d8b82f6a
......@@ -17,24 +17,24 @@
*
*/
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gst = imports.gi.Gst;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var Gst = imports.gi.Gst;
var Gtk = imports.gi.Gtk;
var Lang = imports.lang;
const MainWindow = imports.mainWindow;
const Preferences = imports.preferences;
const Util = imports.util;
var MainWindow = imports.mainWindow;
var Preferences = imports.preferences;
var Util = imports.util;
const SIGINT = 2;
const SIGTERM = 15;
var SIGINT = 2;
var SIGTERM = 15;
let application = null;
let settings = null;
var application = null;
var settings = null;
const Application = new Lang.Class({
var Application = new Lang.Class({
Name: 'Application',
Extends: Gtk.Application,
......@@ -44,21 +44,21 @@ const Application = new Lang.Class({
},
_initAppMenu: function() {
let preferences = new Gio.SimpleAction({ name: 'preferences' });
var preferences = new Gio.SimpleAction({ name: 'preferences' });
preferences.connect('activate', Lang.bind(this,
function() {
this._showPreferences();
}));
this.add_action(preferences);
let aboutAction = new Gio.SimpleAction({ name: 'about' });
var aboutAction = new Gio.SimpleAction({ name: 'about' });
aboutAction.connect('activate', Lang.bind(this,
function() {
this._showAbout();
}));
this.add_action(aboutAction);
let quitAction = new Gio.SimpleAction({ name: 'quit' });
var quitAction = new Gio.SimpleAction({ name: 'quit' });
quitAction.connect('activate', Lang.bind(this,
function() {
this.quit();
......@@ -81,7 +81,7 @@ const Application = new Lang.Class({
ensure_directory: function() {
/* Translators: "Recordings" here refers to the name of the directory where the application places files */
let path = GLib.build_filenamev([GLib.get_home_dir(), _("Recordings")]);
var path = GLib.build_filenamev([GLib.get_home_dir(), _("Recordings")]);
// Ensure Recordings directory
GLib.mkdir_with_parents(path, parseInt("0755", 8));
......@@ -103,7 +103,7 @@ const Application = new Lang.Class({
},
_showPreferences: function() {
let preferencesDialog = new Preferences.Preferences();
var preferencesDialog = new Preferences.Preferences();
preferencesDialog.widget.connect('response', Lang.bind(this,
function(widget, response) {
......@@ -112,7 +112,7 @@ const Application = new Lang.Class({
},
getPreferences: function() {
let set = settings.get_int("media-type-preset");
var set = settings.get_int("media-type-preset");
return set;
},
......@@ -121,7 +121,7 @@ const Application = new Lang.Class({
},
getChannelsPreferences: function() {
let set = settings.get_int("channel");
var set = settings.get_int("channel");
return set;
},
......@@ -130,7 +130,7 @@ const Application = new Lang.Class({
},
getMicVolume: function() {
let micVolLevel = settings.get_double("mic-volume");
var micVolLevel = settings.get_double("mic-volume");
return micVolLevel;
},
......@@ -139,7 +139,7 @@ const Application = new Lang.Class({
},
getSpeakerVolume: function() {
let speakerVolLevel = settings.get_double("speaker-volume");
var speakerVolLevel = settings.get_double("speaker-volume");
return speakerVolLevel;
},
......@@ -148,7 +148,7 @@ const Application = new Lang.Class({
},
_showAbout: function() {
let aboutDialog = new Gtk.AboutDialog();
var aboutDialog = new Gtk.AboutDialog();
aboutDialog.artists = [ 'Reda Lazri <the.red.shortcut@gmail.com>',
'Garrett LeSage <garrettl@gmail.com>',
'Hylke Bons <hylkebons@gmail.com>',
......
......@@ -17,17 +17,17 @@
*
*/
const _ = imports.gettext.gettext;
const Gio = imports.gi.Gio;
const Gst = imports.gi.Gst;
const GstPbutils = imports.gi.GstPbutils;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
var _ = imports.gettext.gettext;
var Gio = imports.gi.Gio;
var Gst = imports.gi.Gst;
var GstPbutils = imports.gi.GstPbutils;
var Lang = imports.lang;
var Mainloop = imports.mainloop;
const MainWindow = imports.mainWindow;
const Preferences = imports.preferences;
var MainWindow = imports.mainWindow;
var Preferences = imports.preferences;
const comboBoxMap = {
var comboBoxMap = {
OGG_VORBIS: 0,
OPUS: 1,
FLAC: 2,
......@@ -35,7 +35,7 @@ const comboBoxMap = {
MP4: 4
};
const containerProfileMap = {
var containerProfileMap = {
OGG: "application/ogg",
ID3: "application/x-id3",
MP4: "video/quicktime,variant=(string)iso",
......@@ -43,7 +43,7 @@ const containerProfileMap = {
};
const audioCodecMap = {
var audioCodecMap = {
FLAC: "audio/x-flac",
MP3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
MP4: "audio/mpeg,mpegversion=(int)4",
......@@ -52,7 +52,7 @@ const audioCodecMap = {
};
const AudioProfile = new Lang.Class({
var AudioProfile = new Lang.Class({
Name: 'AudioProfile',
profile: function(profileName){
......@@ -89,10 +89,10 @@ const AudioProfile = new Lang.Class({
},
mediaProfile: function(){
let audioCaps;
var audioCaps;
this._containerProfile = null;
if (this._values.audio && this._values.container) {
let caps = Gst.Caps.from_string(this._values.container);
var caps = Gst.Caps.from_string(this._values.container);
this._containerProfile = GstPbutils.EncodingContainerProfile.new("record", null, caps, null);
audioCaps = Gst.Caps.from_string(this._values.audio);
this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
......@@ -108,7 +108,7 @@ const AudioProfile = new Lang.Class({
},
fileExtensionReturner: function() {
let suffixName;
var suffixName;
if (this._values.audio) {
if (this._containerProfile != null)
......
......@@ -17,25 +17,25 @@
*
*/
const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gst = imports.gi.Gst;
const GstPbutils = imports.gi.GstPbutils;
const Lang = imports.lang;
const Signals = imports.signals;
var Gettext = imports.gettext;
var _ = imports.gettext.gettext;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var GObject = imports.gi.GObject;
var Gst = imports.gi.Gst;
var GstPbutils = imports.gi.GstPbutils;
var Lang = imports.lang;
var Signals = imports.signals;
const Listview = imports.listview;
const MainWindow = imports.mainWindow;
const Record = imports.record;
var Listview = imports.listview;
var MainWindow = imports.mainWindow;
var Record = imports.record;
const _OFFSET_STEP = 20;
let CurrentEndIdx;
let totItems;
var _OFFSET_STEP = 20;
var CurrentEndIdx;
var totItems;
const OffsetController = new Lang.Class({
var OffsetController = new Lang.Class({
Name: 'OffsetController',
_init: function(context) {
......@@ -69,18 +69,18 @@ const OffsetController = new Lang.Class({
}
});
const DisplayTime = new Lang.Class({
var DisplayTime = new Lang.Class({
Name: 'DisplayTime',
getDisplayTime: function(mtime) {
let text = "";
let DAY = 86400000000;
let now = GLib.DateTime.new_now_local();
let difference = now.difference(mtime);
let days = Math.floor(difference / DAY);
let weeks = Math.floor(difference / (7 * DAY));
let months = Math.floor(difference / (30 * DAY));
let years = Math.floor(difference / (365 * DAY));
var text = "";
var DAY = 86400000000;
var now = GLib.DateTime.new_now_local();
var difference = now.difference(mtime);
var days = Math.floor(difference / DAY);
var weeks = Math.floor(difference / (7 * DAY));
var months = Math.floor(difference / (30 * DAY));
var years = Math.floor(difference / (365 * DAY));
if (difference < DAY) {
text = mtime.format('%X');
......
......@@ -18,21 +18,21 @@
*
*/
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var Gtk = imports.gi.Gtk;
var Lang = imports.lang;
const _ = imports.gettext.gettext;
const C_ = imports.gettext.pgettext;
var _ = imports.gettext.gettext;
var C_ = imports.gettext.pgettext;
const MainWindow = imports.mainWindow;
var MainWindow = imports.mainWindow;
const InfoDialog = new Lang.Class({
var InfoDialog = new Lang.Class({
Name: 'InfoDialog',
_init: function(fileNav) {
let fileName = fileNav;
var fileName = fileNav;
this._file = Gio.File.new_for_uri(fileNav.uri);
......@@ -41,26 +41,26 @@ const InfoDialog = new Lang.Class({
destroy_with_parent: true,
default_width: 400 });
this.widget.set_transient_for(Gio.Application.get_default().get_active_window());
let header = new Gtk.HeaderBar({ title: _("Info") });
var header = new Gtk.HeaderBar({ title: _("Info") });
header.set_show_close_button(false);
this.widget.set_titlebar(header);
let cancelButton = new Gtk.Button({ label: _("Cancel") });
var cancelButton = new Gtk.Button({ label: _("Cancel") });
cancelButton.connect("clicked", Lang.bind(this, this.onCancelClicked));
header.pack_start(cancelButton);
let doneButton = new Gtk.Button({ label: _("Done") });
var doneButton = new Gtk.Button({ label: _("Done") });
doneButton.connect("clicked", Lang.bind(this, this.onDoneClicked));
header.pack_end(doneButton);
let headerBarSizeGroup = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
var headerBarSizeGroup = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
headerBarSizeGroup.add_widget(cancelButton);
headerBarSizeGroup.add_widget(doneButton);
let grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
var grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
row_homogeneous: true,
column_homogeneous: true,
halign: Gtk.Align.CENTER,
......@@ -71,7 +71,7 @@ const InfoDialog = new Lang.Class({
margin_start: 18,
margin_top: 18 });
let contentArea = this.widget.get_content_area();
var contentArea = this.widget.get_content_area();
contentArea.pack_start(grid, true, true, 2);
// File Name item
......@@ -125,8 +125,8 @@ const InfoDialog = new Lang.Class({
grid.attach_next_to(this._fileNameEntry, this._name, Gtk.PositionType.RIGHT, 2, 1);
// Source value
let sourceLink = this._file.get_parent();
let sourcePath = sourceLink.get_path();
var sourceLink = this._file.get_parent();
var sourcePath = sourceLink.get_path();
this._sourceData = new Gtk.LinkButton({ label: sourcePath,
uri: sourceLink.get_uri(),
......@@ -157,7 +157,7 @@ const InfoDialog = new Lang.Class({
},
onDoneClicked: function() {
let newFileName = this._fileNameEntry.get_text();
var newFileName = this._fileNameEntry.get_text();
this._file.set_display_name_async(newFileName, GLib.PRIORITY_DEFAULT, null, null);
this.widget.destroy();
},
......
......@@ -18,25 +18,25 @@
*
*/
const _ = imports.gettext.gettext;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gst = imports.gi.Gst;
const GstPbutils = imports.gi.GstPbutils;
const Lang = imports.lang;
const Signals = imports.signals;
const AudioProfile = imports.audioProfile;
const MainWindow = imports.mainWindow;
const Record = imports.record;
const EnumeratorState = {
var _ = imports.gettext.gettext;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var GObject = imports.gi.GObject;
var Gst = imports.gi.Gst;
var GstPbutils = imports.gi.GstPbutils;
var Lang = imports.lang;
var Signals = imports.signals;
var AudioProfile = imports.audioProfile;
var MainWindow = imports.mainWindow;
var Record = imports.record;
var EnumeratorState = {
ACTIVE: 0,
CLOSED: 1
};
const mediaTypeMap = {
var mediaTypeMap = {
FLAC: "FLAC",
OGG_VORBIS: "Ogg Vorbis",
OPUS: "Opus",
......@@ -44,25 +44,25 @@ const mediaTypeMap = {
MP4: "MP4"
};
const ListType = {
var ListType = {
NEW: 0,
REFRESH: 1
};
const CurrentlyEnumerating = {
var CurrentlyEnumerating = {
TRUE: 0,
FALSE: 1
};
let allFilesInfo = null;
let currentlyEnumerating = null;
let fileInfo = null;
let listType = null;
let startRecording = false;
let stopVal = null;
var allFilesInfo = null;
var currentlyEnumerating = null;
var fileInfo = null;
var listType = null;
var startRecording = false;
var stopVal = null;
var trackNumber = 0;
const Listview = new Lang.Class({
var Listview = new Lang.Class({
Name: "Listview",
_init: function() {
......@@ -100,14 +100,14 @@ const Listview = new Lang.Class({
try{
this._enumerator.next_files_async(20, GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
function(obj, res) {
let files = obj.next_files_finish(res);
var files = obj.next_files_finish(res);
if (files.length) {
files.forEach(Lang.bind(this,
function(file) {
let returnedName = file.get_attribute_as_string("standard::display-name");
var returnedName = file.get_attribute_as_string("standard::display-name");
try {
let returnedNumber = parseInt(returnedName.split(" ")[1]);
var returnedNumber = parseInt(returnedName.split(" ")[1]);
if (returnedNumber > trackNumber)
trackNumber = returnedNumber;
......@@ -118,19 +118,19 @@ const Listview = new Lang.Class({
log("Tracknumber not returned");
// Don't handle the error
}
let finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
var finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
returnedName]);
let fileUri = GLib.filename_to_uri(finalFileName, null);
let timeVal = file.get_modification_time();
let date = GLib.DateTime.new_from_timeval_local(timeVal);
let dateModifiedSortString = date.format("%Y%m%d%H%M%S");
let dateTime = GLib.DateTime.new_from_timeval_local(timeVal);
let dateModifiedDisplayString = MainWindow.displayTime.getDisplayTime(dateTime);
let dateCreatedYes = file.has_attribute("time::created");
let dateCreatedString = null;
var fileUri = GLib.filename_to_uri(finalFileName, null);
var timeVal = file.get_modification_time();
var date = GLib.DateTime.new_from_timeval_local(timeVal);
var dateModifiedSortString = date.format("%Y%m%d%H%M%S");
var dateTime = GLib.DateTime.new_from_timeval_local(timeVal);
var dateModifiedDisplayString = MainWindow.displayTime.getDisplayTime(dateTime);
var dateCreatedYes = file.has_attribute("time::created");
var dateCreatedString = null;
if (this.dateCreatedYes) {
let dateCreatedVal = file.get_attribute_uint64("time::created");
let dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
var dateCreatedVal = file.get_attribute_uint64("time::created");
var dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
dateCreatedString = MainWindow.displayTime.getDisplayTime(dateCreated);
}
......@@ -191,9 +191,9 @@ const Listview = new Lang.Class({
this.idx = 0;
this._discoverer = new GstPbutils.Discoverer();
this._discoverer.start();
for (let i = 0; i <= this.endIdx; i++) {
let file = allFilesInfo[i];
let uri = file.uri;
for (var i = 0; i <= this.endIdx; i++) {
var file = allFilesInfo[i];
var uri = file.uri;
this._discoverer.discover_uri_async(uri);
}
this._runDiscover();
......@@ -202,7 +202,7 @@ const Listview = new Lang.Class({
_runDiscover: function() {
this._discoverer.connect('discovered', Lang.bind(this,
function(_discoverer, info, error) {
let result = info.get_result();
var result = info.get_result();
this._onDiscovererFinished(result, info, error);
}));
},
......@@ -211,16 +211,16 @@ const Listview = new Lang.Class({
this.result = res;
if (this.result == GstPbutils.DiscovererResult.OK && allFilesInfo[this.idx]) {
this.tagInfo = info.get_tags();
let appString = "";
var appString = "";
appString = this.tagInfo.get_value_index(Gst.TAG_APPLICATION_NAME, 0);
let dateTimeTag = this.tagInfo.get_date_time('datetime')[1];
let durationInfo = info.get_duration();
var dateTimeTag = this.tagInfo.get_date_time('datetime')[1];
var durationInfo = info.get_duration();
allFilesInfo[this.idx].duration = durationInfo;
/* this.file.dateCreated will usually be null since time::created it doesn't usually exist.
Therefore, we prefer to set it with tags */
if (dateTimeTag != null) {
let dateTimeCreatedString = dateTimeTag.to_g_date_time();
var dateTimeCreatedString = dateTimeTag.to_g_date_time();
if (dateTimeCreatedString) {
allFilesInfo[this.idx].dateCreated = MainWindow.displayTime.getDisplayTime(dateTimeCreatedString);
......@@ -312,12 +312,12 @@ const Listview = new Lang.Class({
},
_getCapsForList: function(info) {
let discovererStreamInfo = null;
var discovererStreamInfo = null;
discovererStreamInfo = info.get_stream_info();
let containerStreams = info.get_container_streams()[0];
let containerCaps = discovererStreamInfo.get_caps();
let audioStreams = info.get_audio_streams()[0];
let audioCaps = audioStreams.get_caps();
var containerStreams = info.get_container_streams()[0];
var containerCaps = discovererStreamInfo.get_caps();
var audioStreams = info.get_audio_streams()[0];
var audioCaps = audioStreams.get_caps();
if (containerCaps.can_intersect(this.capTypes(AudioProfile.containerProfileMap.AUDIO_OGG))) {
......@@ -348,7 +348,7 @@ const Listview = new Lang.Class({
},
capTypes: function(capString) {
let caps = Gst.Caps.from_string(capString);
var caps = Gst.Caps.from_string(capString);
return caps;
},
......
......@@ -36,7 +36,7 @@ pkg.require({ 'Gdk': '3.0',
'GstAudio': '1.0',
'GstPbutils': '1.0' });
const Application = imports.application;
var Application = imports.application;
function main(argv) {
return (new Application.Application()).run(argv);
......
......@@ -17,77 +17,77 @@
*
*/
const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
const Gdk = imports.gi.Gdk;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gst = imports.gi.Gst;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Pango = imports.gi.Pango;
const Application = imports.application;
const AudioProfile = imports.audioProfile;
const FileUtil = imports.fileUtil;
const Info = imports.info;
const Listview = imports.listview;
const Params = imports.params;
const Play = imports.play;
const Preferences = imports.preferences;
const Record = imports.record;
const Waveform = imports.waveform;
let activeProfile = null;
let audioProfile = null;
let displayTime = null;
let grid = null;
let groupGrid;
let header;
let list = null;
let loadMoreButton = null;
let offsetController = null;
let play = null;
let previousSelRow = null;
let recordPipeline = null;
let recordButton = null;
let appMenuButton = null;
let selectable = null;
let setVisibleID = null;
let UpperBoundVal = 182;
let view = null;
let volumeValue = [];
var Gettext = imports.gettext;
var _ = imports.gettext.gettext;
var Gdk = imports.gi.Gdk;
var GdkPixbuf = imports.gi.GdkPixbuf;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var Gst = imports.gi.Gst;
var Gtk = imports.gi.Gtk;
var Lang = imports.lang;
var Pango = imports.gi.Pango;
var Application = imports.application;
var AudioProfile = imports.audioProfile;
var FileUtil = imports.fileUtil;
var Info = imports.info;
var Listview = imports.listview;
var Params = imports.params;
var Play = imports.play;
var Preferences = imports.preferences;
var Record = imports.record;
var Waveform = imports.waveform;
var activeProfile = null;
var audioProfile = null;
var displayTime = null;
var grid = null;
var groupGrid;
var header;
var list = null;
var loadMoreButton = null;
var offsetController = null;
var play = null;
var previousSelRow = null;
var recordPipeline = null;
var recordButton = null;
var appMenuButton = null;
var selectable = null;
var setVisibleID = null;
var UpperBoundVal = 182;
var view = null;
var volumeValue = [];
var wave = null;
const rtl = Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL;
var rtl = Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL;
const ActiveArea = {
var ActiveArea = {
RECORD: 0,
PLAY: 1
};
const ListColumns = {
var ListColumns = {
NAME: 0,
MENU: 1
};
const PipelineStates = {
var PipelineStates = {
PLAYING: 0,
PAUSED: 1,
STOPPED: 2
};
const RecordPipelineStates = {
var RecordPipelineStates = {
PLAYING: 0,
PAUSED: 1,
STOPPED: 2
};
const _TIME_DIVISOR = 60;
const _SEC_TIMEOUT = 100;
var _TIME_DIVISOR = 60;
var _SEC_TIMEOUT = 100;
const MainWindow = new Lang.Class({
var MainWindow = new Lang.Class({
Name: 'MainWindow',
Extends: Gtk.ApplicationWindow,
......@@ -122,7 +122,7 @@ const MainWindow = new Lang.Class({
},
_addAppMenu: function() {
let menu = new Gio.Menu();
var menu = new Gio.Menu();
menu.append(_("Preferences"), 'app.preferences');
menu.append(_("About Sound Recorder"), 'app.about');
......@@ -134,7 +134,7 @@ const MainWindow = new Lang.Class({
}
});
const MainView = new Lang.Class({
var MainView = new Lang.Class({
Name: 'MainView',
Extends: Gtk.Stack,
......@@ -157,16 +157,16 @@ const MainView = new Lang.Class({
valign: Gtk.Align.CENTER });
this._scrolledWin.add(this.emptyGrid);
let emptyPageImage = new Gtk.Image({ icon_name: 'audio-input-microphone-symbolic',
var emptyPageImage = new Gtk.Image({ icon_name: 'audio-input-microphone-symbolic',
icon_size: Gtk.IconSize.DIALOG });
emptyPageImage.get_style_context().add_class('dim-label');
this.emptyGrid.add(emptyPageImage);
let emptyPageTitle = new Gtk.Label({ label: _("Add Recordings"),
var emptyPageTitle = new Gtk.Label({ label: _("Add Recordings"),
halign: Gtk.Align.CENTER,
valign: Gtk.Align.CENTER });
emptyPageTitle.get_style_context().add_class('dim-label');
this.emptyGrid.add(emptyPageTitle);
let emptyPageDirections = new Gtk.Label({ label: _("Use the <b>Record</b> button to make sound recordings"),
var emptyPageDirections = new Gtk.Label({ label: _("Use the <b>Record</b> button to make sound recordings"),
use_markup: true,