2024-01-30 21:33:07 +01:00
|
|
|
// GTK crates
|
|
|
|
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
|
|
|
|
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
|
|
|
|
use gtk::prelude::*;
|
|
|
|
use gtk::*;
|
|
|
|
use adw::prelude::*;
|
|
|
|
use adw::*;
|
2024-01-31 19:48:55 +01:00
|
|
|
use adw::ffi::{ADW_TOOLBAR_FLAT, AdwToolbarStyle};
|
2024-01-30 21:33:07 +01:00
|
|
|
use glib::*;
|
|
|
|
use gdk::Display;
|
|
|
|
|
|
|
|
// application crates
|
|
|
|
use crate::save_window_size;
|
2024-01-31 19:48:55 +01:00
|
|
|
/// first setup crates
|
|
|
|
use crate::first_setup::first_setup::first_setup;
|
2024-01-30 21:33:07 +01:00
|
|
|
|
|
|
|
pub fn build_ui(app: &adw::Application) {
|
|
|
|
|
|
|
|
// setup glib
|
2024-01-30 21:47:31 +01:00
|
|
|
gtk::glib::set_prgname(Some("PikaOS First Setup"));
|
|
|
|
glib::set_application_name("PikaOS First Setup");
|
|
|
|
let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikafirstsetup");
|
2024-01-30 21:33:07 +01:00
|
|
|
|
|
|
|
// create the main Application window
|
|
|
|
let window = adw::ApplicationWindow::builder()
|
|
|
|
// The text on the titlebar
|
2024-01-30 21:47:31 +01:00
|
|
|
.title("PikaOS First Setup")
|
2024-01-30 21:33:07 +01:00
|
|
|
// link it to the application "app"
|
|
|
|
.application(app)
|
2024-01-31 19:48:55 +01:00
|
|
|
// Add the box called "window_box" to it
|
2024-01-30 21:33:07 +01:00
|
|
|
// Application icon
|
2024-01-30 21:47:31 +01:00
|
|
|
.icon_name("com.github.pikaos-linux.pikafirstsetup")
|
2024-01-30 21:33:07 +01:00
|
|
|
// Get current size from glib
|
|
|
|
.default_width(glib_settings.int("window-width"))
|
|
|
|
.default_height(glib_settings.int("window-height"))
|
|
|
|
// Minimum Size/Default
|
|
|
|
.width_request(700)
|
|
|
|
.height_request(500)
|
|
|
|
// Hide window instead of destroy
|
|
|
|
.hide_on_close(true)
|
2024-01-30 21:47:31 +01:00
|
|
|
.deletable(false)
|
2024-01-30 21:33:07 +01:00
|
|
|
// Startup
|
2024-01-30 21:47:31 +01:00
|
|
|
.startup_id("com.github.pikaos-linux.pikafirstsetup")
|
2024-01-30 21:33:07 +01:00
|
|
|
// build the window
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// glib maximization
|
|
|
|
if glib_settings.boolean("is-maximized") == true {
|
|
|
|
window.maximize()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Connect the hiding of window to the save_window_size function and window destruction
|
|
|
|
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
|
|
|
|
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
|
|
|
|
|
2024-01-31 19:48:55 +01:00
|
|
|
first_setup(&window);
|
|
|
|
|
2024-01-30 21:33:07 +01:00
|
|
|
// show the window
|
|
|
|
window.present()
|
2024-01-31 19:48:55 +01:00
|
|
|
}
|