[gnome-sound-recorder] remove preferences dialog



commit 8e5f8d73cfe30030b6392eb3b8021243f9de2135
Author: Kavan Mevada <kavanmevada gmail com>
Date:   Mon Jun 1 16:15:02 2020 +0530

    remove preferences dialog

 data/org.gnome.SoundRecorder.data.gresource.xml  |   1 -
 data/org.gnome.SoundRecorder.gschema.xml.in      |  31 +---
 data/ui/preferences.ui                           | 177 -----------------------
 data/ui/window.ui                                |  37 +++++
 po/POTFILES.in                                   |   2 -
 src/application.js                               |  40 ++++-
 src/mainWindow.js                                |  10 +-
 src/org.gnome.SoundRecorder.src.gresource.xml.in |   1 -
 src/preferences.js                               | 103 -------------
 src/record.js                                    |  37 +----
 10 files changed, 84 insertions(+), 355 deletions(-)
---
diff --git a/data/org.gnome.SoundRecorder.data.gresource.xml b/data/org.gnome.SoundRecorder.data.gresource.xml
index 4654ba1..2fe2a70 100644
--- a/data/org.gnome.SoundRecorder.data.gresource.xml
+++ b/data/org.gnome.SoundRecorder.data.gresource.xml
@@ -3,7 +3,6 @@
   <gresource prefix="/org/gnome/SoundRecorder">
     <file>application.css</file>
     <file>ui/window.ui</file>
-    <file>ui/preferences.ui</file>
     <file>ui/row.ui</file>
   </gresource>
 </gresources>
diff --git a/data/org.gnome.SoundRecorder.gschema.xml.in b/data/org.gnome.SoundRecorder.gschema.xml.in
index bc890a8..bc68bec 100644
--- a/data/org.gnome.SoundRecorder.gschema.xml.in
+++ b/data/org.gnome.SoundRecorder.gschema.xml.in
@@ -1,10 +1,10 @@
 <schemalist>
-  <enum id="@app-id@.EncodingProfile">
-    <value nick='VORBIS' value='0'/>
-    <value nick='OPUS' value='1'/>
-    <value nick='FLAC' value='2'/>
-    <value nick='MP3' value='3'/>
-    <value nick='M4A' value='4'/>
+  <enum id="@app-id@.AudioProfile">
+    <value nick='vorbis' value='0'/>
+    <value nick='opus' value='1'/>
+    <value nick='flac' value='2'/>
+    <value nick='mp3' value='3'/>
+    <value nick='m4a' value='4'/>
   </enum>
   <schema id="@app-id@" path="/org/gnome/SoundRecorder/" gettext-domain="@gettext-package@">
     <key name="window-size" type="ai">
@@ -17,26 +17,11 @@
       <summary>Window position</summary>
       <description>Window position (x and y).</description>
     </key>
-    <key name="media-type-preset" enum="@app-id@.EncodingProfile">
-      <default>'VORBIS'</default>
+    <key name="audio-profile" enum="@app-id@.AudioProfile">
+      <default>'flac'</default>
       <summary>Maps media types to audio encoder preset names.</summary>
       <description>Maps media types to audio encoder preset names. If there is no mapping set, the default 
encoder settings will be used.</description>
     </key>
-    <key name="channel" type="i">
-      <default>1</default>
-      <summary>Available channels</summary>
-      <description>Maps available channels. If there is not no mapping set, stereo channel will be used by 
default.</description>
-    </key>
-    <key name="mic-volume" type="d">
-      <default>0.75</default>
-      <summary>Microphone volume level</summary>
-      <description>Microphone volume level.</description>
-    </key>
-    <key name="speaker-volume" type="d">
-      <default>0.75</default>
-      <summary>Speaker volume level</summary>
-      <description>Speaker volume level.</description>
-    </key>
   </schema>
 </schemalist>
 
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 33a967d..eae7907 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -71,6 +71,7 @@
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
                 <property name="valign">center</property>
+                <property name="menu_model">primaryMenu</property>
                 <child>
                   <object class="GtkImage">
                     <property name="visible">True</property>
@@ -292,4 +293,40 @@
       </object>
     </child>
   </template>
