Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Commit d99eba1

Browse files
committed
correctly save/restore window state
fix #15
1 parent 20efdb8 commit d99eba1

File tree

3 files changed

+98
-46
lines changed

3 files changed

+98
-46
lines changed
+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<schemalist>
33
<schema id="@app-id@" path="/com/vixalien/decibels/" gettext-domain="@gettext-package@">
4-
<key name="last-window-size" type="(ii)">
5-
<default>(-1,-1)</default>
6-
<summary>Last width &amp; height of window</summary>
7-
<description>The saved last size of the window (to be restored)</description>
8-
</key>
4+
<key name="width" type="i">
5+
<default>640</default>
6+
</key>
7+
<key name="height" type="i">
8+
<default>480</default>
9+
</key>
10+
<key name="is-maximized" type="b">
11+
<default>false</default>
12+
</key>
13+
<key name="is-fullscreen" type="b">
14+
<default>false</default>
15+
</key>
916
</schema>
1017
</schemalist>

po/decibels.pot

+61-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: decibels\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2023-09-24 14:06+0200\n"
11+
"POT-Creation-Date: 2023-10-03 17:20+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -53,37 +53,75 @@ msgid "Easy seek controls"
5353
msgstr ""
5454

5555
#: data/com.vixalien.decibels.metainfo.xml.in.in:34
56-
msgid "A few bug fixes that polishes up the app"
56+
msgid "A few improvements and papercut fixes"
5757
msgstr ""
5858

5959
#: data/com.vixalien.decibels.metainfo.xml.in.in:36
60-
msgid ""
61-
"Differentiate development versions of the app from the stable app by styling "
62-
"the icon and header differently"
60+
msgid "Support drag and drop"
6361
msgstr ""
6462

6563
#: data/com.vixalien.decibels.metainfo.xml.in.in:37
66-
msgid "Added donation link in application metadata"
64+
msgid "Seek to the start of a track after it ends"
6765
msgstr ""
6866

6967
#: data/com.vixalien.decibels.metainfo.xml.in.in:38
70-
msgid "Fix the About Window being detached from main window"
68+
msgid "Allow dragging the app window from everywhere (except the waveform)"
7169
msgstr ""
7270

7371
#: data/com.vixalien.decibels.metainfo.xml.in.in:39
74-
msgid "Fix the About Window showing release notes for an older version"
72+
msgid ""
73+
"Made the playback speed popover look less cluttered by removing the +/- "
74+
"buttons and mark labels"
7575
msgstr ""
7676

77-
#: data/com.vixalien.decibels.metainfo.xml.in.in:46
78-
msgid "Initial Release"
77+
#: data/com.vixalien.decibels.metainfo.xml.in.in:40
78+
msgid ""
79+
"Fix an issue that prevented accessing file metadata from within the Flatpak "
80+
"sandbox"
7981
msgstr ""
8082

81-
#: data/com.vixalien.decibels.gschema.xml.in:6
82-
msgid "Last width & height of window"
83+
#: data/com.vixalien.decibels.metainfo.xml.in.in:41
84+
msgid ""
85+
"Don't try to play files without audio streams (images and videos without "
86+
"sound)"
8387
msgstr ""
8488

85-
#: data/com.vixalien.decibels.gschema.xml.in:7
86-
msgid "The saved last size of the window (to be restored)"
89+
#: data/com.vixalien.decibels.metainfo.xml.in.in:42
90+
msgid "Don't try to process video streams even if they were not rendered"
91+
msgstr ""
92+
93+
#: data/com.vixalien.decibels.metainfo.xml.in.in:43
94+
msgid "Fixed some issues with the Development build of Decibels"
95+
msgstr ""
96+
97+
#: data/com.vixalien.decibels.metainfo.xml.in.in:44
98+
msgid "Fixed a minor glitch with the app icon"
99+
msgstr ""
100+
101+
#: data/com.vixalien.decibels.metainfo.xml.in.in:50
102+
msgid "A few bug fixes that polishes up the app"
103+
msgstr ""
104+
105+
#: data/com.vixalien.decibels.metainfo.xml.in.in:52
106+
msgid ""
107+
"Differentiate development versions of the app from the stable app by styling "
108+
"the icon and header differently"
109+
msgstr ""
110+
111+
#: data/com.vixalien.decibels.metainfo.xml.in.in:53
112+
msgid "Added donation link in application metadata"
113+
msgstr ""
114+
115+
#: data/com.vixalien.decibels.metainfo.xml.in.in:54
116+
msgid "Fix the About Window being detached from main window"
117+
msgstr ""
118+
119+
#: data/com.vixalien.decibels.metainfo.xml.in.in:55
120+
msgid "Fix the About Window showing release notes for an older version"
121+
msgstr ""
122+
123+
#: data/com.vixalien.decibels.metainfo.xml.in.in:62
124+
msgid "Initial Release"
87125
msgstr ""
88126

