8
8
const Gio = imports.gi.Gio;
9
const GLib = imports.gi.GLib;
9
10
const Lang = imports.lang;
13
let _default_settings_object = null;
14
function get_settings () {
15
if (!_default_settings_object) {
16
_default_settings_object = new SettingsData ();
18
return _default_settings_object;
12
21
const SettingsData = new Lang.Class ({
13
22
Name: 'SettingsData',
24
/* Member definitions */
25
_settings_file_path: String,
27
_settings_file: Gio.File,
15
29
_init: function () {
30
/* First we construct the path for where to store the settings file. */
31
this._settings_file_path = "";
32
this._settings_file_path += GLib.get_user_config_dir ();
33
this._settings_file_path += "/gpump/gpump.json";
34
print ("Config file is: " + this._settings_file_path);
36
this._settings_file = Gio.File.new_for_path (this._settings_file_path);
38
/* Then we check that the file exists. If the file doen not ekist we
39
* construct some sane default values.
41
if (!GLib.file_test (this._settings_file_path, GLib.FileTest.EXISTS)) {
42
/* -1 is undefined, and will be set at construction of the window */
53
only_show_avatar: false
60
print (JSON.stringify (this._settings, null, 2).toString () );
63
let file_stream = this._settings_file.create (Gio.FileCreateFlags.PRIVATE,
65
file_stream.write_all (JSON.stringify (
66
this._settings, null, 2).toString (), null);
68
file_stream.close (null);
71
/* The file exists, we load the settings data into memory */