flatpak update dialog

This commit is contained in:
Ward from fusion-voyager-3 2024-07-19 17:33:47 +03:00
parent 5364e4fdf5
commit 521dfe6ecb
3 changed files with 57 additions and 14 deletions

View File

@ -8,10 +8,9 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment=""> <list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/data/com.github.pikaos-linux.pikmanupdatemanager.gschema.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/locales/en_US.json" beforeDir="false" afterPath="$PROJECT_DIR$/locales/en_US.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/bin/gui/build_ui/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/build_ui/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bin/gui/flatpak_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/flatpak_update_page/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bin/gui/flatpak_update_page/process.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/flatpak_update_page/process.rs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -166,7 +165,7 @@
<workItem from="1720668957580" duration="53000" /> <workItem from="1720668957580" duration="53000" />
<workItem from="1720669130008" duration="560000" /> <workItem from="1720669130008" duration="560000" />
<workItem from="1721340242546" duration="6495000" /> <workItem from="1721340242546" duration="6495000" />
<workItem from="1721388775654" duration="5094000" /> <workItem from="1721388775654" duration="8284000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<schemalist>
<schema id="com.github.pikaos-linux.pikmanupdatemanager" path="/com/github/pikaos-linux/pikmanupdatemanager/">
<key name="window-width" type="i">
<default>1400</default>
<summary>Default window width</summary>
</key>
<key name="window-height" type="i">
<default>700</default>
<summary>Default window height</summary>
</key>
<key name="is-maximized" type="b">
<default>false</default>
<summary>Default window maximized behaviour</summary>
</key>
<key type="b" name="startup-show">
<default>true</default>
<summary>Show PikaOS Welcome on startup.</summary>
<description>
Show PikaOS Welcome on startup.
</description>
</key>
</schema>
</schemalist>

View File

@ -14,6 +14,7 @@ pub fn build_ui(app: &Application) {
// setup glib // setup glib
glib::set_prgname(Some(t!("application_name").to_string())); glib::set_prgname(Some(t!("application_name").to_string()));
glib::set_application_name(&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_connected = Rc::new(RefCell::new(false));
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded(); 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()) .title_widget(&WindowTitle::builder().title(t!("application_name")).build())
.build(); .build();
let window_adw_view_stack = ViewStack::builder() let window_adw_stack = gtk::Stack::builder()
.hhomogeneous(true) .hhomogeneous(true)
.vhomogeneous(true) .vhomogeneous(true)
.transition_type(gtk::StackTransitionType::SlideUpDown)
.build(); .build();
let window_toolbar = ToolbarView::builder() let window_toolbar = ToolbarView::builder()
.content(&window_adw_view_stack) .content(&window_adw_stack)
.top_bar_style(ToolbarStyle::Flat) .top_bar_style(ToolbarStyle::Flat)
.bottom_bar_style(ToolbarStyle::Flat) .bottom_bar_style(ToolbarStyle::Flat)
.build(); .build();
let window_adw_view_switcher_bar = ViewSwitcherBar::builder() let window_adw_view_switcher_sidebar = gtk::StackSidebar::builder()
.stack(&window_adw_view_stack) .vexpand(true)
.reveal(true) .hexpand(true)
.stack(&window_adw_stack)
.build(); .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_headerbar);
window_toolbar.add_top_bar(&window_banner); window_toolbar.add_top_bar(&window_banner);
@ -92,6 +95,9 @@ pub fn build_ui(app: &Application) {
// Application icon // Application icon
.icon_name(APP_ICON) .icon_name(APP_ICON)
// Minimum Size/Default // Minimum Size/Default
.default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height"))
//
.width_request(700) .width_request(700)
.height_request(500) .height_request(500)
.content(&window_toolbar) .content(&window_toolbar)
@ -100,6 +106,21 @@ pub fn build_ui(app: &Application) {
// build the window // build the window
.build(); .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() let credits_button = gtk::Button::builder()
.icon_name("dialog-information-symbolic") .icon_name("dialog-information-symbolic")
.build(); .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, &apt_update_view_stack_bin,
Some("apt_update_page"), Some("apt_update_page"),
&t!("apt_update_page_title"), &t!("apt_update_page_title"),
"software-update-available-symbolic",
); );
// //
@ -187,9 +207,9 @@ pub fn build_ui(app: &Application) {
#[weak] #[weak]
apt_retry_signal_action, apt_retry_signal_action,
#[weak] #[weak]
window_adw_view_stack, window_adw_stack,
move |_| { 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), "apt_update_page" => apt_retry_signal_action.activate(None),
_ => {} _ => {}
} }