+  <menu id="primaryMenu">
+    <submenu>
+      <attribute translatable="yes" name="label">Preferred Format</attribute>
+      <item>
+        <attribute translatable="yes" name="label">VORBIS</attribute>
+        <attribute name="action">app.audio-profile</attribute>
+        <attribute name="target">vorbis</attribute>
+      </item>
+      <item>
+        <attribute translatable="yes" name="label">OPUS</attribute>
+        <attribute name="action">app.audio-profile</attribute>
+        <attribute name="target">opus</attribute>
+      </item>
+      <item>
+        <attribute translatable="yes" name="label">FLAC</attribute>
+        <attribute name="action">app.audio-profile</attribute>
+        <attribute name="target">flac</attribute>
+      </item>
+      <item>
+        <attribute translatable="yes" name="label">MP3</attribute>
+        <attribute name="action">app.audio-profile</attribute>
+        <attribute name="target">mp3</attribute>
+      </item>
+      <item>
+        <attribute translatable="yes" name="label">M4A</attribute>
+        <attribute name="action">app.audio-profile</attribute>
+        <attribute name="target">m4a</attribute>
+      </item>
+    </submenu>
+    <section>
+      <item>
+        <attribute name="action">app.about</attribute>
+        <attribute name="label" translatable="yes">About Sound Recorder</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index db28586..5eadd3c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@ data/appdata/org.gnome.SoundRecorder.appdata.xml.in.in
 data/org.gnome.SoundRecorder.gschema.xml.in
 data/org.gnome.SoundRecorder.desktop.in.in
 data/ui/window.ui
-data/ui/preferences.ui
 data/ui/row.ui
 src/application.js
 src/utils.js
@@ -10,6 +9,5 @@ src/row.js
 src/main.js
 src/mainWindow.js
 src/player.js
-src/preferences.js
 src/record.js
 src/waveform.js
