also save window position
This commit is contained in:
parent
3017ee3ee4
commit
72a985a9e4
2 changed files with 32 additions and 2 deletions
|
@ -6,6 +6,15 @@
|
||||||
</key>
|
</key>
|
||||||
<key name="volume" type="i">
|
<key name="volume" type="i">
|
||||||
<default>100</default>
|
<default>100</default>
|
||||||
|
</key>
|
||||||
|
<key name="window-width" type="i">
|
||||||
|
<default>-1</default>
|
||||||
|
</key>
|
||||||
|
<key name="window-height" type="i">
|
||||||
|
<default>-1</default>
|
||||||
|
</key>
|
||||||
|
<key name="is-maximized" type="b">
|
||||||
|
<default>false</default>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
@ -172,7 +172,15 @@ mod imp {
|
||||||
|
|
||||||
let settings = gio::Settings::new(crate::APP_ID);
|
let settings = gio::Settings::new(crate::APP_ID);
|
||||||
settings.bind("mute", self.obj().as_ref(), "mute").build();
|
settings.bind("mute", self.obj().as_ref(), "mute").build();
|
||||||
settings.bind("volume", self.obj().as_ref(), "volume").build();
|
settings
|
||||||
|
.bind("volume", self.obj().as_ref(), "volume")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
self.obj()
|
||||||
|
.set_default_size(settings.int("window-width"), settings.int("window-height"));
|
||||||
|
if settings.boolean("is-maximized") {
|
||||||
|
self.obj().maximize();
|
||||||
|
}
|
||||||
|
|
||||||
// update time-pos every 100 ms
|
// update time-pos every 100 ms
|
||||||
let window = self.obj().downgrade();
|
let window = self.obj().downgrade();
|
||||||
|
@ -293,7 +301,20 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowImpl for Window {}
|
impl WindowImpl for Window {
|
||||||
|
fn close_request(&self) -> glib::Propagation {
|
||||||
|
let size = self.obj().default_size();
|
||||||
|
// TODO: don't instantiate this so many times maybe? OnceCell in imp struct?
|
||||||
|
let settings = gio::Settings::new(crate::APP_ID);
|
||||||
|
settings.set_int("window-width", size.0).unwrap();
|
||||||
|
settings.set_int("window-height", size.1).unwrap();
|
||||||
|
settings
|
||||||
|
.set_boolean("is-maximized", self.obj().is_maximized())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
glib::Propagation::Proceed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ApplicationWindowImpl for Window {}
|
impl ApplicationWindowImpl for Window {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue