| 1 |
/* exported FlatsealSettingsModel getDefault */ |
| 2 |
|
| 3 |
/* settings.js |
| 4 |
* |
| 5 |
* Copyright 2021 Martin Abente Lahaye |
| 6 |
* |
| 7 |
* This program is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation, either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
const {GObject, Gio} = imports.gi; |
| 22 |
|
| 23 |
|
| 24 |
var FlatsealSettingsModel = GObject.registerClass({ |
| 25 |
GTypeName: 'FlatsealSettingsModel', |
| 26 |
}, class FlatsealSettingsModel extends GObject.Object { |
| 27 |
_init() { |
| 28 |
super._init({}); |
| 29 |
this._settings = new Gio.Settings({schema_id: 'com.github.tchx84.Flatseal'}); |
| 30 |
} |
| 31 |
|
| 32 |
restoreWindowState(window) { |
| 33 |
window.default_width = this._settings.get_int('window-width'); |
| 34 |
window.default_height = this._settings.get_int('window-height'); |
| 35 |
if (this._settings.get_boolean('window-maximized')) |
| 36 |
window.maximize(); |
| 37 |
} |
| 38 |
|
| 39 |
saveWindowState(window) { |
| 40 |
if (!window.maximized) { |
| 41 |
const [width, height] = window.get_default_size(); |
| 42 |
this._settings.set_int('window-width', width); |
| 43 |
this._settings.set_int('window-height', height); |
| 44 |
} |
| 45 |
this._settings.set_boolean('window-maximized', window.maximized); |
| 46 |
} |
| 47 |
|
| 48 |
getSelectedAppId() { |
| 49 |
return this._settings.get_string('selected-app-id'); |
| 50 |
} |
| 51 |
|
| 52 |
setSelectedAppId(appId) { |
| 53 |
this._settings.set_string('selected-app-id', appId); |
| 54 |
} |
| 55 |
}); |