This commit is contained in:
Ward from fusion-voyager-3 2024-07-08 11:19:15 +03:00
parent 8ec3ea1855
commit fb5929523a
4 changed files with 54 additions and 21 deletions

View File

@ -9,8 +9,9 @@
<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_package_row/imp.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_package_row/imp.rs" 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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -109,7 +110,8 @@
<workItem from="1719872581190" duration="4000" />
<workItem from="1720090281244" duration="5582000" />
<workItem from="1720289925469" duration="7265000" />
<workItem from="1720301553869" duration="6532000" />
<workItem from="1720301553869" duration="12211000" />
<workItem from="1720423242486" duration="2526000" />
</task>
<servers />
</component>

View File

@ -52,7 +52,7 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
println!("{}", message);
Runtime::new()
.unwrap()
.block_on(send_progress_status(message, self.status_socket_path));
.block_on(send_progress_status(&message, self.status_socket_path));
}
/// Called when an Item has started to download
@ -63,7 +63,7 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
println!("{}", message);
Runtime::new()
.unwrap()
.block_on(send_progress_status(message, self.status_socket_path));
.block_on(send_progress_status(&message, self.status_socket_path));
}
/// Called when an item is successfully and completely fetched.
@ -74,7 +74,7 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
println!("{}", message);
Runtime::new()
.unwrap()
.block_on(send_progress_status(message, self.status_socket_path));
.block_on(send_progress_status(&message, self.status_socket_path));
}
/// Called when progress has started.
@ -96,14 +96,21 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
/// Print out the ErrorText for the Item.
fn fail(&mut self, item: &ItemDesc) {
let message = format!(
"Download Failed!: {} {}",
"Download Failed: {} {}",
item.description(),
item.short_desc()
);
eprintln!("{}", message);
eprintln!("{}", &message);
Runtime::new()
.unwrap()
.block_on(send_progress_status(message, self.status_socket_path));
.block_on(send_progress_status(&message, self.status_socket_path));
Runtime::new()
.unwrap()
.block_on(send_failed_to_socket(self.percent_socket_path));
Runtime::new()
.unwrap()
.block_on(send_failed_to_socket(self.status_socket_path));
panic!("{}", message.to_string())
}
/// Called periodically to provide the overall progress information
@ -163,7 +170,7 @@ async fn send_progress_percent(progress_f32: f32, socket_path: &str) {
.expect("Failed to write to stream");
}
async fn send_progress_status(message: String, socket_path: &str) {
async fn send_progress_status(message: &str, socket_path: &str) {
// Connect to the Unix socket
let mut stream = UnixStream::connect(socket_path)
.await

View File

@ -33,7 +33,13 @@ pub struct AptPackageSocket {
pub is_last: bool,
}
pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
pub fn apt_update_page(window: adw::ApplicationWindow) -> adw::Bin {
adw::Bin::builder()
.child(&create_bin_content(window))
.build()
}
fn create_bin_content(window: adw::ApplicationWindow) -> 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>();
@ -204,6 +210,7 @@ pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
update_status_server_context.spawn_local(
clone!(@weak apt_update_dialog, @weak apt_update_dialog_spinner => async move {
while let Ok(state) = update_status_receiver.recv().await {
println!("egg: {}", state);
match state.as_ref() {
"FN_OVERRIDE_SUCCESSFUL" => {}
"FN_OVERRIDE_FAILED" => {

View File

@ -41,16 +41,16 @@ pub fn build_ui(app: &adw::Application) {
while let Ok(state) = internet_loop_receiver.recv().await {
let banner_text = t!("banner_text_no_internet").to_string();
if state == true {
*internet_connected_status.borrow_mut()=true;
if window_banner.title() == banner_text {
window_banner.set_revealed(false)
}
} else {
*internet_connected_status.borrow_mut()=false;
if window_banner.title() != t!("banner_text_url_error").to_string() {
window_banner.set_title(&banner_text);
window_banner.set_revealed(true)
*internet_connected_status.borrow_mut()=true;
if window_banner.title() == banner_text {
window_banner.set_revealed(false)
}
} else {
*internet_connected_status.borrow_mut()=false;
if window_banner.title() != t!("banner_text_url_error").to_string() {
window_banner.set_title(&banner_text);
window_banner.set_revealed(true)
}
}
}
}));
@ -63,7 +63,23 @@ pub fn build_ui(app: &adw::Application) {
)
.build();
let window_toolbar = adw::ToolbarView::builder().build();
let window_adw_view_stack = adw::ViewStack::builder()
.hhomogeneous(true)
.vhomogeneous(true)
.build();
let window_toolbar = adw::ToolbarView::builder()
.content(&window_adw_view_stack)
.top_bar_style(ToolbarStyle::Flat)
.bottom_bar_style(ToolbarStyle::Flat)
.build();
let window_adw_view_switcher_bar = adw::ViewSwitcherBar::builder()
.stack(&window_adw_view_stack)
.reveal(true)
.build();
window_headerbar.pack_start(&window_adw_view_switcher_bar);
window_toolbar.add_top_bar(&window_headerbar);
window_toolbar.add_top_bar(&window_banner);
@ -108,5 +124,6 @@ pub fn build_ui(app: &adw::Application) {
// show the window
window.present();
window_toolbar.set_content(Some(&apt_update_page::apt_update_page(window)));
window_adw_view_stack.add_titled_with_icon(&apt_update_page::apt_update_page(window), 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"));
}