[gnome-sound-recorder/bilelmoussaoui/misc: 5/6] misc: prefer using props instead of calling func if possible
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder/bilelmoussaoui/misc: 5/6] misc: prefer using props instead of calling func if possible
- Date: Sun, 14 Jun 2020 13:59:36 +0000 (UTC)
commit 95c607024a79dcfa5a27b68fd3bf649f891bfe8e
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sun Jun 14 15:42:21 2020 +0200
misc: prefer using props instead of calling func if possible
src/mainWindow.js | 34 ++++++++++++++++++----------------
src/player.js | 4 ++--
src/row.js | 4 ++--
3 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d7eef92..103f53f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -17,7 +17,7 @@
* Author: Meg Ford <megford gnome org>
*
*/
-const { GObject, Gst, Handy } = imports.gi;
+const { GObject, Handy } = imports.gi;
const { Player } = imports.player;
const { Recorder } = imports.recorder;
@@ -37,23 +37,23 @@ var MainWindow = GObject.registerClass({
icon_name: pkg.name,
}, params));
- this._recorder = new Recorder();
+ this.recorder = new Recorder();
this.player = new Player();
this.waveform = new WaveForm();
this._recordGrid.add(this.waveform);
- this._recorder.connect('waveform', (_, time, peak) => {
+ this.recorder.connect('waveform', (_, time, peak) => {
this.waveform.drawAt(time, peak);
});
- this._recorder.connect('notify::duration', _recorder => {
+ this.recorder.connect('notify::duration', _recorder => {
this._recordTimeLabel.label = Utils.Time.formatTime(_recorder.duration);
});
this.connect('destroy', () => {
this.waveform.destroy();
this.player.stop();
- this._recorder.stop();
+ this.recorder.stop();
});
this._recordingList = new RecordingList();
@@ -81,37 +81,39 @@ var MainWindow = GObject.registerClass({
}
onRecorderPause() {
- this._recorder.pause();
- this._playbackStack.set_visible_child_name('recorder-start');
+ this.recorder.pause();
+ this._playbackStack.visible_child_name = 'recorder-start';
}
onRecorderResume() {
- this._recorder.resume();
- this._playbackStack.set_visible_child_name('recorder-pause');
+ this.recorder.resume();
+ this._playbackStack.visible_child_name = 'recorder-pause';
}
onRecorderStart() {
this.player.stop();
- this._mainStack.set_visible_child_name('recorderView');
- this._recorder.start();
+
this._headerRevealer.reveal_child = false;
+ this._mainStack.visible_child_name = 'recorderView';
+ this._playbackStack.visible_child_name = 'recorder-pause';
- this._playbackStack.set_visible_child_name('recorder-pause');
+ this.recorder.start();
}
onRecorderStop() {
- const recording = this._recorder.stop();
+ const recording = this.recorder.stop();
this._recordingList.insert(0, recording);
+
this._headerRevealer.reveal_child = true;
+ this._playbackStack.visible_child_name = 'recorder-start';
this.waveform.destroy();
- this._playbackStack.set_visible_child_name('recorder-start');
}
_refreshView() {
if (this._recordingList.get_n_items() === 0)
- this._mainStack.set_visible_child_name('emptyView');
+ this._mainStack.visible_child_name = 'emptyView';
else
- this._mainStack.set_visible_child_name('mainView');
+ this._mainStack.visible_child_name = 'mainView';
}
});
diff --git a/src/player.js b/src/player.js
index 59af66c..5ba697e 100644
--- a/src/player.js
+++ b/src/player.js
@@ -68,9 +68,9 @@ var Player = class Player {
let errorDialog = new Gtk.MessageDialog({ destroy_with_parent: true,
buttons: Gtk.ButtonsType.OK,
message_type: Gtk.MessageType.WARNING,
- text: errorMessage });
+ text: errorMessage,
+ transient_for: Gio.Application.get_default().get_active_window() });
- errorDialog.set_transient_for(Gio.Application.get_default().get_active_window());
errorDialog.connect('response', () => errorDialog.destroy());
errorDialog.show();
}
diff --git a/src/row.js b/src/row.js
index b176acd..d96b8bc 100644
--- a/src/row.js
+++ b/src/row.js
@@ -46,8 +46,8 @@ var Row = GObject.registerClass({
setState(rowState) {
if (rowState === RowState.PLAYING)
- this._playbackStack.set_visible_child_name('pause');
+ this._playbackStack.visible_child_name = 'pause';
else if (rowState === RowState.PAUSED)
- this._playbackStack.set_visible_child_name('play');
+ this._playbackStack.visible_child_name = 'play';
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]