flatpak confirm dialog
This commit is contained in:
parent
635a9714fa
commit
4498dcd11e
@ -8,17 +8,10 @@
|
|||||||
</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$/.idea/bin-apt.iml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/bin-gui.iml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/pikman-update-manager.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/lib.iml" 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$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" 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$/locales/en_US.json" beforeDir="false" afterPath="$PROJECT_DIR$/locales/en_US.json" 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" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" 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/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/main.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" />
|
||||||
@ -49,35 +42,28 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"Cargo.Build all.executor": "Run",
|
||||||
"Cargo.Build all.executor": "Run",
|
"Cargo.Run apt_update.executor": "Run",
|
||||||
"Cargo.Run apt_update.executor": "Run",
|
"Cargo.Run pikman-update-manager.executor": "Run",
|
||||||
"Cargo.Run pikman-update-manager.executor": "Run",
|
"Cargo.Test pikman-update-manager.executor": "Run",
|
||||||
"Cargo.Test pikman-update-manager.executor": "Run",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
"git-widget-placeholder": "main",
|
||||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"last_opened_file_path": "/home/ward/RustroverProjects/pkg-pikman-update-manager",
|
||||||
"git-widget-placeholder": "main",
|
"node.js.detected.package.eslint": "true",
|
||||||
"last_opened_file_path": "/home/ward/RustroverProjects/pkg-pikman-update-manager/.idea",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.detected.package.eslint": "true",
|
"nodejs_package_manager_path": "npm",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
||||||
"nodejs_package_manager_path": "npm",
|
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
|
||||||
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
"org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pkg-pikman-update-manager/src/apt_update_progress_socket/lib.rs": "true",
|
||||||
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
|
"org.rust.first.attach.projects": "true"
|
||||||
"org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pkg-pikman-update-manager/src/apt_update_progress_socket/lib.rs": "true",
|
|
||||||
"org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pkg-pikman-update-manager/src/bin/gui/flatpak_package_row/imp.rs": "true",
|
|
||||||
"org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pkg-pikman-update-manager/src/bin/gui/flatpak_package_row/mod.rs": "true",
|
|
||||||
"org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pkg-pikman-update-manager/src/bin/gui/main.rs": "true",
|
|
||||||
"org.rust.first.attach.projects": "true",
|
|
||||||
"settings.editor.selected.configurable": "language.rust.cargo.check"
|
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/.idea" />
|
|
||||||
<recent name="$PROJECT_DIR$/src/lib" />
|
<recent name="$PROJECT_DIR$/src/lib" />
|
||||||
<recent name="$PROJECT_DIR$/src" />
|
<recent name="$PROJECT_DIR$/src" />
|
||||||
</key>
|
</key>
|
||||||
@ -89,27 +75,7 @@
|
|||||||
<recent name="$PROJECT_DIR$" />
|
<recent name="$PROJECT_DIR$" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RsExternalLinterProjectSettings">
|
|
||||||
<option name="runOnTheFly" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="RunManager" selected="Cargo.Run pikman-update-manager">
|
<component name="RunManager" selected="Cargo.Run pikman-update-manager">
|
||||||
<configuration name="Build all" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="command" value="build" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<option name="emulateTerminal" value="true" />
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="requiredFeatures" value="true" />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="withSudo" value="false" />
|
|
||||||
<option name="buildTarget" value="REMOTE" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="isRedirectInput" value="false" />
|
|
||||||
<option name="redirectInputPath" value="" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration name="Build all" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
<configuration name="Build all" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||||
<option name="command" value="build" />
|
<option name="command" value="build" />
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||||
@ -144,40 +110,6 @@
|
|||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="Run pikman-update-manager" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="command" value="run --package pikman-update-manager --bin pikman-update-manager" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<option name="emulateTerminal" value="true" />
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="requiredFeatures" value="true" />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="withSudo" value="false" />
|
|
||||||
<option name="buildTarget" value="REMOTE" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="isRedirectInput" value="false" />
|
|
||||||
<option name="redirectInputPath" value="" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration name="Test pikman-update-manager" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="command" value="test --workspace" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<option name="emulateTerminal" value="true" />
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="requiredFeatures" value="true" />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="withSudo" value="false" />
|
|
||||||
<option name="buildTarget" value="REMOTE" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="isRedirectInput" value="false" />
|
|
||||||
<option name="redirectInputPath" value="" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration name="Test pikman-update-manager" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
<configuration name="Test pikman-update-manager" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||||
<option name="command" value="test --workspace" />
|
<option name="command" value="test --workspace" />
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||||
@ -233,10 +165,7 @@
|
|||||||
<workItem from="1720657757166" duration="11187000" />
|
<workItem from="1720657757166" duration="11187000" />
|
||||||
<workItem from="1720668957580" duration="53000" />
|
<workItem from="1720668957580" duration="53000" />
|
||||||
<workItem from="1720669130008" duration="560000" />
|
<workItem from="1720669130008" duration="560000" />
|
||||||
<workItem from="1721221767735" duration="512000" />
|
<workItem from="1721340242546" duration="2597000" />
|
||||||
<workItem from="1721222294632" duration="410000" />
|
|
||||||
<workItem from="1721222719941" duration="6652000" />
|
|
||||||
<workItem from="1721303523476" duration="21064000" />
|
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -246,15 +175,4 @@
|
|||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
|
||||||
<breakpoint-manager>
|
|
||||||
<breakpoints>
|
|
||||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
|
||||||
<url>file://$PROJECT_DIR$/src/bin/gui/flatpak_update_page/mod.rs</url>
|
|
||||||
<line>492</line>
|
|
||||||
<option name="timeStamp" value="1" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
|
||||||
</breakpoint-manager>
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
@ -95,7 +95,7 @@ pub fn apt_process_update(
|
|||||||
retry_signal_action,
|
retry_signal_action,
|
||||||
#[strong]
|
#[strong]
|
||||||
excluded_updates_vec,
|
excluded_updates_vec,
|
||||||
move |_, _| { apt_confirm_window(&excluded_updates_vec, window, &retry_signal_action) }
|
move |_, _| apt_confirm_window(&excluded_updates_vec, window, &retry_signal_action)
|
||||||
));
|
));
|
||||||
|
|
||||||
if excluded_updates_vec.is_empty() {
|
if excluded_updates_vec.is_empty() {
|
||||||
|
@ -39,9 +39,11 @@ pub fn flatpak_update_page(
|
|||||||
let appstream_sync_status_sender = appstream_sync_status_sender.clone();
|
let appstream_sync_status_sender = appstream_sync_status_sender.clone();
|
||||||
let appstream_sync_status_sender_clone0 = appstream_sync_status_sender.clone();
|
let appstream_sync_status_sender_clone0 = appstream_sync_status_sender.clone();
|
||||||
|
|
||||||
let system_refs_for_upgrade_vec: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(Vec::new()));
|
let system_refs_for_upgrade_vec: Rc<RefCell<Vec<FlatpakRefRow>>> =
|
||||||
|
Rc::new(RefCell::new(Vec::new()));
|
||||||
|
|
||||||
let user_refs_for_upgrade_vec: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(Vec::new()));
|
let user_refs_for_upgrade_vec: Rc<RefCell<Vec<FlatpakRefRow>>> =
|
||||||
|
Rc::new(RefCell::new(Vec::new()));
|
||||||
|
|
||||||
let cancellable_no = libflatpak::gio::Cancellable::NONE;
|
let cancellable_no = libflatpak::gio::Cancellable::NONE;
|
||||||
|
|
||||||
@ -277,8 +279,12 @@ pub fn flatpak_update_page(
|
|||||||
#[strong]
|
#[strong]
|
||||||
user_refs_for_upgrade_vec,
|
user_refs_for_upgrade_vec,
|
||||||
move |_| {
|
move |_| {
|
||||||
dbg!(&system_refs_for_upgrade_vec);
|
process::flatpak_process_update(
|
||||||
dbg!(&user_refs_for_upgrade_vec);
|
&system_refs_for_upgrade_vec.borrow(),
|
||||||
|
&user_refs_for_upgrade_vec.borrow(),
|
||||||
|
window,
|
||||||
|
&retry_signal_action,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -418,11 +424,11 @@ pub fn flatpak_update_page(
|
|||||||
is_last: flatpak_system_updates_iter.peek().is_none(),
|
is_last: flatpak_system_updates_iter.peek().is_none(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let flatpak_row = FlatpakRefRow::new(&flatref_struct);
|
||||||
|
|
||||||
system_refs_for_upgrade_vec
|
system_refs_for_upgrade_vec
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(flatpak_ref.format_ref().unwrap().into());
|
.push(flatpak_row.clone());
|
||||||
|
|
||||||
let flatpak_row = FlatpakRefRow::new(&flatref_struct);
|
|
||||||
|
|
||||||
flatpak_row.connect_closure(
|
flatpak_row.connect_closure(
|
||||||
"checkbutton-toggled",
|
"checkbutton-toggled",
|
||||||
@ -451,7 +457,7 @@ pub fn flatpak_update_page(
|
|||||||
));
|
));
|
||||||
system_refs_for_upgrade_vec
|
system_refs_for_upgrade_vec
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(flatpak_row.flatref_ref_format());
|
.push(flatpak_row);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -474,9 +480,10 @@ pub fn flatpak_update_page(
|
|||||||
update_button.set_sensitive(!is_all_children_unmarked(
|
update_button.set_sensitive(!is_all_children_unmarked(
|
||||||
&packages_boxedlist,
|
&packages_boxedlist,
|
||||||
));
|
));
|
||||||
system_refs_for_upgrade_vec
|
system_refs_for_upgrade_vec.borrow_mut().retain(|x| {
|
||||||
.borrow_mut()
|
x.flatref_ref_format()
|
||||||
.retain(|x| x != &flatpak_row.flatref_ref_format());
|
!= flatpak_row.flatref_ref_format()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -495,7 +502,7 @@ pub fn flatpak_update_page(
|
|||||||
while let Some(flatpak_ref) = flatpak_user_updates_iter.next() {
|
while let Some(flatpak_ref) = flatpak_user_updates_iter.next() {
|
||||||
let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None;
|
let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None;
|
||||||
while let Ok(remotes) = libflatpak::Installation::list_remotes(
|
while let Ok(remotes) = libflatpak::Installation::list_remotes(
|
||||||
&flatpak_system_installation,
|
&flatpak_user_installation,
|
||||||
cancellable_no,
|
cancellable_no,
|
||||||
) {
|
) {
|
||||||
for remote in remotes {
|
for remote in remotes {
|
||||||
@ -503,7 +510,7 @@ pub fn flatpak_update_page(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
match libflatpak::Installation::fetch_remote_ref_sync(
|
match libflatpak::Installation::fetch_remote_ref_sync(
|
||||||
&flatpak_system_installation,
|
&flatpak_user_installation,
|
||||||
&match remote.name() {
|
&match remote.name() {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
None => continue,
|
None => continue,
|
||||||
@ -565,11 +572,11 @@ pub fn flatpak_update_page(
|
|||||||
is_last: flatpak_user_updates_iter.peek().is_none(),
|
is_last: flatpak_user_updates_iter.peek().is_none(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let flatpak_row = FlatpakRefRow::new(&flatref_struct);
|
||||||
|
|
||||||
user_refs_for_upgrade_vec
|
user_refs_for_upgrade_vec
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(flatpak_ref.format_ref().unwrap().into());
|
.push(flatpak_row.clone());
|
||||||
|
|
||||||
let flatpak_row = FlatpakRefRow::new(&flatref_struct);
|
|
||||||
|
|
||||||
flatpak_row.connect_closure(
|
flatpak_row.connect_closure(
|
||||||
"checkbutton-toggled",
|
"checkbutton-toggled",
|
||||||
@ -598,7 +605,7 @@ pub fn flatpak_update_page(
|
|||||||
));
|
));
|
||||||
user_refs_for_upgrade_vec
|
user_refs_for_upgrade_vec
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(flatpak_row.flatref_ref_format());
|
.push(flatpak_row);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -621,9 +628,10 @@ pub fn flatpak_update_page(
|
|||||||
update_button.set_sensitive(!is_all_children_unmarked(
|
update_button.set_sensitive(!is_all_children_unmarked(
|
||||||
&packages_boxedlist,
|
&packages_boxedlist,
|
||||||
));
|
));
|
||||||
user_refs_for_upgrade_vec
|
user_refs_for_upgrade_vec.borrow_mut().retain(|x| {
|
||||||
.borrow_mut()
|
x.flatref_ref_format()
|
||||||
.retain(|x| x != &flatpak_row.flatref_ref_format());
|
!= flatpak_row.flatref_ref_format()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
|
use crate::flatpak_ref_row::FlatpakRefRow;
|
||||||
use adw::gio::SimpleAction;
|
use adw::gio::SimpleAction;
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use gtk::glib::*;
|
use gtk::glib::*;
|
||||||
use gtk::*;
|
use gtk::*;
|
||||||
use pika_unixsocket_tools::pika_unixsocket_tools::{
|
use libflatpak::prelude::*;
|
||||||
start_socket_server, start_socket_server_no_log,
|
|
||||||
};
|
|
||||||
use pretty_bytes::converter::convert;
|
use pretty_bytes::converter::convert;
|
||||||
use rust_apt::cache::Upgrade;
|
|
||||||
use rust_apt::new_cache;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -17,11 +14,9 @@ use std::rc::Rc;
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
struct AptChangesInfo {
|
struct FlatpakChangesInfo {
|
||||||
package_count_upgrade: u64,
|
system_flatref_count: u64,
|
||||||
package_count_install: u64,
|
user_flatref_count: u64,
|
||||||
package_count_downgrade: u64,
|
|
||||||
package_count_remove: u64,
|
|
||||||
total_download_size: u64,
|
total_download_size: u64,
|
||||||
total_installed_size: i64,
|
total_installed_size: i64,
|
||||||
}
|
}
|
||||||
@ -30,18 +25,12 @@ struct Exclusions {
|
|||||||
exclusions: Vec<Value>,
|
exclusions: Vec<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AptChangesInfo {
|
impl FlatpakChangesInfo {
|
||||||
fn add_upgrade(&mut self) {
|
fn add_system(&mut self) {
|
||||||
self.package_count_upgrade += 1;
|
self.system_flatref_count += 1;
|
||||||
}
|
}
|
||||||
fn add_install(&mut self) {
|
fn add_user(&mut self) {
|
||||||
self.package_count_install += 1;
|
self.user_flatref_count += 1;
|
||||||
}
|
|
||||||
fn add_downgrade(&mut self) {
|
|
||||||
self.package_count_downgrade += 1;
|
|
||||||
}
|
|
||||||
fn add_remove(&mut self) {
|
|
||||||
self.package_count_remove += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increase_total_download_size_by(&mut self, value: u64) {
|
fn increase_total_download_size_by(&mut self, value: u64) {
|
||||||
@ -57,324 +46,143 @@ impl AptChangesInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apt_process_update(
|
pub fn flatpak_process_update(
|
||||||
excluded_updates_vec: &Vec<String>,
|
system_refs_for_upgrade_vec: &Vec<FlatpakRefRow>,
|
||||||
|
user_refs_for_upgrade_vec: &Vec<FlatpakRefRow>,
|
||||||
window: adw::ApplicationWindow,
|
window: adw::ApplicationWindow,
|
||||||
retry_signal_action: &SimpleAction,
|
retry_signal_action: &SimpleAction,
|
||||||
) {
|
) {
|
||||||
let excluded_updates_alert_dialog = adw::MessageDialog::builder()
|
let cancellable = libflatpak::gio::Cancellable::NONE;
|
||||||
.transient_for(&window)
|
// Emulate Flatpak Full Upgrade to get transaction info
|
||||||
.heading(t!("excluded_updates_alert_dialog_heading"))
|
let mut flatpak_changes_struct = FlatpakChangesInfo {
|
||||||
.body(t!("excluded_updates_alert_dialog_body"))
|
system_flatref_count: 0,
|
||||||
.build();
|
user_flatref_count: 0,
|
||||||
|
|
||||||
excluded_updates_alert_dialog.add_response(
|
|
||||||
"excluded_updates_alert_dialog_cancel",
|
|
||||||
&t!("excluded_updates_alert_dialog_cancel_label").to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
excluded_updates_alert_dialog.add_response(
|
|
||||||
"excluded_updates_alert_continue",
|
|
||||||
&t!("excluded_updates_alert_continue_label").to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
excluded_updates_alert_dialog.set_response_appearance(
|
|
||||||
"excluded_updates_alert_continue",
|
|
||||||
adw::ResponseAppearance::Destructive,
|
|
||||||
);
|
|
||||||
|
|
||||||
excluded_updates_alert_dialog.set_default_response(Some("excluded_updates_alert_continue"));
|
|
||||||
|
|
||||||
let excluded_updates_alert_dialog_action =
|
|
||||||
SimpleAction::new("excluded_updates_alert_dialog_action", None);
|
|
||||||
|
|
||||||
excluded_updates_alert_dialog_action.connect_activate(clone!(
|
|
||||||
#[weak]
|
|
||||||
window,
|
|
||||||
#[weak]
|
|
||||||
retry_signal_action,
|
|
||||||
#[strong]
|
|
||||||
excluded_updates_vec,
|
|
||||||
move |_, _| { apt_confirm_window(&excluded_updates_vec, window, &retry_signal_action) }
|
|
||||||
));
|
|
||||||
|
|
||||||
if excluded_updates_vec.is_empty() {
|
|
||||||
excluded_updates_alert_dialog_action.activate(None);
|
|
||||||
} else {
|
|
||||||
excluded_updates_alert_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
|
||||||
if choice == "excluded_updates_alert_continue" {
|
|
||||||
excluded_updates_alert_dialog_action.activate(None);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn apt_confirm_window(
|
|
||||||
excluded_updates_vec: &Vec<String>,
|
|
||||||
window: adw::ApplicationWindow,
|
|
||||||
retry_signal_action: &SimpleAction,
|
|
||||||
) {
|
|
||||||
let to_be_removed_packages_vec: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(Vec::new()));
|
|
||||||
// Emulate Apt Full Upgrade to get transaction info
|
|
||||||
let mut apt_changes_struct = AptChangesInfo {
|
|
||||||
package_count_upgrade: 0,
|
|
||||||
package_count_install: 0,
|
|
||||||
package_count_downgrade: 0,
|
|
||||||
package_count_remove: 0,
|
|
||||||
total_download_size: 0,
|
total_download_size: 0,
|
||||||
total_installed_size: 0,
|
total_installed_size: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let apt_cache = new_cache!().unwrap();
|
let flatpak_system_installation = libflatpak::Installation::new_system(cancellable).unwrap();
|
||||||
let apt_upgrade_cache = new_cache!().unwrap();
|
let flatpak_system_transaction =
|
||||||
|
libflatpak::Transaction::for_installation(&flatpak_system_installation, cancellable)
|
||||||
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
.unwrap();
|
||||||
|
for flatpak_row in system_refs_for_upgrade_vec {
|
||||||
for change in apt_cache.get_changes(false) {
|
flatpak_changes_struct.add_system();
|
||||||
if !excluded_updates_vec
|
//
|
||||||
.iter()
|
let installed_size_installed = flatpak_row.flatref_installed_size_installed();
|
||||||
.any(|e| change.name().contains(e))
|
let installed_size_remote = flatpak_row.flatref_installed_size_installed();
|
||||||
{
|
let installed_download_size = flatpak_row.flatref_download_size();
|
||||||
let pkg = apt_upgrade_cache.get(change.name()).unwrap();
|
let ref_format = flatpak_row.flatref_ref_format();
|
||||||
if change.marked_upgrade() || change.marked_install() || change.marked_downgrade() {
|
//
|
||||||
pkg.mark_install(true, false);
|
flatpak_changes_struct.decrease_total_installed_size_by(installed_size_installed);
|
||||||
} else if change.marked_delete() {
|
flatpak_changes_struct.increase_total_installed_size_by(installed_size_remote);
|
||||||
pkg.mark_delete(false);
|
//
|
||||||
to_be_removed_packages_vec
|
flatpak_changes_struct.increase_total_download_size_by(installed_download_size);
|
||||||
.borrow_mut()
|
//
|
||||||
.push(pkg.name().to_owned());
|
flatpak_system_transaction
|
||||||
}
|
.add_update(&ref_format, &[], None)
|
||||||
pkg.protect();
|
.unwrap();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apt_upgrade_cache.resolve(true).unwrap();
|
let flatpak_user_installation = libflatpak::Installation::new_user(cancellable).unwrap();
|
||||||
|
let flatpak_user_transaction =
|
||||||
println!("{}", t!("gui_changes_emu_msg_0"));
|
libflatpak::Transaction::for_installation(&flatpak_user_installation, cancellable).unwrap();
|
||||||
for change in apt_upgrade_cache.get_changes(false) {
|
for flatpak_row in user_refs_for_upgrade_vec {
|
||||||
if change.is_installed() {
|
flatpak_changes_struct.add_user();
|
||||||
apt_changes_struct
|
//
|
||||||
.decrease_total_installed_size_by(change.installed().unwrap().installed_size());
|
let installed_size_installed = flatpak_row.flatref_installed_size_installed();
|
||||||
}
|
let installed_size_remote = flatpak_row.flatref_installed_size_installed();
|
||||||
if change.marked_upgrade() && change.is_installed() {
|
let installed_download_size = flatpak_row.flatref_download_size();
|
||||||
println!("{}: {}", t!("gui_changes_emu_msg_upgrading"), change.name());
|
let ref_format = flatpak_row.flatref_ref_format();
|
||||||
apt_changes_struct.add_upgrade();
|
//
|
||||||
apt_changes_struct.increase_total_download_size_by(change.candidate().unwrap().size());
|
flatpak_changes_struct.decrease_total_installed_size_by(installed_size_installed);
|
||||||
apt_changes_struct
|
flatpak_changes_struct.increase_total_installed_size_by(installed_size_remote);
|
||||||
.increase_total_installed_size_by(change.candidate().unwrap().installed_size());
|
//
|
||||||
} else if change.marked_install() || change.marked_upgrade() && !change.is_installed() {
|
flatpak_changes_struct.increase_total_download_size_by(installed_download_size);
|
||||||
println!(
|
//
|
||||||
"{}: {}",
|
flatpak_user_transaction
|
||||||
t!("gui_changes_emu_msg_installing"),
|
.add_update(&ref_format, &[], None)
|
||||||
change.name()
|
.unwrap();
|
||||||
);
|
|
||||||
apt_changes_struct.add_install();
|
|
||||||
apt_changes_struct.increase_total_download_size_by(change.candidate().unwrap().size());
|
|
||||||
apt_changes_struct
|
|
||||||
.increase_total_installed_size_by(change.candidate().unwrap().installed_size());
|
|
||||||
} else if change.marked_downgrade() {
|
|
||||||
println!(
|
|
||||||
"{}: {}",
|
|
||||||
t!("gui_changes_emu_msg_downgrading"),
|
|
||||||
change.name()
|
|
||||||
);
|
|
||||||
apt_changes_struct.add_downgrade();
|
|
||||||
apt_changes_struct.increase_total_download_size_by(change.candidate().unwrap().size());
|
|
||||||
apt_changes_struct
|
|
||||||
.increase_total_installed_size_by(change.candidate().unwrap().installed_size());
|
|
||||||
} else if change.marked_delete() {
|
|
||||||
println!("{}: {}", t!("gui_changes_emu_msg_removing"), change.name());
|
|
||||||
apt_changes_struct.add_remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let apt_confirm_dialog_child_box = Box::builder().orientation(Orientation::Vertical).build();
|
let flatpak_confirm_dialog_child_box =
|
||||||
|
Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
|
||||||
let apt_update_dialog_badges_size_group = SizeGroup::new(SizeGroupMode::Both);
|
let flatpak_update_dialog_badges_size_group = SizeGroup::new(SizeGroupMode::Both);
|
||||||
let apt_update_dialog_badges_size_group0 = SizeGroup::new(SizeGroupMode::Both);
|
let flatpak_update_dialog_badges_size_group0 = SizeGroup::new(SizeGroupMode::Both);
|
||||||
let apt_update_dialog_badges_size_group1 = SizeGroup::new(SizeGroupMode::Both);
|
let flatpak_update_dialog_badges_size_group1 = SizeGroup::new(SizeGroupMode::Both);
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
flatpak_confirm_dialog_child_box.append(&create_color_badge(
|
||||||
&t!("package_count_upgrade_badge_label"),
|
&t!("system_flatref_count_badge_label"),
|
||||||
&apt_changes_struct.package_count_upgrade.to_string(),
|
&flatpak_changes_struct.system_flatref_count.to_string(),
|
||||||
"background-accent-bg",
|
"background-accent-bg",
|
||||||
&apt_update_dialog_badges_size_group,
|
&flatpak_update_dialog_badges_size_group,
|
||||||
&apt_update_dialog_badges_size_group0,
|
&flatpak_update_dialog_badges_size_group0,
|
||||||
&apt_update_dialog_badges_size_group1,
|
&flatpak_update_dialog_badges_size_group1,
|
||||||
));
|
));
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
flatpak_confirm_dialog_child_box.append(&create_color_badge(
|
||||||
&t!("package_count_install_badge_label"),
|
&t!("user_flatref_count_badge_label"),
|
||||||
&apt_changes_struct.package_count_install.to_string(),
|
&flatpak_changes_struct.user_flatref_count.to_string(),
|
||||||
"background-accent-bg",
|
"background-accent-bg",
|
||||||
&apt_update_dialog_badges_size_group,
|
&flatpak_update_dialog_badges_size_group,
|
||||||
&apt_update_dialog_badges_size_group0,
|
&flatpak_update_dialog_badges_size_group0,
|
||||||
&apt_update_dialog_badges_size_group1,
|
&flatpak_update_dialog_badges_size_group1,
|
||||||
));
|
));
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
flatpak_confirm_dialog_child_box.append(&create_color_badge(
|
||||||
&t!("package_count_downgrade_badge_label"),
|
|
||||||
&apt_changes_struct.package_count_downgrade.to_string(),
|
|
||||||
"background-accent-bg",
|
|
||||||
&apt_update_dialog_badges_size_group,
|
|
||||||
&apt_update_dialog_badges_size_group0,
|
|
||||||
&apt_update_dialog_badges_size_group1,
|
|
||||||
));
|
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
|
||||||
&t!("package_count_remove_badge_label"),
|
|
||||||
&apt_changes_struct.package_count_remove.to_string(),
|
|
||||||
"background-accent-bg",
|
|
||||||
&apt_update_dialog_badges_size_group,
|
|
||||||
&apt_update_dialog_badges_size_group0,
|
|
||||||
&apt_update_dialog_badges_size_group1,
|
|
||||||
));
|
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
|
||||||
&t!("total_download_size_badge_label"),
|
&t!("total_download_size_badge_label"),
|
||||||
&convert(apt_changes_struct.total_download_size as f64),
|
&convert(flatpak_changes_struct.total_download_size as f64),
|
||||||
"background-accent-bg",
|
"background-accent-bg",
|
||||||
&apt_update_dialog_badges_size_group,
|
&flatpak_update_dialog_badges_size_group,
|
||||||
&apt_update_dialog_badges_size_group0,
|
&flatpak_update_dialog_badges_size_group0,
|
||||||
&apt_update_dialog_badges_size_group1,
|
&flatpak_update_dialog_badges_size_group1,
|
||||||
));
|
));
|
||||||
|
|
||||||
apt_confirm_dialog_child_box.append(&create_color_badge(
|
flatpak_confirm_dialog_child_box.append(&create_color_badge(
|
||||||
&t!("total_installed_size_badge_label"),
|
&t!("total_installed_size_badge_label"),
|
||||||
&convert(apt_changes_struct.total_installed_size as f64),
|
&convert(flatpak_changes_struct.total_installed_size as f64),
|
||||||
"background-accent-bg",
|
"background-accent-bg",
|
||||||
&apt_update_dialog_badges_size_group,
|
&flatpak_update_dialog_badges_size_group,
|
||||||
&apt_update_dialog_badges_size_group0,
|
&flatpak_update_dialog_badges_size_group0,
|
||||||
&apt_update_dialog_badges_size_group1,
|
&flatpak_update_dialog_badges_size_group1,
|
||||||
));
|
));
|
||||||
|
|
||||||
let apt_confirm_dialog = adw::MessageDialog::builder()
|
let flatpak_confirm_dialog = adw::MessageDialog::builder()
|
||||||
.transient_for(&window)
|
.transient_for(&window)
|
||||||
.heading(t!("apt_confirm_dialog_heading"))
|
.heading(t!("flatpak_confirm_dialog_heading"))
|
||||||
.body(t!("apt_confirm_dialog_body"))
|
.body(t!("flatpak_confirm_dialog_body"))
|
||||||
.extra_child(&apt_confirm_dialog_child_box)
|
.extra_child(&flatpak_confirm_dialog_child_box)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
apt_confirm_dialog.add_response(
|
flatpak_confirm_dialog.add_response(
|
||||||
"apt_confirm_dialog_cancel",
|
"flatpak_confirm_dialog_cancel",
|
||||||
&t!("apt_confirm_dialog_cancel_label").to_string(),
|
&t!("flatpak_confirm_dialog_cancel_label").to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
apt_confirm_dialog.add_response(
|
flatpak_confirm_dialog.add_response(
|
||||||
"apt_confirm_dialog_confirm",
|
"flatpak_confirm_dialog_confirm",
|
||||||
&t!("apt_confirm_dialog_confirm_label").to_string(),
|
&t!("flatpak_confirm_dialog_confirm_label").to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
apt_confirm_dialog.set_response_appearance(
|
flatpak_confirm_dialog.set_response_appearance(
|
||||||
"apt_confirm_dialog_confirm",
|
"flatpak_confirm_dialog_confirm",
|
||||||
adw::ResponseAppearance::Destructive,
|
adw::ResponseAppearance::Destructive,
|
||||||
);
|
);
|
||||||
|
|
||||||
apt_confirm_dialog.set_default_response(Some("apt_confirm_dialog_confirm"));
|
flatpak_confirm_dialog.set_default_response(Some("flatpak_confirm_dialog_confirm"));
|
||||||
apt_confirm_dialog.set_close_response("apt_confirm_dialog_cancel");
|
flatpak_confirm_dialog.set_close_response("flatpak_confirm_dialog_cancel");
|
||||||
|
|
||||||
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
|
||||||
|
|
||||||
if Path::new(json_file_path).exists() {
|
|
||||||
std::fs::remove_file(json_file_path).expect("Failed to remove old json file");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !excluded_updates_vec.is_empty() {
|
|
||||||
let exclusions_array = Exclusions {
|
|
||||||
exclusions: excluded_updates_vec
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| serde_json::from_str(format!("{{\"package\":\"{}\"}}", i).as_str()))
|
|
||||||
.collect::<Result<Vec<Value>, _>>()
|
|
||||||
.unwrap(),
|
|
||||||
};
|
|
||||||
|
|
||||||
std::fs::write(
|
|
||||||
json_file_path,
|
|
||||||
serde_json::to_string_pretty(&exclusions_array).unwrap(),
|
|
||||||
)
|
|
||||||
.expect("Failed to write to json file");
|
|
||||||
}
|
|
||||||
|
|
||||||
let apt_confirm_start_signal_action = SimpleAction::new("apt_confirm_start", None);
|
|
||||||
|
|
||||||
apt_confirm_start_signal_action.connect_activate(clone!(
|
|
||||||
#[weak]
|
|
||||||
window,
|
|
||||||
#[strong]
|
|
||||||
retry_signal_action,
|
|
||||||
#[strong]
|
|
||||||
apt_confirm_dialog,
|
|
||||||
move |_, _| {
|
|
||||||
let retry_signal_action0 = retry_signal_action.clone();
|
let retry_signal_action0 = retry_signal_action.clone();
|
||||||
apt_confirm_dialog
|
flatpak_confirm_dialog
|
||||||
.clone()
|
.clone()
|
||||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||||
if choice == "apt_confirm_dialog_confirm" {
|
if choice == "flatpak_confirm_dialog_confirm" {
|
||||||
apt_full_upgrade_from_socket(window, &retry_signal_action0);
|
//flatpak_full_upgrade_from_socket(window, &retry_signal_action0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
));
|
|
||||||
|
|
||||||
let to_be_removed_packages_borrow = to_be_removed_packages_vec.borrow();
|
fn flatpak_full_upgrade_from_socket(
|
||||||
if to_be_removed_packages_borrow.is_empty() {
|
|
||||||
apt_confirm_start_signal_action.activate(None);
|
|
||||||
} else {
|
|
||||||
let apt_remove_confirm_text_buffer = TextBuffer::builder()
|
|
||||||
.text(
|
|
||||||
to_be_removed_packages_borrow
|
|
||||||
.iter()
|
|
||||||
.map(|x| x.to_string() + "\n")
|
|
||||||
.collect::<String>()
|
|
||||||
+ "\n",
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let apt_remove_confirm_text_view = TextView::builder()
|
|
||||||
.buffer(&apt_remove_confirm_text_buffer)
|
|
||||||
.hexpand(true)
|
|
||||||
.vexpand(true)
|
|
||||||
.margin_top(15)
|
|
||||||
.margin_bottom(15)
|
|
||||||
.margin_start(15)
|
|
||||||
.margin_end(15)
|
|
||||||
.editable(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let apt_remove_confirm_dialog = adw::MessageDialog::builder()
|
|
||||||
.transient_for(&window)
|
|
||||||
.heading(t!("apt_remove_confirm_dialog_heading"))
|
|
||||||
.body(t!("apt_remove_confirm_dialog_body"))
|
|
||||||
.extra_child(&apt_remove_confirm_text_view)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
apt_remove_confirm_dialog.add_response(
|
|
||||||
"apt_remove_confirm_dialog_cancel",
|
|
||||||
&t!("apt_remove_confirm_dialog_cancel_label").to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
apt_remove_confirm_dialog.add_response(
|
|
||||||
"apt_remove_confirm_dialog_confirm",
|
|
||||||
&t!("apt_remove_confirm_dialog_confirm_label").to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
apt_remove_confirm_dialog.set_response_appearance(
|
|
||||||
"apt_remove_confirm_dialog_confirm",
|
|
||||||
adw::ResponseAppearance::Destructive,
|
|
||||||
);
|
|
||||||
|
|
||||||
apt_remove_confirm_dialog.set_default_response(Some("apt_remove_confirm_dialog_confirm"));
|
|
||||||
apt_remove_confirm_dialog.set_close_response("apt_remove_confirm_dialog_cancel");
|
|
||||||
|
|
||||||
apt_remove_confirm_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
|
||||||
if choice == "apt_remove_confirm_dialog_confirm" {
|
|
||||||
apt_confirm_start_signal_action.activate(None);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn apt_full_upgrade_from_socket(
|
|
||||||
window: adw::ApplicationWindow,
|
window: adw::ApplicationWindow,
|
||||||
retry_signal_action: &SimpleAction,
|
retry_signal_action: &SimpleAction,
|
||||||
) {
|
) {
|
||||||
@ -385,55 +193,18 @@ fn apt_full_upgrade_from_socket(
|
|||||||
let upgrade_status_sender_clone0 = upgrade_status_sender.clone();
|
let upgrade_status_sender_clone0 = upgrade_status_sender.clone();
|
||||||
|
|
||||||
let log_file_path = format!(
|
let log_file_path = format!(
|
||||||
"/tmp/pika-apt-upgrade_{}.log",
|
"/tmp/pika-flatpak-upgrade_{}.log",
|
||||||
chrono::offset::Local::now().format("%Y-%m-%d_%H:%M")
|
chrono::offset::Local::now().format("%Y-%m-%d_%H:%M")
|
||||||
);
|
);
|
||||||
let log_file_path_clone0 = log_file_path.clone();
|
let log_file_path_clone0 = log_file_path.clone();
|
||||||
|
|
||||||
thread::spawn(move || {
|
let flatpak_upgrade_dialog_child_box =
|
||||||
Runtime::new().unwrap().block_on(start_socket_server_no_log(
|
Box::builder().orientation(Orientation::Vertical).build();
|
||||||
upgrade_percent_sender,
|
|
||||||
"/tmp/pika_apt_upgrade_percent.sock",
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
let flatpak_upgrade_dialog_progress_bar =
|
||||||
Runtime::new().unwrap().block_on(start_socket_server(
|
|
||||||
upgrade_status_sender,
|
|
||||||
"/tmp/pika_apt_upgrade_status.sock",
|
|
||||||
&log_file_path,
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
let apt_upgrade_command = Command::new("pkexec")
|
|
||||||
.args([
|
|
||||||
"/home/ward/RustroverProjects/pkg-pikman-update-manager/target/debug/apt_full_upgrade",
|
|
||||||
])
|
|
||||||
.status()
|
|
||||||
.unwrap();
|
|
||||||
match apt_upgrade_command.code().unwrap() {
|
|
||||||
0 => upgrade_status_sender_clone0
|
|
||||||
.send_blocking("FN_OVERRIDE_SUCCESSFUL".to_owned())
|
|
||||||
.unwrap(),
|
|
||||||
53 => {}
|
|
||||||
_ => {
|
|
||||||
upgrade_status_sender_clone0
|
|
||||||
.send_blocking(t!("upgrade_status_error_perms").to_string())
|
|
||||||
.unwrap();
|
|
||||||
upgrade_status_sender_clone0
|
|
||||||
.send_blocking("FN_OVERRIDE_FAILED".to_owned())
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let apt_upgrade_dialog_child_box = Box::builder().orientation(Orientation::Vertical).build();
|
|
||||||
|
|
||||||
let apt_upgrade_dialog_progress_bar =
|
|
||||||
ProgressBar::builder().show_text(true).hexpand(true).build();
|
ProgressBar::builder().show_text(true).hexpand(true).build();
|
||||||
|
|
||||||
let apt_upgrade_dialog_spinner = Spinner::builder()
|
let flatpak_upgrade_dialog_spinner = Spinner::builder()
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.valign(Align::Start)
|
.valign(Align::Start)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
@ -442,31 +213,31 @@ fn apt_full_upgrade_from_socket(
|
|||||||
.width_request(128)
|
.width_request(128)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
apt_upgrade_dialog_child_box.append(&apt_upgrade_dialog_spinner);
|
flatpak_upgrade_dialog_child_box.append(&flatpak_upgrade_dialog_spinner);
|
||||||
apt_upgrade_dialog_child_box.append(&apt_upgrade_dialog_progress_bar);
|
flatpak_upgrade_dialog_child_box.append(&flatpak_upgrade_dialog_progress_bar);
|
||||||
|
|
||||||
let apt_upgrade_dialog = adw::MessageDialog::builder()
|
let flatpak_upgrade_dialog = adw::MessageDialog::builder()
|
||||||
.transient_for(&window)
|
.transient_for(&window)
|
||||||
.extra_child(&apt_upgrade_dialog_child_box)
|
.extra_child(&flatpak_upgrade_dialog_child_box)
|
||||||
.heading(t!("apt_upgrade_dialog_heading"))
|
.heading(t!("flatpak_upgrade_dialog_heading"))
|
||||||
.width_request(500)
|
.width_request(500)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
apt_upgrade_dialog.add_response(
|
flatpak_upgrade_dialog.add_response(
|
||||||
"apt_upgrade_dialog_ok",
|
"flatpak_upgrade_dialog_ok",
|
||||||
&t!("apt_upgrade_dialog_ok_label").to_string(),
|
&t!("flatpak_upgrade_dialog_ok_label").to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let apt_upgrade_dialog_child_box_done =
|
let flatpak_upgrade_dialog_child_box_done =
|
||||||
Box::builder().orientation(Orientation::Vertical).build();
|
Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
|
||||||
let apt_upgrade_log_image = Image::builder()
|
let flatpak_upgrade_log_image = Image::builder()
|
||||||
.pixel_size(128)
|
.pixel_size(128)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let apt_upgrade_log_button = Button::builder()
|
let flatpak_upgrade_log_button = Button::builder()
|
||||||
.label(t!("apt_upgrade_dialog_open_log_file_label"))
|
.label(t!("flatpak_upgrade_dialog_open_log_file_label"))
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.margin_start(15)
|
.margin_start(15)
|
||||||
.margin_end(15)
|
.margin_end(15)
|
||||||
@ -474,23 +245,23 @@ fn apt_full_upgrade_from_socket(
|
|||||||
.margin_bottom(15)
|
.margin_bottom(15)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
apt_upgrade_dialog_child_box_done.append(&apt_upgrade_log_image);
|
flatpak_upgrade_dialog_child_box_done.append(&flatpak_upgrade_log_image);
|
||||||
apt_upgrade_dialog_child_box_done.append(&apt_upgrade_log_button);
|
flatpak_upgrade_dialog_child_box_done.append(&flatpak_upgrade_log_button);
|
||||||
|
|
||||||
apt_upgrade_dialog.set_response_enabled("apt_upgrade_dialog_ok", false);
|
flatpak_upgrade_dialog.set_response_enabled("flatpak_upgrade_dialog_ok", false);
|
||||||
apt_upgrade_dialog.set_close_response("apt_upgrade_dialog_ok");
|
flatpak_upgrade_dialog.set_close_response("flatpak_upgrade_dialog_ok");
|
||||||
|
|
||||||
let upgrade_percent_server_context = MainContext::default();
|
let upgrade_percent_server_context = MainContext::default();
|
||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
upgrade_percent_server_context.spawn_local(clone!(
|
upgrade_percent_server_context.spawn_local(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
apt_upgrade_dialog_progress_bar,
|
flatpak_upgrade_dialog_progress_bar,
|
||||||
async move {
|
async move {
|
||||||
while let Ok(state) = upgrade_percent_receiver.recv().await {
|
while let Ok(state) = upgrade_percent_receiver.recv().await {
|
||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {}
|
"FN_OVERRIDE_SUCCESSFUL" => {}
|
||||||
_ => match state.parse::<f64>() {
|
_ => match state.parse::<f64>() {
|
||||||
Ok(p) => apt_upgrade_dialog_progress_bar.set_fraction(p / 100.0),
|
Ok(p) => flatpak_upgrade_dialog_progress_bar.set_fraction(p / 100.0),
|
||||||
Err(_) => {}
|
Err(_) => {}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -502,38 +273,41 @@ fn apt_full_upgrade_from_socket(
|
|||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
upgrade_status_server_context.spawn_local(clone!(
|
upgrade_status_server_context.spawn_local(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
apt_upgrade_dialog,
|
flatpak_upgrade_dialog,
|
||||||
#[weak]
|
#[weak]
|
||||||
apt_upgrade_dialog_child_box,
|
flatpak_upgrade_dialog_child_box,
|
||||||
#[strong]
|
#[strong]
|
||||||
apt_upgrade_dialog_child_box_done,
|
flatpak_upgrade_dialog_child_box_done,
|
||||||
#[strong]
|
#[strong]
|
||||||
apt_upgrade_log_image,
|
flatpak_upgrade_log_image,
|
||||||
async move {
|
async move {
|
||||||
while let Ok(state) = upgrade_status_receiver.recv().await {
|
while let Ok(state) = upgrade_status_receiver.recv().await {
|
||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {
|
"FN_OVERRIDE_SUCCESSFUL" => {
|
||||||
apt_upgrade_dialog_child_box.set_visible(false);
|
flatpak_upgrade_dialog_child_box.set_visible(false);
|
||||||
apt_upgrade_log_image.set_icon_name(Some("face-cool-symbolic"));
|
flatpak_upgrade_log_image.set_icon_name(Some("face-cool-symbolic"));
|
||||||
apt_upgrade_dialog
|
flatpak_upgrade_dialog
|
||||||
.set_extra_child(Some(&apt_upgrade_dialog_child_box_done));
|
.set_extra_child(Some(&flatpak_upgrade_dialog_child_box_done));
|
||||||
apt_upgrade_dialog.set_title(Some(
|
flatpak_upgrade_dialog.set_title(Some(
|
||||||
&t!("apt_upgrade_dialog_status_successful").to_string(),
|
&t!("flatpak_upgrade_dialog_status_successful").to_string(),
|
||||||
));
|
));
|
||||||
apt_upgrade_dialog.set_response_enabled("apt_upgrade_dialog_ok", true);
|
flatpak_upgrade_dialog
|
||||||
|
.set_response_enabled("flatpak_upgrade_dialog_ok", true);
|
||||||
}
|
}
|
||||||
"FN_OVERRIDE_FAILED" => {
|
"FN_OVERRIDE_FAILED" => {
|
||||||
apt_upgrade_dialog_child_box.set_visible(false);
|
flatpak_upgrade_dialog_child_box.set_visible(false);
|
||||||
apt_upgrade_log_image.set_icon_name(Some("dialog-error-symbolic"));
|
flatpak_upgrade_log_image.set_icon_name(Some("dialog-error-symbolic"));
|
||||||
apt_upgrade_dialog
|
flatpak_upgrade_dialog
|
||||||
.set_extra_child(Some(&apt_upgrade_dialog_child_box_done));
|
.set_extra_child(Some(&flatpak_upgrade_dialog_child_box_done));
|
||||||
apt_upgrade_dialog
|
flatpak_upgrade_dialog.set_title(Some(
|
||||||
.set_title(Some(&t!("apt_upgrade_dialog_status_failed").to_string()));
|
&t!("flatpak_upgrade_dialog_status_failed").to_string(),
|
||||||
apt_upgrade_dialog.set_response_enabled("apt_upgrade_dialog_ok", true);
|
));
|
||||||
apt_upgrade_dialog
|
flatpak_upgrade_dialog
|
||||||
.set_response_enabled("apt_upgrade_dialog_open_log_file", true);
|
.set_response_enabled("flatpak_upgrade_dialog_ok", true);
|
||||||
|
flatpak_upgrade_dialog
|
||||||
|
.set_response_enabled("flatpak_upgrade_dialog_open_log_file", true);
|
||||||
}
|
}
|
||||||
_ => apt_upgrade_dialog.set_body(&state),
|
_ => flatpak_upgrade_dialog.set_body(&state),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,15 +315,15 @@ fn apt_full_upgrade_from_socket(
|
|||||||
|
|
||||||
let retry_signal_action0 = retry_signal_action.clone();
|
let retry_signal_action0 = retry_signal_action.clone();
|
||||||
|
|
||||||
apt_upgrade_log_button.connect_clicked(move |_| {
|
flatpak_upgrade_log_button.connect_clicked(move |_| {
|
||||||
let _ = Command::new("xdg-open")
|
let _ = Command::new("xdg-open")
|
||||||
.arg(log_file_path_clone0.to_owned())
|
.arg(log_file_path_clone0.to_owned())
|
||||||
.spawn();
|
.spawn();
|
||||||
});
|
});
|
||||||
|
|
||||||
apt_upgrade_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
flatpak_upgrade_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
||||||
match choice.as_str() {
|
match choice.as_str() {
|
||||||
"apt_upgrade_dialog_ok" => {
|
"flatpak_upgrade_dialog_ok" => {
|
||||||
retry_signal_action0.activate(None);
|
retry_signal_action0.activate(None);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user