Compare commits

...

2 Commits

Author SHA1 Message Date
Ward from fusion-voyager-3
edec6d5048 try fixing resize 2024-09-27 17:58:55 +03:00
Ward from fusion-voyager-3
e6c08cc200 Attempt to fix legacy repo 2024-09-24 21:56:20 +03:00
7 changed files with 300 additions and 16 deletions

4
Cargo.lock generated
View File

@ -1071,8 +1071,8 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "legacy-apt-list-tools-rs" name = "legacy-apt-list-tools-rs"
version = "0.1.0" version = "0.1.1"
source = "git+https://github.com/CosmicFusion/legacy-apt-list-tools-rs#0606e8431239a45a14cddc9934ad3eab46e4bb99" source = "git+https://github.com/CosmicFusion/legacy-apt-list-tools-rs#f6ad0545a2cc32bda63ba4d72f99374644c3abf9"
dependencies = [ dependencies = [
"apt-sources-lists", "apt-sources-lists",
] ]

View File

@ -27,7 +27,7 @@ async-channel = "2.1.1"
rust-i18n = "3.0.1" rust-i18n = "3.0.1"
rust-apt = { git = "https://gitlab.com/volian/rust-apt" } rust-apt = { git = "https://gitlab.com/volian/rust-apt" }
apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" } apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" }
apt-legacy-tools = { package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" } apt-legacy-tools = { version = "0.1.1", package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" }
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
tokio-uds = "0.2" tokio-uds = "0.2"
serde = { version = "1.0.203", features = ["derive"] } serde = { version = "1.0.203", features = ["derive"] }

View File

@ -120,5 +120,7 @@
"apt_src_remove_warning_dialog_ok_label": "OK", "apt_src_remove_warning_dialog_ok_label": "OK",
"unofficial_source_add_is_enabled_label_label": "Enabled", "unofficial_source_add_is_enabled_label_label": "Enabled",
"unofficial_source_edit_dialog_add_edit": "Save Changes", "unofficial_source_edit_dialog_add_edit": "Save Changes",
"unofficial_source_edit_dialog_heading": "Editing" "unofficial_source_edit_dialog_heading": "Editing",
"unofficial_source_add_legacy_options_prefrencesgroup_title": "Options",
"unofficial_source_add_is_legacy_source_label_label": "Is A Source Repository"
} }

View File

