Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to rust-gtk4 0.7 #205

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 10 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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<RefCell<Settings>>) {
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;
Expand All @@ -336,7 +336,7 @@ fn setup_system_timeout(rfs: &RequiredForSettings, settings: &Rc<RefCell<Setting

info.update_system_info(&sys, display_fahrenheit);
info.update_system_info_display(&sys);
glib::Continue(true)
glib::ControlFlow::Continue
}),
);
}
Expand Down Expand Up @@ -543,7 +543,7 @@ fn build_ui(application: &gtk::Application) {
let graphs = gio::SimpleAction::new_stateful(
"graphs",
None,
settings.borrow().display_graph.to_variant(),
&settings.borrow().display_graph.to_variant(),
);
graphs.connect_activate(glib::clone!(@weak settings => move |g, _| {
let mut is_active = false;
Expand All @@ -562,7 +562,7 @@ fn build_ui(application: &gtk::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;
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/network_dialog.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gtk::prelude::*;
use gtk::{glib, EventControllerKey, Inhibit};
use gtk::{glib, EventControllerKey};

use sysinfo::NetworkExt;

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/process_dialog.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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);
Expand Down
Loading