Skip to content

Commit b0e5b39

Browse files
author
Deren Vural
committed
Added working(ish?) code for closing the nvidia-settings app on MainWindow close:
- Modified close_request() function in MainWindow class to check if any Cancellable objects on stack - Added Controller object creation to open_settings() function in Provider class - All commented for now - app doesn't respect the "cancel()" call Signed-off-by: Deren Vural <[email protected]>
1 parent bf02f14 commit b0e5b39

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/mainwindow/imp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,12 @@ impl WindowImpl for MainWindow {
18601860
// serde_json::to_writer(file, &gpu_data)
18611861
// .expect("Could not write data to json file");
18621862

1863+
// Cancel any under-way sub processes
1864+
// if let Some(control) = Cancellable::current() {
1865+
// println!("Closing open windows..");
1866+
// control.cancel();
1867+
// }
1868+
18631869
// Store sub-window states in settings
18641870
self.update_setting("app-settings-open", false);
18651871
self.update_setting("nvidia-settings-open", false);

src/provider/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod imp;
2222

2323
// Imports
2424
use adwaita::{gio, glib};
25-
use gio::Settings;
25+
use gio::{Settings, Cancellable};
2626
use glib::Object;
2727
use gtk::{prelude::*, subclass::prelude::*};
2828
use std::ffi::OsStr;
@@ -307,7 +307,12 @@ impl Provider {
307307
match self.property::<i32>("provider-type") {
308308
// Open Nvidia Settings
309309
0 | 1 => {
310-
match exec_communicate_async(&[OsStr::new("nvidia-settings")], None::<&gio::Cancellable>, |result| {
310+
// Add new cancellable object to stack
311+
//let control: Cancellable = Cancellable::new();
312+
//control.push_current();
313+
314+
// Start cancellable async process
315+
match exec_communicate_async(&[OsStr::new("nvidia-settings")], None::<&Cancellable>/*Some(&control)*/, |result| {
311316
// Callback
312317
match result {
313318
Err(err) => {

0 commit comments

Comments
 (0)