[gnome-sound-recorder] Makefile.am, main.js, mainWindow.js, waveform.js: Add signals so pipeline is set to null before memo



commit bcfa16cd34367aa5919ce273345d6fd49ef1e8e3
Author: Meg Ford <meg387 gmail com>
Date:   Wed Jan 29 21:40:50 2014 -0600

    Makefile.am, main.js, mainWindow.js, waveform.js: Add signals so pipeline is set to null before memory is 
released
    
    Gstreamer was warning that memory was being freed before the pipeline elements were set to null. This 
fixes it using the method suggested by Nicolas Dufresne
    See https://bugzilla.gnome.org/show_bug.cgi?id=723209

 src/Makefile.am   |    1 +
 src/main.js       |  107 +----------------------------------------------------
 src/mainWindow.js |    2 -
 src/waveform.js   |    9 ++++
 4 files changed, 12 insertions(+), 107 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8a83b19..5caae1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ nodist_bin_SCRIPTS = gnome-sound-recorder
 jsdir = $(pkgdatadir)
 dist_js_DATA = \
     util.js    \
+    application.js \
     audioProfile.js \
     fileUtil.js \
     info.js \
diff --git a/src/main.js b/src/main.js
index ff4a338..3c75886 100644
--- a/src/main.js
+++ b/src/main.js
@@ -39,111 +39,8 @@ pkg.require({ 'Gd': '1.0',
               'System': '' });
               
 imports.gi.versions.Gst = '1.0';
-
-const Util = imports.util;
-const Gio = imports.gi.Gio;
-const Gst = imports.gi.Gst;
-const GLib = imports.gi.GLib;
-
-const MainWindow = imports.mainWindow;
-const Preferences = imports.preferences;
-
-const Application = new Lang.Class({
-    Name: 'Application',
-    Extends: Gtk.Application,
-
-    _init: function() {
-        this.parent({ application_id: "org.gnome.SoundRecorder"}); 
-        GLib.set_application_name(_("SoundRecorder"));         
-    },
-    
-    _initAppMenu: function() {
-        let menu = new Gio.Menu();
-        let section = new Gio.Menu();
-        menu.append_section(null, section);
-        section.append(_("Preferences"), 'app.preferences');
-        section = new Gio.Menu();
-        menu.append_section(null, section);
-        section.append(_("About"), 'app.about');
-        section.append(_("Quit"),'app.quit');
-        this.set_app_menu(menu);
-        
-        let 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' });
-        aboutAction.connect('activate', Lang.bind(this, 
-            function() {
-                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);
-    },
-
-    vfunc_startup: function() {
-        this.parent();
-
-        Util.loadStyleSheet();
-        log(_("Sound Recorder started"));
-        Gst.init(null, 0);
-        this._initAppMenu();
-
-        /* 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")]);
-
-        // Ensure Recordings directory
-        GLib.mkdir_with_parents(path, 0755);
-        this.saveDir = Gio.file_new_for_path(path);
-    },
-
-    vfunc_activate: function() {
-        (this.window = new MainWindow.MainWindow({ application: this })).show();
-    },
-    
-    _showPreferences: function() {
-         let preferencesDialog = new Preferences.Preferences();
-
-        preferencesDialog.widget.connect('response', Lang.bind(this,
-            function(widget, response) {
-                preferencesDialog.widget.destroy();
-            }));
-    },
-    
-    _showAbout: function() {
-        let aboutDialog = new Gtk.AboutDialog({ use_header_bar: true });
-        aboutDialog.artists = [ 'Reda Lazri <the red shortcut gmail com>',
-                                'Garrett LeSage <garrettl gmail com>',
-                                'Hylke Bons <hylkebons gmail com>' ];
-        aboutDialog.authors = [ 'Meg Ford <megford gnome org>' ];
-        /* Translators: Replace "translator-credits" with your names, one name per line */
-        aboutDialog.translator_credits = _("translator-credits");
-        aboutDialog.program_name = _("Sound Recorder");
-        aboutDialog.copyright = 'Copyright ' + String.fromCharCode(0x00A9) + ' 2013' + 
String.fromCharCode(0x2013) + 'Meg Ford';
-        aboutDialog.license_type = Gtk.License.GPL_2_0;
-        aboutDialog.logo_icon_name = 'audio-input-microphone';
-        aboutDialog.version = '3.11.4';
-        aboutDialog.website = 'http://live.gnome.org/GnomeSoundRecorder';
-        aboutDialog.wrap_license = true;
-        aboutDialog.modal = true;
-        aboutDialog.transient_for = this.window;
-
-        aboutDialog.show();
-        aboutDialog.connect('response', function() {
-            aboutDialog.destroy();
-        });
-    }
-});
+const Application = imports.application;
 
 function main(argv) {
-    return (new Application()).run(argv);
+    return (new Application.Application()).run(argv);
 }
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a16faa9..b37c702 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -25,8 +25,6 @@ const GdkPixbuf = imports.gi.GdkPixbuf;
 const Gio = imports.gi.Gio;
 const Gst = imports.gi.Gst;
 
-const Signals = imports.signals;
-
 const AudioProfile = imports.audioProfile;
 const FileUtil = imports.fileUtil;
 const Info = imports.info;
diff --git a/src/waveform.js b/src/waveform.js
index 3a394b6..b4a0237 100644
--- a/src/waveform.js
+++ b/src/waveform.js
@@ -32,11 +32,14 @@ const C_ = imports.gettext.pgettext;
 const Mainloop = imports.mainloop;
 
 const MainWindow = imports.mainWindow;
+const Application = imports.application;
 
 const INTERVAL = 100000000;
 const peaks = [];
 const pauseVal = 10;
 const waveSamples = 40;
+const SIGINT = 2;
+const SIGTERM = 15;
 
 const WaveType = {
     RECORD: 0,
@@ -94,6 +97,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);
 
         this.nSamples = Math.ceil(this.duration / INTERVAL);
 
@@ -258,5 +263,9 @@ 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]