[gnome-sound-recorder] multiple files: correct GStreamer code
- From: Meg Ford (Margaret) <megford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] multiple files: correct GStreamer code
- Date: Thu, 13 Feb 2014 04:49:12 +0000 (UTC)
commit d58a3ef4c33f561b8273dbf204068eaf9334d9fd
Author: Meg Ford <meg387 gmail com>
Date: Wed Feb 12 22:43:31 2014 -0600
multiple files: correct GStreamer code
src/application.js | 11 ++++++++++-
src/listview.js | 8 +++++++-
src/mainWindow.js | 3 ++-
src/play.js | 27 ++++++---------------------
src/record.js | 8 ++++++--
src/waveform.js | 10 ++--------
6 files changed, 33 insertions(+), 34 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 0511416..01df459 100644
--- a/src/application.js
+++ b/src/application.js
@@ -24,9 +24,12 @@ const GLib = imports.gi.GLib;
const MainWindow = imports.mainWindow;
const Preferences = imports.preferences;
+const SIGINT = 2;
+const SIGTERM = 15;
let application = null;
+
const Application = new Lang.Class({
Name: 'Application',
Extends: Gtk.Application,
@@ -92,7 +95,13 @@ const Application = new Lang.Class({
onWindowDestroy: function() {
if (MainWindow.wave != null)
- MainWindow.wave.pipeline.set_state(Gst.State.NULL);
+ MainWindow.wave.pipeline.set_state(Gst.State.NULL);
+
+ if (MainWindow._record.pipeline.getState(Gst.Second) != null)
+ MainWindow._record.pipeline.set_state(Gst.State.NULL);
+
+ if (MainWindow.play.play.getState(Gst.Second) != null)
+ MainWindow.play.play.set_state(Gst.State.NULL);
},
_showPreferences: function() {
diff --git a/src/listview.js b/src/listview.js
index cbda87d..61941a8 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -241,7 +241,13 @@ const Listview = new Lang.Class({
this._getCapsForList(info);
} else {
// don't index files we can't play
- log("File cannot be played");
+ log("File cannot be played");
+ let name = allFilesInfo[this.idx].fileName;
+ let application = Gio.Application.get_default();
+ let deleteFile = application.saveDir.get_child_for_display_name(name);
+ deleteFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
+ allFilesInfo.splice(this.idx, 1);
+ this.idx -= this.idx++;
}
if (this.idx == this.endIdx) {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 26de132..978d6b7 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -194,7 +194,8 @@ const MainView = new Lang.Class({
this._record.stopRecording();
this.recordGrid.hide();
recordPipeline = RecordPipelineStates.STOPPED;
- recordButton.set_sensitive(true);
+ recordButton.set_sensitive(true);
+ this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
},
_formatTime: function(unformattedTime) {
diff --git a/src/play.js b/src/play.js
index 490032b..b63447d 100644
--- a/src/play.js
+++ b/src/play.js
@@ -27,6 +27,7 @@ const GstPbutils = imports.gi.GstPbutils;
const Mainloop = imports.mainloop;
+const Application = imports.application;
const MainWindow = imports.mainWindow;
const Waveform = imports.waveform;
@@ -81,7 +82,9 @@ const _TENTH_SEC = 100000000;
this.onEndOfStream();
} else if (this.ret == Gst.StateChangeReturn.SUCCESS) {
MainWindow.view.setVolume();
- }
+ }
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGINT,
Application.application.onWindowDestroy, this.play);
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGTERM,
Application.application.onWindowDestroy, this.play);
},
pausePlaying: function() {
@@ -122,24 +125,6 @@ const _TENTH_SEC = 100000000;
this.localMsg = message;
let msg = message.type;
switch(msg) {
-
- case Gst.MessageType.ELEMENT:
- if (GstPbutils.is_missing_plugin_message(this.localMsg)) {
- let errorOne = null;
- let errorTwo = null;
- let detail = GstPbutils.missing_plugin_message_get_installer_detail(this.localMsg);
-
- if (detail != null)
- errorOne = detail;
-
- let description = GstPbutils.missing_plugin_message_get_description(this.localMsg);
-
- if (description != null)
- errorTwo = description;
-
- this._showErrorDialog(errorOne, errorTwo);
- }
- break;
case Gst.MessageType.EOS:
this.onEndOfStream();
@@ -240,10 +225,10 @@ const _TENTH_SEC = 100000000;
let errorDialog = new Gtk.MessageDialog ({ modal: true,
destroy_with_parent: true,
buttons: Gtk.ButtonsType.OK,
- message_type: Gtk.MessageType.ERROR });
+ message_type: Gtk.MessageType.WARNING });
if (errorStrOne != null) {
- let strOne = errorDialog.set_property('text', errorStrOne);
+ errorDialog.set_property('text', errorStrOne);
}
if (errorStrTwo != null)
diff --git a/src/record.js b/src/record.js
index d65fed4..1d93b77 100644
--- a/src/record.js
+++ b/src/record.js
@@ -31,6 +31,7 @@ const Pango = imports.gi.Pango;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
+const Application = imports.application;
const AudioProfile = imports.audioProfile;
const MainWindow = imports.mainWindow;
@@ -118,6 +119,9 @@ const Record = new Lang.Class({
this._showErrorDialog(_('Not all of the elements were linked'));
this.onEndOfStream();
}
+
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGINT,
Application.application.onWindowDestroy, this.pipeline);
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGTERM,
Application.application.onWindowDestroy, this.pipeline);
},
_updateTime: function() {
@@ -248,9 +252,9 @@ const Record = new Lang.Class({
let errorDialog = new Gtk.MessageDialog ({ modal: true,
destroy_with_parent: true,
buttons: Gtk.ButtonsType.OK,
- message_type: Gtk.MessageType.ERROR });
+ message_type: Gtk.MessageType.WARNING });
if (errorStrOne != null) {
- let strOne = errorDialog.set_property('text', errorStrOne);
+ errorDialog.set_property('text', errorStrOne);
}
if (errorStrTwo != null)
diff --git a/src/waveform.js b/src/waveform.js
index b4a0237..44b5f14 100644
--- a/src/waveform.js
+++ b/src/waveform.js
@@ -38,8 +38,6 @@ const INTERVAL = 100000000;
const peaks = [];
const pauseVal = 10;
const waveSamples = 40;
-const SIGINT = 2;
-const SIGTERM = 15;
const WaveType = {
RECORD: 0,
@@ -97,8 +95,8 @@ const WaveForm = new Lang.Class({
let decode = this.pipeline.get_by_name("decode");
let bus = this.pipeline.get_bus();
bus.add_signal_watch();
- GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, SIGINT, Application.application.onWindowDestroy,
this.pipeline);
- GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, SIGTERM, Application.application.onWindowDestroy,
this.pipeline);
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGINT,
Application.application.onWindowDestroy, this.pipeline);
+ GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGTERM,
Application.application.onWindowDestroy, this.pipeline);
this.nSamples = Math.ceil(this.duration / INTERVAL);
@@ -263,9 +261,5 @@ const WaveForm = new Lang.Class({
this.count = 0;
peaks.length = 0;
this.drawing.destroy();
- },
-
- print: function() {
- log("HELL");
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]