@ -0,0 +1,271 @@
use crate::apt_package_row::AptPackageRow;
use adw::gio::SimpleAction;
use adw::prelude::*;
use apt_legacy_tools::LegacyAptSource;
use regex::Regex;
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
use gtk::*;
use std::cell::Ref;
use std::ops::Deref;
use pika_unixsocket_tools::pika_unixsocket_tools::*;
use rust_apt::cache::*;
use rust_apt::new_cache;
use rust_apt::records::RecordField;
use std::cell::RefCell;
use std::process::Command;
use std::rc::Rc;
use std::thread;
use tokio::runtime::Runtime;
use std::path::Path;
pub fn legacy_edit_dialog_fn(
window: adw::ApplicationWindow,
legacy_repo: &LegacyAptSource,
reload_action: &gio::SimpleAction,
) {
let repofile_path = Path::new(&legacy_repo.filepath);
let repo_file_name = repofile_path
.file_name()
.unwrap()
.to_str()
.unwrap()
.trim_end_matches(".list")
.to_owned();
let unofficial_source_add_dialog_child_box = Box::builder()
.hexpand(true)
.orientation(Orientation::Vertical)
.build();
let unofficial_source_add_uri_entry = gtk::Entry::builder()
.build();
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
.build();
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
let unofficial_source_add_suites_entry = gtk::Entry::builder()
.build();
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
.build();
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
let unofficial_source_add_components_entry = gtk::Entry::builder()
.build();
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
.build();
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
let unofficial_source_add_legacy_options_entry = gtk::Entry::builder()
.build();
let unofficial_source_add_legacy_options_prefrencesgroup = adw::PreferencesGroup::builder()
.title(t!("unofficial_source_add_legacy_options_prefrencesgroup_title"))
.build();
unofficial_source_add_legacy_options_prefrencesgroup.add(&unofficial_source_add_legacy_options_entry);
let unofficial_source_add_box2 = gtk::Box::builder()
.margin_top(10)
.orientation(Orientation::Horizontal)
.hexpand(true)
.spacing(5)
.build();
let unofficial_source_add_is_source_label = gtk::Label::builder()
.label(t!("unofficial_source_add_is_legacy_source_label_label"))
.halign(Align::Start)
.valign(Align::Center)
.build();
let unofficial_source_add_is_enabled_label = gtk::Label::builder()
.label(t!("unofficial_source_add_is_enabled_label_label"))
.halign(Align::Start)
.valign(Align::Center)
.build();
let unofficial_source_add_is_source_switch = gtk::Switch::builder()
.halign(Align::Start)
.valign(Align::Center)
.build();
let unofficial_source_add_is_enabled_switch = gtk::Switch::builder()
.halign(Align::Start)
.valign(Align::Center)
.build();
//
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
.child(&unofficial_source_add_dialog_child_box)
.maximum_size(500)
.build();
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
.hexpand(true)
.vexpand(true)
.child(&unofficial_source_add_dialog_child_clamp)
.hscrollbar_policy(PolicyType::Never)
.build();
let unofficial_source_add_dialog = adw::MessageDialog::builder()
.transient_for(&window)
.extra_child(&unofficial_source_add_viewport)
.heading(t!("unofficial_source_edit_dialog_heading").to_string() + " " + &repo_file_name)
.width_request(700)
.height_request(500)
.build();
unofficial_source_add_dialog.add_response(
"unofficial_source_edit_dialog_edit",
&t!("unofficial_source_edit_dialog_add_edit").to_string(),
);
unofficial_source_add_dialog.add_response(
"unofficial_source_add_dialog_cancel",
&t!("unofficial_source_add_dialog_cancel_label").to_string(),
);
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
unofficial_source_add_dialog.set_response_appearance(
"unofficial_source_add_dialog_cancel",
adw::ResponseAppearance::Destructive,
);
unofficial_source_add_dialog.set_response_appearance(
"unofficial_source_edit_dialog_edit",
adw::ResponseAppearance::Suggested,
);
//
let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone();
let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone();
let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone();
let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone();
let add_button_update_state = move || {
if
!unofficial_source_add_uri_entry_clone0.text().is_empty() &&
!unofficial_source_add_suites_entry_clone0.text().is_empty() &&
!unofficial_source_add_components_entry_clone0.text().is_empty()
{
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
} else {
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
}
};
//
for entry in [
&unofficial_source_add_uri_entry,
&unofficial_source_add_suites_entry,
&unofficial_source_add_components_entry,
&unofficial_source_add_legacy_options_entry,
] {
entry.connect_text_notify(clone!(
#[strong]
add_button_update_state,
move |_|
{
add_button_update_state();
}
)
);
}
//
unofficial_source_add_box2.append(&unofficial_source_add_is_source_label);
unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch);
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_label);
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_switch);
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup);
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup);
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup);
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2);
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_legacy_options_prefrencesgroup);
//
unofficial_source_add_uri_entry.set_text(&legacy_repo.url);
unofficial_source_add_suites_entry.set_text(&legacy_repo.suite);
unofficial_source_add_components_entry.set_text(&legacy_repo.components);
match &legacy_repo.options {
Some(t) => {
unofficial_source_add_legacy_options_entry.set_text(&t);
}
None => {}
}
unofficial_source_add_is_enabled_switch.set_active(legacy_repo.enabled);
unofficial_source_add_is_source_switch.set_active(legacy_repo.is_source);
//
let legacy_repo_clone0 = legacy_repo.clone();
let reload_action_clone0 = reload_action.clone();
unofficial_source_add_dialog.clone()
.choose(None::<&gio::Cancellable>, move |choice| {
match choice.as_str() {
"unofficial_source_edit_dialog_edit" => {
let new_repo = LegacyAptSource {
url: unofficial_source_add_uri_entry.text().to_string(),
is_source: unofficial_source_add_is_source_switch.is_active(),
suite: unofficial_source_add_suites_entry.text().to_string(),
components: unofficial_source_add_components_entry.text().to_string(),
options: Some(unofficial_source_add_legacy_options_entry.text().to_string()),
enabled: unofficial_source_add_is_enabled_switch.is_active(),
..legacy_repo_clone0
};
/*match LegacyAptSource::save_to_file(new_repo.clone(), LegacyAptSource::get_legacy_sources().unwrap(), &format!("/tmp/{}.list", repo_file_name)) {
Ok(_) => {
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "legacy_move", repo_file_name).run() {
Ok(_) => {}
Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder()
.heading(t!("apt_src_create_error_dialog_heading"))
.body(e.to_string())
.build();
apt_src_create_error_dialog.add_response(
"apt_src_create_error_dialog_ok",
&t!("apt_src_create_error_dialog_ok_label").to_string(),
);
apt_src_create_error_dialog.present();
}
}
reload_action_clone0.activate(None);
}
Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder()
.heading(t!("apt_src_create_error_dialog_heading"))
.body(e.to_string())
.build();
apt_src_create_error_dialog.add_response(
"apt_src_create_error_dialog_ok",
&t!("apt_src_create_error_dialog_ok_label").to_string(),
);
apt_src_create_error_dialog.present();
reload_action_clone0.activate(None);
}
}*/
dbg!(&new_repo);
LegacyAptSource::save_to_file(new_repo.clone(), LegacyAptSource::get_legacy_sources().unwrap(), &format!("/tmp/{}.list", repo_file_name)).unwrap();
}
_ => {}
}
});
}

