From d87d6262c0fa19fca67b4d94396c61bde4270ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20B=C3=ADcha?= Date: Fri, 29 Sep 2023 17:21:43 -0400 Subject: [PATCH 1/2] Update minimum rust version to 1.70.0 required by rust-gtk4 0.7 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fe1aaf5..cd6663c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,7 +26,7 @@ jobs: - stable - beta - nightly - - "1.64.0" # Minimum supported version (from gtk-rs) + - "1.70" # Minimum supported version (from gtk-rs) os: - ubuntu-22.04 - macos-latest From 19418558b205afd7e1aa050cac2409bd495c11e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20B=C3=ADcha?= Date: Thu, 28 Sep 2023 12:13:18 -0400 Subject: [PATCH 2/2] Update to rust-gtk4 0.7 --- Cargo.toml | 2 +- src/main.rs | 20 ++++++++++---------- src/network_dialog.rs | 10 +++++----- src/process_dialog.rs | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e246f9c..7c401e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" keywords = ["GUI", "process", "viewer", "gtk"] [dependencies] -gtk = { version = "0.6", package = "gtk4" } +gtk = { version = "0.7", package = "gtk4" } sysinfo = "0.28.2" libc = "0.2" serde = "1.0" diff --git a/src/main.rs b/src/main.rs index 8c1b264..06cd4ec 100755 --- a/src/main.rs +++ b/src/main.rs @@ -230,7 +230,7 @@ pub struct RequiredForSettings { } fn setup_timeout(rfs: &RequiredForSettings) { - let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); + let (ready_tx, ready_rx) = glib::MainContext::channel(glib::Priority::default()); let sys = &rfs.sys; let process_dialogs = &rfs.process_dialogs; @@ -250,7 +250,7 @@ fn setup_timeout(rfs: &RequiredForSettings) { ); ready_rx.attach(None, - glib::clone!(@weak sys, @weak list_store, @weak process_dialogs => @default-return glib::Continue(true), move |_: bool| { + glib::clone!(@weak sys, @weak list_store, @weak process_dialogs => @default-return glib::ControlFlow::Continue, move |_: bool| { // first part, deactivate sorting let sorted = TreeSortableExtManual::sort_column_id(&list_store); list_store.set_unsorted(); @@ -277,12 +277,12 @@ fn setup_timeout(rfs: &RequiredForSettings) { panic!("failed to lock sys to refresh UI"); } dialogs.retain(|x| !x.need_remove()); - glib::Continue(true) + glib::ControlFlow::Continue })); } fn setup_network_timeout(rfs: &RequiredForSettings) { - let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); + let (ready_tx, ready_rx) = glib::MainContext::channel(glib::Priority::default()); let network_refresh_timeout = &rfs.network_refresh_timeout; let network_tab = &rfs.network_tab; @@ -303,13 +303,13 @@ fn setup_network_timeout(rfs: &RequiredForSettings) { ready_rx.attach(None, glib::clone!(@weak sys, @weak network_tab => @default-panic, move |_: bool| { network_tab.borrow_mut().update_networks(&sys.lock().expect("failed to lock to update networks")); - glib::Continue(true) + glib::ControlFlow::Continue }) ); } fn setup_system_timeout(rfs: &RequiredForSettings, settings: &Rc>) { - let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); + let (ready_tx, ready_rx) = glib::MainContext::channel(glib::Priority::default()); let system_refresh_timeout = &rfs.system_refresh_timeout; let sys = &rfs.sys; @@ -336,7 +336,7 @@ fn setup_system_timeout(rfs: &RequiredForSettings, settings: &Rc move |g, _| { let mut is_active = false; @@ -562,7 +562,7 @@ fn build_ui(application: >k::Application) { let temperature = gio::SimpleAction::new_stateful( "temperature", None, - settings.borrow().display_fahrenheit.to_variant(), + &settings.borrow().display_fahrenheit.to_variant(), ); temperature.connect_activate(move |g, _| { let mut is_active = false; @@ -684,7 +684,7 @@ graph_widget { } "#, ); - gtk::StyleContext::add_provider_for_display( + gtk::style_context_add_provider_for_display( &gdk::Display::default().expect("Could not connect to a display."), &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, diff --git a/src/network_dialog.rs b/src/network_dialog.rs index 9050e61..b87c88a 100644 --- a/src/network_dialog.rs +++ b/src/network_dialog.rs @@ -1,5 +1,5 @@ use gtk::prelude::*; -use gtk::{glib, EventControllerKey, Inhibit}; +use gtk::{glib, EventControllerKey}; use sysinfo::NetworkExt; @@ -422,21 +422,21 @@ pub fn create_network_dialog( popup.close(); })); popup.connect_close_request( - glib::clone!(@weak to_be_removed => @default-return Inhibit(false), move |_| { + glib::clone!(@weak to_be_removed => @default-return glib::Propagation::Proceed, move |_| { to_be_removed.set(true); - Inhibit(false) + glib::Propagation::Proceed }), ); let event_controller = EventControllerKey::new(); event_controller.connect_key_pressed(glib::clone!( @weak popup, @weak to_be_removed - => @default-return Inhibit(false), move |_, key, _, _modifier| { + => @default-return glib::Propagation::Proceed, move |_, key, _, _modifier| { if key == gtk::gdk::Key::Escape { popup.close(); to_be_removed.set(true); } - Inhibit(false) + glib::Propagation::Proceed } )); popup.add_controller(event_controller); diff --git a/src/process_dialog.rs b/src/process_dialog.rs index 3841920..8d7db10 100644 --- a/src/process_dialog.rs +++ b/src/process_dialog.rs @@ -1,5 +1,5 @@ use gtk::prelude::*; -use gtk::{glib, pango, EventControllerKey, Inhibit}; +use gtk::{glib, pango, EventControllerKey}; use sysinfo::{self, Pid, ProcessExt}; use std::cell::{Cell, RefCell}; @@ -393,19 +393,19 @@ pub fn create_process_dialog(process: &sysinfo::Process, total_memory: u64) -> P to_be_removed.set(true); })); popup.connect_close_request( - glib::clone!(@weak to_be_removed => @default-return Inhibit(false), move |_| { + glib::clone!(@weak to_be_removed => @default-return glib::Propagation::Proceed, move |_| { to_be_removed.set(true); - Inhibit(false) + glib::Propagation::Proceed }), ); let event_controller = EventControllerKey::new(); event_controller.connect_key_pressed( - glib::clone!(@weak popup, @weak to_be_removed => @default-return Inhibit(false), move |_, key, _, _modifier| { + glib::clone!(@weak popup, @weak to_be_removed => @default-return glib::Propagation::Proceed, move |_, key, _, _modifier| { if key == gtk::gdk::Key::Escape { popup.close(); to_be_removed.set(true); } - Inhibit(false) + glib::Propagation::Proceed }), ); popup.add_controller(event_controller);