Compare commits
No commits in common. "40c0a64c85861c9b3544c79b5ed173ab7689a82a" and "51cceb495577f76f9bff64eecc86f76ac20770aa" have entirely different histories.
40c0a64c85
...
51cceb4955
2
.github/release-nest-v3
vendored
2
.github/release-nest-v3
vendored
@ -1 +1 @@
|
||||
11
|
||||
9
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1736,7 +1736,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "pikman-update-manager"
|
||||
version = "1.0.1"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-trait",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pikman-update-manager"
|
||||
version = "1.0.1"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -13,13 +13,12 @@
|
||||
<default>false</default>
|
||||
<summary>Default window maximized behaviour</summary>
|
||||
</key>
|
||||
<key name="check-for-updates" type="b">
|
||||
<key type="b" name="startup-show">
|
||||
<default>true</default>
|
||||
<summary>Default window maximized behaviour</summary>
|
||||
</key>
|
||||
<key name="update-interval" type="i">
|
||||
<default>22000000</default>
|
||||
<summary>Update intervals in ms</summary>
|
||||
<summary>Show PikaOS Welcome on startup.</summary>
|
||||
<description>
|
||||
Show PikaOS Welcome on startup.
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -1,4 +1,4 @@
|
||||
pikman-update-manager (1.0.1-100pika2) pikauwu; urgency=medium
|
||||
pikman-update-manager (1.0.0-100pika4) pikauwu; urgency=medium
|
||||
|
||||
* initial release
|
||||
|
||||
|
2
main.sh
2
main.sh
@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="1.0.1"
|
||||
VERSION="1.0.0"
|
||||
|
||||
source ./pika-build-config.sh
|
||||
|
||||
|
@ -457,25 +457,23 @@ pub fn apt_manage_page(
|
||||
let item = selection.downcast_ref::<BoxedAnyObject>().unwrap();
|
||||
let apt_src: Ref<AptSourceConfig> = item.borrow();
|
||||
match apt_src.deref() {
|
||||
AptSourceConfig::DEB822(src) => match &src.signed_by {
|
||||
Some(t) => {
|
||||
_command = duct::cmd!(
|
||||
AptSourceConfig::DEB822(src) => {
|
||||
match &src.signed_by {
|
||||
Some(t) => _command = duct::cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
|
||||
"delete_deb822",
|
||||
&src.filepath,
|
||||
t
|
||||
)
|
||||
}
|
||||
None => {
|
||||
_command = duct::cmd!(
|
||||
),
|
||||
None => _command = duct::cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
|
||||
"delete_legacy",
|
||||
&src.filepath
|
||||
)
|
||||
),
|
||||
}
|
||||
}
|
||||
},
|
||||
AptSourceConfig::Legacy(list) => {
|
||||
_command = duct::cmd!(
|
||||
"pkexec",
|
||||
|
@ -11,9 +11,6 @@ use ksni;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -86,30 +83,15 @@ impl ksni::Tray for PikmanTray {
|
||||
}
|
||||
}
|
||||
|
||||
enum ConstantLoopMessage {
|
||||
InternetStatus(bool),
|
||||
RefreshRequest,
|
||||
}
|
||||
|
||||
pub fn build_ui(app: &Application) {
|
||||
// setup glib
|
||||
glib::set_prgname(Some(t!("application_name").to_string()));
|
||||
glib::set_application_name(&t!("application_name").to_string());
|
||||
let glib_settings = gio::Settings::new(APP_ID);
|
||||
|
||||
let automatically_check_for_updates_arc =
|
||||
Arc::new(AtomicBool::new(glib_settings.boolean("check-for-updates")));
|
||||
let update_interval_arc = Arc::new(Mutex::new(glib_settings.int("update-interval")));
|
||||
let internet_connected = Rc::new(RefCell::new(false));
|
||||
|
||||
let (constant_loop_sender, constant_loop_receiver) = async_channel::unbounded();
|
||||
let constant_loop_sender_clone0 = constant_loop_sender.clone();
|
||||
let constant_loop_sender_clone1 = constant_loop_sender.clone();
|
||||
|
||||
let refresh_button = gtk::Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text(t!("refresh_button_tooltip_text"))
|
||||
.build();
|
||||
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
||||
let internet_loop_sender = internet_loop_sender.clone();
|
||||
|
||||
// Systray
|
||||
|
||||
@ -134,8 +116,6 @@ pub fn build_ui(app: &Application) {
|
||||
update_sys_tray.connect_activate(clone!(
|
||||
#[strong]
|
||||
tray_handle,
|
||||
#[strong]
|
||||
refresh_button,
|
||||
move |_, param| {
|
||||
let array: &[i32] = param.unwrap().fixed_array().unwrap();
|
||||
let vec = array.to_vec();
|
||||
@ -175,68 +155,48 @@ pub fn build_ui(app: &Application) {
|
||||
.unwrap(),
|
||||
);
|
||||
});
|
||||
if apt_update_count == -1 || flatpak_update_count == -1 {
|
||||
refresh_button.set_sensitive(false);
|
||||
refresh_button.set_tooltip_text(Some(
|
||||
&t!("pikman_indicator_flatpak_item_label_calculating").to_string(),
|
||||
));
|
||||
} else {
|
||||
refresh_button.set_sensitive(true);
|
||||
refresh_button
|
||||
.set_tooltip_text(Some(&t!("refresh_button_tooltip_text").to_string()));
|
||||
}
|
||||
}
|
||||
));
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
|
||||
|
||||
// internet check loop
|
||||
thread::spawn(move || {
|
||||
let mut last_result = false;
|
||||
loop {
|
||||
if last_result == true {
|
||||
std::thread::sleep(std::time::Duration::from_secs(60));
|
||||
}
|
||||
|
||||
let check_internet_connection_cli = Command::new("ping")
|
||||
.arg("iso.pika-os.com")
|
||||
.arg("-c 1")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
if check_internet_connection_cli.status.success() {
|
||||
constant_loop_sender_clone0
|
||||
.send_blocking(ConstantLoopMessage::InternetStatus(true))
|
||||
.expect("The channel needs to be open.");
|
||||
last_result = true
|
||||
} else {
|
||||
constant_loop_sender_clone0
|
||||
.send_blocking(ConstantLoopMessage::InternetStatus(false))
|
||||
.expect("The channel needs to be open.");
|
||||
last_result = false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// update interval loop
|
||||
thread::spawn(move || loop {
|
||||
let automatically_check_for_updates =
|
||||
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
||||
if automatically_check_for_updates {
|
||||
match update_interval_arc.lock() {
|
||||
Ok(update_interval) => {
|
||||
std::thread::sleep(std::time::Duration::from_millis(*update_interval as u64));
|
||||
constant_loop_sender_clone1
|
||||
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
||||
.expect("The channel needs to be open.");
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
match Command::new("ping").arg("google.com").arg("-c 1").output() {
|
||||
Ok(t) if t.status.success() => internet_loop_sender
|
||||
.send_blocking(true)
|
||||
.expect("The channel needs to be open"),
|
||||
_ => internet_loop_sender
|
||||
.send_blocking(false)
|
||||
.expect("The channel needs to be open"),
|
||||
};
|
||||
thread::sleep(std::time::Duration::from_secs(5));
|
||||
});
|
||||
|
||||
let window_banner = Banner::builder().revealed(false).build();
|
||||
|
||||
let internet_connected_status = internet_connected.clone();
|
||||
|
||||
let internet_loop_context = MainContext::default();
|
||||
// The main loop executes the asynchronous block
|
||||
internet_loop_context.spawn_local(clone!(
|
||||
#[weak]
|
||||
window_banner,
|
||||
async move {
|
||||
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;
|
||||
window_banner.set_title(&banner_text);
|
||||
window_banner.set_revealed(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
let window_headerbar = HeaderBar::builder()
|
||||
.title_widget(&WindowTitle::builder().title(t!("application_name")).build())
|
||||
.show_title(false)
|
||||
@ -244,8 +204,8 @@ pub fn build_ui(app: &Application) {
|
||||
|
||||
let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(
|
||||
BreakpointConditionLengthType::MaxWidth,
|
||||
1140.0,
|
||||
LengthUnit::Sp,
|
||||
1100.0,
|
||||
LengthUnit::Px,
|
||||
));
|
||||
|
||||
let window_adw_stack = gtk::Stack::builder()
|
||||
@ -338,7 +298,7 @@ pub fn build_ui(app: &Application) {
|
||||
.default_width(glib_settings.int("window-width"))
|
||||
.default_height(glib_settings.int("window-height"))
|
||||
//
|
||||
.width_request(900)
|
||||
.width_request(1000)
|
||||
.height_request(700)
|
||||
.content(&window_content_page_split_view)
|
||||
// Startup
|
||||
@ -366,6 +326,11 @@ pub fn build_ui(app: &Application) {
|
||||
.icon_name("dialog-information-symbolic")
|
||||
.build();
|
||||
|
||||
let refresh_button = gtk::Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text(t!("refresh_button_tooltip_text"))
|
||||
.build();
|
||||
|
||||
let credits_window = AboutWindow::builder()
|
||||
.application_icon(APP_ICON)
|
||||
.application_name(t!("application_name"))
|
||||
@ -586,7 +551,8 @@ pub fn build_ui(app: &Application) {
|
||||
.unwrap() as i32)
|
||||
+ 1) as usize;
|
||||
if index > gtk_application_args.len() -1 {
|
||||
flatpak_entry_signal_action.activate(Some(&glib::Variant::from("")));
|
||||
flatpak_entry_signal_action
|
||||
.activate(Some(&glib::Variant::from("")));
|
||||
} else {
|
||||
flatpak_entry_signal_action
|
||||
.activate(Some(&glib::Variant::from(>k_application_args[index])));
|
||||
@ -635,43 +601,6 @@ pub fn build_ui(app: &Application) {
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
let constant_loop_context = MainContext::default();
|
||||
// The main loop executes the asynchronous block
|
||||
constant_loop_context.spawn_local(clone!(
|
||||
#[weak]
|
||||
window_banner,
|
||||
#[strong]
|
||||
update_sys_tray,
|
||||
#[strong]
|
||||
apt_retry_signal_action,
|
||||
#[strong]
|
||||
flatpak_retry_signal_action,
|
||||
async move {
|
||||
while let Ok(message) = constant_loop_receiver.recv().await {
|
||||
let banner_text = t!("banner_text_no_internet").to_string();
|
||||
match message {
|
||||
ConstantLoopMessage::InternetStatus(state) => {
|
||||
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;
|
||||
window_banner.set_title(&banner_text);
|
||||
window_banner.set_revealed(true)
|
||||
}
|
||||
}
|
||||
ConstantLoopMessage::RefreshRequest => {
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
|
||||
apt_retry_signal_action.activate(None);
|
||||
flatpak_retry_signal_action.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
fn add_content_button(
|
||||
|
Loading…
Reference in New Issue
Block a user