From 521dfe6ecb8b69b7cc3d2393993891499ce28ea6 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 19 Jul 2024 17:33:47 +0300 Subject: [PATCH] flatpak update dialog --- .idea/workspace.xml | 7 ++-- ...kaos-linux.pikmanupdatemanager.gschema.xml | 24 +++++++++++ src/bin/gui/build_ui/mod.rs | 40 ++++++++++++++----- 3 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 data/com.github.pikaos-linux.pikmanupdatemanager.gschema.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e0669bc..73afd77 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,10 +8,9 @@ + - - - + diff --git a/data/com.github.pikaos-linux.pikmanupdatemanager.gschema.xml b/data/com.github.pikaos-linux.pikmanupdatemanager.gschema.xml new file mode 100644 index 0000000..033a9b9 --- /dev/null +++ b/data/com.github.pikaos-linux.pikmanupdatemanager.gschema.xml @@ -0,0 +1,24 @@ + + + + + 1400 + Default window width + + + 700 + Default window height + + + false + Default window maximized behaviour + + + true + Show PikaOS Welcome on startup. + + Show PikaOS Welcome on startup. + + + + \ No newline at end of file diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index d6b4a75..f54fe85 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -14,6 +14,7 @@ pub fn build_ui(app: &Application) { // setup glib glib::set_prgname(Some(t!("application_name").to_string())); glib::set_application_name(&t!("application_name").to_string()); + let glib_settings = gio::Settings::new(APP_ID); let internet_connected = Rc::new(RefCell::new(false)); let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded(); @@ -61,23 +62,25 @@ pub fn build_ui(app: &Application) { .title_widget(&WindowTitle::builder().title(t!("application_name")).build()) .build(); - let window_adw_view_stack = ViewStack::builder() + let window_adw_stack = gtk::Stack::builder() .hhomogeneous(true) .vhomogeneous(true) + .transition_type(gtk::StackTransitionType::SlideUpDown) .build(); let window_toolbar = ToolbarView::builder() - .content(&window_adw_view_stack) + .content(&window_adw_stack) .top_bar_style(ToolbarStyle::Flat) .bottom_bar_style(ToolbarStyle::Flat) .build(); - let window_adw_view_switcher_bar = ViewSwitcherBar::builder() - .stack(&window_adw_view_stack) - .reveal(true) + let window_adw_view_switcher_sidebar = gtk::StackSidebar::builder() + .vexpand(true) + .hexpand(true) + .stack(&window_adw_stack) .build(); - window_headerbar.pack_start(&window_adw_view_switcher_bar); + window_headerbar.pack_start(&window_adw_view_switcher_sidebar); window_toolbar.add_top_bar(&window_headerbar); window_toolbar.add_top_bar(&window_banner); @@ -92,6 +95,9 @@ pub fn build_ui(app: &Application) { // Application icon .icon_name(APP_ICON) // Minimum Size/Default + .default_width(glib_settings.int("window-width")) + .default_height(glib_settings.int("window-height")) + // .width_request(700) .height_request(500) .content(&window_toolbar) @@ -100,6 +106,21 @@ pub fn build_ui(app: &Application) { // build the window .build(); + if glib_settings.boolean("is-maximized") == true { + window.maximize() + } + + window.connect_close_request(move |window| { + if let Some(application) = window.application() { + let size = window.default_size(); + let _ = glib_settings.set_int("window-width", size.0); + let _ = glib_settings.set_int("window-height", size.1); + let _ = glib_settings.set_boolean("is-maximized", window.is_maximized()); + application.remove_window(window); + } + glib::Propagation::Proceed + }); + let credits_button = gtk::Button::builder() .icon_name("dialog-information-symbolic") .build(); @@ -175,11 +196,10 @@ pub fn build_ui(app: &Application) { } )); - window_adw_view_stack.add_titled_with_icon( + window_adw_stack.add_titled( &apt_update_view_stack_bin, Some("apt_update_page"), &t!("apt_update_page_title"), - "software-update-available-symbolic", ); // @@ -187,9 +207,9 @@ pub fn build_ui(app: &Application) { #[weak] apt_retry_signal_action, #[weak] - window_adw_view_stack, + window_adw_stack, move |_| { - match window_adw_view_stack.visible_child_name().unwrap().as_str() { + match window_adw_stack.visible_child_name().unwrap().as_str() { "apt_update_page" => apt_retry_signal_action.activate(None), _ => {} }