View File

@ -20,6 +20,7 @@ use tokio::runtime::Runtime;
mod add_dialog; mod add_dialog;
mod deb822_edit_dialog; mod deb822_edit_dialog;
mod legacy_edit_dialog;
enum AptSourceConfig { enum AptSourceConfig {
Legacy(apt_legacy_tools::LegacyAptSource), Legacy(apt_legacy_tools::LegacyAptSource),
@ -349,7 +350,9 @@ pub fn apt_manage_page(
AptSourceConfig::DEB822(src) => { AptSourceConfig::DEB822(src) => {
deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &reload_unofficial_action); deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &reload_unofficial_action);
} }
AptSourceConfig::Legacy(list) => {} AptSourceConfig::Legacy(list) => {
legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &reload_unofficial_action)
}
}; };
} }

View File

@ -5,7 +5,7 @@ use crate::flatpak_update_page;
use adw::prelude::*; use adw::prelude::*;
use adw::*; use adw::*;
use gtk::glib::{clone, MainContext}; use gtk::glib::{clone, MainContext};
use gtk::License; use gtk::{License, WindowControls};
use std::cell::RefCell; use std::cell::RefCell;
use std::process::Command; use std::process::Command;
use std::rc::Rc; use std::rc::Rc;
@ -66,7 +66,7 @@ pub fn build_ui(app: &Application) {
let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length( let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(
BreakpointConditionLengthType::MaxWidth, BreakpointConditionLengthType::MaxWidth,
800.0, 1100.0,
LengthUnit::Px, LengthUnit::Px,
)); ));
@ -90,11 +90,19 @@ pub fn build_ui(app: &Application) {
.stack(&window_adw_stack) .stack(&window_adw_stack)
.build(); .build();
let window_adw_view_switcher_sidebar_control_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.margin_top(10)
.margin_bottom(20)
.margin_start(5)
.margin_end(5)
.build();
window_adw_view_switcher_sidebar_control_box.append(&WindowControls::builder().build());
window_adw_view_switcher_sidebar_control_box.append(&WindowTitle::builder().title(t!("application_name")).build());
let window_adw_view_switcher_sidebar_box = gtk::Box::new(gtk::Orientation::Vertical, 0); let window_adw_view_switcher_sidebar_box = gtk::Box::new(gtk::Orientation::Vertical, 0);
window_adw_view_switcher_sidebar_box.append(&WindowTitle::builder().title(t!("application_name")).margin_top(20).margin_bottom(20).margin_start(5).margin_end(5).build()); window_adw_view_switcher_sidebar_box.append(&window_adw_view_switcher_sidebar_control_box);
window_adw_view_switcher_sidebar_box.append(&window_adw_view_switcher_sidebar); //window_adw_view_switcher_sidebar_box.append(&window_adw_view_switcher_sidebar);
let window_adw_view_sidebar_navigation_page = adw::NavigationPage::new(&window_adw_view_switcher_sidebar_box, "sidebar_view");
let sidebar_toggle_button = gtk::ToggleButton::builder() let sidebar_toggle_button = gtk::ToggleButton::builder()
.icon_name("view-right-pane-symbolic") .icon_name("view-right-pane-symbolic")
@ -105,7 +113,7 @@ pub fn build_ui(app: &Application) {
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.content(&window_toolbar) .content(&window_toolbar)
.sidebar(&window_adw_view_sidebar_navigation_page) .sidebar(&window_adw_view_switcher_sidebar_box)
.max_sidebar_width(300.0) .max_sidebar_width(300.0)
.min_sidebar_width(300.0) .min_sidebar_width(300.0)
.enable_hide_gesture(true) .enable_hide_gesture(true)
@ -152,8 +160,8 @@ pub fn build_ui(app: &Application) {
.default_width(glib_settings.int("window-width")) .default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height")) .default_height(glib_settings.int("window-height"))
// //
.width_request(700) .width_request(1000)
.height_request(500) .height_request(700)
.content(&window_content_page_split_view) .content(&window_content_page_split_view)
// Startup // Startup
.startup_id(APP_ID) .startup_id(APP_ID)

View File

@ -24,10 +24,10 @@ struct FlatpakChangesInfo {
total_download_size: u64, total_download_size: u64,
total_installed_size: i64, total_installed_size: i64,
} }
#[derive(Serialize)] /*#[derive(Serialize)]
struct Exclusions { struct Exclusions {
exclusions: Vec<Value>, exclusions: Vec<Value>,
} }*/
impl FlatpakChangesInfo { impl FlatpakChangesInfo {
fn add_system(&mut self) { fn add_system(&mut self) {