retry button

This commit is contained in:
Ward from fusion-voyager-3 2024-07-09 03:09:22 +03:00
parent 7fef8d8739
commit bd7f3368c6
3 changed files with 35 additions and 7 deletions

View File

@ -9,7 +9,6 @@
<component name="ChangeListManager">
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/apt_update/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update_page/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/build_ui/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/build_ui/mod.rs" afterDir="false" />
</list>
@ -112,7 +111,7 @@
<workItem from="1720289925469" duration="7265000" />
<workItem from="1720301553869" duration="12211000" />
<workItem from="1720423242486" duration="3396000" />
<workItem from="1720476457389" duration="3531000" />
<workItem from="1720476457389" duration="7123000" />
</task>
<servers />
</component>

View File

@ -1,3 +1,4 @@
use std::rc::Rc;
use crate::apt_package_row::AptPackageRow;
use adw::gio::Action;
use adw::prelude::*;
@ -15,6 +16,7 @@ use std::process::Command;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::{fs, thread};
use std::ops::Deref;
use tokio::io::AsyncReadExt;
use tokio::net::{UnixListener, UnixStream};
use tokio::runtime::Runtime;
@ -32,7 +34,7 @@ pub struct AptPackageSocket {
pub installed_size: u64,
pub is_last: bool,
}
pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
pub fn apt_update_page(window: adw::ApplicationWindow, retry_signal_action: &gtk::Button) -> gtk::Box {
let (update_percent_sender, update_percent_receiver) = async_channel::unbounded::<String>();
let update_percent_sender = update_percent_sender.clone();
let (update_status_sender, update_status_receiver) = async_channel::unbounded::<String>();
@ -135,6 +137,23 @@ pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
.width_request(500)
.build();
apt_update_dialog.add_response("apt_update_dialog_retry", &t!("apt_update_dialog_retry_label").to_string());
apt_update_dialog.set_response_appearance(
"apt_update_dialog_retry",
adw::ResponseAppearance::Suggested,
);
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", false);
let retry_signal_action0 = retry_signal_action.clone();
apt_update_dialog.clone().choose(None::<&gio::Cancellable>, move |choice| {
if choice == "apt_update_dialog_retry" {
retry_signal_action0.emit_by_name("clicked", &[])
}
});
let bottom_bar = gtk::Box::builder()
.valign(Align::End)
.build();
@ -219,8 +238,8 @@ pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
"FN_OVERRIDE_SUCCESSFUL" => {}
"FN_OVERRIDE_FAILED" => {
apt_update_dialog_child_box.set_visible(false);
apt_update_dialog.set_title(Some(&t!("apt_update_dialog_status_failed").to_string()))
//apt_update_dialog.add_response("apt_update_dialog_retry", &t!("apt_update_dialog_retry_label").to_string());
apt_update_dialog.set_title(Some(&t!("apt_update_dialog_status_failed").to_string()));
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", true);
}
_ => apt_update_dialog.set_body(&state)
}

View File

@ -1,11 +1,13 @@
use crate::glib::closure_local;
use crate::apt_update_page;
use crate::apt_update_page::apt_update_page;
use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION};
use adw::prelude::*;
use adw::*;
use gtk::glib::{clone, MainContext};
use gtk::{License, Orientation};
use gtk::{License, Orientation, SignalAction};
use std::cell::RefCell;
use std::ops::Deref;
use std::process::Command;
use std::rc::Rc;
use std::thread;
@ -122,13 +124,21 @@ pub fn build_ui(app: &adw::Application) {
.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present()));
// show the window
window.present();
// Apt Update Page
let apt_retry_signal_action = gtk::Button::builder().build();
let apt_update_view_stack_bin = adw::Bin::builder()
.child(&apt_update_page::apt_update_page(window))
.child(&apt_update_page::apt_update_page(window.clone(), &apt_retry_signal_action))
.build();
apt_retry_signal_action.connect_clicked(clone!(@weak window, @strong apt_retry_signal_action, @strong apt_update_view_stack_bin => move |_| {
apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(window, &apt_retry_signal_action)));
}));
window_adw_view_stack.add_titled_with_icon(&apt_update_view_stack_bin, Some("apt_update_page"), &t!("apt_update_page_title"), "software-update-available-symbolic");
window_adw_view_stack.add_titled(&gtk::Image::builder().icon_name("firefox").build(), Some("apt_update_page2"), &t!("apt_update_page_title2"));
}