diff --git a/src/application.js b/src/application.js
index 3792cfe..5af3546 100644
--- a/src/application.js
+++ b/src/application.js
@@ -1,4 +1,4 @@
-/* exported SIGINT SIGTERM application Application */
+/* exported SIGINT SIGTERM application settings Application */
 /*
 * Copyright 2013 Meg Ford
 * This library is free software; you can redistribute it and/or
@@ -26,13 +26,14 @@ const Gtk = imports.gi.Gtk;
 const Gdk = imports.gi.Gdk;
 
 const MainWindow = imports.mainWindow;
-const Settings = imports.preferences;
 
 var SIGINT = 2;
 var SIGTERM = 15;
 
 var application = null;
 
+var settings = new Gio.Settings({ schema: pkg.name });
+
 var Application = GObject.registerClass(class Application extends Gtk.Application {
     _init() {
         super._init({ application_id: pkg.name });
@@ -57,11 +58,38 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
     }
 
     _initAppMenu() {
-        let preferences = new Gio.SimpleAction({ name: 'preferences' });
-        preferences.connect('activate', () => {
-            (new Settings.SettingsDialog()).show();
+        function getDefaultProfile() {
+            switch (settings.get_enum('audio-profile')) {
+            case 0:
+                return new GLib.Variant('s', 'vorbis');
+            case 1:
+                return new GLib.Variant('s', 'opus');
+            case 2:
+                return new GLib.Variant('s', 'flac');
+            case 3:
+                return new GLib.Variant('s', 'mp3');
+            case 4:
+                return new GLib.Variant('s', 'm4a');
+            }
+        }
+
+        let profileAction = new Gio.SimpleAction({
+            enabled: true,
+            name: 'audio-profile',
+            state: getDefaultProfile(),
+            parameter_type: new GLib.VariantType('s'),
+        });
+        profileAction.connect('activate', (action, parameter) => {
+            action.change_state(parameter);
         });
-        this.add_action(preferences);
+        profileAction.connect('change-state', (action, state) => {
+            settings.set_value('audio-profile', state);
+        });
+        settings.connect('changed::audio-profile', () => {
+            profileAction.state = getDefaultProfile();
+        });
+        this.add_action(profileAction);
+
 
         let aboutAction = new Gio.SimpleAction({ name: 'about' });
         aboutAction.connect('activate', () => {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 92c1950..be39ff0 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -35,7 +35,7 @@ var view = null;
 
 var MainWindow = GObject.registerClass({
     Template: 'resource:///org/gnome/SoundRecorder/ui/window.ui',
-    InternalChildren: ['recordStartButton', 'recordStopButton', 'recordTimeLabel', 'appMenuButton', 
'mainStack', 'recordGrid', 'listBox', 'emptyIcon'],
+    InternalChildren: ['recordStartButton', 'recordStopButton', 'recordTimeLabel', 'mainStack', 
'recordGrid', 'listBox', 'emptyIcon'],
 }, class MainWindow extends Handy.ApplicationWindow {
 
     _init(params) {
@@ -87,17 +87,9 @@ var MainWindow = GObject.registerClass({
 
         this._recordStartButton.connect('clicked', () => this._onRecordStart());
         this._recordStopButton.connect('clicked', () => this._onRecordStop());
-        this._addAppMenu();
         this.show();
     }
 
-    _addAppMenu() {
-        let menu = new Gio.Menu();
-        menu.append(_('Preferences'), 'app.preferences');
-        menu.append(_('About Sound Recorder'), 'app.about');
-        this._appMenuButton.set_menu_model(menu);
-    }
-
     _onRecordStart() {
         this.player.stop();
         this._mainStack.set_visible_child_name('recorderView');
diff --git a/src/org.gnome.SoundRecorder.src.gresource.xml.in 
b/src/org.gnome.SoundRecorder.src.gresource.xml.in
index 4457702..a24b417 100644
--- a/src/org.gnome.SoundRecorder.src.gresource.xml.in
+++ b/src/org.gnome.SoundRecorder.src.gresource.xml.in
@@ -9,7 +9,6 @@
     <file>main.js</file>
     <file>mainWindow.js</file>
     <file>player.js</file>
-    <file>preferences.js</file>
     <file>record.js</file>
     <file>waveform.js</file>
   </gresource>
diff --git a/src/record.js b/src/record.js
index 8ca2478..765b74a 100644
--- a/src/record.js
+++ b/src/record.js
@@ -21,12 +21,11 @@
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Gst = imports.gi.Gst;
-const GstAudio = imports.gi.GstAudio;
 const GstPbutils = imports.gi.GstPbutils;
 const Gtk = imports.gi.Gtk;
 const GObject = imports.gi.GObject;
 
-const Settings = imports.preferences;
+const Application = imports.application;
 
 var PipelineStates = {
     PLAYING: 0,
@@ -39,11 +38,6 @@ const ErrState = {
     ON: 1,
 };
 
-const Channels = {
-    MONO: 0,
-    STEREO: 1,
-};
-
 const _TENTH_SEC = 100000000;
 const _SEC_TIMEOUT = 100;
 
@@ -123,7 +117,7 @@ var Record = new GObject.registerClass({
         this.pipeline.add(this.srcElement);
         this.audioConvert = Gst.ElementFactory.make('audioconvert', 'audioConvert');
         this.pipeline.add(this.audioConvert);
-        this.caps = Gst.Caps.from_string(`audio/x-raw, channels=${this._getChannels()}`);
+        this.caps = Gst.Caps.from_string('audio/x-raw');
         this.clock = this.pipeline.get_clock();
         this.recordBus = this.pipeline.get_bus();
         this.recordBus.add_signal_watch();
@@ -172,8 +166,6 @@ var Record = new GObject.registerClass({
             this._showErrorDialog(_('Unable to set the pipeline \n to the recording state.'));
             errorDialogState = ErrState.ON;
             this._buildFileName.getTitle().delete_async(GLib.PRIORITY_DEFAULT, null, null);
-        } else {
-            this.volume.set_volume(GstAudio.StreamVolumeFormat.CUBIC, Settings.settings.micVolume);
         }
 
         this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, _SEC_TIMEOUT, () => {
@@ -286,27 +278,6 @@ var Record = new GObject.registerClass({
         }
     }
 
-    _getChannels() {
-
-        let channels = null;
-        let channelsPref = Settings.settings.channel;
-
-        switch (channelsPref) {
-        case Channels.MONO:
-            channels = 1;
-            break;
-
-        case Channels.STEREO:
-            channels = 2;
-            break;
-
-        default:
-            channels = 2;
-        }
-
-        return channels;
-    }
-
     _showErrorDialog(errorStrOne, errorStrTwo) {
         if (errorDialogState === ErrState.OFF) {
             let errorDialog = new Gtk.MessageDialog({ modal: true,
@@ -330,11 +301,11 @@ var Record = new GObject.registerClass({
     }
 
     _getProfile() {
-        let profileIndex = Settings.settings.encodingProfile;
+        let profileIndex = Application.settings.get_enum('audio-profile');
         const profile = EncodingProfiles[profileIndex];
 
         let audioCaps = Gst.Caps.from_string(profile.audioCaps);
-        audioCaps.set_value('channels', this._getChannels());
+        audioCaps.set_value('channels', 2);
 
         let encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
         let containerCaps = Gst.Caps.from_string(profile.containerCaps);


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