[gnome-sound-recorder/wip/jtojnar/es6: 7/9] Use arrow functions instead of Lang.bind



commit 6eadf51cf8d9097a39b97e4b96abf5c6ab4937f0
Author: Jan Tojnar <jtojnar gmail com>
Date:   Thu Jan 17 23:37:40 2019 +0100

    Use arrow functions instead of Lang.bind

 src/application.js |  32 +++--
 src/info.js        |   5 +-
 src/listview.js    | 140 +++++++++++----------
 src/mainWindow.js  | 349 +++++++++++++++++++++++++----------------------------
 src/play.js        |  25 ++--
 src/preferences.js |  14 +--
 src/record.js      |  56 ++++-----
 src/waveform.js    |  14 +--
 8 files changed, 299 insertions(+), 336 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index dca02cd..723eae8 100644
--- a/src/application.js
+++ b/src/application.js
@@ -45,26 +45,23 @@ var Application = new Lang.Class({
 
     _initAppMenu: function() {
         let preferences = new Gio.SimpleAction({ name: 'preferences' });
-        preferences.connect('activate', Lang.bind(this,
-            function() {
-                this._showPreferences();
-            }));
+        preferences.connect('activate', () => {
+            this._showPreferences();
+        });
         this.add_action(preferences);
 
         let aboutAction = new Gio.SimpleAction({ name: 'about' });
-        aboutAction.connect('activate', Lang.bind(this,
-            function() {
-                this._showAbout();
-            }));
+        aboutAction.connect('activate', () => {
+            this._showAbout();
+        });
         this.add_action(aboutAction);
 
         let quitAction = new Gio.SimpleAction({ name: 'quit' });
-        quitAction.connect('activate', Lang.bind(this,
-            function() {
-                this.quit();
-            }));
-         this.add_action(quitAction);
-         this.add_accelerator('<Primary>q', 'app.quit', null);
+        quitAction.connect('activate', () => {
+            this.quit();
+        });
+        this.add_action(quitAction);
+        this.add_accelerator('<Primary>q', 'app.quit', null);
     },
 
     vfunc_startup: function() {
@@ -105,10 +102,9 @@ var Application = new Lang.Class({
     _showPreferences: function() {
         let preferencesDialog = new Preferences.Preferences();
 
-        preferencesDialog.widget.connect('response', Lang.bind(this,
-            function(widget, response) {
-                preferencesDialog.widget.destroy();
-            }));
+        preferencesDialog.widget.connect('response', (widget, response) => {
+            preferencesDialog.widget.destroy();
+        });
     },
 
     getPreferences: function() {
diff --git a/src/info.js b/src/info.js
index 5c52219..70f7374 100644
--- a/src/info.js
+++ b/src/info.js
@@ -46,13 +46,14 @@ var InfoDialog = new Lang.Class({
         header.set_show_close_button(false);
         this.widget.set_titlebar(header);
 
+
         let cancelButton = new Gtk.Button({ label: _("Cancel") });
-        cancelButton.connect("clicked", Lang.bind(this, this.onCancelClicked));
+        cancelButton.connect("clicked", () => this.onCancelClicked());
 
         header.pack_start(cancelButton);
 
         let doneButton = new Gtk.Button({ label: _("Done") });
-        doneButton.connect("clicked", Lang.bind(this, this.onDoneClicked));
+        doneButton.connect("clicked", () => this.onDoneClicked());
 
         header.pack_end(doneButton);
 
diff --git a/src/listview.js b/src/listview.js
index f86b7a3..875e323 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -83,8 +83,8 @@ var Listview = new Lang.Class({
         this._saveDir.enumerate_children_async('standard::display-name,time::created,time::modified',
                                      Gio.FileQueryInfoFlags.NONE,
                                      GLib.PRIORITY_LOW,
-                                     null, Lang.bind(this,
-                                     this._onEnumerator));
+                                     null,
+                                     (obj, res) => this._onEnumerator(obj, res));
     },
 
     _onEnumerator: function(obj, res) {
@@ -99,73 +99,70 @@ var Listview = new Lang.Class({
     _onNextFileComplete: function () {
         fileInfo = [];
         try{
-            this._enumerator.next_files_async(20, GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
-                function(obj, res) {
-                    let 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");
-                                try {
-                                    let returnedNumber = parseInt(returnedName.split(" ")[1]);
-                                    if (returnedNumber > trackNumber)
-                                        trackNumber = returnedNumber;
-
-                                }  catch (e) {
-                                    if (!e instanceof TypeError)
-                                        throw e;
-
-                                    log("Tracknumber not returned");
-                                    // Don't handle the error
-                                }
-                                let 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;
-                                if (this.dateCreatedYes) {
-                                    let dateCreatedVal = file.get_attribute_uint64("time::created");
-                                    let dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
-                                    dateCreatedString = MainWindow.displayTime.getDisplayTime(dateCreated);
-                                }
-
-                                fileInfo =
-                                    fileInfo.concat({ appName: null,
-                                                      dateCreated: dateCreatedString,
-                                                      dateForSort: dateModifiedSortString,
-                                                      dateModified: dateModifiedDisplayString,
-                                                      duration: null,
-                                                      fileName: returnedName,
-                                                      mediaType: null,
-                                                      title: null,
-                                                      uri: fileUri });
-                            }));
-                        this._sortItems(fileInfo);
-                    } else {
-                        stopVal = EnumeratorState.CLOSED;
-                        this._enumerator.close(null);
-
-                        if (MainWindow.offsetController.getEndIdx() == -1) {
-                             if (listType == ListType.NEW) {
-                                MainWindow.view.listBoxAdd();
-                                MainWindow.view.scrolledWinAdd();
-                            } else if (listType == ListType.REFRESH) {
-                                MainWindow.view.scrolledWinDelete();
-                            }
-                            currentlyEnumerating = CurrentlyEnumerating.FALSE;
-                        } else {
+            this._enumerator.next_files_async(20, GLib.PRIORITY_DEFAULT, null, (obj, res) => {
+                let files = obj.next_files_finish(res);
+
+                if (files.length) {
+                    files.forEach((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)
+                                throw e;
+
+                            log("Tracknumber not returned");
+                            // Don't handle the error
+                        }
+                        let 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;
+                        if (this.dateCreatedYes) {
+                            let dateCreatedVal = file.get_attribute_uint64("time::created");
+                            let dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
+                            dateCreatedString = MainWindow.displayTime.getDisplayTime(dateCreated);
+                        }
 
-                        this._setDiscover();
+                        fileInfo =
+                            fileInfo.concat({ appName: null,
+                                              dateCreated: dateCreatedString,
+                                              dateForSort: dateModifiedSortString,
+                                              dateModified: dateModifiedDisplayString,
+                                              duration: null,
+                                              fileName: returnedName,
+                                              mediaType: null,
+                                              title: null,
+                                              uri: fileUri });
+                    });
+                    this._sortItems(fileInfo);
+                } else {
+                    stopVal = EnumeratorState.CLOSED;
+                    this._enumerator.close(null);
+
+                    if (MainWindow.offsetController.getEndIdx() == -1) {
+                         if (listType == ListType.NEW) {
+                            MainWindow.view.listBoxAdd();
+                            MainWindow.view.scrolledWinAdd();
+                        } else if (listType == ListType.REFRESH) {
+                            MainWindow.view.scrolledWinDelete();
                         }
-                        return;
-                   }
-                }));
+                        currentlyEnumerating = CurrentlyEnumerating.FALSE;
+                    } else {
+                        this._setDiscover();
+                    }
+                    return;
+               }
+            });
         } catch(e) {
             log(e);
         }
@@ -201,11 +198,10 @@ var Listview = new Lang.Class({
      },
 
      _runDiscover: function() {
-          this._discoverer.connect('discovered', Lang.bind(this,
-            function(_discoverer, info, error) {
-                let result = info.get_result();
-                this._onDiscovererFinished(result, info, error);
-             }));
+        this._discoverer.connect('discovered', (_discoverer, info, error) => {
+            let result = info.get_result();
+            this._onDiscovererFinished(result, info, error);
+        });
     },
 
     _onDiscovererFinished: function(res, info, err) {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index b3386f7..0000748 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -197,31 +197,28 @@ const MainView = new Lang.Class({
             play.stopPlaying();
             let listRow = this.listBox.get_selected_row();
             let rowGrid = listRow.get_child();
-            rowGrid.foreach(Lang.bind(this,
-                function(child) {
-
-                    if (child.name == "PauseButton") {
-                        child.hide();
-                        child.sensitive = false;
-                    }
-                    else if (child.name == "PlayLabelBox") {
-                        child.show();
-                        child.foreach(Lang.bind(this,
-                            function(grandchild) {
-
-                                if (grandchild.name == "PlayTimeLabel") {
-                                    grandchild.hide();
-                                }
-
-                                if (grandchild.name == "DividerLabel" )
-                                    grandchild.hide();
-                             }));
-                    }
-                    else {
-                        child.show();
-                        child.sensitive = true;
-                    }
-                }));
+            rowGrid.foreach((child) => {
+                if (child.name == "PauseButton") {
+                    child.hide();
+                    child.sensitive = false;
+                }
+                else if (child.name == "PlayLabelBox") {
+                    child.show();
+                    child.foreach((grandchild) => {
+                        if (grandchild.name == "PlayTimeLabel") {
+                            grandchild.hide();
+                        }
+
+                        if (grandchild.name == "DividerLabel") {
+                            grandchild.hide();
+                        }
+                    });
+                }
+                else {
+                    child.show();
+                    child.sensitive = true;
+                }
+            });
         }
     },
 
@@ -339,7 +336,7 @@ const MainView = new Lang.Class({
                                           margin_start: 6,
                                           margin_top: 6 });
         stopRecord.get_style_context().add_class('text-button');
-        stopRecord.connect("clicked", Lang.bind(this, this.onRecordStopClicked));
+        stopRecord.connect("clicked", () => this.onRecordStopClicked());
         this.toolbarStart.pack_start(stopRecord, true, true, 0);
         this.recordGrid.attach(this.toolbarStart, 5, 1, 2, 2);
     },
@@ -349,8 +346,7 @@ const MainView = new Lang.Class({
         this._scrolledWin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
         this.scrollbar = this._scrolledWin.get_vadjustment();
 
-        this.scrollbar.connect("value_changed", Lang.bind(this,
-            function() {
+        this.scrollbar.connect("value_changed", () => {
                 this.currentBound = this.scrollbar.get_value();
                 UpperBoundVal = this.scrollbar.upper - this.scrollbar.page_size;
                 if (UpperBoundVal == this.currentBound && loadMoreButton == null) {
@@ -359,7 +355,7 @@ const MainView = new Lang.Class({
                     loadMoreButton.destroy();
                     loadMoreButton = null;
                 }
-            }));
+            });
 
         this.groupGrid.add(this._scrolledWin);
         this._scrolledWin.show();
@@ -388,10 +384,9 @@ const MainView = new Lang.Class({
             this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
             this.listBox.set_header_func(null);
             this.listBox.set_activate_on_single_click(true);
-            this.listBox.connect("row-selected", Lang.bind(this,
-                function(){
-                    this.rowGridCallback()
-                }));
+            this.listBox.connect("row-selected", () => {
+                this.rowGridCallback()
+            });
             this.listBox.show();
 
             this._files = [];
@@ -417,16 +412,15 @@ const MainView = new Lang.Class({
                 this._playListButton.set_tooltip_text(_("Play"));
                 this.rowGrid.attach(this._playListButton, 0, 0, 2, 2);
                 this._playListButton.show();
-                this._playListButton.connect('clicked', Lang.bind(this,
-                    function(button){
-                        let row = button.get_parent().get_parent();
-                        this.listBox.select_row(row);
-                        play.passSelected(row);
-                        let gridForName = row.get_child();
-                        let idx = parseInt(gridForName.name);
-                        let file = this._files[idx];
-                        this.onPlayPauseToggled(row, file);
-                    }));
+                this._playListButton.connect('clicked', (button) => {
+                    let row = button.get_parent().get_parent();
+                    this.listBox.select_row(row);
+                    play.passSelected(row);
+                    let gridForName = row.get_child();
+                    let idx = parseInt(gridForName.name);
+                    let file = this._files[idx];
+                    this.onPlayPauseToggled(row, file);
+                });
 
                 // pause button
                 this.pauseImage = Gtk.Image.new();
@@ -438,12 +432,11 @@ const MainView = new Lang.Class({
                 this._pauseListButton.set_tooltip_text(_("Pause"));
                 this.rowGrid.attach(this._pauseListButton, 0, 0, 2, 2);
                 this._pauseListButton.hide();
-                this._pauseListButton.connect('clicked', Lang.bind(this,
-                    function(button){
-                        let row = button.get_parent().get_parent();
-                        this.listBox.select_row(row);
-                        this.onPause(row);
-                    }));
+                this._pauseListButton.connect('clicked', (button) => {
+                    let row = button.get_parent().get_parent();
+                    this.listBox.select_row(row);
+                    this.onPause(row);
+                });
 
                 this._fileName = new Gtk.Label({ name: "FileNameLabel",
                                                  ellipsize: Pango.EllipsizeMode.END,
@@ -519,15 +512,14 @@ const MainView = new Lang.Class({
                                               vexpand: true,
                                               margin_end: 2 });
                 this._info.image = Gtk.Image.new_from_icon_name("dialog-information-symbolic", 
Gtk.IconSize.BUTTON);
-                this._info.connect("clicked", Lang.bind(this,
-                    function(button) {
-                        let row = button.get_parent().get_parent();
-                        this.listBox.select_row(row);
-                        let gridForName = row.get_child();
-                        let idx = parseInt(gridForName.name);
-                        let file = this._files[idx];
-                        this._onInfoButton(file);
-                    }));
+                this._info.connect("clicked", (button) => {
+                    let row = button.get_parent().get_parent();
+                    this.listBox.select_row(row);
+                    let gridForName = row.get_child();
+                    let idx = parseInt(gridForName.name);
+                    let file = this._files[idx];
+                    this._onInfoButton(file);
+                });
                 this._info.set_tooltip_text(_("Info"));
                 this.rowGrid.attach(this._info, 27, 0, 1, 2);
                 this._info.hide();
@@ -537,12 +529,11 @@ const MainView = new Lang.Class({
                                                 hexpand: false,
                                                 margin_start: 2, });
                 this._delete.image = Gtk.Image.new_from_icon_name("user-trash-symbolic", 
Gtk.IconSize.BUTTON);
-                this._delete.connect("clicked", Lang.bind(this,
-                    function(button) {
-                        let row = button.get_parent().get_parent();
-                        this.listBox.select_row(row);
-                        this._deleteFile(row);
-                    }));
+                this._delete.connect("clicked", (button) => {
+                    let row = button.get_parent().get_parent();
+                    this.listBox.select_row(row);
+                    this._deleteFile(row);
+                });
                 this._delete.set_tooltip_text(_("Delete"));
                 this.rowGrid.attach(this._delete, 28, 0, 1, 2);
                 this._delete.hide();
@@ -553,7 +544,7 @@ const MainView = new Lang.Class({
 
     addLoadMoreButton: function() {
        loadMoreButton = new LoadMoreButton();
-       loadMoreButton.connect('clicked', Lang.bind(this, loadMoreButton.onLoadMore));
+       loadMoreButton.connect('clicked', () => loadMoreButton.onLoadMore());
        this.groupGrid.add(loadMoreButton);
        loadMoreButton.show();
     },
@@ -592,44 +583,42 @@ const MainView = new Lang.Class({
     },
 
     hasPreviousSelRow: function() {
-       this.destroyLoadMoreButton();
-           if (previousSelRow != null) {
-              let rowGrid = previousSelRow.get_child();
-              rowGrid.foreach(Lang.bind(this,
-                function(child) {
-                    let alwaysShow = child.get_no_show_all();
-
-                    if (!alwaysShow)
-                        child.hide();
-
-                    if (child.name == "PauseButton") {
-                        child.hide();
-                        child.sensitive = false;
-                    }
-                    if (child.name == "PlayButton") {
-                        child.show();
-                        child.sensitive = true;
-                    }
-
-                    if (child.name == "PlayLabelBox") {
-                        child.show();
-                        child.foreach(Lang.bind(this,
-                            function(grandchild) {
-
-                                if (grandchild.name == "PlayTimeLabel") {
-                                    grandchild.hide();
-                                }
-
-                                if (grandchild.name == "DividerLabel" )
-                                    grandchild.hide();
-                             }));
-                    }
-                }));
-
-                if (play.getPipeStates() == PipelineStates.PLAYING || play.getPipeStates()== 
PipelineStates.PAUSED) {
-                    play.stopPlaying();
+        this.destroyLoadMoreButton();
+        if (previousSelRow != null) {
+            let rowGrid = previousSelRow.get_child();
+            rowGrid.foreach((child) => {
+                let alwaysShow = child.get_no_show_all();
+
+                if (!alwaysShow)
+                    child.hide();
+
+                if (child.name == "PauseButton") {
+                    child.hide();
+                    child.sensitive = false;
+                }
+                if (child.name == "PlayButton") {
+                    child.show();
+                    child.sensitive = true;
+                }
+
+                if (child.name == "PlayLabelBox") {
+                    child.show();
+                    child.foreach((grandchild) => {
+                        if (grandchild.name == "PlayTimeLabel") {
+                            grandchild.hide();
+                        }
+
+                        if (grandchild.name == "DividerLabel") {
+                            grandchild.hide();
+                        }
+                    });
                 }
+            });
+
+            if (play.getPipeStates() == PipelineStates.PLAYING || play.getPipeStates()== 
PipelineStates.PAUSED) {
+                play.stopPlaying();
             }
+        }
         previousSelRow = null;
     },
 
@@ -638,7 +627,6 @@ const MainView = new Lang.Class({
         this.destroyLoadMoreButton();
 
         if (selectedRow) {
-
             if (previousSelRow != null) {
                 this.hasPreviousSelRow();
             }
@@ -646,36 +634,34 @@ const MainView = new Lang.Class({
             previousSelRow = selectedRow;
             let selectedRowGrid = previousSelRow.get_child();
             selectedRowGrid.show_all();
-            selectedRowGrid.foreach(Lang.bind(this,
-                function(child) {
-                    let alwaysShow = child.get_no_show_all();
+            selectedRowGrid.foreach((child) => {
+                let alwaysShow = child.get_no_show_all();
 
-                    if (!alwaysShow)
-                        child.sensitive = true;
+                if (!alwaysShow)
+                    child.sensitive = true;
 
-                    if (child.name == "PauseButton") {
-                        child.hide();
-                        child.sensitive = false;
-                    }
+                if (child.name == "PauseButton") {
+                    child.hide();
+                    child.sensitive = false;
+                }
 
-                    if (child.name == "WaveFormGrid")
-                        child.sensitive = true;
-                }));
+                if (child.name == "WaveFormGrid")
+                    child.sensitive = true;
+            });
         }
     },
 
     _getFileFromRow: function(selected) {
+
         let fileForAction = null;
         let rowGrid = selected.get_child();
-        rowGrid.foreach(Lang.bind(this,
-            function(child) {
-
-                if (child.name == "FileNameLabel") {
-                    let name = child.get_text();
-                    let application = Gio.Application.get_default();
-                    fileForAction = application.saveDir.get_child_for_display_name(name);
-                }
-             }));
+        rowGrid.foreach((child) => {
+            if (child.name == "FileNameLabel") {
+                let name = child.get_text();
+                let application = Gio.Application.get_default();
+                fileForAction = application.saveDir.get_child_for_display_name(name);
+            }
+        });
 
         return fileForAction;
     },
@@ -694,10 +680,9 @@ const MainView = new Lang.Class({
     _onInfoButton: function(selected) {
         let infoDialog = new Info.InfoDialog(selected);
 
-        infoDialog.widget.connect('response', Lang.bind(this,
-            function(widget, response) {
-                infoDialog.widget.destroy();
-            }));
+        infoDialog.widget.connect('response', (widget, response) => {
+            infoDialog.widget.destroy();
+        });
     },
 
     setLabel: function(time) {
@@ -714,17 +699,16 @@ const MainView = new Lang.Class({
     },
 
     setNameLabel: function(newName, oldName, index) {
+
         let selected = this.listBox.get_row_at_index(index);
         let rowGrid = selected.get_child();
-        rowGrid.foreach(Lang.bind(this,
-            function(child) {
-
-                if (child.name == "FileNameLabel") {
-                    let name = child.get_text();
-                    let markup = ('<b>'+ newName + '</b>');
-                    child.label = markup;
-                }
-             }));
+        rowGrid.foreach((child) => {
+            if (child.name == "FileNameLabel") {
+                let name = child.get_text();
+                let markup = ('<b>'+ newName + '</b>');
+                child.label = markup;
+            }
+        });
         rowGrid.set_name(newName);
     },
 
@@ -733,20 +717,19 @@ const MainView = new Lang.Class({
 
         if (activeState == PipelineStates.PLAYING) {
             play.pausePlaying();
+
             let rowGrid = listRow.get_child();
-            rowGrid.foreach(Lang.bind(this,
-                function(child) {
-
-                    if (child.name == "PauseButton") {
-                        child.hide();
-                        child.sensitive = false;
-                    }
-
-                    if (child.name == "PlayButton" ) {
-                        child.show();
-                        child.sensitive = true;
-                    }
-                }));
+            rowGrid.foreach((child) => {
+                if (child.name == "PauseButton") {
+                    child.hide();
+                    child.sensitive = false;
+                }
+
+                if (child.name == "PlayButton") {
+                    child.show();
+                    child.sensitive = true;
+                }
+            });
         }
     },
 
@@ -757,39 +740,37 @@ const MainView = new Lang.Class({
         if (activeState != PipelineStates.PLAYING) {
             play.startPlaying();
 
+
             let rowGrid = listRow.get_child();
-            rowGrid.foreach(Lang.bind(this,
-                function(child) {
-
-                    if (child.name == "InfoButton" || child.name == "DeleteButton" ||
-                        child.name == "PlayButton" ) {
-                        child.hide();
-                        child.sensitive = false;
-                    }
-
-                    if (child.name == "PauseButton") {
-                        child.show();
-                        child.sensitive = true;
-                    }
-
-                    if (child.name == "PlayLabelBox") {
-                        child.foreach(Lang.bind(this,
-                            function(grandchild) {
-
-                                if (grandchild.name == "PlayTimeLabel") {
-                                    view.playTimeLabel = grandchild;
-                                }
-
-                                if (grandchild.name == "DividerLabel" )
-                                    grandchild.show();
-                             }));
-                    }
-
-                    if (child.name == "WaveFormGrid") {
-                        this.wFGrid = child;
-                        child.sensitive = true;
-                    }
-                }));
+            rowGrid.foreach((child) => {
+                if (child.name == "InfoButton" || child.name == "DeleteButton" ||
+                    child.name == "PlayButton") {
+                    child.hide();
+                    child.sensitive = false;
+                }
+
+                if (child.name == "PauseButton") {
+                    child.show();
+                    child.sensitive = true;
+                }
+
+                if (child.name == "PlayLabelBox") {
+                    child.foreach((grandchild) => {
+                        if (grandchild.name == "PlayTimeLabel") {
+                            view.playTimeLabel = grandchild;
+                        }
+
+                        if (grandchild.name == "DividerLabel") {
+                            grandchild.show();
+                        }
+                    });
+                }
+
+                if (child.name == "WaveFormGrid") {
+                    this.wFGrid = child;
+                    child.sensitive = true;
+                }
+            });
 
             if (activeState != PipelineStates.PAUSED) {
                 wave = new Waveform.WaveForm(this.wFGrid, selFile);
@@ -809,7 +790,7 @@ const RecordButton = new Lang.Class({
         this.set_valign(Gtk.Align.CENTER);
         this.set_label(_("Record"));
         this.get_style_context().add_class('text-button');
-        this.connect("clicked", Lang.bind(this, this._onRecord));
+        this.connect("clicked", () => this._onRecord());
     },
 
     _onRecord: function() {
@@ -850,7 +831,7 @@ var EncoderComboBox = new Lang.Class({
         this.set_sensitive(true);
         activeProfile = Application.application.getPreferences();
         this.set_active(activeProfile);
-        this.connect("changed", Lang.bind(this, this._onComboBoxTextChanged));
+        this.connect("changed", () => this._onComboBoxTextChanged());
     },
 
     _onComboBoxTextChanged: function() {
@@ -874,7 +855,7 @@ var ChannelsComboBox = new Lang.Class({
         this.set_sensitive(true);
         let chanProfile = Application.application.getChannelsPreferences();
         this.set_active(chanProfile);
-        this.connect("changed", Lang.bind(this, this._onChannelComboBoxTextChanged));
+        this.connect("changed", () => this._onChannelComboBoxTextChanged());
     },
 
     _onChannelComboBoxTextChanged: function() {
diff --git a/src/play.js b/src/play.js
index d46fff7..233a34c 100644
--- a/src/play.js
+++ b/src/play.js
@@ -61,13 +61,11 @@ var Play = new Lang.Class({
         this.clock = this.play.get_clock();
         this.playBus = this.play.get_bus();
         this.playBus.add_signal_watch();
-        this.playBus.connect("message", Lang.bind(this,
-            function(playBus, message) {
-
-                if (message != null) {
-                    this._onMessageReceived(message);
-                }
-            }));
+        this.playBus.connect("message", (playBus, message) => {
+            if (message != null) {
+                this._onMessageReceived(message);
+            }
+        });
     },
 
     startPlaying: function() {
@@ -224,8 +222,8 @@ var Play = new Lang.Class({
 
     updatePosition: function() {
         if (!this.timeout) {
-            this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 10, Lang.bind(this,
-                this._updateTime));
+            this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 10, () =>
+                this._updateTime());
         }
     },
 
@@ -251,11 +249,10 @@ var Play = new Lang.Class({
                 errorDialog.set_property('secondary-text', errorStrTwo);
 
             errorDialog.set_transient_for(Gio.Application.get_default().get_active_window());
-            errorDialog.connect ('response', Lang.bind(this,
-                function() {
-                    errorDialog.destroy();
-                    this.onEndOfStream();
-                }));
+            errorDialog.connect ('response', () => {
+                errorDialog.destroy();
+                this.onEndOfStream();
+            });
             errorDialog.show();
         }
     }
diff --git a/src/preferences.js b/src/preferences.js
index 4d6ec91..ead0ac9 100644
--- a/src/preferences.js
+++ b/src/preferences.js
@@ -87,10 +87,9 @@ var Preferences = new Lang.Class({
         this.playRange = Gtk.Adjustment.new(MainWindow.volumeValue[0].play, 0, 1.0, 0.05, 0.0, 0.0);
         playVolume.set_adjustment(this.playRange);
         playVolume.set_sensitive(true);
-        playVolume.connect("value-changed", Lang.bind(this, 
-            function() {
-                MainWindow.view.presetVolume(MainWindow.ActiveArea.PLAY, playVolume.get_value());
-            }));
+        playVolume.connect("value-changed", () => {
+            MainWindow.view.presetVolume(MainWindow.ActiveArea.PLAY, playVolume.get_value());
+        });
         grid.attach(playVolume, 2, 2, 2, 1);
         
         let micVolLabel = new Gtk.Label({ label: _("Microphone"),
@@ -102,10 +101,9 @@ var Preferences = new Lang.Class({
         this.recordRange = Gtk.Adjustment.new(MainWindow.volumeValue[0].record, 0, 1.0, 0.05, 0.0, 0.0);
         recordVolume.set_adjustment(this.recordRange);
         recordVolume.set_sensitive(true);
-        recordVolume.connect("value-changed", Lang.bind(this, 
-            function() {
-                MainWindow.view.presetVolume(MainWindow.ActiveArea.RECORD, recordVolume.get_value());
-            }));
+        recordVolume.connect("value-changed", () => {
+            MainWindow.view.presetVolume(MainWindow.ActiveArea.RECORD, recordVolume.get_value());
+        });
         grid.attach(recordVolume, 2, 3, 2, 1);
         
         this.widget.show_all();
diff --git a/src/record.js b/src/record.js
index 765c5b6..b0f3a9d 100644
--- a/src/record.js
+++ b/src/record.js
@@ -98,35 +98,32 @@ var Record = new Lang.Class({
         this.clock = this.pipeline.get_clock();
         this.recordBus = this.pipeline.get_bus();
         this.recordBus.add_signal_watch();
-        this.recordBus.connect("message", Lang.bind(this,
-            function(recordBus, message) {
-
-                if (message != null) {
-                    this._onMessageReceived(message);
-                }
-            }));
+        this.recordBus.connect("message", (recordBus, message) => {
+            if (message != null) {
+                this._onMessageReceived(message);
+            }
+        });
         this.level = Gst.ElementFactory.make("level", "level");
         this.pipeline.add(this.level);
         this.volume = Gst.ElementFactory.make("volume", "volume");
         this.pipeline.add(this.volume);
         this.ebin = Gst.ElementFactory.make("encodebin", "ebin");
-        this.ebin.connect("element-added", Lang.bind(this,
-            function(ebin, element) {
-                let factory = element.get_factory();
-
-                if (factory != null) {
-                        this.hasTagSetter = factory.has_interface("GstTagSetter");
-                        if (this.hasTagSetter == true) {
-                            this.taglist = Gst.TagList.new_empty();
-                            this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_APPLICATION_NAME, 
_("Sound Recorder"));
-                            element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
-                            this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_TITLE, 
this.initialFileName);
-                            element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
-                            this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_DATE_TIME, 
this.gstreamerDateTime);
-                            element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
-                    }
+        this.ebin.connect("element-added", (ebin, element) => {
+            let factory = element.get_factory();
+
+            if (factory != null) {
+                this.hasTagSetter = factory.has_interface("GstTagSetter");
+                if (this.hasTagSetter == true) {
+                    this.taglist = Gst.TagList.new_empty();
+                    this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_APPLICATION_NAME, _("Sound 
Recorder"));
+                    element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
+                    this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_TITLE, this.initialFileName);
+                    element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
+                    this.taglist.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_DATE_TIME, 
this.gstreamerDateTime);
+                    element.merge_tags(this.taglist, Gst.TagMergeMode.REPLACE);
                 }
-            }));
+            }
+        });
         this.pipeline.add(this.ebin);
         let ebinProfile = this.ebin.set_property("profile", this._mediaProfile);
         let srcpad = this.ebin.get_static_pad("src");
@@ -191,7 +188,7 @@ var Record = new Lang.Class({
         }
 
         if (!this.timeout) {
-            this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MainWindow._SEC_TIMEOUT, Lang.bind(this, 
this._updateTime));
+            this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MainWindow._SEC_TIMEOUT, () => 
this._updateTime());
         }
     },
 
@@ -341,12 +338,11 @@ var Record = new Lang.Class({
                 errorDialog.set_property("secondary-text", errorStrTwo);
 
             errorDialog.set_transient_for(Gio.Application.get_default().get_active_window());
-            errorDialog.connect("response", Lang.bind(this,
-                function() {
-                    errorDialog.destroy();
-                    MainWindow.view.onRecordStopClicked();
-                    this.onEndOfStream();
-                }));
+            errorDialog.connect("response", () => {
+                errorDialog.destroy();
+                MainWindow.view.onRecordStopClicked();
+                this.onEndOfStream();
+            });
             errorDialog.show();
         }
     }
diff --git a/src/waveform.js b/src/waveform.js
index 4161919..1959841 100644
--- a/src/waveform.js
+++ b/src/waveform.js
@@ -79,7 +79,7 @@ var WaveForm = new Lang.Class({
             this._grid.add(this.drawing);
         }
 
-        this.drawing.connect("draw", Lang.bind(this, this.fillSurface));
+        this.drawing.connect("draw", (drawing, cr) => this.fillSurface(drawing, cr));
         this.drawing.show_all();
         this._grid.show_all();
 
@@ -101,13 +101,11 @@ var WaveForm = new Lang.Class({
 
         this.nSamples = Math.ceil(this.duration / INTERVAL);
 
-        bus.connect("message", Lang.bind(this,
-            function(bus, message) {
-
-                if (message != null) {
-                    this._messageCb(message);
-                }
-            }));
+        bus.connect("message", (bus, message) => {
+            if (message != null) {
+                this._messageCb(message);
+            }
+        });
     },
 
     _messageCb: function(message) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]