Add desktop integration files and window state persistence

This commit is contained in:
2026-03-02 00:58:21 +02:00
parent 92d4d7b234
commit 893acd6437
4 changed files with 85 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
use adw::prelude::*;
use gtk::glib;
use outlay_core::db::Database;
use std::rc::Rc;
@@ -114,14 +115,52 @@ impl MainWindow {
split_view.set_sidebar(Some(&sidebar_page));
split_view.set_content(Some(&content_page));
// Restore window size from settings
let saved_width: i32 = db
.get_setting("window_width")
.ok()
.flatten()
.and_then(|s| s.parse().ok())
.unwrap_or(900);
let saved_height: i32 = db
.get_setting("window_height")
.ok()
.flatten()
.and_then(|s| s.parse().ok())
.unwrap_or(600);
let saved_maximized: bool = db
.get_setting("window_maximized")
.ok()
.flatten()
.map(|s| s == "true")
.unwrap_or(false);
let window = adw::ApplicationWindow::builder()
.application(app)
.title("Outlay")
.default_width(900)
.default_height(600)
.default_width(saved_width)
.default_height(saved_height)
.content(&split_view)
.build();
if saved_maximized {
window.maximize();
}
// Save window size on close
{
let db_ref = db.clone();
window.connect_close_request(move |win| {
let (width, height) = win.default_size();
db_ref.set_setting("window_width", &width.to_string()).ok();
db_ref.set_setting("window_height", &height.to_string()).ok();
db_ref
.set_setting("window_maximized", if win.is_maximized() { "true" } else { "false" })
.ok();
glib::Propagation::Proceed
});
}
MainWindow {
window,
split_view,