use std::sync::Arc;
use adw::Application;
use gtk4::prelude::*;
use gtk4::ApplicationWindow;
use crate::{ExitCode, HandleBox, WaylandConn};
pub trait Cb {
fn cb(&self, h: HandleBox);
}
pub fn pmse_gtk_main(
app_id: String,
title: String,
rect: (i32, i32, i32, i32),
margin: (i32, i32, i32, i32),
cb: Arc<Box<dyn Cb>>,
) -> ExitCode {
let app = Application::builder().application_id(&app_id).build();
let x = rect.0 + margin.1 + margin.3;
let y = rect.1 + margin.0 + margin.2;
let 偏移 = (margin.3 + rect.2, margin.0 + rect.3);
println!(
"pmse_gtk_main: {:?} {:?} x = {}, y = {} {:?}",
rect, margin, x, y, 偏移
);
app.connect_activate(move |app| {
let w = ApplicationWindow::builder()
.application(app)
.default_width(x)
.default_height(y)
.title(&title)
.resizable(false)
.build();
let c = WaylandConn::new(&w).unwrap();
w.present();
let vs = c.surface().unwrap();
vs.run(偏移, cb.clone());
});
app.run()
}