Commit 88ebd295 authored by Meg Ford's avatar Meg Ford

multiple files: Implement gschema

The gschema settings were not being saved.
Closes Bug 727984 https://bugzilla.gnome.org/show_bug.cgi?id=727984
parent ee8ba599
<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,31 +10,20 @@
<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>
<description>Maps media types to audio encoder preset names. If there is no mapping set, 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>
<summary>Micophone volume level</summary>
<description>Micophone 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>
<summary>Speaker volume level</summary>
<description>Speaker volume level.</description>
</key>
</schema>
</schemalist>
......
......@@ -24,10 +24,12 @@ const GLib = imports.gi.GLib;
const MainWindow = imports.mainWindow;
const Preferences = imports.preferences;
const SIGINT = 2;
const SIGTERM = 15;
let application = null;
let settings = null;
const Application = new Lang.Class({
......@@ -49,7 +51,6 @@ const Application = new Lang.Class({
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() {
......@@ -81,7 +82,7 @@ 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")]);
......@@ -97,7 +98,7 @@ const Application = new Lang.Class({
onWindowDestroy: function() {
if (MainWindow.wave.pipeline)
MainWindow.wave.pipeline.set_state(Gst.State.NULL);
media-type-preset
if (MainWindow._record.pipeline)
MainWindow._record.pipeline.set_state(Gst.State.NULL);
......@@ -112,6 +113,33 @@ const Application = new Lang.Class({
function(widget, response) {
preferencesDialog.widget.destroy();
}));
},
getPreferences: function() {
let set = settings.get_int("media-type-preset");
return set;
},
setPreferences: function(profileName) {
settings.set_int("media-type-preset", profileName);
},
getMicVolume: function(level) {
let micVolLevel = settings.get_double("mic-volume");
return micVolLevel;
},
setMicVolume: function(level) {
settings.set_double("mic-volume", level);
},
getSpeakerVolume: function(level) {
let speakerVolLevel = settings.get_double("speaker-volume");
return speakerVolLevel;
},
setSpeakerVolume: function(level) {
settings.set_double("speaker-volume", level);
},
_showAbout: function() {
......
......@@ -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);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment