[gnome-sound-recorder/gnome-3-12] mulitple files: fix GSchema without changing strings



commit de1dd52323f523fc979d599a78687b1779f19b3b
Author: Meg Ford <megford gnome org>
Date:   Sun May 11 18:18:50 2014 -0500

    mulitple files: fix GSchema without changing strings

 data/org.gnome.gnome-sound-recorder.gschema.xml |   16 +++--------
 src/application.js                              |   32 +++++++++++++++++++++-
 src/mainWindow.js                               |   16 ++++++++---
 3 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/data/org.gnome.gnome-sound-recorder.gschema.xml b/data/org.gnome.gnome-sound-recorder.gschema.xml
index 0893668..a84f058 100644
--- a/data/org.gnome.gnome-sound-recorder.gschema.xml
+++ b/data/org.gnome.gnome-sound-recorder.gschema.xml
@@ -1,7 +1,7 @@
 <schemalist>
   <schema id="org.gnome.gnome-sound-recorder" path="/org/gnome/gnome-sound-recorder/">
     <key name="window-size" type="ai">
-      <default>[700, 480]</default>
+      <default>[800, 480]</default>
       <summary>Window size</summary>
       <description>Window size (width and height).</description>
     </key>
@@ -10,28 +10,22 @@
       <summary>Window position</summary>
       <description>Window position (x and y).</description>
     </key>
-  </schema>
-  <schema id="org.gnome.gnome-sound-recorder.encoding-settings" 
path="/org/gnome/gnome-sound-recorder/encoding-settings/">
     <key name="media-type" type="s">
       <default>'audio/x-vorbis'</default>
       <summary>Preferred media type for encoding audio when recording</summary>
       <description>Preferred media type for encoding audio when recording. 'audio/x-vorbis' for Ogg Vorbis, 
or 'audio/mpeg' for MP3, for example. This is not a MIME type.</description>
     </key>
-    <key name="media-type-presets" type="a{ss}">
-      <default>[]</default>
+    <key name="media-type-preset" type="i">
+      <default>0</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 for a media type, 
the default encoder settings will be used.</description>
     </key>
-  </schema>
-   <schema id="org.gnome.gnome-sound-recorder.play" path="/org/gnome/gnome-sound-recorder/play/">
- <key name="volume" type="d">
+ <key name="mic-volume" type="d">
       <default>0.75</default>
       <summary>Volume level</summary>
       <description>Volume level.</description>
     </key>
-  </schema>
-   <schema id="org.gnome.gnome-sound-recorder.record" path="/org/gnome/gnome-sound-recorder/record/">
- <key name="volume" type="d">
+ <key name="speaker-volume" type="d">
       <default>0.75</default>
       <summary>Volume level</summary>
       <description>Volume level.</description>
diff --git a/src/application.js b/src/application.js
index a1a3f31..e077f10 100644
--- a/src/application.js
+++ b/src/application.js
@@ -28,7 +28,7 @@ const SIGINT = 2;
 const SIGTERM = 15;
 
 let application = null;
-
+let settings = null;
 
 const Application = new Lang.Class({
     Name: 'Application',
@@ -81,7 +81,8 @@ const Application = new Lang.Class({
         Gst.init(null, 0);
         this._initAppMenu();
         application = this;
-
+        
+        settings = new Gio.Settings({ schema: 'org.gnome.gnome-sound-recorder' });
         /* 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")]);
 
@@ -114,6 +115,33 @@ const Application = new Lang.Class({
             }));
     },
     
+    getPreferences: function() {
+        let set = settings.get_int("media-type-preset");
+        return set;
+     },
+    
+    setPreferences: function(profileName) {
+        settings.set_int("media-type-preset", profileName);
+    },
+     
+    getMicVolume: function() {
+        let micVolLevel = settings.get_double("mic-volume");
+        return micVolLevel;
+    },
+     
+    setMicVolume: function(level) {
+         settings.set_double("mic-volume", level);
+    },
+    
+    getSpeakerVolume: function() {
+        let speakerVolLevel = settings.get_double("speaker-volume");
+        return speakerVolLevel;
+    },
+     
+    setSpeakerVolume: function(level) {
+         settings.set_double("speaker-volume", level);
+    },
+    
     _showAbout: function() {
         let aboutDialog = new Gtk.AboutDialog({ use_header_bar: true });
         aboutDialog.artists = [ 'Reda Lazri <the red shortcut gmail com>',
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 05c7b03..be4aa97 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -27,6 +27,7 @@ const Gio = imports.gi.Gio;
 const Gst = imports.gi.Gst;
 const Pango = imports.gi.Pango;
 
+const Application = imports.application;
 const AudioProfile = imports.audioProfile;
 const FileUtil = imports.fileUtil;
 const Info = imports.info;
@@ -218,10 +219,13 @@ const MainView = new Lang.Class({
     },
     
     presetVolume: function(source, vol) {
-        if (source == ActiveArea.PLAY)
+        if (source == ActiveArea.PLAY) {
             volumeValue[0].play = vol;
-        else
-            volumeValue[0].record = vol;               
+            Application.application.setSpeakerVolume(vol);
+        } else {
+            volumeValue[0].record = vol;
+            Application.application.setMicVolume(vol);
+        }              
     },
     
     setVolume: function() {
@@ -241,7 +245,9 @@ const MainView = new Lang.Class({
     listBoxAdd: function() {
         selectable = true;
         this.groupGrid = groupGrid;
-        volumeValue.push({ record: 0.5, play: 0.5 });
+        let playVolume = Application.application.getSpeakerVolume();
+        let micVolume = Application.application.getMicVolume();
+        volumeValue.push({ record: micVolume, play: playVolume });
         activeProfile = AudioProfile.comboBoxMap.OGG_VORBIS;
                 
         this.recordGrid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
@@ -813,12 +819,14 @@ const EncoderComboBox = new Lang.Class({
             this.append_text(combo[i]);
         this.set_property('valign', Gtk.Align.CENTER);  
         this.set_sensitive(true);
+        activeProfile = Application.application.getPreferences();
         this.set_active(activeProfile);
         this.connect("changed", Lang.bind(this, this._onComboBoxTextChanged));
     },
    
     _onComboBoxTextChanged: function() {
         activeProfile = this.get_active();
+        Application.application.setPreferences(activeProfile);
     }
 });
 


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