89127
#: data/empty.ui:13
@@ -94,7 +132,7 @@ msgstr ""
94132
msgid "_Open…"
95133
msgstr ""
96134

97-
#: data/error.ui:13 src/window.ts:123 src/window.ts:165
135+
#: data/error.ui:13 src/window.ts:155 src/window.ts:197
98136
msgid "File Cannot Be Played"
99137
msgstr ""
100138

@@ -126,38 +164,38 @@ msgstr ""
126164
msgid "Unable to access dropped files"
127165
msgstr ""
128166

129-
#: src/error.ts:57
167+
#: src/error.ts:42
130168
msgid "An unknown error happened"
131169
msgstr ""
132170

133-
#: src/stream.ts:252
171+
#: src/stream.ts:259
134172
msgid ""
135173
"File uses a format that cannot be played. Additional media codecs may be "
136174
"required."
137175
msgstr ""
138176

139-
#: src/stream.ts:262
177+
#: src/stream.ts:269
140178
msgid ""
141179
"An error happened while trying to get information about the file. Please try "
142180
"again."
143181
msgstr ""
144182

145-
#: src/stream.ts:386
183+
#: src/stream.ts:393
146184
msgid "Unknown File"
147185
msgstr ""
148186

149-
#: src/stream.ts:590
187+
#: src/stream.ts:619
150188
msgid "The selected file doesn't contain any audio"
151189
msgstr ""
152190

153-
#: src/window.ts:129
191+
#: src/window.ts:161
154192
msgid "Audio files"
155193
msgstr ""
156194

157-
#: src/window.ts:136
195+
#: src/window.ts:168
158196
msgid "Open File"
159197
msgstr ""
160198

161-
#: src/window.ts:166
199+
#: src/window.ts:198
162200
msgid "The file could not be accessed"
163201
msgstr ""

src/window.ts

+25-18
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,31 @@ export class Window extends Adw.ApplicationWindow {
7979
constructor(params?: Partial<Adw.ApplicationWindow.ConstructorProperties>) {
8080
super(params);
8181

82-
const window_size = Settings.get_value("last-window-size");
83-
84-
const width = window_size.get_child_value(0).get_int32();
85-
const height = window_size.get_child_value(1).get_int32();
86-
87-
if (width > 0) this.default_width = width;
88-
if (height > 0) this.default_height = height;
82+
// update the settings when the properties change and vice versa
83+
Settings.bind(
84+
"width",
85+
this,
86+
"default-width",
87+
Gio.SettingsBindFlags.DEFAULT,
88+
);
89+
Settings.bind(
90+
"height",
91+
this,
92+
"default-height",
93+
Gio.SettingsBindFlags.DEFAULT,
94+
);
95+
Settings.bind(
96+
"is-maximized",
97+
this,
98+
"maximized",
99+
Gio.SettingsBindFlags.DEFAULT,
100+
);
101+
Settings.bind(
102+
"is-fullscreen",
103+
this,
104+
"fullscreened",
105+
Gio.SettingsBindFlags.DEFAULT,
106+
);
89107

90108
this.stream = new APMediaStream();
91109

@@ -202,15 +220,4 @@ export class Window extends Adw.ApplicationWindow {
202220

203221
this._error.show_error(title, error);
204222
}
205-
206-
vfunc_close_request() {
207-
const window_size = GLib.Variant.new("(ii)", [
208-
this.get_width(),
209-
this.get_height(),
210-
]);
211-
212-
Settings.set_value("last-window-size", window_size);
213-
214-
return super.vfunc_close_request();
215-
}
216223
}

0 commit comments

Comments
 (0)