| 1 |
From: Peter Michael Green <[email protected]> |
| 2 |
Date: Thu, 25 Sep 2025 11:58:17 +0000 |
| 3 |
Subject: update-gtk-crates |
| 4 |
MIME-Version: 1.0 |
| 5 |
Content-Type: text/plain; charset="utf-8" |
| 6 |
Content-Transfer-Encoding: 8bit |
| 7 |
|
| 8 |
This patch is based on the upstream commits described below adapted |
| 9 |
for use in the Debian package by Peter Michael Green. |
| 10 |
|
| 11 |
commit 27f81842a1c1f8a3178e3a006570b48b5b7c938b |
| 12 |
Author: Maximiliano Sandoval <[email protected]> |
| 13 |
Date: Sun Jul 14 11:20:03 2024 +0200 |
| 14 |
|
| 15 |
Use adw::Spinner |
| 16 |
|
| 17 |
commit b2cbf3dbc1b15bb507f68aeeef9cb6c76b2cbe80 |
| 18 |
Author: Felix Häcker <[email protected]> |
| 19 |
Date: Sun Aug 3 14:53:48 2025 +0200 |
| 20 |
|
| 21 |
misc: Upgrade gtk-rs to 0.21 |
| 22 |
|
| 23 |
commit 89296ea1ae3c4633f697f120c4e77e32a693a5f8 |
| 24 |
Author: Maximiliano Sandoval <[email protected]> |
| 25 |
Date: Sun Jul 14 12:58:35 2024 +0200 |
| 26 |
|
| 27 |
Port to new clone macro |
| 28 |
--- |
| 29 |
Cargo.toml | 6 +- |
| 30 |
data/gtk/add_connection_dialog.ui | 5 +- |
| 31 |
data/gtk/connection_box.ui | 5 +- |
| 32 |
data/gtk/torrent_row.ui | 4 +- |
| 33 |
src/actions.rs | 402 ++++++++++++++++++++++++++------------ |
| 34 |
src/app.rs | 322 +++++++++++++++++++----------- |
| 35 |
src/backend/connection.rs | 2 +- |
| 36 |
src/backend/connection_manager.rs | 61 ++++-- |
| 37 |
src/backend/daemon.rs | 16 ++ |
| 38 |
src/ui/add_connection_dialog.rs | 66 ++++--- |
| 39 |
src/ui/connection_box.rs | 139 +++++++------ |
| 40 |
src/ui/connection_popover.rs | 47 +++-- |
| 41 |
src/ui/connection_row.rs | 5 +- |
| 42 |
src/ui/drag_overlay.rs | 15 +- |
| 43 |
src/ui/file_page.rs | 7 +- |
| 44 |
src/ui/file_row.rs | 31 +-- |
| 45 |
src/ui/folder_page.rs | 5 +- |
| 46 |
src/ui/folder_page_contents.rs | 47 +++-- |
| 47 |
src/ui/preferences_dialog.rs | 116 +++++++---- |
| 48 |
src/ui/stats_dialog.rs | 121 ++++++++---- |
| 49 |
src/ui/status_header.rs | 5 +- |
| 50 |
src/ui/torrent_dialog.rs | 121 +++++++----- |
| 51 |
src/ui/torrent_group.rs | 17 +- |
| 52 |
src/ui/torrent_page.rs | 23 ++- |
| 53 |
src/ui/torrent_row.rs | 50 +++-- |
| 54 |
src/ui/window.rs | 189 +++++++++++------- |
| 55 |
src/utils.rs | 30 ++- |
| 56 |
27 files changed, 1189 insertions(+), 668 deletions(-) |
| 57 |
|
| 58 |
diff --git a/Cargo.toml b/Cargo.toml |
| 59 |
index 68fa4dc..9d2b312 100644 |
| 60 |
--- a/Cargo.toml |
| 61 |
+++ b/Cargo.toml |
| 62 |
@@ -7,7 +7,7 @@ license = "GPL-3.0-or-later" |
| 63 |
|
| 64 |
[dependencies] |
| 65 |
anyhow = "1.0" |
| 66 |
-ashpd = { version = "0.11", default-features=false, features = ["gtk4", "async-std"] } |
| 67 |
+ashpd = { version = "0.13", default-features=false, features = ["gtk4", "async-io", "open_uri"] } |
| 68 |
async-process = "2.2" |
| 69 |
async-recursion = "1.1" |
| 70 |
base64 = "0.22" |
| 71 |
@@ -28,8 +28,8 @@ strum_macros = "0.28" |
| 72 |
url = "2.5" |
| 73 |
uuid = { version = "1.10", features = ["v4"] } |
| 74 |
|
| 75 |
-gtk = { package = "gtk4", version = "0.9", features = ["gnome_47"] } |
| 76 |
-adw = { package = "libadwaita", version = "0.7", features = ["v1_7"] } |
| 77 |
+gtk = { package = "gtk4", version = "0.11", features = ["gnome_47"] } |
| 78 |
+adw = { package = "libadwaita", version = "0.9", features = ["v1_7"] } |
| 79 |
|
| 80 |
[dependencies.transmission-gobject] |
| 81 |
version = "0.1.6" |
| 82 |
diff --git a/data/gtk/add_connection_dialog.ui b/data/gtk/add_connection_dialog.ui |
| 83 |
index 53262e2..0740827 100644 |
| 84 |
--- a/data/gtk/add_connection_dialog.ui |
| 85 |
+++ b/data/gtk/add_connection_dialog.ui |
| 86 |
@@ -133,10 +133,7 @@ |
| 87 |
<object class="GtkStackPage"> |
| 88 |
<property name="name">loading</property> |
| 89 |
<property name="child"> |
| 90 |
- <object class="GtkSpinner" id="spinner"> |
| 91 |
- <property name="halign">center</property> |
| 92 |
- <property name="valign">center</property> |
| 93 |
- </object> |
| 94 |
+ <object class="AdwSpinner" /> |
| 95 |
</property> |
| 96 |
</object> |
| 97 |
</child> |
| 98 |
diff --git a/data/gtk/connection_box.ui b/data/gtk/connection_box.ui |
| 99 |
index 133d09d..92b9b72 100644 |
| 100 |
--- a/data/gtk/connection_box.ui |
| 101 |
+++ b/data/gtk/connection_box.ui |
| 102 |
@@ -25,10 +25,7 @@ |
| 103 |
<object class="GtkStackPage"> |
| 104 |
<property name="name">loading</property> |
| 105 |
<property name="child"> |
| 106 |
- <object class="GtkSpinner" id="spinner"> |
| 107 |
- <property name="halign">center</property> |
| 108 |
- <property name="width-request">32</property> |
| 109 |
- </object> |
| 110 |
+ <object class="AdwSpinner" /> |
| 111 |
</property> |
| 112 |
</object> |
| 113 |
</child> |
| 114 |
diff --git a/data/gtk/torrent_row.ui b/data/gtk/torrent_row.ui |
| 115 |
index 9af2c33..5e1a62b 100644 |
| 116 |
--- a/data/gtk/torrent_row.ui |
| 117 |
+++ b/data/gtk/torrent_row.ui |
| 118 |
@@ -50,9 +50,7 @@ |
| 119 |
<object class="GtkStackPage"> |
| 120 |
<property name="name">check</property> |
| 121 |
<property name="child"> |
| 122 |
- <object class="GtkSpinner" id="spinner"> |
| 123 |
- <property name="halign">center</property> |
| 124 |
- <property name="valign">center</property> |
| 125 |
+ <object class="AdwSpinner"> |
| 126 |
<style> |
| 127 |
<class name="bubble"/> |
| 128 |
</style> |
| 129 |
diff --git a/src/actions.rs b/src/actions.rs |
| 130 |
index 1f4211a..a38890a 100644 |
| 131 |
--- a/src/actions.rs |
| 132 |
+++ b/src/actions.rs |
| 133 |
@@ -1,5 +1,5 @@ |
| 134 |
// Fragments - actions.rs |
| 135 |
-// Copyright (C) 2023-2024 Felix Häcker <[email protected]> |
| 136 |
+// Copyright (C) 2023-2025 Felix Häcker <[email protected]> |
| 137 |
// |
| 138 |
// This program is free software: you can redistribute it and/or modify |
| 139 |
// it under the terms of the GNU General Public License as published by |
| 140 |
@@ -38,119 +38,195 @@ pub fn install_torrent_actions(torrent: &TrTorrent, widget: gtk::Widget) { |
| 141 |
|
| 142 |
// torrent.continue |
| 143 |
let continue_action = SimpleAction::new("continue", None); |
| 144 |
- continue_action.connect_activate(clone!(@weak torrent => move |_, _| { |
| 145 |
- let fut = async move { |
| 146 |
- torrent.start(false).await.expect("Unable to start torrent"); |
| 147 |
- }; |
| 148 |
- glib::spawn_future_local(fut); |
| 149 |
- })); |
| 150 |
+ continue_action.connect_activate(clone!( |
| 151 |
+ #[weak] |
| 152 |
+ torrent, |
| 153 |
+ move |_, _| { |
| 154 |
+ let fut = async move { |
| 155 |
+ torrent.start(false).await.expect("Unable to start torrent"); |
| 156 |
+ }; |
| 157 |
+ glib::spawn_future_local(fut); |
| 158 |
+ } |
| 159 |
+ )); |
| 160 |
actions.add_action(&continue_action); |
| 161 |
|
| 162 |
// torrent.pause |
| 163 |
let pause_action = SimpleAction::new("pause", None); |
| 164 |
- pause_action.connect_activate(clone!(@weak torrent => move |_, _| { |
| 165 |
- let fut = async move { |
| 166 |
- torrent.stop().await.expect("Unable to stop torrent"); |
| 167 |
- }; |
| 168 |
- glib::spawn_future_local(fut); |
| 169 |
- })); |
| 170 |
+ pause_action.connect_activate(clone!( |
| 171 |
+ #[weak] |
| 172 |
+ torrent, |
| 173 |
+ move |_, _| { |
| 174 |
+ let fut = async move { |
| 175 |
+ torrent.stop().await.expect("Unable to stop torrent"); |
| 176 |
+ }; |
| 177 |
+ glib::spawn_future_local(fut); |
| 178 |
+ } |
| 179 |
+ )); |
| 180 |
actions.add_action(&pause_action); |
| 181 |
|
| 182 |
// Disable `continue`/`pause` action depending on the torrent status |
| 183 |
- torrent.connect_status_notify( |
| 184 |
- clone!(@weak torrent, @weak continue_action, @weak pause_action => move |_|{ |
| 185 |
+ torrent.connect_status_notify(clone!( |
| 186 |
+ #[weak] |
| 187 |
+ torrent, |
| 188 |
+ #[weak] |
| 189 |
+ continue_action, |
| 190 |
+ #[weak] |
| 191 |
+ pause_action, |
| 192 |
+ move |_| { |
| 193 |
update_status_action(&torrent, &continue_action, &pause_action); |
| 194 |
- }), |
| 195 |
- ); |
| 196 |
+ } |
| 197 |
+ )); |
| 198 |
update_status_action(torrent, &continue_action, &pause_action); |
| 199 |
|
| 200 |
// torrent.remove |
| 201 |
let remove_action = SimpleAction::new("remove", None); |
| 202 |
- remove_action.connect_activate(clone!(@weak torrent, @weak widget => move |_, _| { |
| 203 |
- show_remove_torrent_dialog(&torrent, widget); |
| 204 |
- })); |
| 205 |
+ remove_action.connect_activate(clone!( |
| 206 |
+ #[weak] |
| 207 |
+ torrent, |
| 208 |
+ #[weak] |
| 209 |
+ widget, |
| 210 |
+ move |_, _| { |
| 211 |
+ show_remove_torrent_dialog(&torrent, widget); |
| 212 |
+ } |
| 213 |
+ )); |
| 214 |
actions.add_action(&remove_action); |
| 215 |
|
| 216 |
// torrent.copy-magnet |
| 217 |
let copy_magnet_action = SimpleAction::new("copy-magnet", None); |
| 218 |
- copy_magnet_action.connect_activate(clone!(@weak torrent, @weak widget => move |_, _| { |
| 219 |
- let display = gdk::Display::default().unwrap(); |
| 220 |
- let clipboard = display.clipboard(); |
| 221 |
- |
| 222 |
- let content = gdk::ContentProvider::for_value(&torrent.magnet_link().to_value()); |
| 223 |
- if let Err(err) = clipboard.set_content(Some(&content)){ |
| 224 |
- utils::inapp_notification(&i18n("Unable to copy magnet link to clipboard"), Some(&widget)); |
| 225 |
- warn!("Unable to copy magnet link to clipboard: {}", err.to_string()); |
| 226 |
- } |
| 227 |
+ copy_magnet_action.connect_activate(clone!( |
| 228 |
+ #[weak] |
| 229 |
+ torrent, |
| 230 |
+ #[weak] |
| 231 |
+ widget, |
| 232 |
+ move |_, _| { |
| 233 |
+ let display = gdk::Display::default().unwrap(); |
| 234 |
+ let clipboard = display.clipboard(); |
| 235 |
+ |
| 236 |
+ let content = gdk::ContentProvider::for_value(&torrent.magnet_link().to_value()); |
| 237 |
+ if let Err(err) = clipboard.set_content(Some(&content)) { |
| 238 |
+ utils::inapp_notification( |
| 239 |
+ &i18n("Unable to copy magnet link to clipboard"), |
| 240 |
+ Some(&widget), |
| 241 |
+ ); |
| 242 |
+ warn!( |
| 243 |
+ "Unable to copy magnet link to clipboard: {}", |
| 244 |
+ err.to_string() |
| 245 |
+ ); |
| 246 |
+ } |
| 247 |
|
| 248 |
- utils::inapp_notification(&i18n("Copied magnet link to clipboard"), Some(&widget)); |
| 249 |
- })); |
| 250 |
+ utils::inapp_notification(&i18n("Copied magnet link to clipboard"), Some(&widget)); |
| 251 |
+ } |
| 252 |
+ )); |
| 253 |
actions.add_action(©_magnet_action); |
| 254 |
|
| 255 |
// torrent.manual-update |
| 256 |
let manual_update_action = SimpleAction::new("manual-update", None); |
| 257 |
- manual_update_action.connect_activate(clone!(@weak torrent => move |_, _| { |
| 258 |
- let fut = async move { |
| 259 |
- torrent.reannounce().await.expect("Unable to reannounce torrent"); |
| 260 |
- }; |
| 261 |
- glib::spawn_future_local(fut); |
| 262 |
- })); |
| 263 |
+ manual_update_action.connect_activate(clone!( |
| 264 |
+ #[weak] |
| 265 |
+ torrent, |
| 266 |
+ move |_, _| { |
| 267 |
+ let fut = async move { |
| 268 |
+ torrent |
| 269 |
+ .reannounce() |
| 270 |
+ .await |
| 271 |
+ .expect("Unable to reannounce torrent"); |
| 272 |
+ }; |
| 273 |
+ glib::spawn_future_local(fut); |
| 274 |
+ } |
| 275 |
+ )); |
| 276 |
actions.add_action(&manual_update_action); |
| 277 |
|
| 278 |
// torrent.queue-up |
| 279 |
let queue_up_action = SimpleAction::new("queue-up", None); |
| 280 |
- queue_up_action.connect_activate(clone!(@weak torrent => move |_, _| { |
| 281 |
- move_queue(false, torrent); |
| 282 |
- })); |
| 283 |
+ queue_up_action.connect_activate(clone!( |
| 284 |
+ #[weak] |
| 285 |
+ torrent, |
| 286 |
+ move |_, _| { |
| 287 |
+ move_queue(false, torrent); |
| 288 |
+ } |
| 289 |
+ )); |
| 290 |
actions.add_action(&queue_up_action); |
| 291 |
|
| 292 |
// torrent.queue-down |
| 293 |
let queue_down_action = SimpleAction::new("queue-down", None); |
| 294 |
- queue_down_action.connect_activate(clone!(@weak torrent => move |_, _| { |
| 295 |
- move_queue(true, torrent); |
| 296 |
- })); |
| 297 |
+ queue_down_action.connect_activate(clone!( |
| 298 |
+ #[weak] |
| 299 |
+ torrent, |
| 300 |
+ move |_, _| { |
| 301 |
+ move_queue(true, torrent); |
| 302 |
+ } |
| 303 |
+ )); |
| 304 |
actions.add_action(&queue_down_action); |
| 305 |
|
| 306 |
// Disable queue actions for non queued torrents |
| 307 |
- torrent.connect_status_notify( |
| 308 |
- clone!(@weak torrent, @weak queue_up_action, @weak queue_down_action => move |_|{ |
| 309 |
+ torrent.connect_status_notify(clone!( |
| 310 |
+ #[weak] |
| 311 |
+ torrent, |
| 312 |
+ #[weak] |
| 313 |
+ queue_up_action, |
| 314 |
+ #[weak] |
| 315 |
+ queue_down_action, |
| 316 |
+ move |_| { |
| 317 |
update_queue_action(&torrent, &queue_up_action, &queue_down_action); |
| 318 |
- }), |
| 319 |
- ); |
| 320 |
+ } |
| 321 |
+ )); |
| 322 |
update_queue_action(torrent, &queue_up_action, &queue_down_action); |
| 323 |
|
| 324 |
// torrent.show-dialog |
| 325 |
let show_dialog_action = SimpleAction::new("show-dialog", None); |
| 326 |
- show_dialog_action.connect_activate(clone!(@weak torrent, @weak widget => move |_, _| { |
| 327 |
- let dialog = FrgTorrentDialog::new(&torrent); |
| 328 |
- dialog.present(Some(&widget)); |
| 329 |
- })); |
| 330 |
+ show_dialog_action.connect_activate(clone!( |
| 331 |
+ #[weak] |
| 332 |
+ torrent, |
| 333 |
+ #[weak] |
| 334 |
+ widget, |
| 335 |
+ move |_, _| { |
| 336 |
+ let dialog = FrgTorrentDialog::new(&torrent); |
| 337 |
+ dialog.present(Some(&widget)); |
| 338 |
+ } |
| 339 |
+ )); |
| 340 |
actions.add_action(&show_dialog_action); |
| 341 |
|
| 342 |
// torrent.open |
| 343 |
let open_action = SimpleAction::new("open", None); |
| 344 |
- open_action.connect_activate(clone!(@weak torrent, @weak widget => move |_, _| { |
| 345 |
- let name = if let Some(top_level) = torrent.files().top_level() { |
| 346 |
- top_level.name() |
| 347 |
- } else { |
| 348 |
- warn!("Top level file is not available, falling back to torrent name for opening"); |
| 349 |
- torrent.name() |
| 350 |
- }; |
| 351 |
- |
| 352 |
- let path = Path::new(&torrent.download_dir()).join(name); |
| 353 |
- open(path, &widget.native().unwrap(), false, Some(widget)); |
| 354 |
- })); |
| 355 |
+ open_action.connect_activate(clone!( |
| 356 |
+ #[weak] |
| 357 |
+ torrent, |
| 358 |
+ #[weak] |
| 359 |
+ widget, |
| 360 |
+ move |_, _| { |
| 361 |
+ let name = if let Some(top_level) = torrent.files().top_level() { |
| 362 |
+ top_level.name() |
| 363 |
+ } else { |
| 364 |
+ warn!("Top level file is not available, falling back to torrent name for opening"); |
| 365 |
+ torrent.name() |
| 366 |
+ }; |
| 367 |
+ |
| 368 |
+ let path = Path::new(&torrent.download_dir()).join(name); |
| 369 |
+ open(path, &widget.native().unwrap(), false, Some(widget)); |
| 370 |
+ } |
| 371 |
+ )); |
| 372 |
actions.add_action(&open_action); |
| 373 |
|
| 374 |
// Only downloaded torrents can be opened |
| 375 |
- torrent.connect_downloaded_notify(clone!(@weak torrent, @weak open_action => move |_|{ |
| 376 |
- update_torrent_open_action(&torrent, &open_action); |
| 377 |
- })); |
| 378 |
+ torrent.connect_downloaded_notify(clone!( |
| 379 |
+ #[weak] |
| 380 |
+ torrent, |
| 381 |
+ #[weak] |
| 382 |
+ open_action, |
| 383 |
+ move |_| { |
| 384 |
+ update_torrent_open_action(&torrent, &open_action); |
| 385 |
+ } |
| 386 |
+ )); |
| 387 |
update_torrent_open_action(torrent, &open_action); |
| 388 |
|
| 389 |
// torrent.set-location |
| 390 |
let set_location_action = SimpleAction::new("set-location", None); |
| 391 |
- set_location_action.connect_activate(clone!(@weak torrent, @weak widget => move |_, _| { |
| 392 |
+ set_location_action.connect_activate(clone!( |
| 393 |
+ #[weak] |
| 394 |
+ torrent, |
| 395 |
+ #[weak] |
| 396 |
+ widget, |
| 397 |
+ move |_, _| { |
| 398 |
show_set_torrent_location(&torrent, &widget); |
| 399 |
} |
| 400 |
)); |
| 401 |
@@ -158,12 +234,18 @@ pub fn install_torrent_actions(torrent: &TrTorrent, widget: gtk::Widget) { |
| 402 |
actions.add_action(&set_location_action); |
| 403 |
|
| 404 |
// Disable filesystem actions when connected with a remote session |
| 405 |
- current_connection.connect_is_fragments_notify( |
| 406 |
- clone!(@weak torrent, @weak open_action, @weak set_location_action => move |c|{ |
| 407 |
+ current_connection.connect_is_fragments_notify(clone!( |
| 408 |
+ #[weak] |
| 409 |
+ torrent, |
| 410 |
+ #[weak] |
| 411 |
+ open_action, |
| 412 |
+ #[weak] |
| 413 |
+ set_location_action, |
| 414 |
+ move |c| { |
| 415 |
set_location_action.set_enabled(c.is_fragments()); |
| 416 |
update_torrent_open_action(&torrent, &open_action); |
| 417 |
- }), |
| 418 |
- ); |
| 419 |
+ } |
| 420 |
+ )); |
| 421 |
} |
| 422 |
|
| 423 |
pub fn install_file_actions(file: &TrFile, widget: gtk::Widget) { |
| 424 |
@@ -174,44 +256,73 @@ pub fn install_file_actions(file: &TrFile, widget: gtk::Widget) { |
| 425 |
|
| 426 |
// file.open |
| 427 |
let open_action = SimpleAction::new("open", None); |
| 428 |
- open_action.connect_activate(clone!(@weak file, @weak widget => move |_, _| { |
| 429 |
- let path = Path::new(&file.torrent().download_dir()).join(file.name()); |
| 430 |
- open(path, &widget.native().unwrap(), false, Some(widget)); |
| 431 |
- })); |
| 432 |
+ open_action.connect_activate(clone!( |
| 433 |
+ #[weak] |
| 434 |
+ file, |
| 435 |
+ #[weak] |
| 436 |
+ widget, |
| 437 |
+ move |_, _| { |
| 438 |
+ let path = Path::new(&file.torrent().download_dir()).join(file.name()); |
| 439 |
+ open(path, &widget.native().unwrap(), false, Some(widget)); |
| 440 |
+ } |
| 441 |
+ )); |
| 442 |
actions.add_action(&open_action); |
| 443 |
|
| 444 |
// file.open-containing-folder |
| 445 |
let open_containing_action = SimpleAction::new("open-containing-folder", None); |
| 446 |
- open_containing_action.connect_activate(clone!(@weak file, @weak widget => move |_, _| { |
| 447 |
- let path = Path::new(&file.torrent().download_dir()).join(file.name()); |
| 448 |
- open(path, &widget.native().unwrap(), true, Some(widget)); |
| 449 |
- })); |
| 450 |
+ open_containing_action.connect_activate(clone!( |
| 451 |
+ #[weak] |
| 452 |
+ file, |
| 453 |
+ #[weak] |
| 454 |
+ widget, |
| 455 |
+ move |_, _| { |
| 456 |
+ let path = Path::new(&file.torrent().download_dir()).join(file.name()); |
| 457 |
+ open(path, &widget.native().unwrap(), true, Some(widget)); |
| 458 |
+ } |
| 459 |
+ )); |
| 460 |
actions.add_action(&open_containing_action); |
| 461 |
|
| 462 |
// Only downloaded files can be opened |
| 463 |
- file.connect_bytes_completed_notify(clone!(@weak file, @weak actions => move |_|{ |
| 464 |
- update_file_open_actions(&file, &actions); |
| 465 |
- })); |
| 466 |
+ file.connect_bytes_completed_notify(clone!( |
| 467 |
+ #[weak] |
| 468 |
+ file, |
| 469 |
+ #[weak] |
| 470 |
+ actions, |
| 471 |
+ move |_| { |
| 472 |
+ update_file_open_actions(&file, &actions); |
| 473 |
+ } |
| 474 |
+ )); |
| 475 |
update_file_open_actions(file, &actions); |
| 476 |
|
| 477 |
// Disable filesystem actions when connected with a remote session |
| 478 |
- current_connection.connect_is_fragments_notify( |
| 479 |
- clone!(@weak file, @weak open_action, @weak actions => move |c|{ |
| 480 |
+ current_connection.connect_is_fragments_notify(clone!( |
| 481 |
+ #[weak] |
| 482 |
+ file, |
| 483 |
+ #[weak] |
| 484 |
+ actions, |
| 485 |
+ move |c| { |
| 486 |
open_containing_action.set_enabled(c.is_fragments()); |
| 487 |
update_file_open_actions(&file, &actions); |
| 488 |
- }), |
| 489 |
- ); |
| 490 |
+ } |
| 491 |
+ )); |
| 492 |
} |
| 493 |
|
| 494 |
fn move_queue(down: bool, torrent: TrTorrent) { |
| 495 |
- let fut = clone!(@weak torrent => async move { |
| 496 |
- let pos = if down{ |
| 497 |
- torrent.download_queue_position() + 1 |
| 498 |
- }else{ |
| 499 |
- torrent.download_queue_position() - 1 |
| 500 |
- }; |
| 501 |
- torrent.set_download_queue_position(pos).await.expect("Unable to set download queue position"); |
| 502 |
- }); |
| 503 |
+ let fut = clone!( |
| 504 |
+ #[weak] |
| 505 |
+ torrent, |
| 506 |
+ async move { |
| 507 |
+ let pos = if down { |
| 508 |
+ torrent.download_queue_position() + 1 |
| 509 |
+ } else { |
| 510 |
+ torrent.download_queue_position() - 1 |
| 511 |
+ }; |
| 512 |
+ torrent |
| 513 |
+ .set_download_queue_position(pos) |
| 514 |
+ .await |
| 515 |
+ .expect("Unable to set download queue position"); |
| 516 |
+ } |
| 517 |
+ ); |
| 518 |
glib::spawn_future_local(fut); |
| 519 |
} |
| 520 |
|
| 521 |
@@ -282,22 +393,36 @@ fn show_remove_torrent_dialog(torrent: &TrTorrent, parent: gtk::Widget) { |
| 522 |
check_button.set_halign(gtk::Align::Center); |
| 523 |
dialog.set_extra_child(Some(&check_button)); |
| 524 |
|
| 525 |
- dialog.connect_response(None, |
| 526 |
- clone!(@strong dialog, @weak torrent, @weak parent, @weak check_button => move |_ , resp| { |
| 527 |
- if resp == "remove" { |
| 528 |
- let fut = async move { |
| 529 |
- torrent.remove(check_button.is_active()).await.expect("Unable to remove torrent"); |
| 530 |
- }; |
| 531 |
+ dialog.connect_response( |
| 532 |
+ None, |
| 533 |
+ clone!( |
| 534 |
+ #[strong] |
| 535 |
+ dialog, |
| 536 |
+ #[weak] |
| 537 |
+ torrent, |
| 538 |
+ #[weak] |
| 539 |
+ parent, |
| 540 |
+ #[weak] |
| 541 |
+ check_button, |
| 542 |
+ move |_, resp| { |
| 543 |
+ if resp == "remove" { |
| 544 |
+ let fut = async move { |
| 545 |
+ torrent |
| 546 |
+ .remove(check_button.is_active()) |
| 547 |
+ .await |
| 548 |
+ .expect("Unable to remove torrent"); |
| 549 |
+ }; |
| 550 |
+ |
| 551 |
+ if let Ok(dialog) = parent.downcast::<adw::Dialog>() { |
| 552 |
+ dialog.close(); |
| 553 |
+ } |
| 554 |
|
| 555 |
- if let Ok(dialog) = parent.downcast::<adw::Dialog>(){ |
| 556 |
- dialog.close(); |
| 557 |
+ glib::spawn_future_local(fut); |
| 558 |
} |
| 559 |
|
| 560 |
- glib::spawn_future_local(fut); |
| 561 |
+ dialog.close(); |
| 562 |
} |
| 563 |
- |
| 564 |
- dialog.close(); |
| 565 |
- }), |
| 566 |
+ ), |
| 567 |
); |
| 568 |
|
| 569 |
dialog.present(Some(&parent)); |
| 570 |
@@ -312,7 +437,7 @@ fn show_set_torrent_location(torrent: &TrTorrent, parent: >k::Widget) { |
| 571 |
dialog.set_accept_label(Some(&i18n("_Select"))); |
| 572 |
|
| 573 |
let root = parent.root().unwrap().downcast::<gtk::Window>().unwrap(); |
| 574 |
- dialog.select_folder(Some(&root), gio::Cancellable::NONE, clone!(@weak torrent, @weak parent, @strong dialog => move |result| { |
| 575 |
+ dialog.select_folder(Some(&root), gio::Cancellable::NONE, clone!(#[weak] torrent, #[weak] parent, #[strong(rename_to = _dialog)] dialog, move |result| { |
| 576 |
match result { |
| 577 |
Ok(folder) => { |
| 578 |
debug!("Selected torrent directory: {:?}", folder.path()); |
| 579 |
@@ -330,9 +455,9 @@ fn show_set_torrent_location(torrent: &TrTorrent, parent: >k::Widget) { |
| 580 |
dialog.present(Some(&parent)); |
| 581 |
dialog.connect_response( |
| 582 |
None, |
| 583 |
- clone!(@strong dialog, @strong torrent, @strong folder => move |_ , resp| { |
| 584 |
+ clone!(#[strong(rename_to = _dialog)] dialog, #[strong] torrent, #[strong] folder, move |_ , resp| { |
| 585 |
let resp = resp.to_string(); |
| 586 |
- let fut = clone!(@strong resp, @strong torrent, @strong folder => async move { |
| 587 |
+ let fut = clone!(#[strong] resp, #[strong] torrent, #[strong] folder, async move { |
| 588 |
let _ = torrent.set_location(folder, resp == "move-data").await; |
| 589 |
}); |
| 590 |
|
| 591 |
@@ -364,28 +489,51 @@ fn open( |
| 592 |
open_containing_folder: bool, |
| 593 |
widget: Option<gtk::Widget>, |
| 594 |
) { |
| 595 |
- let fut = clone!(@strong path, @weak native, @strong open_containing_folder, @strong widget => async move { |
| 596 |
- debug!("Opening: {:?} (containing folder: {})", path, open_containing_folder); |
| 597 |
- match File::open(&path){ |
| 598 |
- Ok(file) => { |
| 599 |
- let identifier = WindowIdentifier::from_native(&native).await; |
| 600 |
- |
| 601 |
- let res = if open_containing_folder || path.is_dir() { |
| 602 |
- OpenDirectoryRequest::default().identifier(identifier).send(&file.as_fd()).await |
| 603 |
- } else { |
| 604 |
- OpenFileRequest::default().identifier(identifier).ask(true).send_file(&file.as_fd()).await |
| 605 |
- }; |
| 606 |
+ let fut = clone!( |
| 607 |
+ #[strong] |
| 608 |
+ path, |
| 609 |
+ #[weak] |
| 610 |
+ native, |
| 611 |
+ #[strong] |
| 612 |
+ open_containing_folder, |
| 613 |
+ #[strong] |
| 614 |
+ widget, |
| 615 |
+ async move { |
| 616 |
+ debug!( |
| 617 |
+ "Opening: {:?} (containing folder: {})", |
| 618 |
+ path, open_containing_folder |
| 619 |
+ ); |
| 620 |
+ match File::open(&path) { |
| 621 |
+ Ok(file) => { |
| 622 |
+ let identifier = WindowIdentifier::from_native(&native).await; |
| 623 |
+ |
| 624 |
+ let res = if open_containing_folder || path.is_dir() { |
| 625 |
+ OpenDirectoryRequest::default() |
| 626 |
+ .identifier(identifier) |
| 627 |
+ .send(&file.as_fd()) |
| 628 |
+ .await |
| 629 |
+ } else { |
| 630 |
+ OpenFileRequest::default() |
| 631 |
+ .identifier(identifier) |
| 632 |
+ .ask(true) |
| 633 |
+ .send_file(&file.as_fd()) |
| 634 |
+ .await |
| 635 |
+ }; |
| 636 |
|
| 637 |
- if let Err(err) = res { |
| 638 |
- warn!("Could not open folder / file: {}", err.to_string()); |
| 639 |
- utils::inapp_notification(&i18n("Unable to open file / folder"), widget.as_ref()); |
| 640 |
+ if let Err(err) = res { |
| 641 |
+ warn!("Could not open folder / file: {}", err.to_string()); |
| 642 |
+ utils::inapp_notification( |
| 643 |
+ &i18n("Unable to open file / folder"), |
| 644 |
+ widget.as_ref(), |
| 645 |
+ ); |
| 646 |
+ } |
| 647 |
+ } |
| 648 |
+ Err(err) => { |
| 649 |
+ warn!("Could not open file: {}", err.to_string()); |
| 650 |
+ utils::inapp_notification(&i18n("Could not open file"), widget.as_ref()); |
| 651 |
} |
| 652 |
- }, |
| 653 |
- Err(err) => { |
| 654 |
- warn!("Could not open file: {}", err.to_string()); |
| 655 |
- utils::inapp_notification(&i18n("Could not open file"), widget.as_ref()); |
| 656 |
} |
| 657 |
} |
| 658 |
- }); |
| 659 |
+ ); |
| 660 |
glib::spawn_future_local(fut); |
| 661 |
} |
| 662 |
diff --git a/src/app.rs b/src/app.rs |
| 663 |
index 987ea22..51260b4 100644 |
| 664 |
--- a/src/app.rs |
| 665 |
+++ b/src/app.rs |
| 666 |
@@ -90,20 +90,24 @@ mod imp { |
| 667 |
} |
| 668 |
|
| 669 |
// Connect to last used connection |
| 670 |
- let fut = clone!(@weak self as this => async move { |
| 671 |
- let cm = FrgConnectionManager::default(); |
| 672 |
+ let fut = clone!( |
| 673 |
+ #[weak(rename_to = this)] |
| 674 |
+ self, |
| 675 |
+ async move { |
| 676 |
+ let cm = FrgConnectionManager::default(); |
| 677 |
|
| 678 |
- let local_connection = FrgConnection::default(); |
| 679 |
- cm.connections().insert(0, &local_connection); |
| 680 |
+ let local_connection = FrgConnection::default(); |
| 681 |
+ cm.connections().insert(0, &local_connection); |
| 682 |
|
| 683 |
- if let Err(err) = secret_store::open_keyring().await { |
| 684 |
- error!("Could not unlock keyring: {err}"); |
| 685 |
- }; |
| 686 |
+ if let Err(err) = secret_store::open_keyring().await { |
| 687 |
+ error!("Could not unlock keyring: {err}"); |
| 688 |
+ }; |
| 689 |
|
| 690 |
- // Restore last used connection |
| 691 |
- let uuid = settings_manager::string(Key::ClientLastConnection); |
| 692 |
- this.set_connection(uuid).await; |
| 693 |
- }); |
| 694 |
+ // Restore last used connection |
| 695 |
+ let uuid = settings_manager::string(Key::ClientLastConnection); |
| 696 |
+ this.set_connection(uuid).await; |
| 697 |
+ } |
| 698 |
+ ); |
| 699 |
glib::spawn_future_local(fut); |
| 700 |
|
| 701 |
// No window available -> we have to create one |
| 702 |
@@ -117,44 +121,60 @@ mod imp { |
| 703 |
|
| 704 |
// app.add-torrent |
| 705 |
let action = gio::SimpleAction::new("add-torrent", None); |
| 706 |
- action.connect_activate(clone!(@weak self as app => move |_, _| { |
| 707 |
- app.open_torrent_filechooser(); |
| 708 |
- })); |
| 709 |
+ action.connect_activate(clone!( |
| 710 |
+ #[weak(rename_to = app)] |
| 711 |
+ self, |
| 712 |
+ move |_, _| { |
| 713 |
+ app.open_torrent_filechooser(); |
| 714 |
+ } |
| 715 |
+ )); |
| 716 |
utils::bind_connected_property(&action); |
| 717 |
obj.add_action(&action); |
| 718 |
obj.set_accels_for_action("app.add-torrent", &["<primary>o"]); |
| 719 |
|
| 720 |
// app.add-link |
| 721 |
let action = gio::SimpleAction::new("add-link", string_ty); |
| 722 |
- action.connect_activate(clone!(@weak self as this => move |_, target| { |
| 723 |
- if let Some(torrent_link) = target.and_then(|x| x.get::<String>()) { |
| 724 |
- // Both magnet and torrent links are supported |
| 725 |
- this.add_torrent_by_link(torrent_link); |
| 726 |
+ action.connect_activate(clone!( |
| 727 |
+ #[weak(rename_to = this)] |
| 728 |
+ self, |
| 729 |
+ move |_, target| { |
| 730 |
+ if let Some(torrent_link) = target.and_then(|x| x.get::<String>()) { |
| 731 |
+ // Both magnet and torrent links are supported |
| 732 |
+ this.add_torrent_by_link(torrent_link); |
| 733 |
+ } |
| 734 |
} |
| 735 |
- })); |
| 736 |
+ )); |
| 737 |
utils::bind_connected_property(&action); |
| 738 |
obj.add_action(&action); |
| 739 |
|
| 740 |
// app.search |
| 741 |
let action = gio::SimpleAction::new("search", None); |
| 742 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 743 |
- window.show_search(false); |
| 744 |
- })); |
| 745 |
+ action.connect_activate(clone!( |
| 746 |
+ #[weak] |
| 747 |
+ window, |
| 748 |
+ move |_, _| { |
| 749 |
+ window.show_search(false); |
| 750 |
+ } |
| 751 |
+ )); |
| 752 |
utils::bind_connected_property(&action); |
| 753 |
obj.add_action(&action); |
| 754 |
obj.set_accels_for_action("app.search", &["<primary>f"]); |
| 755 |
|
| 756 |
// app.toggle-search |
| 757 |
let action = gio::SimpleAction::new("toggle-search", None); |
| 758 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 759 |
- window.show_search(true); |
| 760 |
- })); |
| 761 |
+ action.connect_activate(clone!( |
| 762 |
+ #[weak] |
| 763 |
+ window, |
| 764 |
+ move |_, _| { |
| 765 |
+ window.show_search(true); |
| 766 |
+ } |
| 767 |
+ )); |
| 768 |
utils::bind_connected_property(&action); |
| 769 |
obj.add_action(&action); |
| 770 |
|
| 771 |
// app.resume-torrents |
| 772 |
let action = gio::SimpleAction::new("resume-torrents", None); |
| 773 |
- action.connect_activate(clone!(@weak self as app => move |_, _| { |
| 774 |
+ action.connect_activate(move |_, _| { |
| 775 |
let fut = async move { |
| 776 |
let client = FrgConnectionManager::default().client(); |
| 777 |
if let Err(err) = client.start_torrents().await { |
| 778 |
@@ -162,12 +182,12 @@ mod imp { |
| 779 |
}; |
| 780 |
}; |
| 781 |
glib::spawn_future_local(fut); |
| 782 |
- })); |
| 783 |
+ }); |
| 784 |
obj.add_action(&action); |
| 785 |
|
| 786 |
// app.pause-torrents |
| 787 |
let action = gio::SimpleAction::new("pause-torrents", None); |
| 788 |
- action.connect_activate(clone!(@weak self as app => move |_, _| { |
| 789 |
+ action.connect_activate(move |_, _| { |
| 790 |
let fut = async move { |
| 791 |
let client = FrgConnectionManager::default().client(); |
| 792 |
if let Err(err) = client.stop_torrents().await { |
| 793 |
@@ -175,73 +195,107 @@ mod imp { |
| 794 |
}; |
| 795 |
}; |
| 796 |
glib::spawn_future_local(fut); |
| 797 |
- |
| 798 |
- })); |
| 799 |
+ }); |
| 800 |
obj.add_action(&action); |
| 801 |
|
| 802 |
// app.remove-torrents |
| 803 |
let action = gio::SimpleAction::new("remove-torrents", None); |
| 804 |
- action.connect_activate(clone!(@weak self as this => move |_, _| { |
| 805 |
- this.show_remove_torrents_dialog(); |
| 806 |
- })); |
| 807 |
+ action.connect_activate(clone!( |
| 808 |
+ #[weak(rename_to = this)] |
| 809 |
+ self, |
| 810 |
+ move |_, _| { |
| 811 |
+ this.show_remove_torrents_dialog(); |
| 812 |
+ } |
| 813 |
+ )); |
| 814 |
obj.add_action(&action); |
| 815 |
|
| 816 |
// app.show-stats |
| 817 |
let action = gio::SimpleAction::new("show-stats", None); |
| 818 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 819 |
- FrgStatsDialog::new().present(Some(&window)); |
| 820 |
- })); |
| 821 |
+ action.connect_activate(clone!( |
| 822 |
+ #[weak] |
| 823 |
+ window, |
| 824 |
+ move |_, _| { |
| 825 |
+ FrgStatsDialog::new().present(Some(&window)); |
| 826 |
+ } |
| 827 |
+ )); |
| 828 |
utils::bind_connected_property(&action); |
| 829 |
obj.add_action(&action); |
| 830 |
|
| 831 |
// app.set-connection |
| 832 |
let action = gio::SimpleAction::new("set-connection", string_ty); |
| 833 |
- action.connect_activate(clone!(@weak self as this => move |_, target| { |
| 834 |
- if let Some(connection_uuid) = target.and_then(|x| x.get::<String>()) { |
| 835 |
- let fut = async move { |
| 836 |
- this.set_connection(connection_uuid).await; |
| 837 |
- }; |
| 838 |
- glib::spawn_future_local(fut); |
| 839 |
+ action.connect_activate(clone!( |
| 840 |
+ #[weak(rename_to = this)] |
| 841 |
+ self, |
| 842 |
+ move |_, target| { |
| 843 |
+ if let Some(connection_uuid) = target.and_then(|x| x.get::<String>()) { |
| 844 |
+ let fut = async move { |
| 845 |
+ this.set_connection(connection_uuid).await; |
| 846 |
+ }; |
| 847 |
+ glib::spawn_future_local(fut); |
| 848 |
+ } |
| 849 |
} |
| 850 |
- })); |
| 851 |
+ )); |
| 852 |
obj.add_action(&action); |
| 853 |
|
| 854 |
// app.reconnect |
| 855 |
let action = gio::SimpleAction::new("reconnect", None); |
| 856 |
- action.connect_activate(clone!(@weak self as this => move |_, _| { |
| 857 |
- let cm = FrgConnectionManager::default(); |
| 858 |
- this.obj().activate_action("set-connection", Some(&cm.current_connection().uuid().to_variant())); |
| 859 |
- })); |
| 860 |
+ action.connect_activate(clone!( |
| 861 |
+ #[weak(rename_to = this)] |
| 862 |
+ self, |
| 863 |
+ move |_, _| { |
| 864 |
+ let cm = FrgConnectionManager::default(); |
| 865 |
+ this.obj().activate_action( |
| 866 |
+ "set-connection", |
| 867 |
+ Some(&cm.current_connection().uuid().to_variant()), |
| 868 |
+ ); |
| 869 |
+ } |
| 870 |
+ )); |
| 871 |
obj.add_action(&action); |
| 872 |
|
| 873 |
// app.add-remote-connection |
| 874 |
let action = gio::SimpleAction::new("add-remote-connection", None); |
| 875 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 876 |
- let dialog = FrgAddConnectionDialog::new(); |
| 877 |
- dialog.present(Some(&window)); |
| 878 |
- })); |
| 879 |
+ action.connect_activate(clone!( |
| 880 |
+ #[weak] |
| 881 |
+ window, |
| 882 |
+ move |_, _| { |
| 883 |
+ let dialog = FrgAddConnectionDialog::new(); |
| 884 |
+ dialog.present(Some(&window)); |
| 885 |
+ } |
| 886 |
+ )); |
| 887 |
obj.add_action(&action); |
| 888 |
|
| 889 |
// app.show-preferences |
| 890 |
let action = gio::SimpleAction::new("show-preferences", None); |
| 891 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 892 |
- FrgPreferencesDialog::default().present(Some(&window)); |
| 893 |
- })); |
| 894 |
+ action.connect_activate(clone!( |
| 895 |
+ #[weak] |
| 896 |
+ window, |
| 897 |
+ move |_, _| { |
| 898 |
+ FrgPreferencesDialog::default().present(Some(&window)); |
| 899 |
+ } |
| 900 |
+ )); |
| 901 |
obj.set_accels_for_action("app.show-preferences", &["<primary>comma"]); |
| 902 |
obj.add_action(&action); |
| 903 |
|
| 904 |
// app.about |
| 905 |
let action = gio::SimpleAction::new("about", None); |
| 906 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 907 |
- about_dialog::show(&window); |
| 908 |
- })); |
| 909 |
+ action.connect_activate(clone!( |
| 910 |
+ #[weak] |
| 911 |
+ window, |
| 912 |
+ move |_, _| { |
| 913 |
+ about_dialog::show(&window); |
| 914 |
+ } |
| 915 |
+ )); |
| 916 |
obj.add_action(&action); |
| 917 |
|
| 918 |
// app.quit |
| 919 |
let action = gio::SimpleAction::new("quit", None); |
| 920 |
- action.connect_activate(clone!(@weak window => move |_, _| { |
| 921 |
- window.close(); |
| 922 |
- })); |
| 923 |
+ action.connect_activate(clone!( |
| 924 |
+ #[weak] |
| 925 |
+ window, |
| 926 |
+ move |_, _| { |
| 927 |
+ window.close(); |
| 928 |
+ } |
| 929 |
+ )); |
| 930 |
obj.set_accels_for_action("app.quit", &["<primary>q"]); |
| 931 |
obj.add_action(&action); |
| 932 |
|
| 933 |
@@ -249,25 +303,45 @@ mod imp { |
| 934 |
|
| 935 |
// Update state of `pause-torrents` and `remove-torrents` action |
| 936 |
let stats = FrgConnectionManager::default().client().session_stats(); |
| 937 |
- stats.connect_active_torrent_count_notify(clone!(@weak self as this => move |_|{ |
| 938 |
- this.obj().update_inhibit_state(); |
| 939 |
- })); |
| 940 |
- stats.connect_downloaded_torrent_count_notify(clone!(@weak self as this => move |_|{ |
| 941 |
- this.update_session_gactions(); |
| 942 |
- this.obj().update_inhibit_state(); |
| 943 |
- })); |
| 944 |
- stats.connect_paused_torrent_count_notify(clone!(@weak self as this => move |_|{ |
| 945 |
- this.update_session_gactions(); |
| 946 |
- this.obj().update_inhibit_state(); |
| 947 |
- })); |
| 948 |
- stats.connect_torrent_count_notify(clone!(@weak self as this => move |_|{ |
| 949 |
- this.update_session_gactions(); |
| 950 |
- })); |
| 951 |
+ stats.connect_active_torrent_count_notify(clone!( |
| 952 |
+ #[weak(rename_to = this)] |
| 953 |
+ self, |
| 954 |
+ move |_| { |
| 955 |
+ this.obj().update_inhibit_state(); |
| 956 |
+ } |
| 957 |
+ )); |
| 958 |
+ stats.connect_downloaded_torrent_count_notify(clone!( |
| 959 |
+ #[weak(rename_to = this)] |
| 960 |
+ self, |
| 961 |
+ move |_| { |
| 962 |
+ this.update_session_gactions(); |
| 963 |
+ this.obj().update_inhibit_state(); |
| 964 |
+ } |
| 965 |
+ )); |
| 966 |
+ stats.connect_paused_torrent_count_notify(clone!( |
| 967 |
+ #[weak(rename_to = this)] |
| 968 |
+ self, |
| 969 |
+ move |_| { |
| 970 |
+ this.update_session_gactions(); |
| 971 |
+ this.obj().update_inhibit_state(); |
| 972 |
+ } |
| 973 |
+ )); |
| 974 |
+ stats.connect_torrent_count_notify(clone!( |
| 975 |
+ #[weak(rename_to = this)] |
| 976 |
+ self, |
| 977 |
+ move |_| { |
| 978 |
+ this.update_session_gactions(); |
| 979 |
+ } |
| 980 |
+ )); |
| 981 |
|
| 982 |
let client = FrgConnectionManager::default().client(); |
| 983 |
- client.connect_is_connected_notify(clone!(@weak self as this => move |_|{ |
| 984 |
- this.update_session_gactions(); |
| 985 |
- })); |
| 986 |
+ client.connect_is_connected_notify(clone!( |
| 987 |
+ #[weak(rename_to = this)] |
| 988 |
+ self, |
| 989 |
+ move |_| { |
| 990 |
+ this.update_session_gactions(); |
| 991 |
+ } |
| 992 |
+ )); |
| 993 |
|
| 994 |
self.update_session_gactions(); |
| 995 |
} |
| 996 |
@@ -285,8 +359,14 @@ mod imp { |
| 997 |
// Wait till we're connected with something to add the files |
| 998 |
let signal_id: Rc<RefCell<Option<glib::SignalHandlerId>>> = Rc::default(); |
| 999 |
let files = files.to_vec().clone(); |
| 1000 |
- *signal_id.borrow_mut() = Some(client.connect_is_connected_notify( |
| 1001 |
- clone!(@weak application, @strong signal_id, @strong files => move |client| { |
| 1002 |
+ *signal_id.borrow_mut() = Some(client.connect_is_connected_notify(clone!( |
| 1003 |
+ #[weak] |
| 1004 |
+ application, |
| 1005 |
+ #[strong] |
| 1006 |
+ signal_id, |
| 1007 |
+ #[strong] |
| 1008 |
+ files, |
| 1009 |
+ move |client| { |
| 1010 |
if client.is_connected() { |
| 1011 |
application.add_torrents_from_files(&files); |
| 1012 |
|
| 1013 |
@@ -294,8 +374,8 @@ mod imp { |
| 1014 |
let signal_id = signal_id.borrow_mut().take().unwrap(); |
| 1015 |
glib::object::ObjectExt::disconnect(client, signal_id); |
| 1016 |
} |
| 1017 |
- }), |
| 1018 |
- )); |
| 1019 |
+ } |
| 1020 |
+ ))); |
| 1021 |
} |
| 1022 |
} |
| 1023 |
} |
| 1024 |
@@ -387,32 +467,46 @@ mod imp { |
| 1025 |
} |
| 1026 |
} |
| 1027 |
|
| 1028 |
- let fut = clone!(@strong file => async move { |
| 1029 |
- match fs::read(&file).await { |
| 1030 |
- Ok(content) => { |
| 1031 |
- let encoded = STANDARD.encode(content); |
| 1032 |
- |
| 1033 |
- let cm = FrgConnectionManager::default(); |
| 1034 |
- let res = cm.add_torrent_by_metainfo(encoded).await; |
| 1035 |
- if let Err(err) = res { |
| 1036 |
- debug!("Could not add file torrent: {:?}", err); |
| 1037 |
- utils::inapp_notification("Unable to add file torrent", gtk::Widget::NONE); |
| 1038 |
- } |
| 1039 |
+ let fut = clone!( |
| 1040 |
+ #[strong] |
| 1041 |
+ file, |
| 1042 |
+ async move { |
| 1043 |
+ match fs::read(&file).await { |
| 1044 |
+ Ok(content) => { |
| 1045 |
+ let encoded = STANDARD.encode(content); |
| 1046 |
+ |
| 1047 |
+ let cm = FrgConnectionManager::default(); |
| 1048 |
+ let res = cm.add_torrent_by_metainfo(encoded).await; |
| 1049 |
+ if let Err(err) = res { |
| 1050 |
+ debug!("Could not add file torrent: {:?}", err); |
| 1051 |
+ utils::inapp_notification( |
| 1052 |
+ "Unable to add file torrent", |
| 1053 |
+ gtk::Widget::NONE, |
| 1054 |
+ ); |
| 1055 |
+ } |
| 1056 |
|
| 1057 |
- if settings_manager::boolean(Key::TrashOriginalTorrentFiles){ |
| 1058 |
- let gfile = gio::File::for_path(file); |
| 1059 |
- if let Err(err) = gfile.trash_future(glib::Priority::DEFAULT).await { |
| 1060 |
- debug!("Unable to trash torrent file: {:?}", err); |
| 1061 |
- utils::inapp_notification("Unable to trash torrent file", gtk::Widget::NONE); |
| 1062 |
+ if settings_manager::boolean(Key::TrashOriginalTorrentFiles) { |
| 1063 |
+ let gfile = gio::File::for_path(file); |
| 1064 |
+ if let Err(err) = gfile.trash_future(glib::Priority::DEFAULT).await |
| 1065 |
+ { |
| 1066 |
+ debug!("Unable to trash torrent file: {:?}", err); |
| 1067 |
+ utils::inapp_notification( |
| 1068 |
+ "Unable to trash torrent file", |
| 1069 |
+ gtk::Widget::NONE, |
| 1070 |
+ ); |
| 1071 |
+ } |
| 1072 |
} |
| 1073 |
} |
| 1074 |
- } |
| 1075 |
- Err(err) => { |
| 1076 |
- debug!("Unable to read file content: {:?}", err); |
| 1077 |
- utils::inapp_notification("Unable to read file content", gtk::Widget::NONE); |
| 1078 |
+ Err(err) => { |
| 1079 |
+ debug!("Unable to read file content: {:?}", err); |
| 1080 |
+ utils::inapp_notification( |
| 1081 |
+ "Unable to read file content", |
| 1082 |
+ gtk::Widget::NONE, |
| 1083 |
+ ); |
| 1084 |
+ } |
| 1085 |
} |
| 1086 |
} |
| 1087 |
- }); |
| 1088 |
+ ); |
| 1089 |
|
| 1090 |
glib::spawn_future_local(fut); |
| 1091 |
} |
| 1092 |
@@ -460,16 +554,22 @@ mod imp { |
| 1093 |
dialog.open_multiple( |
| 1094 |
Some(&window), |
| 1095 |
gio::Cancellable::NONE, |
| 1096 |
- clone!(@strong dialog, @weak self as this => move |result| { |
| 1097 |
- if let Ok(files) = result { |
| 1098 |
- let files = files |
| 1099 |
- .snapshot() |
| 1100 |
- .iter() |
| 1101 |
- .map(|o| o.downcast_ref::<gio::File>().unwrap().clone()) |
| 1102 |
- .collect(); |
| 1103 |
- this.obj().add_torrents_from_files(&files); |
| 1104 |
+ clone!( |
| 1105 |
+ #[strong(rename_to = _dialog)] |
| 1106 |
+ dialog, |
| 1107 |
+ #[weak(rename_to = this)] |
| 1108 |
+ self, |
| 1109 |
+ move |result| { |
| 1110 |
+ if let Ok(files) = result { |
| 1111 |
+ let files = files |
| 1112 |
+ .snapshot() |
| 1113 |
+ .iter() |
| 1114 |
+ .map(|o| o.downcast_ref::<gio::File>().unwrap().clone()) |
| 1115 |
+ .collect(); |
| 1116 |
+ this.obj().add_torrents_from_files(&files); |
| 1117 |
+ } |
| 1118 |
} |
| 1119 |
- }), |
| 1120 |
+ ), |
| 1121 |
); |
| 1122 |
} |
| 1123 |
|
| 1124 |
diff --git a/src/backend/connection.rs b/src/backend/connection.rs |
| 1125 |
index 614957d..82dd317 100644 |
| 1126 |
--- a/src/backend/connection.rs |
| 1127 |
+++ b/src/backend/connection.rs |
| 1128 |
@@ -1,5 +1,5 @@ |
| 1129 |
// Fragments - connection.rs |
| 1130 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 1131 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1132 |
// |
| 1133 |
// This program is free software: you can redistribute it and/or modify |
| 1134 |
// it under the terms of the GNU General Public License as published by |
| 1135 |
diff --git a/src/backend/connection_manager.rs b/src/backend/connection_manager.rs |
| 1136 |
index d747aeb..b7e2ac8 100644 |
| 1137 |
--- a/src/backend/connection_manager.rs |
| 1138 |
+++ b/src/backend/connection_manager.rs |
| 1139 |
@@ -1,5 +1,5 @@ |
| 1140 |
// Fragments - connection_manager.rs |
| 1141 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 1142 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1143 |
// |
| 1144 |
// This program is free software: you can redistribute it and/or modify |
| 1145 |
// it under the terms of the GNU General Public License as published by |
| 1146 |
@@ -112,15 +112,22 @@ mod imp { |
| 1147 |
self.parent_constructed(); |
| 1148 |
|
| 1149 |
let nm = gio::NetworkMonitor::default(); |
| 1150 |
- nm.connect_network_metered_notify(clone!(@weak self as this => move |_| { |
| 1151 |
- this.check_for_stop_reason(); |
| 1152 |
- })); |
| 1153 |
+ nm.connect_network_metered_notify(clone!( |
| 1154 |
+ #[weak(rename_to = this)] |
| 1155 |
+ self, |
| 1156 |
+ move |_| { |
| 1157 |
+ this.check_for_stop_reason(); |
| 1158 |
+ } |
| 1159 |
+ )); |
| 1160 |
|
| 1161 |
self.read_connections(); |
| 1162 |
- self.connections |
| 1163 |
- .connect_items_changed(clone!(@weak self as this => move |_, _, _, _|{ |
| 1164 |
+ self.connections.connect_items_changed(clone!( |
| 1165 |
+ #[weak(rename_to = this)] |
| 1166 |
+ self, |
| 1167 |
+ move |_, _, _, _| { |
| 1168 |
this.write_connections(); |
| 1169 |
- })); |
| 1170 |
+ } |
| 1171 |
+ )); |
| 1172 |
} |
| 1173 |
|
| 1174 |
fn signals() -> &'static [Signal] { |
| 1175 |
@@ -214,22 +221,38 @@ mod imp { |
| 1176 |
} |
| 1177 |
|
| 1178 |
info!("Reason for stopping daemon: {:?}", reason); |
| 1179 |
- let fut = clone!(@weak self as this, @strong reason => async move { |
| 1180 |
- let res = this.stop_daemon(&reason).await; |
| 1181 |
- if let Err(e) = res { |
| 1182 |
- utils::inapp_notification(&i18n("Unable to stop transmission-daemon"), gtk::Widget::NONE); |
| 1183 |
- error!("Unable to stop transmission-daemon: {}", e.to_string()); |
| 1184 |
+ let fut = clone!( |
| 1185 |
+ #[weak(rename_to = this)] |
| 1186 |
+ self, |
| 1187 |
+ #[strong] |
| 1188 |
+ reason, |
| 1189 |
+ async move { |
| 1190 |
+ let res = this.stop_daemon(&reason).await; |
| 1191 |
+ if let Err(e) = res { |
| 1192 |
+ utils::inapp_notification( |
| 1193 |
+ &i18n("Unable to stop transmission-daemon"), |
| 1194 |
+ gtk::Widget::NONE, |
| 1195 |
+ ); |
| 1196 |
+ error!("Unable to stop transmission-daemon: {}", e.to_string()); |
| 1197 |
+ } |
| 1198 |
} |
| 1199 |
- }); |
| 1200 |
+ ); |
| 1201 |
glib::spawn_future_local(fut); |
| 1202 |
} else if stop_reason.is_none() && is_fragments { |
| 1203 |
- let fut = clone!(@weak self as this => async move { |
| 1204 |
- let res = this.start_daemon().await; |
| 1205 |
- if let Err(e) = res { |
| 1206 |
- utils::inapp_notification(&i18n("Unable to start transmission-daemon"), gtk::Widget::NONE); |
| 1207 |
- error!("Unable to start transmission-daemon: {}", e.to_string()); |
| 1208 |
+ let fut = clone!( |
| 1209 |
+ #[weak(rename_to = this)] |
| 1210 |
+ self, |
| 1211 |
+ async move { |
| 1212 |
+ let res = this.start_daemon().await; |
| 1213 |
+ if let Err(e) = res { |
| 1214 |
+ utils::inapp_notification( |
| 1215 |
+ &i18n("Unable to start transmission-daemon"), |
| 1216 |
+ gtk::Widget::NONE, |
| 1217 |
+ ); |
| 1218 |
+ error!("Unable to start transmission-daemon: {}", e.to_string()); |
| 1219 |
+ } |
| 1220 |
} |
| 1221 |
- }); |
| 1222 |
+ ); |
| 1223 |
glib::spawn_future_local(fut); |
| 1224 |
} |
| 1225 |
} |
| 1226 |
diff --git a/src/backend/daemon.rs b/src/backend/daemon.rs |
| 1227 |
index 8afee2e..61a7179 100644 |
| 1228 |
--- a/src/backend/daemon.rs |
| 1229 |
+++ b/src/backend/daemon.rs |
| 1230 |
@@ -1,3 +1,19 @@ |
| 1231 |
+// Fragments - daemon.rs |
| 1232 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1233 |
+// |
| 1234 |
+// This program is free software: you can redistribute it and/or modify |
| 1235 |
+// it under the terms of the GNU General Public License as published by |
| 1236 |
+// the Free Software Foundation, either version 3 of the License, or |
| 1237 |
+// (at your option) any later version. |
| 1238 |
+// |
| 1239 |
+// This program is distributed in the hope that it will be useful, |
| 1240 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1241 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1242 |
+// GNU General Public License for more details. |
| 1243 |
+// |
| 1244 |
+// You should have received a copy of the GNU General Public License |
| 1245 |
+// along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 1246 |
+ |
| 1247 |
use std::cell::RefCell; |
| 1248 |
use std::fs; |
| 1249 |
use std::path::Path; |
| 1250 |
diff --git a/src/ui/add_connection_dialog.rs b/src/ui/add_connection_dialog.rs |
| 1251 |
index b83597d..2984bf9 100644 |
| 1252 |
--- a/src/ui/add_connection_dialog.rs |
| 1253 |
+++ b/src/ui/add_connection_dialog.rs |
| 1254 |
@@ -1,5 +1,5 @@ |
| 1255 |
// Fragments - add_connection_dialog.rs |
| 1256 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 1257 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1258 |
// |
| 1259 |
// This program is free software: you can redistribute it and/or modify |
| 1260 |
// it under the terms of the GNU General Public License as published by |
| 1261 |
@@ -48,8 +48,6 @@ mod imp { |
| 1262 |
connect_button: TemplateChild<gtk::Button>, |
| 1263 |
#[template_child] |
| 1264 |
error_label: TemplateChild<gtk::Label>, |
| 1265 |
- #[template_child] |
| 1266 |
- spinner: TemplateChild<gtk::Spinner>, |
| 1267 |
|
| 1268 |
title_ok: Cell<bool>, |
| 1269 |
address_ok: Cell<bool>, |
| 1270 |
@@ -91,36 +89,41 @@ mod imp { |
| 1271 |
|
| 1272 |
#[template_callback] |
| 1273 |
fn connect_button_clicked(&self) { |
| 1274 |
- let fut = clone!(@weak self as this => async move { |
| 1275 |
- let title = this.title_row.text(); |
| 1276 |
- let address = this.address.borrow().clone(); |
| 1277 |
- |
| 1278 |
- let connection = FrgConnection::new(&title, &address); |
| 1279 |
- |
| 1280 |
- this.stack.set_visible_child_name("loading"); |
| 1281 |
- this.spinner.set_spinning(true); |
| 1282 |
- this.connect_button.set_sensitive(false); |
| 1283 |
- |
| 1284 |
- let res = TrClient::test_connectivity(connection.address(), None).await; |
| 1285 |
- match res { |
| 1286 |
- Ok(_) => this.add_connection(connection), |
| 1287 |
- Err(ref err) => { |
| 1288 |
- // Skip "Unauthorized" errors since we can handle those |
| 1289 |
- if matches!(err, ClientError::TransmissionUnauthorized) { |
| 1290 |
- this.add_connection(connection); |
| 1291 |
- } else { |
| 1292 |
- let msg = i18n_f("Could not connect with “{}”:\n{}", &[&this.address.borrow(), &err.to_string()]); |
| 1293 |
- |
| 1294 |
- this.error_label.set_visible(true); |
| 1295 |
- this.error_label.set_text(&msg); |
| 1296 |
- |
| 1297 |
- this.stack.set_visible_child_name("input"); |
| 1298 |
- this.spinner.set_spinning(false); |
| 1299 |
- this.connect_button.set_sensitive(true); |
| 1300 |
+ let fut = clone!( |
| 1301 |
+ #[weak(rename_to = this)] |
| 1302 |
+ self, |
| 1303 |
+ async move { |
| 1304 |
+ let title = this.title_row.text(); |
| 1305 |
+ let address = this.address.borrow().clone(); |
| 1306 |
+ |
| 1307 |
+ let connection = FrgConnection::new(&title, &address); |
| 1308 |
+ |
| 1309 |
+ this.stack.set_visible_child_name("loading"); |
| 1310 |
+ this.connect_button.set_sensitive(false); |
| 1311 |
+ |
| 1312 |
+ let res = TrClient::test_connectivity(connection.address(), None).await; |
| 1313 |
+ match res { |
| 1314 |
+ Ok(_) => this.add_connection(connection), |
| 1315 |
+ Err(ref err) => { |
| 1316 |
+ // Skip "Unauthorized" errors since we can handle those |
| 1317 |
+ if matches!(err, ClientError::TransmissionUnauthorized) { |
| 1318 |
+ this.add_connection(connection); |
| 1319 |
+ } else { |
| 1320 |
+ let msg = i18n_f( |
| 1321 |
+ "Could not connect with “{}”:\n{}", |
| 1322 |
+ &[&this.address.borrow(), &err.to_string()], |
| 1323 |
+ ); |
| 1324 |
+ |
| 1325 |
+ this.error_label.set_visible(true); |
| 1326 |
+ this.error_label.set_text(&msg); |
| 1327 |
+ |
| 1328 |
+ this.stack.set_visible_child_name("input"); |
| 1329 |
+ this.connect_button.set_sensitive(true); |
| 1330 |
+ } |
| 1331 |
} |
| 1332 |
} |
| 1333 |
} |
| 1334 |
- }); |
| 1335 |
+ ); |
| 1336 |
glib::spawn_future_local(fut); |
| 1337 |
} |
| 1338 |
|
| 1339 |
@@ -179,7 +182,8 @@ mod imp { |
| 1340 |
|
| 1341 |
glib::wrapper! { |
| 1342 |
pub struct FrgAddConnectionDialog(ObjectSubclass<imp::FrgAddConnectionDialog>) |
| 1343 |
- @extends gtk::Widget, adw::Dialog; |
| 1344 |
+ @extends gtk::Widget, adw::Dialog, |
| 1345 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1346 |
} |
| 1347 |
|
| 1348 |
impl FrgAddConnectionDialog { |
| 1349 |
diff --git a/src/ui/connection_box.rs b/src/ui/connection_box.rs |
| 1350 |
index 711ae6f..3d528db 100644 |
| 1351 |
--- a/src/ui/connection_box.rs |
| 1352 |
+++ b/src/ui/connection_box.rs |
| 1353 |
@@ -1,5 +1,5 @@ |
| 1354 |
// Fragments - connection_box.rs |
| 1355 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 1356 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1357 |
// |
| 1358 |
// This program is free software: you can redistribute it and/or modify |
| 1359 |
// it under the terms of the GNU General Public License as published by |
| 1360 |
@@ -49,8 +49,6 @@ mod imp { |
| 1361 |
#[template_child] |
| 1362 |
pub torrent_page: TemplateChild<FrgTorrentPage>, |
| 1363 |
#[template_child] |
| 1364 |
- spinner: TemplateChild<gtk::Spinner>, |
| 1365 |
- #[template_child] |
| 1366 |
welcome_status_page: TemplateChild<adw::StatusPage>, |
| 1367 |
#[template_child] |
| 1368 |
failure_status_page: TemplateChild<adw::StatusPage>, |
| 1369 |
@@ -99,51 +97,70 @@ mod imp { |
| 1370 |
self.set_view(View::Loading); |
| 1371 |
|
| 1372 |
// Show a message when the currently configured directory is not accessible |
| 1373 |
- cm.connect_invalid_dir_notify(clone!(@weak self as this => move |cm|{ |
| 1374 |
- let res: Option<String> = match cm.invalid_dir(){ |
| 1375 |
- FrgDirectoryType::Download => Some( |
| 1376 |
- i18n("The configured download directory cannot be accessed."), |
| 1377 |
- ), |
| 1378 |
- FrgDirectoryType::Incomplete => Some( |
| 1379 |
- i18n("The configured incomplete directory cannot be accessed."), |
| 1380 |
- ), |
| 1381 |
- _ => None, |
| 1382 |
- }; |
| 1383 |
+ cm.connect_invalid_dir_notify(clone!( |
| 1384 |
+ #[weak(rename_to = this)] |
| 1385 |
+ self, |
| 1386 |
+ move |cm| { |
| 1387 |
+ let res: Option<String> = match cm.invalid_dir() { |
| 1388 |
+ FrgDirectoryType::Download => Some(i18n( |
| 1389 |
+ "The configured download directory cannot be accessed.", |
| 1390 |
+ )), |
| 1391 |
+ FrgDirectoryType::Incomplete => Some(i18n( |
| 1392 |
+ "The configured incomplete directory cannot be accessed.", |
| 1393 |
+ )), |
| 1394 |
+ _ => None, |
| 1395 |
+ }; |
| 1396 |
|
| 1397 |
- if let Some(res) = res{ |
| 1398 |
- this.invalid_dir_banner.set_revealed(true); |
| 1399 |
- this.invalid_dir_banner.set_title(&res); |
| 1400 |
- }else{ |
| 1401 |
- this.invalid_dir_banner.set_revealed(false); |
| 1402 |
+ if let Some(res) = res { |
| 1403 |
+ this.invalid_dir_banner.set_revealed(true); |
| 1404 |
+ this.invalid_dir_banner.set_title(&res); |
| 1405 |
+ } else { |
| 1406 |
+ this.invalid_dir_banner.set_revealed(false); |
| 1407 |
+ } |
| 1408 |
} |
| 1409 |
- })); |
| 1410 |
+ )); |
| 1411 |
|
| 1412 |
cm.connect_local( |
| 1413 |
"daemon-started", |
| 1414 |
false, |
| 1415 |
- clone!(@weak self as this => @default-panic, move |_| { |
| 1416 |
- this.update_torrents_view(); |
| 1417 |
- None |
| 1418 |
- }), |
| 1419 |
+ clone!( |
| 1420 |
+ #[weak(rename_to = this)] |
| 1421 |
+ self, |
| 1422 |
+ #[upgrade_or_panic] |
| 1423 |
+ move |_| { |
| 1424 |
+ this.update_torrents_view(); |
| 1425 |
+ None |
| 1426 |
+ } |
| 1427 |
+ ), |
| 1428 |
); |
| 1429 |
|
| 1430 |
cm.connect_local( |
| 1431 |
"daemon-stopped", |
| 1432 |
false, |
| 1433 |
- clone!(@weak self as this => @default-panic, move |val| { |
| 1434 |
- let reason = val[1].get::<FrgDaemonStopReason>().unwrap(); |
| 1435 |
- this.show_stop_reason(reason); |
| 1436 |
- None |
| 1437 |
- }), |
| 1438 |
+ clone!( |
| 1439 |
+ #[weak(rename_to = this)] |
| 1440 |
+ self, |
| 1441 |
+ #[upgrade_or_panic] |
| 1442 |
+ move |val| { |
| 1443 |
+ let reason = val[1].get::<FrgDaemonStopReason>().unwrap(); |
| 1444 |
+ this.show_stop_reason(reason); |
| 1445 |
+ None |
| 1446 |
+ } |
| 1447 |
+ ), |
| 1448 |
); |
| 1449 |
|
| 1450 |
client.torrents().connect_local( |
| 1451 |
"items-changed", |
| 1452 |
false, |
| 1453 |
- clone!(@weak self as this => @default-panic, move |_| { |
| 1454 |
- this.update_torrents_view(); |
| 1455 |
- None |
| 1456 |
- }), |
| 1457 |
+ clone!( |
| 1458 |
+ #[weak(rename_to = this)] |
| 1459 |
+ self, |
| 1460 |
+ #[upgrade_or_panic] |
| 1461 |
+ move |_| { |
| 1462 |
+ this.update_torrents_view(); |
| 1463 |
+ None |
| 1464 |
+ } |
| 1465 |
+ ), |
| 1466 |
); |
| 1467 |
|
| 1468 |
client.connect_local("connection-failure", false, move |_| { |
| 1469 |
@@ -165,31 +182,35 @@ mod imp { |
| 1470 |
let drop_target = self.drag_overlay.drop_target(); |
| 1471 |
drop_target.set_types(&[gdk::FileList::static_type()]); |
| 1472 |
|
| 1473 |
- drop_target.connect_accept(clone!(@weak client => @default-return false, move |_, _| { |
| 1474 |
- // Only accept drops when we're connected to a Transmission session |
| 1475 |
- client.is_connected() |
| 1476 |
- })); |
| 1477 |
- |
| 1478 |
- drop_target.connect_drop( |
| 1479 |
- clone!(@weak cm => @default-return false, move |_, value, _, _| { |
| 1480 |
- let files = match value.get::<gdk::FileList>() { |
| 1481 |
- Ok(list) => list.files(), |
| 1482 |
- Err(err) => { |
| 1483 |
- error!("Issue with drop value: {err}"); |
| 1484 |
- return false; |
| 1485 |
- } |
| 1486 |
- }; |
| 1487 |
+ drop_target.connect_accept(clone!( |
| 1488 |
+ #[weak] |
| 1489 |
+ client, |
| 1490 |
+ #[upgrade_or] |
| 1491 |
+ false, |
| 1492 |
+ move |_, _| { |
| 1493 |
+ // Only accept drops when we're connected to a Transmission session |
| 1494 |
+ client.is_connected() |
| 1495 |
+ } |
| 1496 |
+ )); |
| 1497 |
|
| 1498 |
- if !files.is_empty() { |
| 1499 |
- let app = FrgApplication::default(); |
| 1500 |
- app.add_torrents_from_files(&files); |
| 1501 |
- return true; |
| 1502 |
- } else { |
| 1503 |
- error!("Dropped FileList was empty"); |
| 1504 |
+ drop_target.connect_drop(move |_, value, _, _| { |
| 1505 |
+ let files = match value.get::<gdk::FileList>() { |
| 1506 |
+ Ok(list) => list.files(), |
| 1507 |
+ Err(err) => { |
| 1508 |
+ error!("Issue with drop value: {err}"); |
| 1509 |
return false; |
| 1510 |
} |
| 1511 |
- }), |
| 1512 |
- ); |
| 1513 |
+ }; |
| 1514 |
+ |
| 1515 |
+ if !files.is_empty() { |
| 1516 |
+ let app = FrgApplication::default(); |
| 1517 |
+ app.add_torrents_from_files(&files); |
| 1518 |
+ return true; |
| 1519 |
+ } else { |
| 1520 |
+ error!("Dropped FileList was empty"); |
| 1521 |
+ return false; |
| 1522 |
+ } |
| 1523 |
+ }); |
| 1524 |
|
| 1525 |
self.stack.add_controller(drop_target.clone()); |
| 1526 |
} |
| 1527 |
@@ -236,8 +257,6 @@ mod imp { |
| 1528 |
} |
| 1529 |
|
| 1530 |
pub fn set_view(&self, view: View) { |
| 1531 |
- self.spinner.set_spinning(false); |
| 1532 |
- |
| 1533 |
let name = match view { |
| 1534 |
View::Authentication => { |
| 1535 |
// Unset previous entry text |
| 1536 |
@@ -245,10 +264,7 @@ mod imp { |
| 1537 |
self.password_row.set_text(""); |
| 1538 |
"authentication" |
| 1539 |
} |
| 1540 |
- View::Loading => { |
| 1541 |
- self.spinner.set_spinning(true); |
| 1542 |
- "loading" |
| 1543 |
- } |
| 1544 |
+ View::Loading => "loading", |
| 1545 |
View::Ready => "ready", |
| 1546 |
View::Torrents => "torrents", |
| 1547 |
View::Metered => "metered", |
| 1548 |
@@ -300,7 +316,8 @@ mod imp { |
| 1549 |
glib::wrapper! { |
| 1550 |
pub struct FrgConnectionBox( |
| 1551 |
ObjectSubclass<imp::FrgConnectionBox>) |
| 1552 |
- @extends gtk::Widget, gtk::Box; |
| 1553 |
+ @extends gtk::Widget, gtk::Box, |
| 1554 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1555 |
} |
| 1556 |
|
| 1557 |
impl FrgConnectionBox { |
| 1558 |
diff --git a/src/ui/connection_popover.rs b/src/ui/connection_popover.rs |
| 1559 |
index 3730dd9..1a8b5ea 100644 |
| 1560 |
--- a/src/ui/connection_popover.rs |
| 1561 |
+++ b/src/ui/connection_popover.rs |
| 1562 |
@@ -1,5 +1,5 @@ |
| 1563 |
// Fragments - connection_popover.rs |
| 1564 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 1565 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1566 |
// |
| 1567 |
// This program is free software: you can redistribute it and/or modify |
| 1568 |
// it under the terms of the GNU General Public License as published by |
| 1569 |
@@ -53,14 +53,20 @@ mod imp { |
| 1570 |
self.parent_constructed(); |
| 1571 |
let cm = FrgConnectionManager::default(); |
| 1572 |
|
| 1573 |
- self.listbox |
| 1574 |
- .connect_row_activated(clone!(@weak self as this => move |_, row|{ |
| 1575 |
+ self.listbox.connect_row_activated(clone!( |
| 1576 |
+ #[weak(rename_to = this)] |
| 1577 |
+ self, |
| 1578 |
+ move |_, row| { |
| 1579 |
let row = row.downcast_ref::<FrgConnectionRow>().unwrap(); |
| 1580 |
let app = FrgApplication::default(); |
| 1581 |
|
| 1582 |
- app.activate_action("set-connection", Some(&row.connection().uuid().to_variant())); |
| 1583 |
+ app.activate_action( |
| 1584 |
+ "set-connection", |
| 1585 |
+ Some(&row.connection().uuid().to_variant()), |
| 1586 |
+ ); |
| 1587 |
this.obj().popdown(); |
| 1588 |
- })); |
| 1589 |
+ } |
| 1590 |
+ )); |
| 1591 |
|
| 1592 |
self.listbox |
| 1593 |
.bind_model(Some(&cm.connections()), |connection| { |
| 1594 |
@@ -68,21 +74,31 @@ mod imp { |
| 1595 |
.upcast() |
| 1596 |
}); |
| 1597 |
|
| 1598 |
- cm.connect_current_connection_notify(clone!(@weak self as this => move |_|{ |
| 1599 |
- this.update_ui(); |
| 1600 |
- })); |
| 1601 |
+ cm.connect_current_connection_notify(clone!( |
| 1602 |
+ #[weak(rename_to = this)] |
| 1603 |
+ self, |
| 1604 |
+ move |_| { |
| 1605 |
+ this.update_ui(); |
| 1606 |
+ } |
| 1607 |
+ )); |
| 1608 |
|
| 1609 |
- cm.client() |
| 1610 |
- .connect_is_busy_notify(clone!(@weak self as this => move |client|{ |
| 1611 |
+ cm.client().connect_is_busy_notify(clone!( |
| 1612 |
+ #[weak(rename_to = this)] |
| 1613 |
+ self, |
| 1614 |
+ move |client| { |
| 1615 |
// Don't allow changing the active connection |
| 1616 |
// when the client is still busy establishing a connection |
| 1617 |
this.obj().set_sensitive(!client.is_busy()); |
| 1618 |
- })); |
| 1619 |
+ } |
| 1620 |
+ )); |
| 1621 |
|
| 1622 |
- cm.connections() |
| 1623 |
- .connect_items_changed(clone!(@weak self as this => move |_,_,_,_|{ |
| 1624 |
+ cm.connections().connect_items_changed(clone!( |
| 1625 |
+ #[weak(rename_to = this)] |
| 1626 |
+ self, |
| 1627 |
+ move |_, _, _, _| { |
| 1628 |
this.update_ui(); |
| 1629 |
- })); |
| 1630 |
+ } |
| 1631 |
+ )); |
| 1632 |
|
| 1633 |
self.update_ui(); |
| 1634 |
} |
| 1635 |
@@ -111,5 +127,6 @@ mod imp { |
| 1636 |
glib::wrapper! { |
| 1637 |
pub struct FrgConnectionPopover( |
| 1638 |
ObjectSubclass<imp::FrgConnectionPopover>) |
| 1639 |
- @extends gtk::Widget, gtk::Popover; |
| 1640 |
+ @extends gtk::Widget, gtk::Popover, |
| 1641 |
+ @implements gtk::Native, gtk::ShortcutManager, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1642 |
} |
| 1643 |
diff --git a/src/ui/connection_row.rs b/src/ui/connection_row.rs |
| 1644 |
index ef477be..3a3cb7b 100644 |
| 1645 |
--- a/src/ui/connection_row.rs |
| 1646 |
+++ b/src/ui/connection_row.rs |
| 1647 |
@@ -1,5 +1,5 @@ |
| 1648 |
// Fragments - connection_row.rs |
| 1649 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 1650 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1651 |
// |
| 1652 |
// This program is free software: you can redistribute it and/or modify |
| 1653 |
// it under the terms of the GNU General Public License as published by |
| 1654 |
@@ -126,7 +126,8 @@ mod imp { |
| 1655 |
glib::wrapper! { |
| 1656 |
pub struct FrgConnectionRow( |
| 1657 |
ObjectSubclass<imp::FrgConnectionRow>) |
| 1658 |
- @extends gtk::Widget, gtk::ListBoxRow; |
| 1659 |
+ @extends gtk::Widget, gtk::ListBoxRow, |
| 1660 |
+ @implements gtk::Actionable, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1661 |
} |
| 1662 |
|
| 1663 |
impl FrgConnectionRow { |
| 1664 |
diff --git a/src/ui/drag_overlay.rs b/src/ui/drag_overlay.rs |
| 1665 |
index ad82315..ad5f20c 100644 |
| 1666 |
--- a/src/ui/drag_overlay.rs |
| 1667 |
+++ b/src/ui/drag_overlay.rs |
| 1668 |
@@ -1,5 +1,5 @@ |
| 1669 |
// Fragments - drag_overlay.rs |
| 1670 |
-// Copyright (C) 2023 Felix Häcker <[email protected]> |
| 1671 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1672 |
// |
| 1673 |
// This program is free software: you can redistribute it and/or modify |
| 1674 |
// it under the terms of the GNU General Public License as published by |
| 1675 |
@@ -57,12 +57,14 @@ mod imp { |
| 1676 |
self.revealer.set_reveal_child(false); |
| 1677 |
|
| 1678 |
self.drop_target.set_actions(gtk::gdk::DragAction::COPY); |
| 1679 |
- self.drop_target.connect_current_drop_notify( |
| 1680 |
- glib::clone!(@weak self.revealer as revealer => move |target| { |
| 1681 |
+ self.drop_target.connect_current_drop_notify(glib::clone!( |
| 1682 |
+ #[weak(rename_to = revealer)] |
| 1683 |
+ self.revealer, |
| 1684 |
+ move |target| { |
| 1685 |
let reveal = target.current_drop().is_some(); |
| 1686 |
revealer.set_reveal_child(reveal); |
| 1687 |
- }), |
| 1688 |
- ); |
| 1689 |
+ } |
| 1690 |
+ )); |
| 1691 |
|
| 1692 |
let bin = adw::Bin::new(); |
| 1693 |
bin.set_can_target(false); |
| 1694 |
@@ -90,5 +92,6 @@ mod imp { |
| 1695 |
glib::wrapper! { |
| 1696 |
pub struct FrgDragOverlay( |
| 1697 |
ObjectSubclass<imp::FrgDragOverlay>) |
| 1698 |
- @extends gtk::Widget, adw::Bin; |
| 1699 |
+ @extends gtk::Widget, adw::Bin, |
| 1700 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1701 |
} |
| 1702 |
diff --git a/src/ui/file_page.rs b/src/ui/file_page.rs |
| 1703 |
index b4bcb5c..6f4092c 100644 |
| 1704 |
--- a/src/ui/file_page.rs |
| 1705 |
+++ b/src/ui/file_page.rs |
| 1706 |
@@ -1,5 +1,5 @@ |
| 1707 |
// Fragments - file_page.rs |
| 1708 |
-// Copyright (C) 2023 Felix Häcker <[email protected]> |
| 1709 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1710 |
// |
| 1711 |
// This program is free software: you can redistribute it and/or modify |
| 1712 |
// it under the terms of the GNU General Public License as published by |
| 1713 |
@@ -66,7 +66,7 @@ mod imp { |
| 1714 |
|
| 1715 |
self.status_header.set_title(file.title()); |
| 1716 |
|
| 1717 |
- let mimetype = gio::content_type_guess(Some(&file.name()), &[]) |
| 1718 |
+ let mimetype = gio::content_type_guess(Some(&file.name()), None) |
| 1719 |
.0 |
| 1720 |
.to_string(); |
| 1721 |
self.status_header.set_mimetype(mimetype); |
| 1722 |
@@ -106,7 +106,8 @@ mod imp { |
| 1723 |
|
| 1724 |
glib::wrapper! { |
| 1725 |
pub struct FrgFilePage(ObjectSubclass<imp::FrgFilePage>) |
| 1726 |
- @extends gtk::Widget, adw::NavigationPage; |
| 1727 |
+ @extends gtk::Widget, adw::NavigationPage, |
| 1728 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1729 |
} |
| 1730 |
|
| 1731 |
impl FrgFilePage { |
| 1732 |
diff --git a/src/ui/file_row.rs b/src/ui/file_row.rs |
| 1733 |
index 48226e4..6552373 100644 |
| 1734 |
--- a/src/ui/file_row.rs |
| 1735 |
+++ b/src/ui/file_row.rs |
| 1736 |
@@ -1,5 +1,5 @@ |
| 1737 |
// Fragments - file_row.rs |
| 1738 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 1739 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1740 |
// |
| 1741 |
// This program is free software: you can redistribute it and/or modify |
| 1742 |
// it under the terms of the GNU General Public License as published by |
| 1743 |
@@ -106,7 +106,7 @@ mod imp { |
| 1744 |
self.mimetype_image.set_icon_name(Some("folder-symbolic")); |
| 1745 |
self.folder_arrow_image.set_visible(true); |
| 1746 |
} else { |
| 1747 |
- let mimetype = gio::content_type_guess(Some(&file.name()), &[]) |
| 1748 |
+ let mimetype = gio::content_type_guess(Some(&file.name()), None) |
| 1749 |
.0 |
| 1750 |
.to_string(); |
| 1751 |
utils::set_mimetype_image(&mimetype, &self.mimetype_image.get()) |
| 1752 |
@@ -142,19 +142,27 @@ mod imp { |
| 1753 |
// Progress & Subtitle |
| 1754 |
let id = file.connect_notify_local( |
| 1755 |
Some("bytes-completed"), |
| 1756 |
- clone!(@weak self as this => move|_,_|{ |
| 1757 |
- this.update_progressbar(); |
| 1758 |
- this.update_subtitle(); |
| 1759 |
- }), |
| 1760 |
+ clone!( |
| 1761 |
+ #[weak(rename_to = this)] |
| 1762 |
+ self, |
| 1763 |
+ move |_, _| { |
| 1764 |
+ this.update_progressbar(); |
| 1765 |
+ this.update_subtitle(); |
| 1766 |
+ } |
| 1767 |
+ ), |
| 1768 |
); |
| 1769 |
self.signal_handlers.borrow_mut().push(id); |
| 1770 |
|
| 1771 |
let id = file.connect_notify_local( |
| 1772 |
Some("wanted"), |
| 1773 |
- clone!(@weak self as this => move|_,_|{ |
| 1774 |
- this.update_progressbar(); |
| 1775 |
- this.update_subtitle(); |
| 1776 |
- }), |
| 1777 |
+ clone!( |
| 1778 |
+ #[weak(rename_to = this)] |
| 1779 |
+ self, |
| 1780 |
+ move |_, _| { |
| 1781 |
+ this.update_progressbar(); |
| 1782 |
+ this.update_subtitle(); |
| 1783 |
+ } |
| 1784 |
+ ), |
| 1785 |
); |
| 1786 |
self.signal_handlers.borrow_mut().push(id); |
| 1787 |
|
| 1788 |
@@ -213,7 +221,8 @@ mod imp { |
| 1789 |
|
| 1790 |
glib::wrapper! { |
| 1791 |
pub struct FrgFileRow(ObjectSubclass<imp::FrgFileRow>) |
| 1792 |
- @extends gtk::Widget, adw::Bin; |
| 1793 |
+ @extends gtk::Widget, adw::Bin, |
| 1794 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1795 |
} |
| 1796 |
|
| 1797 |
impl FrgFileRow { |
| 1798 |
diff --git a/src/ui/folder_page.rs b/src/ui/folder_page.rs |
| 1799 |
index 607eb5a..8a4f55b 100644 |
| 1800 |
--- a/src/ui/folder_page.rs |
| 1801 |
+++ b/src/ui/folder_page.rs |
| 1802 |
@@ -1,5 +1,5 @@ |
| 1803 |
// Fragments - folder_page.rs |
| 1804 |
-// Copyright (C) 2023 Felix Häcker <[email protected]> |
| 1805 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1806 |
// |
| 1807 |
// This program is free software: you can redistribute it and/or modify |
| 1808 |
// it under the terms of the GNU General Public License as published by |
| 1809 |
@@ -82,7 +82,8 @@ mod imp { |
| 1810 |
|
| 1811 |
glib::wrapper! { |
| 1812 |
pub struct FrgFolderPage(ObjectSubclass<imp::FrgFolderPage>) |
| 1813 |
- @extends gtk::Widget, adw::NavigationPage; |
| 1814 |
+ @extends gtk::Widget, adw::NavigationPage, |
| 1815 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1816 |
} |
| 1817 |
|
| 1818 |
impl FrgFolderPage { |
| 1819 |
diff --git a/src/ui/folder_page_contents.rs b/src/ui/folder_page_contents.rs |
| 1820 |
index af08535..79714dc 100644 |
| 1821 |
--- a/src/ui/folder_page_contents.rs |
| 1822 |
+++ b/src/ui/folder_page_contents.rs |
| 1823 |
@@ -1,5 +1,5 @@ |
| 1824 |
// Fragments - folder_page_contents.rs |
| 1825 |
-// Copyright (C) 2023 Felix Häcker <[email protected]> |
| 1826 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1827 |
// |
| 1828 |
// This program is free software: you can redistribute it and/or modify |
| 1829 |
// it under the terms of the GNU General Public License as published by |
| 1830 |
@@ -81,13 +81,21 @@ mod imp { |
| 1831 |
.set_model(Some(&self.obj().file().related())); |
| 1832 |
|
| 1833 |
// Needed, since listview needs a moment to populate the list |
| 1834 |
- glib::idle_add_local_once(clone!(@weak self as this => move|| { |
| 1835 |
- this.scrolled_window.vadjustment().set_value(*this.scroll_pos.get().unwrap()); |
| 1836 |
- })); |
| 1837 |
+ glib::idle_add_local_once(clone!( |
| 1838 |
+ #[weak(rename_to = this)] |
| 1839 |
+ self, |
| 1840 |
+ move || { |
| 1841 |
+ this.scrolled_window |
| 1842 |
+ .vadjustment() |
| 1843 |
+ .set_value(*this.scroll_pos.get().unwrap()); |
| 1844 |
+ } |
| 1845 |
+ )); |
| 1846 |
|
| 1847 |
// Search |
| 1848 |
- self.searchbar.connect_search_mode_enabled_notify( |
| 1849 |
- clone!(@weak self as this => move |sb| { |
| 1850 |
+ self.searchbar.connect_search_mode_enabled_notify(clone!( |
| 1851 |
+ #[weak(rename_to = this)] |
| 1852 |
+ self, |
| 1853 |
+ move |sb| { |
| 1854 |
let file = this.obj().file(); |
| 1855 |
|
| 1856 |
let model: gio::ListModel = if sb.is_search_mode() { |
| 1857 |
@@ -99,8 +107,8 @@ mod imp { |
| 1858 |
}; |
| 1859 |
|
| 1860 |
this.sort_model.set_model(Some(&model)); |
| 1861 |
- }), |
| 1862 |
- ); |
| 1863 |
+ } |
| 1864 |
+ )); |
| 1865 |
self.searchentry |
| 1866 |
.bind_property("text", &self.filter.get(), "search") |
| 1867 |
.build(); |
| 1868 |
@@ -113,16 +121,24 @@ mod imp { |
| 1869 |
|
| 1870 |
// view.select-all |
| 1871 |
action = SimpleAction::new("select-all", None); |
| 1872 |
- action.connect_activate(clone!(@weak self as this => move |_, _| { |
| 1873 |
- this.obj().file().set_wanted(true); |
| 1874 |
- })); |
| 1875 |
+ action.connect_activate(clone!( |
| 1876 |
+ #[weak(rename_to = this)] |
| 1877 |
+ self, |
| 1878 |
+ move |_, _| { |
| 1879 |
+ this.obj().file().set_wanted(true); |
| 1880 |
+ } |
| 1881 |
+ )); |
| 1882 |
self.view_actions.add_action(&action); |
| 1883 |
|
| 1884 |
// view.deselect-all |
| 1885 |
action = SimpleAction::new("deselect-all", None); |
| 1886 |
- action.connect_activate(clone!(@weak self as this => move |_, _| { |
| 1887 |
- this.obj().file().set_wanted(false); |
| 1888 |
- })); |
| 1889 |
+ action.connect_activate(clone!( |
| 1890 |
+ #[weak(rename_to = this)] |
| 1891 |
+ self, |
| 1892 |
+ move |_, _| { |
| 1893 |
+ this.obj().file().set_wanted(false); |
| 1894 |
+ } |
| 1895 |
+ )); |
| 1896 |
self.view_actions.add_action(&action); |
| 1897 |
} |
| 1898 |
} |
| 1899 |
@@ -157,7 +173,8 @@ mod imp { |
| 1900 |
|
| 1901 |
glib::wrapper! { |
| 1902 |
pub struct FrgFolderPageContents(ObjectSubclass<imp::FrgFolderPageContents>) |
| 1903 |
- @extends gtk::Widget, adw::Bin; |
| 1904 |
+ @extends gtk::Widget, adw::Bin, |
| 1905 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 1906 |
} |
| 1907 |
|
| 1908 |
impl FrgFolderPageContents { |
| 1909 |
diff --git a/src/ui/preferences_dialog.rs b/src/ui/preferences_dialog.rs |
| 1910 |
index a4b0cdb..1fb3fe0 100644 |
| 1911 |
--- a/src/ui/preferences_dialog.rs |
| 1912 |
+++ b/src/ui/preferences_dialog.rs |
| 1913 |
@@ -1,5 +1,5 @@ |
| 1914 |
// Fragments - preferences_dialog.rs |
| 1915 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 1916 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 1917 |
// |
| 1918 |
// This program is free software: you can redistribute it and/or modify |
| 1919 |
// it under the terms of the GNU General Public License as published by |
| 1920 |
@@ -118,11 +118,14 @@ mod imp { |
| 1921 |
let session = client.session(); |
| 1922 |
|
| 1923 |
// We show/hide few widgets depending on the connection type (remote/local) |
| 1924 |
- self.connection_manager.connect_current_connection_notify( |
| 1925 |
- clone!(@weak self as this => move |_|{ |
| 1926 |
- this.update_remote_buttons(); |
| 1927 |
- }), |
| 1928 |
- ); |
| 1929 |
+ self.connection_manager |
| 1930 |
+ .connect_current_connection_notify(clone!( |
| 1931 |
+ #[weak(rename_to = this)] |
| 1932 |
+ self, |
| 1933 |
+ move |_| { |
| 1934 |
+ this.update_remote_buttons(); |
| 1935 |
+ } |
| 1936 |
+ )); |
| 1937 |
|
| 1938 |
// General page |
| 1939 |
// |
| 1940 |
@@ -155,25 +158,41 @@ mod imp { |
| 1941 |
&*self.remote_access_switch, |
| 1942 |
"active", |
| 1943 |
); |
| 1944 |
- self.remote_access_switch.connect_state_set(clone!(@weak self as this => @default-panic, move |switch, _| { |
| 1945 |
- settings_manager::set_boolean(Key::RemoteAccess, switch.is_active()); |
| 1946 |
- switch.set_sensitive(false); |
| 1947 |
- |
| 1948 |
- let fut = clone!(@weak switch, @weak this => async move { |
| 1949 |
- if let Err(err) = FrgConnectionManager::default().reconnect().await{ |
| 1950 |
- utils::inapp_notification(&i18n("Unable to restart Transmission daemon"), Some(this.obj().upcast_ref::<gtk::Widget>())); |
| 1951 |
- warn!("Unable to restart Transmission daemon: {}", err.to_string()); |
| 1952 |
- } |
| 1953 |
- |
| 1954 |
- switch.set_sensitive(true); |
| 1955 |
- }); |
| 1956 |
- glib::spawn_future_local(fut); |
| 1957 |
- glib::Propagation::Proceed |
| 1958 |
- })); |
| 1959 |
- self.open_webinterface_row |
| 1960 |
- .connect_activated(clone!(@weak self as this => move |_| { |
| 1961 |
+ self.remote_access_switch.connect_state_set(clone!( |
| 1962 |
+ #[weak(rename_to = this)] |
| 1963 |
+ self, |
| 1964 |
+ #[upgrade_or_panic] |
| 1965 |
+ move |switch, _| { |
| 1966 |
+ settings_manager::set_boolean(Key::RemoteAccess, switch.is_active()); |
| 1967 |
+ switch.set_sensitive(false); |
| 1968 |
+ |
| 1969 |
+ let fut = clone!( |
| 1970 |
+ #[weak] |
| 1971 |
+ switch, |
| 1972 |
+ #[weak] |
| 1973 |
+ this, |
| 1974 |
+ async move { |
| 1975 |
+ if let Err(err) = FrgConnectionManager::default().reconnect().await { |
| 1976 |
+ utils::inapp_notification( |
| 1977 |
+ &i18n("Unable to restart Transmission daemon"), |
| 1978 |
+ Some(this.obj().upcast_ref::<gtk::Widget>()), |
| 1979 |
+ ); |
| 1980 |
+ warn!("Unable to restart Transmission daemon: {}", err.to_string()); |
| 1981 |
+ } |
| 1982 |
+ |
| 1983 |
+ switch.set_sensitive(true); |
| 1984 |
+ } |
| 1985 |
+ ); |
| 1986 |
+ glib::spawn_future_local(fut); |
| 1987 |
+ glib::Propagation::Proceed |
| 1988 |
+ } |
| 1989 |
+ )); |
| 1990 |
+ self.open_webinterface_row.connect_activated(clone!( |
| 1991 |
+ #[weak(rename_to = this)] |
| 1992 |
+ self, |
| 1993 |
+ move |_| { |
| 1994 |
let fut = async move { |
| 1995 |
- let uri = url::Url::parse("http://127.0.0.1:9091/").unwrap(); |
| 1996 |
+ let uri = ashpd::Uri::parse("http://127.0.0.1:9091/").unwrap(); |
| 1997 |
let native = this.obj().native().unwrap(); |
| 1998 |
let identifier = WindowIdentifier::from_native(&native).await; |
| 1999 |
if let Err(err) = OpenFileRequest::default() |
| 2000 |
@@ -182,21 +201,33 @@ mod imp { |
| 2001 |
.await |
| 2002 |
{ |
| 2003 |
debug!("Unable to open webinterface: {:?}", err); |
| 2004 |
- utils::inapp_notification("Unable to open webinterface", Some(this.obj().upcast_ref::<gtk::Widget>())); |
| 2005 |
+ utils::inapp_notification( |
| 2006 |
+ "Unable to open webinterface", |
| 2007 |
+ Some(this.obj().upcast_ref::<gtk::Widget>()), |
| 2008 |
+ ); |
| 2009 |
} |
| 2010 |
}; |
| 2011 |
glib::spawn_future_local(fut); |
| 2012 |
- })); |
| 2013 |
+ } |
| 2014 |
+ )); |
| 2015 |
|
| 2016 |
// Downloading page |
| 2017 |
// |
| 2018 |
- client.connect_is_connected_notify(clone!(@weak self as this => move |_|{ |
| 2019 |
- this.update_paths(); |
| 2020 |
- })); |
| 2021 |
+ client.connect_is_connected_notify(clone!( |
| 2022 |
+ #[weak(rename_to = this)] |
| 2023 |
+ self, |
| 2024 |
+ move |_| { |
| 2025 |
+ this.update_paths(); |
| 2026 |
+ } |
| 2027 |
+ )); |
| 2028 |
|
| 2029 |
- session.connect_download_dir_notify(glib::clone!(@weak self as this => move |_| { |
| 2030 |
- this.update_paths(); |
| 2031 |
- })); |
| 2032 |
+ session.connect_download_dir_notify(glib::clone!( |
| 2033 |
+ #[weak(rename_to = this)] |
| 2034 |
+ self, |
| 2035 |
+ move |_| { |
| 2036 |
+ this.update_paths(); |
| 2037 |
+ } |
| 2038 |
+ )); |
| 2039 |
|
| 2040 |
self.download_dir_button.connect_clicked(move |btn| { |
| 2041 |
let parent = btn.root().unwrap().downcast::<gtk::Window>().unwrap(); |
| 2042 |
@@ -212,15 +243,17 @@ mod imp { |
| 2043 |
.flags(glib::BindingFlags::SYNC_CREATE | glib::BindingFlags::BIDIRECTIONAL) |
| 2044 |
.build(); |
| 2045 |
|
| 2046 |
- session.connect_incomplete_dir_enabled_notify( |
| 2047 |
- glib::clone!(@weak self as this => move |_| { |
| 2048 |
- FrgConnectionManager::default().check_directories(); |
| 2049 |
- }), |
| 2050 |
- ); |
| 2051 |
+ session.connect_incomplete_dir_enabled_notify(glib::clone!(move |_| { |
| 2052 |
+ FrgConnectionManager::default().check_directories() |
| 2053 |
+ },)); |
| 2054 |
|
| 2055 |
- session.connect_incomplete_dir_notify(glib::clone!(@weak self as this => move |_| { |
| 2056 |
- this.update_paths(); |
| 2057 |
- })); |
| 2058 |
+ session.connect_incomplete_dir_notify(glib::clone!( |
| 2059 |
+ #[weak(rename_to = this)] |
| 2060 |
+ self, |
| 2061 |
+ move |_| { |
| 2062 |
+ this.update_paths(); |
| 2063 |
+ } |
| 2064 |
+ )); |
| 2065 |
|
| 2066 |
self.incomplete_dir_button.connect_clicked(move |btn| { |
| 2067 |
let parent = btn.root().unwrap().downcast::<gtk::Window>().unwrap(); |
| 2068 |
@@ -378,7 +411,8 @@ mod imp { |
| 2069 |
glib::wrapper! { |
| 2070 |
pub struct FrgPreferencesDialog( |
| 2071 |
ObjectSubclass<imp::FrgPreferencesDialog>) |
| 2072 |
- @extends gtk::Widget, adw::Dialog, adw::PreferencesDialog; |
| 2073 |
+ @extends gtk::Widget, adw::Dialog, adw::PreferencesDialog, |
| 2074 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2075 |
} |
| 2076 |
|
| 2077 |
impl Default for FrgPreferencesDialog { |
| 2078 |
diff --git a/src/ui/stats_dialog.rs b/src/ui/stats_dialog.rs |
| 2079 |
index 1adf6e9..58d4d52 100644 |
| 2080 |
--- a/src/ui/stats_dialog.rs |
| 2081 |
+++ b/src/ui/stats_dialog.rs |
| 2082 |
@@ -1,5 +1,5 @@ |
| 2083 |
// Fragments - stats_dialog.rs |
| 2084 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 2085 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2086 |
// |
| 2087 |
// This program is free software: you can redistribute it and/or modify |
| 2088 |
// it under the terms of the GNU General Public License as published by |
| 2089 |
@@ -91,11 +91,13 @@ mod imp { |
| 2090 |
fn constructed(&self) { |
| 2091 |
self.parent_constructed(); |
| 2092 |
|
| 2093 |
- FrgConnectionManager::default().connect_current_connection_notify( |
| 2094 |
- clone!(@weak self as this => move |_|{ |
| 2095 |
+ FrgConnectionManager::default().connect_current_connection_notify(clone!( |
| 2096 |
+ #[weak(rename_to = this)] |
| 2097 |
+ self, |
| 2098 |
+ move |_| { |
| 2099 |
this.update_remote_notice(); |
| 2100 |
- }), |
| 2101 |
- ); |
| 2102 |
+ } |
| 2103 |
+ )); |
| 2104 |
|
| 2105 |
self.bind_properties(); |
| 2106 |
self.update_format_strings(); |
| 2107 |
@@ -179,41 +181,77 @@ mod imp { |
| 2108 |
.flags(BindingFlags::SYNC_CREATE) |
| 2109 |
.build(); |
| 2110 |
|
| 2111 |
- stats.connect_download_speed_notify(clone!(@weak self as this => move |_|{ |
| 2112 |
- this.update_format_strings(); |
| 2113 |
- })); |
| 2114 |
- |
| 2115 |
- stats.connect_upload_speed_notify(clone!(@weak self as this => move |_|{ |
| 2116 |
- this.update_format_strings(); |
| 2117 |
- })); |
| 2118 |
- |
| 2119 |
- current.connect_seconds_active_notify(clone!(@weak self as this => move |_|{ |
| 2120 |
- this.update_format_strings(); |
| 2121 |
- })); |
| 2122 |
- |
| 2123 |
- current.connect_downloaded_bytes_notify(clone!(@weak self as this => move |_|{ |
| 2124 |
- this.update_format_strings(); |
| 2125 |
- })); |
| 2126 |
- |
| 2127 |
- current.connect_uploaded_bytes_notify(clone!(@weak self as this => move |_|{ |
| 2128 |
- this.update_format_strings(); |
| 2129 |
- })); |
| 2130 |
- |
| 2131 |
- cumulative.connect_seconds_active_notify(clone!(@weak self as this => move |_|{ |
| 2132 |
- this.update_format_strings(); |
| 2133 |
- })); |
| 2134 |
- |
| 2135 |
- cumulative.connect_downloaded_bytes_notify(clone!(@weak self as this => move |_|{ |
| 2136 |
- this.update_format_strings(); |
| 2137 |
- })); |
| 2138 |
- |
| 2139 |
- cumulative.connect_uploaded_bytes_notify(clone!(@weak self as this => move |_|{ |
| 2140 |
- this.update_format_strings(); |
| 2141 |
- })); |
| 2142 |
- |
| 2143 |
- cumulative.connect_session_count_notify(clone!(@weak self as this => move |_|{ |
| 2144 |
- this.update_format_strings(); |
| 2145 |
- })); |
| 2146 |
+ stats.connect_download_speed_notify(clone!( |
| 2147 |
+ #[weak(rename_to = this)] |
| 2148 |
+ self, |
| 2149 |
+ move |_| { |
| 2150 |
+ this.update_format_strings(); |
| 2151 |
+ } |
| 2152 |
+ )); |
| 2153 |
+ |
| 2154 |
+ stats.connect_upload_speed_notify(clone!( |
| 2155 |
+ #[weak(rename_to = this)] |
| 2156 |
+ self, |
| 2157 |
+ move |_| { |
| 2158 |
+ this.update_format_strings(); |
| 2159 |
+ } |
| 2160 |
+ )); |
| 2161 |
+ |
| 2162 |
+ current.connect_seconds_active_notify(clone!( |
| 2163 |
+ #[weak(rename_to = this)] |
| 2164 |
+ self, |
| 2165 |
+ move |_| { |
| 2166 |
+ this.update_format_strings(); |
| 2167 |
+ } |
| 2168 |
+ )); |
| 2169 |
+ |
| 2170 |
+ current.connect_downloaded_bytes_notify(clone!( |
| 2171 |
+ #[weak(rename_to = this)] |
| 2172 |
+ self, |
| 2173 |
+ move |_| { |
| 2174 |
+ this.update_format_strings(); |
| 2175 |
+ } |
| 2176 |
+ )); |
| 2177 |
+ |
| 2178 |
+ current.connect_uploaded_bytes_notify(clone!( |
| 2179 |
+ #[weak(rename_to = this)] |
| 2180 |
+ self, |
| 2181 |
+ move |_| { |
| 2182 |
+ this.update_format_strings(); |
| 2183 |
+ } |
| 2184 |
+ )); |
| 2185 |
+ |
| 2186 |
+ cumulative.connect_seconds_active_notify(clone!( |
| 2187 |
+ #[weak(rename_to = this)] |
| 2188 |
+ self, |
| 2189 |
+ move |_| { |
| 2190 |
+ this.update_format_strings(); |
| 2191 |
+ } |
| 2192 |
+ )); |
| 2193 |
+ |
| 2194 |
+ cumulative.connect_downloaded_bytes_notify(clone!( |
| 2195 |
+ #[weak(rename_to = this)] |
| 2196 |
+ self, |
| 2197 |
+ move |_| { |
| 2198 |
+ this.update_format_strings(); |
| 2199 |
+ } |
| 2200 |
+ )); |
| 2201 |
+ |
| 2202 |
+ cumulative.connect_uploaded_bytes_notify(clone!( |
| 2203 |
+ #[weak(rename_to = this)] |
| 2204 |
+ self, |
| 2205 |
+ move |_| { |
| 2206 |
+ this.update_format_strings(); |
| 2207 |
+ } |
| 2208 |
+ )); |
| 2209 |
+ |
| 2210 |
+ cumulative.connect_session_count_notify(clone!( |
| 2211 |
+ #[weak(rename_to = this)] |
| 2212 |
+ self, |
| 2213 |
+ move |_| { |
| 2214 |
+ this.update_format_strings(); |
| 2215 |
+ } |
| 2216 |
+ )); |
| 2217 |
} |
| 2218 |
|
| 2219 |
fn update_format_strings(&self) { |
| 2220 |
@@ -272,7 +310,8 @@ mod imp { |
| 2221 |
|
| 2222 |
glib::wrapper! { |
| 2223 |
pub struct FrgStatsDialog(ObjectSubclass<imp::FrgStatsDialog>) |
| 2224 |
- @extends gtk::Widget, adw::Dialog; |
| 2225 |
+ @extends gtk::Widget, adw::Dialog, |
| 2226 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2227 |
} |
| 2228 |
|
| 2229 |
impl FrgStatsDialog { |
| 2230 |
diff --git a/src/ui/status_header.rs b/src/ui/status_header.rs |
| 2231 |
index 403a554..1030297 100644 |
| 2232 |
--- a/src/ui/status_header.rs |
| 2233 |
+++ b/src/ui/status_header.rs |
| 2234 |
@@ -1,5 +1,5 @@ |
| 2235 |
// Fragments - status_header.rs |
| 2236 |
-// Copyright (C) s2023 Felix Häcker <[email protected]> |
| 2237 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2238 |
// |
| 2239 |
// This program is free software: you can redistribute it and/or modify |
| 2240 |
// it under the terms of the GNU General Public License as published by |
| 2241 |
@@ -120,7 +120,8 @@ mod imp { |
| 2242 |
|
| 2243 |
glib::wrapper! { |
| 2244 |
pub struct FrgStatusHeader(ObjectSubclass<imp::FrgStatusHeader>) |
| 2245 |
- @extends gtk::Widget, adw::Bin; |
| 2246 |
+ @extends gtk::Widget, adw::Bin, |
| 2247 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2248 |
} |
| 2249 |
|
| 2250 |
impl FrgStatusHeader { |
| 2251 |
diff --git a/src/ui/torrent_dialog.rs b/src/ui/torrent_dialog.rs |
| 2252 |
index d4b2aee..31b6f80 100644 |
| 2253 |
--- a/src/ui/torrent_dialog.rs |
| 2254 |
+++ b/src/ui/torrent_dialog.rs |
| 2255 |
@@ -1,5 +1,5 @@ |
| 2256 |
// Fragments - torrent_dialog.rs |
| 2257 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 2258 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2259 |
// |
| 2260 |
// This program is free software: you can redistribute it and/or modify |
| 2261 |
// it under the terms of the GNU General Public License as published by |
| 2262 |
@@ -170,16 +170,24 @@ mod imp { |
| 2263 |
if torrent.files().is_ready() { |
| 2264 |
self.show_overview_files(); |
| 2265 |
} |
| 2266 |
- torrent |
| 2267 |
- .files() |
| 2268 |
- .connect_is_ready_notify(clone!(@weak self as this => move|_| { |
| 2269 |
+ torrent.files().connect_is_ready_notify(clone!( |
| 2270 |
+ #[weak(rename_to = this)] |
| 2271 |
+ self, |
| 2272 |
+ move |_| { |
| 2273 |
this.show_overview_files(); |
| 2274 |
- })); |
| 2275 |
+ } |
| 2276 |
+ )); |
| 2277 |
|
| 2278 |
// Files listbox row activation |
| 2279 |
- self.file_listbox |
| 2280 |
- .connect_row_activated(clone!(@weak self as this => move |_, row|{ |
| 2281 |
- let row = row.downcast_ref::<adw::PreferencesRow>().unwrap().child().unwrap(); |
| 2282 |
+ self.file_listbox.connect_row_activated(clone!( |
| 2283 |
+ #[weak(rename_to = this)] |
| 2284 |
+ self, |
| 2285 |
+ move |_, row| { |
| 2286 |
+ let row = row |
| 2287 |
+ .downcast_ref::<adw::PreferencesRow>() |
| 2288 |
+ .unwrap() |
| 2289 |
+ .child() |
| 2290 |
+ .unwrap(); |
| 2291 |
let file_row = row.downcast_ref::<FrgFileRow>().unwrap(); |
| 2292 |
let file = file_row.file(); |
| 2293 |
|
| 2294 |
@@ -190,7 +198,8 @@ mod imp { |
| 2295 |
this.show_file(&file); |
| 2296 |
} |
| 2297 |
} |
| 2298 |
- })); |
| 2299 |
+ } |
| 2300 |
+ )); |
| 2301 |
|
| 2302 |
// Setup view actions |
| 2303 |
obj.insert_action_group("view", Some(&self.view_actions)); |
| 2304 |
@@ -202,16 +211,18 @@ mod imp { |
| 2305 |
VariantTy::STRING.into(), |
| 2306 |
&"name".to_variant(), |
| 2307 |
); |
| 2308 |
- action.connect_change_state( |
| 2309 |
- clone!(@weak self.files_sorter as files_sorter => move |action, state|{ |
| 2310 |
+ action.connect_change_state(clone!( |
| 2311 |
+ #[weak(rename_to = files_sorter)] |
| 2312 |
+ self.files_sorter, |
| 2313 |
+ move |action, state| { |
| 2314 |
if let Some(state) = state { |
| 2315 |
action.set_state(state); |
| 2316 |
|
| 2317 |
let sorter: FrgFileSorting = state.str().unwrap().into(); |
| 2318 |
files_sorter.set_sorting(sorter); |
| 2319 |
} |
| 2320 |
- }), |
| 2321 |
- ); |
| 2322 |
+ } |
| 2323 |
+ )); |
| 2324 |
self.view_actions.add_action(&action); |
| 2325 |
|
| 2326 |
// view.order |
| 2327 |
@@ -220,73 +231,92 @@ mod imp { |
| 2328 |
VariantTy::STRING.into(), |
| 2329 |
&"ascending".to_variant(), |
| 2330 |
); |
| 2331 |
- action.connect_change_state( |
| 2332 |
- clone!(@weak self.files_sorter as files_sorter => move |action, state|{ |
| 2333 |
+ action.connect_change_state(clone!( |
| 2334 |
+ #[weak(rename_to = files_sorter)] |
| 2335 |
+ self.files_sorter, |
| 2336 |
+ move |action, state| { |
| 2337 |
if let Some(state) = state { |
| 2338 |
action.set_state(state); |
| 2339 |
|
| 2340 |
let descending = state.str().unwrap() == "descending"; |
| 2341 |
files_sorter.set_descending(descending); |
| 2342 |
} |
| 2343 |
- }), |
| 2344 |
- ); |
| 2345 |
+ } |
| 2346 |
+ )); |
| 2347 |
self.view_actions.add_action(&action); |
| 2348 |
|
| 2349 |
// view.folder-before-files |
| 2350 |
action = SimpleAction::new_stateful("folder-before-files", None, &true.to_variant()); |
| 2351 |
- action.connect_change_state( |
| 2352 |
- clone!(@weak self.files_sorter as files_sorter => move |action, state|{ |
| 2353 |
+ action.connect_change_state(clone!( |
| 2354 |
+ #[weak(rename_to = files_sorter)] |
| 2355 |
+ self.files_sorter, |
| 2356 |
+ move |action, state| { |
| 2357 |
if let Some(state) = state { |
| 2358 |
action.set_state(state); |
| 2359 |
|
| 2360 |
let value = state.get::<bool>().unwrap(); |
| 2361 |
files_sorter.set_folders_before_files(value); |
| 2362 |
} |
| 2363 |
- }), |
| 2364 |
- ); |
| 2365 |
+ } |
| 2366 |
+ )); |
| 2367 |
self.view_actions.add_action(&action); |
| 2368 |
|
| 2369 |
// view.show-all |
| 2370 |
action = SimpleAction::new("show-all", None); |
| 2371 |
- action.connect_activate(clone!(@weak self as this => move |_, _|{ |
| 2372 |
- if let Some(top_level) = this.obj().torrent().files().top_level(){ |
| 2373 |
- this.show_folder(&top_level); |
| 2374 |
- } else { |
| 2375 |
- warn!("Unable to show contents, no top level file available"); |
| 2376 |
+ action.connect_activate(clone!( |
| 2377 |
+ #[weak(rename_to = this)] |
| 2378 |
+ self, |
| 2379 |
+ move |_, _| { |
| 2380 |
+ if let Some(top_level) = this.obj().torrent().files().top_level() { |
| 2381 |
+ this.show_folder(&top_level); |
| 2382 |
+ } else { |
| 2383 |
+ warn!("Unable to show contents, no top level file available"); |
| 2384 |
+ } |
| 2385 |
} |
| 2386 |
- |
| 2387 |
- })); |
| 2388 |
+ )); |
| 2389 |
self.view_actions.add_action(&action); |
| 2390 |
|
| 2391 |
// view.show-folder |
| 2392 |
action = SimpleAction::new("show-folder", VariantTy::STRING.into()); |
| 2393 |
- action.connect_activate(clone!(@weak self as this => move |_, param|{ |
| 2394 |
- if let Some(param) = param { |
| 2395 |
- let name = param.get::<String>().unwrap(); |
| 2396 |
- let folder = this.obj().torrent().files().file_by_name(&name).unwrap(); |
| 2397 |
- this.show_folder(&folder); |
| 2398 |
+ action.connect_activate(clone!( |
| 2399 |
+ #[weak(rename_to = this)] |
| 2400 |
+ self, |
| 2401 |
+ move |_, param| { |
| 2402 |
+ if let Some(param) = param { |
| 2403 |
+ let name = param.get::<String>().unwrap(); |
| 2404 |
+ let folder = this.obj().torrent().files().file_by_name(&name).unwrap(); |
| 2405 |
+ this.show_folder(&folder); |
| 2406 |
+ } |
| 2407 |
} |
| 2408 |
- })); |
| 2409 |
+ )); |
| 2410 |
self.view_actions.add_action(&action); |
| 2411 |
|
| 2412 |
// view.show-file |
| 2413 |
action = SimpleAction::new("show-file", VariantTy::STRING.into()); |
| 2414 |
- action.connect_activate(clone!(@weak self as this => move |_, param|{ |
| 2415 |
- if let Some(param) = param { |
| 2416 |
- let name = param.get::<String>().unwrap(); |
| 2417 |
- let file = this.obj().torrent().files().file_by_name(&name).unwrap(); |
| 2418 |
- this.show_file(&file); |
| 2419 |
+ action.connect_activate(clone!( |
| 2420 |
+ #[weak(rename_to = this)] |
| 2421 |
+ self, |
| 2422 |
+ move |_, param| { |
| 2423 |
+ if let Some(param) = param { |
| 2424 |
+ let name = param.get::<String>().unwrap(); |
| 2425 |
+ let file = this.obj().torrent().files().file_by_name(&name).unwrap(); |
| 2426 |
+ this.show_file(&file); |
| 2427 |
+ } |
| 2428 |
} |
| 2429 |
- })); |
| 2430 |
+ )); |
| 2431 |
self.view_actions.add_action(&action); |
| 2432 |
|
| 2433 |
// Update dialog on torrent changes |
| 2434 |
torrent.connect_notify_local( |
| 2435 |
None, |
| 2436 |
- clone!(@weak self as this => move |_, _| { |
| 2437 |
- this.update_labels(); |
| 2438 |
- this.update_widgets(); |
| 2439 |
- }), |
| 2440 |
+ clone!( |
| 2441 |
+ #[weak(rename_to = this)] |
| 2442 |
+ self, |
| 2443 |
+ move |_, _| { |
| 2444 |
+ this.update_labels(); |
| 2445 |
+ this.update_widgets(); |
| 2446 |
+ } |
| 2447 |
+ ), |
| 2448 |
); |
| 2449 |
|
| 2450 |
self.update_labels(); |
| 2451 |
@@ -463,7 +493,8 @@ mod imp { |
| 2452 |
|
| 2453 |
glib::wrapper! { |
| 2454 |
pub struct FrgTorrentDialog(ObjectSubclass<imp::FrgTorrentDialog>) |
| 2455 |
- @extends gtk::Widget, adw::Dialog; |
| 2456 |
+ @extends gtk::Widget, adw::Dialog, |
| 2457 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2458 |
} |
| 2459 |
|
| 2460 |
impl FrgTorrentDialog { |
| 2461 |
diff --git a/src/ui/torrent_group.rs b/src/ui/torrent_group.rs |
| 2462 |
index d9d3f03..2e5bb56 100644 |
| 2463 |
--- a/src/ui/torrent_group.rs |
| 2464 |
+++ b/src/ui/torrent_group.rs |
| 2465 |
@@ -1,5 +1,5 @@ |
| 2466 |
// Fragments - torrent_group.rs |
| 2467 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 2468 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2469 |
// |
| 2470 |
// This program is free software: you can redistribute it and/or modify |
| 2471 |
// it under the terms of the GNU General Public License as published by |
| 2472 |
@@ -60,7 +60,8 @@ mod imp { |
| 2473 |
glib::wrapper! { |
| 2474 |
pub struct FrgTorrentGroup( |
| 2475 |
ObjectSubclass<imp::FrgTorrentGroup>) |
| 2476 |
- @extends gtk::Widget, adw::PreferencesGroup; |
| 2477 |
+ @extends gtk::Widget, adw::PreferencesGroup, |
| 2478 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2479 |
} |
| 2480 |
|
| 2481 |
impl FrgTorrentGroup { |
| 2482 |
@@ -81,8 +82,10 @@ impl FrgTorrentGroup { |
| 2483 |
row.activate_action("torrent.show-dialog", None).unwrap(); |
| 2484 |
}); |
| 2485 |
|
| 2486 |
- model.connect_items_changed( |
| 2487 |
- glib::clone!(@weak self as this, @weak listbox => move |_, _, _, _| { |
| 2488 |
+ model.connect_items_changed(glib::clone!( |
| 2489 |
+ #[weak(rename_to = this)] |
| 2490 |
+ self, |
| 2491 |
+ move |_, _, _, _| { |
| 2492 |
let imp = this.imp(); |
| 2493 |
|
| 2494 |
// Hide this group if all models are empty |
| 2495 |
@@ -95,14 +98,14 @@ impl FrgTorrentGroup { |
| 2496 |
this.set_visible(!is_empty); |
| 2497 |
|
| 2498 |
// Hide empty listboxes |
| 2499 |
- let mut child = imp.listbox_box.first_child (); |
| 2500 |
+ let mut child = imp.listbox_box.first_child(); |
| 2501 |
while let Some(widget) = child { |
| 2502 |
let listbox = widget.downcast_ref::<gtk::ListBox>().unwrap(); |
| 2503 |
listbox.set_visible(listbox.row_at_index(0).is_some()); |
| 2504 |
child = listbox.next_sibling(); |
| 2505 |
} |
| 2506 |
- }), |
| 2507 |
- ); |
| 2508 |
+ } |
| 2509 |
+ )); |
| 2510 |
|
| 2511 |
imp.models.borrow_mut().insert(0, model); |
| 2512 |
} |
| 2513 |
diff --git a/src/ui/torrent_page.rs b/src/ui/torrent_page.rs |
| 2514 |
index 5824759..2308ef4 100644 |
| 2515 |
--- a/src/ui/torrent_page.rs |
| 2516 |
+++ b/src/ui/torrent_page.rs |
| 2517 |
@@ -1,5 +1,5 @@ |
| 2518 |
// Fragments - torrent_page.rs |
| 2519 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 2520 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2521 |
// |
| 2522 |
// This program is free software: you can redistribute it and/or modify |
| 2523 |
// it under the terms of the GNU General Public License as published by |
| 2524 |
@@ -110,11 +110,19 @@ mod imp { |
| 2525 |
model.connect_local( |
| 2526 |
"status-changed", |
| 2527 |
false, |
| 2528 |
- clone!(@weak group_filter, @weak sorter => @default-return None, move |_| { |
| 2529 |
- group_filter.changed(gtk::FilterChange::Different); |
| 2530 |
- sorter.changed(gtk::SorterChange::Different); |
| 2531 |
- None |
| 2532 |
- }), |
| 2533 |
+ clone!( |
| 2534 |
+ #[weak] |
| 2535 |
+ group_filter, |
| 2536 |
+ #[weak] |
| 2537 |
+ sorter, |
| 2538 |
+ #[upgrade_or] |
| 2539 |
+ None, |
| 2540 |
+ move |_| { |
| 2541 |
+ group_filter.changed(gtk::FilterChange::Different); |
| 2542 |
+ sorter.changed(gtk::SorterChange::Different); |
| 2543 |
+ None |
| 2544 |
+ } |
| 2545 |
+ ), |
| 2546 |
); |
| 2547 |
|
| 2548 |
let group_model = FilterListModel::new(Some(model), Some(group_filter)); |
| 2549 |
@@ -128,7 +136,8 @@ mod imp { |
| 2550 |
glib::wrapper! { |
| 2551 |
pub struct FrgTorrentPage( |
| 2552 |
ObjectSubclass<imp::FrgTorrentPage>) |
| 2553 |
- @extends gtk::Widget, adw::PreferencesPage; |
| 2554 |
+ @extends gtk::Widget, adw::PreferencesPage, |
| 2555 |
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2556 |
} |
| 2557 |
|
| 2558 |
impl FrgTorrentPage { |
| 2559 |
diff --git a/src/ui/torrent_row.rs b/src/ui/torrent_row.rs |
| 2560 |
index c399b11..71446f2 100644 |
| 2561 |
--- a/src/ui/torrent_row.rs |
| 2562 |
+++ b/src/ui/torrent_row.rs |
| 2563 |
@@ -1,4 +1,5 @@ |
| 2564 |
-// Copyright (C) 2022-2024 Felix Häcker <[email protected]> |
| 2565 |
+// Fragments - torrent_row.rs |
| 2566 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2567 |
// |
| 2568 |
// This program is free software: you can redistribute it and/or modify |
| 2569 |
// it under the terms of the GNU General Public License as published by |
| 2570 |
@@ -42,8 +43,6 @@ mod imp { |
| 2571 |
#[template_child] |
| 2572 |
progress_bar: TemplateChild<gtk::ProgressBar>, |
| 2573 |
#[template_child] |
| 2574 |
- spinner: TemplateChild<gtk::Spinner>, |
| 2575 |
- #[template_child] |
| 2576 |
queue_box: TemplateChild<gtk::Box>, |
| 2577 |
#[template_child] |
| 2578 |
index_stack: TemplateChild<gtk::Stack>, |
| 2579 |
@@ -96,10 +95,14 @@ mod imp { |
| 2580 |
|
| 2581 |
self.obj().torrent().connect_notify_local( |
| 2582 |
None, |
| 2583 |
- clone!(@weak self as this => move |_, _| { |
| 2584 |
- this.update_labels(); |
| 2585 |
- this.update_widgets(); |
| 2586 |
- }), |
| 2587 |
+ clone!( |
| 2588 |
+ #[weak(rename_to = this)] |
| 2589 |
+ self, |
| 2590 |
+ move |_, _| { |
| 2591 |
+ this.update_labels(); |
| 2592 |
+ this.update_widgets(); |
| 2593 |
+ } |
| 2594 |
+ ), |
| 2595 |
); |
| 2596 |
|
| 2597 |
// Shift+F10 / `Menu` button to open context menu |
| 2598 |
@@ -107,12 +110,16 @@ mod imp { |
| 2599 |
gtk::KeyvalTrigger::new(gdk::Key::F10, gdk::ModifierType::SHIFT_MASK), |
| 2600 |
gtk::KeyvalTrigger::new(gdk::Key::Menu, gdk::ModifierType::empty()), |
| 2601 |
); |
| 2602 |
- let action = gtk::CallbackAction::new( |
| 2603 |
- clone!(@weak self as this => @default-return glib::Propagation::Stop, move |_, _| { |
| 2604 |
+ let action = gtk::CallbackAction::new(clone!( |
| 2605 |
+ #[weak(rename_to = this)] |
| 2606 |
+ self, |
| 2607 |
+ #[upgrade_or] |
| 2608 |
+ glib::Propagation::Stop, |
| 2609 |
+ move |_, _| { |
| 2610 |
this.show_context_menu(None::<>k::Gesture>, 40.0, 40.0); |
| 2611 |
glib::Propagation::Stop |
| 2612 |
- }), |
| 2613 |
- ); |
| 2614 |
+ } |
| 2615 |
+ )); |
| 2616 |
let shortcut = gtk::Shortcut::new(Some(trigger), Some(action)); |
| 2617 |
|
| 2618 |
let controller = gtk::ShortcutController::new(); |
| 2619 |
@@ -122,17 +129,21 @@ mod imp { |
| 2620 |
// Right click to open context menu |
| 2621 |
let controller = gtk::GestureClick::new(); |
| 2622 |
controller.set_button(gdk::BUTTON_SECONDARY); |
| 2623 |
- controller.connect_pressed( |
| 2624 |
- clone!(@weak self as this => move |c, _, x, y| this.show_context_menu(Some(c), x, y)), |
| 2625 |
- ); |
| 2626 |
+ controller.connect_pressed(clone!( |
| 2627 |
+ #[weak(rename_to = this)] |
| 2628 |
+ self, |
| 2629 |
+ move |c, _, x, y| this.show_context_menu(Some(c), x, y) |
| 2630 |
+ )); |
| 2631 |
self.obj().add_controller(controller); |
| 2632 |
|
| 2633 |
// Touch long-press to open context menu |
| 2634 |
let controller = gtk::GestureLongPress::new(); |
| 2635 |
controller.set_touch_only(true); |
| 2636 |
- controller.connect_pressed( |
| 2637 |
- clone!(@weak self as this => move |c, x, y| this.show_context_menu(Some(c), x, y)), |
| 2638 |
- ); |
| 2639 |
+ controller.connect_pressed(clone!( |
| 2640 |
+ #[weak(rename_to = this)] |
| 2641 |
+ self, |
| 2642 |
+ move |c, x, y| this.show_context_menu(Some(c), x, y) |
| 2643 |
+ )); |
| 2644 |
self.obj().add_controller(controller); |
| 2645 |
|
| 2646 |
self.update_labels(); |
| 2647 |
@@ -183,7 +194,6 @@ mod imp { |
| 2648 |
|
| 2649 |
fn update_widgets(&self) { |
| 2650 |
self.queue_box.set_visible(false); |
| 2651 |
- self.spinner.set_spinning(false); |
| 2652 |
|
| 2653 |
self.obj().remove_css_class("inactive"); |
| 2654 |
self.description_label.remove_css_class("error"); |
| 2655 |
@@ -208,7 +218,6 @@ mod imp { |
| 2656 |
action_name = "pause".into(); |
| 2657 |
|
| 2658 |
self.obj().add_css_class("inactive"); |
| 2659 |
- self.spinner.set_spinning(true); |
| 2660 |
} |
| 2661 |
TrTorrentStatus::Stopped => { |
| 2662 |
index_name = "stopped".into(); |
| 2663 |
@@ -280,7 +289,8 @@ mod imp { |
| 2664 |
glib::wrapper! { |
| 2665 |
pub struct FrgTorrentRow( |
| 2666 |
ObjectSubclass<imp::FrgTorrentRow>) |
| 2667 |
- @extends gtk::Widget, gtk::ListBoxRow; |
| 2668 |
+ @extends gtk::Widget, gtk::ListBoxRow, |
| 2669 |
+ @implements gtk::Actionable, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2670 |
} |
| 2671 |
|
| 2672 |
impl FrgTorrentRow { |
| 2673 |
diff --git a/src/ui/window.rs b/src/ui/window.rs |
| 2674 |
index 2f20179..eea19e6 100644 |
| 2675 |
--- a/src/ui/window.rs |
| 2676 |
+++ b/src/ui/window.rs |
| 2677 |
@@ -101,26 +101,33 @@ mod imp { |
| 2678 |
self.search_bar.connect_entry(&self.search_entry.get()); |
| 2679 |
|
| 2680 |
// Recolor headerbar purple for remote connections |
| 2681 |
- cm.connect_current_connection_notify( |
| 2682 |
- clone!(@weak self as this => move |manager|{ |
| 2683 |
- if !manager.current_connection().is_fragments(){ |
| 2684 |
- let subtitle = i18n_f("Remote control \"{}\"", &[&manager.current_connection().title()]); |
| 2685 |
+ cm.connect_current_connection_notify(clone!( |
| 2686 |
+ #[weak(rename_to = this)] |
| 2687 |
+ self, |
| 2688 |
+ move |manager| { |
| 2689 |
+ if !manager.current_connection().is_fragments() { |
| 2690 |
+ let subtitle = i18n_f( |
| 2691 |
+ "Remote control \"{}\"", |
| 2692 |
+ &[&manager.current_connection().title()], |
| 2693 |
+ ); |
| 2694 |
this.window_title.set_subtitle(&subtitle); |
| 2695 |
this.obj().add_css_class("remote"); |
| 2696 |
- }else{ |
| 2697 |
+ } else { |
| 2698 |
this.window_title.set_subtitle(""); |
| 2699 |
this.obj().remove_css_class("remote"); |
| 2700 |
} |
| 2701 |
- }), |
| 2702 |
- ); |
| 2703 |
+ } |
| 2704 |
+ )); |
| 2705 |
|
| 2706 |
// Show connection button if we have more than the standard local connection |
| 2707 |
- cm.connections().connect_items_changed( |
| 2708 |
- clone!(@weak self as this => move |model,_,_,_|{ |
| 2709 |
+ cm.connections().connect_items_changed(clone!( |
| 2710 |
+ #[weak(rename_to = this)] |
| 2711 |
+ self, |
| 2712 |
+ move |model, _, _, _| { |
| 2713 |
let show = model.n_items() > 1; |
| 2714 |
this.connection_menu.set_visible(show); |
| 2715 |
- }), |
| 2716 |
- ); |
| 2717 |
+ } |
| 2718 |
+ )); |
| 2719 |
|
| 2720 |
// Check clipboard content for magnet links |
| 2721 |
obj.connect_is_active_notify(move |window| { |
| 2722 |
@@ -128,73 +135,108 @@ mod imp { |
| 2723 |
let display = gdk::Display::default().unwrap(); |
| 2724 |
let clipboard = display.primary_clipboard(); |
| 2725 |
|
| 2726 |
- let fut = clone!(@weak window, @weak clipboard => async move { |
| 2727 |
- let content = clipboard.read_text_future().await; |
| 2728 |
- let mut clear_clipboard = false; |
| 2729 |
- |
| 2730 |
- if let Ok(Some(text)) = content { |
| 2731 |
- // Check for magnet link |
| 2732 |
- if let Ok(magnet_link) = MagnetURI::from_str(&text) { |
| 2733 |
- let fallback = String::new(); |
| 2734 |
- let info_hash = magnet_link.info_hash().unwrap_or(&fallback); |
| 2735 |
- let cm = FrgConnectionManager::default(); |
| 2736 |
- |
| 2737 |
- // Transmission lowercases info hashes internally |
| 2738 |
- if cm.client().torrents().torrent_by_hash(info_hash.to_lowercase()).is_none() { |
| 2739 |
- debug!("Detected new magnet link: {}", &text); |
| 2740 |
- window.imp().magnet_link_notification(&text, magnet_link.name()); |
| 2741 |
- clear_clipboard = true; |
| 2742 |
- } else { |
| 2743 |
- debug!("Ignore magnet link, torrent is already added."); |
| 2744 |
+ let fut = clone!( |
| 2745 |
+ #[weak] |
| 2746 |
+ window, |
| 2747 |
+ #[weak] |
| 2748 |
+ clipboard, |
| 2749 |
+ async move { |
| 2750 |
+ let content = clipboard.read_text_future().await; |
| 2751 |
+ let mut clear_clipboard = false; |
| 2752 |
+ |
| 2753 |
+ if let Ok(Some(text)) = content { |
| 2754 |
+ // Check for magnet link |
| 2755 |
+ if let Ok(magnet_link) = MagnetURI::from_str(&text) { |
| 2756 |
+ let fallback = String::new(); |
| 2757 |
+ let info_hash = magnet_link.info_hash().unwrap_or(&fallback); |
| 2758 |
+ let cm = FrgConnectionManager::default(); |
| 2759 |
+ |
| 2760 |
+ // Transmission lowercases info hashes internally |
| 2761 |
+ if cm |
| 2762 |
+ .client() |
| 2763 |
+ .torrents() |
| 2764 |
+ .torrent_by_hash(info_hash.to_lowercase()) |
| 2765 |
+ .is_none() |
| 2766 |
+ { |
| 2767 |
+ debug!("Detected new magnet link: {}", &text); |
| 2768 |
+ window |
| 2769 |
+ .imp() |
| 2770 |
+ .magnet_link_notification(&text, magnet_link.name()); |
| 2771 |
+ clear_clipboard = true; |
| 2772 |
+ } else { |
| 2773 |
+ debug!("Ignore magnet link, torrent is already added."); |
| 2774 |
+ } |
| 2775 |
} |
| 2776 |
- } |
| 2777 |
|
| 2778 |
- // Check for torrent link |
| 2779 |
- if let Ok(url) = Url::parse(&text) { |
| 2780 |
- // We only support http/https, and no file links because of sandboxing |
| 2781 |
- if url.path().ends_with(".torrent") && (url.scheme() == "http" || url.scheme() == "https") { |
| 2782 |
- debug!("Detected torrent link: {}", &text); |
| 2783 |
- window.imp().torrent_link_notification(&url); |
| 2784 |
- clear_clipboard = true; |
| 2785 |
+ // Check for torrent link |
| 2786 |
+ if let Ok(url) = Url::parse(&text) { |
| 2787 |
+ // We only support http/https, and no file links because of |
| 2788 |
+ // sandboxing |
| 2789 |
+ if url.path().ends_with(".torrent") |
| 2790 |
+ && (url.scheme() == "http" || url.scheme() == "https") |
| 2791 |
+ { |
| 2792 |
+ debug!("Detected torrent link: {}", &text); |
| 2793 |
+ window.imp().torrent_link_notification(&url); |
| 2794 |
+ clear_clipboard = true; |
| 2795 |
+ } |
| 2796 |
} |
| 2797 |
} |
| 2798 |
- } |
| 2799 |
|
| 2800 |
- if clear_clipboard { |
| 2801 |
- // To avoid that the clipboard toast is shown multiple times, we clear the clipboard |
| 2802 |
- clipboard.set_text(""); |
| 2803 |
+ if clear_clipboard { |
| 2804 |
+ // To avoid that the clipboard toast is shown multiple times, we |
| 2805 |
+ // clear the clipboard |
| 2806 |
+ clipboard.set_text(""); |
| 2807 |
+ } |
| 2808 |
} |
| 2809 |
- }); |
| 2810 |
+ ); |
| 2811 |
glib::spawn_future_local(fut); |
| 2812 |
} |
| 2813 |
}); |
| 2814 |
|
| 2815 |
// torrent-added notification |
| 2816 |
- cm.client().connect_local("torrent-added", false, clone!(@weak self as this => @default-return None, move |torrent|{ |
| 2817 |
- if settings_manager::boolean(Key::EnableNotificationsNewTorrent){ |
| 2818 |
- let torrent: TrTorrent = torrent[1].get().unwrap(); |
| 2819 |
- utils::system_notification(i18n("New torrent added"), torrent.name(), Some("folder-download-symbolic")); |
| 2820 |
- } |
| 2821 |
- None |
| 2822 |
- })); |
| 2823 |
+ cm.client() |
| 2824 |
+ .connect_local("torrent-added", false, move |torrent| { |
| 2825 |
+ if settings_manager::boolean(Key::EnableNotificationsNewTorrent) { |
| 2826 |
+ let torrent: TrTorrent = torrent[1].get().unwrap(); |
| 2827 |
+ utils::system_notification( |
| 2828 |
+ i18n("New torrent added"), |
| 2829 |
+ torrent.name(), |
| 2830 |
+ Some("folder-download-symbolic"), |
| 2831 |
+ ); |
| 2832 |
+ } |
| 2833 |
+ None |
| 2834 |
+ }); |
| 2835 |
|
| 2836 |
// torrent-downloaded notification |
| 2837 |
- cm.client().connect_local("torrent-downloaded", false, clone!(@weak self as this => @default-return None, move |torrent|{ |
| 2838 |
- if settings_manager::boolean(Key::EnableNotificationsDownloaded){ |
| 2839 |
- let torrent: TrTorrent = torrent[1].get().unwrap(); |
| 2840 |
- utils::system_notification(i18n("Torrent completely downloaded"), torrent.name(), Some("folder-download-symbolic")); |
| 2841 |
- } |
| 2842 |
- None |
| 2843 |
- })); |
| 2844 |
+ cm.client() |
| 2845 |
+ .connect_local("torrent-downloaded", false, move |torrent| { |
| 2846 |
+ if settings_manager::boolean(Key::EnableNotificationsDownloaded) { |
| 2847 |
+ let torrent: TrTorrent = torrent[1].get().unwrap(); |
| 2848 |
+ utils::system_notification( |
| 2849 |
+ i18n("Torrent completely downloaded"), |
| 2850 |
+ torrent.name(), |
| 2851 |
+ Some("folder-download-symbolic"), |
| 2852 |
+ ); |
| 2853 |
+ } |
| 2854 |
+ None |
| 2855 |
+ }); |
| 2856 |
|
| 2857 |
// Lower polling rate when window isn't active |
| 2858 |
- obj.connect_is_active_notify(clone!(@weak self as this => move |_| { |
| 2859 |
- this.update_polling_mode(); |
| 2860 |
- })); |
| 2861 |
+ obj.connect_is_active_notify(clone!( |
| 2862 |
+ #[weak(rename_to = this)] |
| 2863 |
+ self, |
| 2864 |
+ move |_| { |
| 2865 |
+ this.update_polling_mode(); |
| 2866 |
+ } |
| 2867 |
+ )); |
| 2868 |
|
| 2869 |
- obj.connect_suspended_notify(clone!(@weak self as this => move |_| { |
| 2870 |
- this.update_polling_mode(); |
| 2871 |
- })); |
| 2872 |
+ obj.connect_suspended_notify(clone!( |
| 2873 |
+ #[weak(rename_to = this)] |
| 2874 |
+ self, |
| 2875 |
+ move |_| { |
| 2876 |
+ this.update_polling_mode(); |
| 2877 |
+ } |
| 2878 |
+ )); |
| 2879 |
} |
| 2880 |
} |
| 2881 |
|
| 2882 |
@@ -211,16 +253,21 @@ mod imp { |
| 2883 |
settings_manager::set_integer(Key::WindowWidth, width); |
| 2884 |
settings_manager::set_integer(Key::WindowHeight, height); |
| 2885 |
|
| 2886 |
- let fut = clone!(@weak window => async move { |
| 2887 |
- window.set_visible(false); |
| 2888 |
+ let fut = clone!( |
| 2889 |
+ #[weak] |
| 2890 |
+ window, |
| 2891 |
+ async move { |
| 2892 |
+ window.set_visible(false); |
| 2893 |
|
| 2894 |
- // Wait till transmission daemon is stopped |
| 2895 |
- FrgConnectionManager::default().disconnect() |
| 2896 |
- .await |
| 2897 |
- .expect("Unable to stop the transmission daemon"); |
| 2898 |
+ // Wait till transmission daemon is stopped |
| 2899 |
+ FrgConnectionManager::default() |
| 2900 |
+ .disconnect() |
| 2901 |
+ .await |
| 2902 |
+ .expect("Unable to stop the transmission daemon"); |
| 2903 |
|
| 2904 |
- FrgApplication::default().quit(); |
| 2905 |
- }); |
| 2906 |
+ FrgApplication::default().quit(); |
| 2907 |
+ } |
| 2908 |
+ ); |
| 2909 |
glib::spawn_future_local(fut); |
| 2910 |
|
| 2911 |
glib::Propagation::Stop |
| 2912 |
@@ -286,7 +333,7 @@ glib::wrapper! { |
| 2913 |
pub struct FrgApplicationWindow( |
| 2914 |
ObjectSubclass<imp::FrgApplicationWindow>) |
| 2915 |
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, |
| 2916 |
- @implements gio::ActionMap, gio::ActionGroup; |
| 2917 |
+ @implements gtk::Root, gtk::Native, gtk::ShortcutManager, gio::ActionMap, gio::ActionGroup, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; |
| 2918 |
} |
| 2919 |
|
| 2920 |
// FrgApplicationWindow implementation itself |
| 2921 |
diff --git a/src/utils.rs b/src/utils.rs |
| 2922 |
index 6b931ac..498ffa4 100644 |
| 2923 |
--- a/src/utils.rs |
| 2924 |
+++ b/src/utils.rs |
| 2925 |
@@ -1,5 +1,5 @@ |
| 2926 |
// Fragments - utils.rs |
| 2927 |
-// Copyright (C) 2022-2023 Felix Häcker <[email protected]> |
| 2928 |
+// Copyright (C) 2022-2025 Felix Häcker <[email protected]> |
| 2929 |
// |
| 2930 |
// This program is free software: you can redistribute it and/or modify |
| 2931 |
// it under the terms of the GNU General Public License as published by |
| 2932 |
@@ -18,7 +18,7 @@ use std::path::PathBuf; |
| 2933 |
|
| 2934 |
use adw::prelude::*; |
| 2935 |
use gio::SimpleAction; |
| 2936 |
-use glib::{clone, BindingFlags}; |
| 2937 |
+use glib::BindingFlags; |
| 2938 |
use gtk::{gio, glib}; |
| 2939 |
use transmission_gobject::{TrTorrent, TrTorrentStatus}; |
| 2940 |
|
| 2941 |
@@ -166,21 +166,19 @@ pub fn session_dir_filechooser(parent: >k::Window, directory_type: FrgDirector |
| 2942 |
dialog.select_folder( |
| 2943 |
Some(parent), |
| 2944 |
gio::Cancellable::NONE, |
| 2945 |
- clone!(@weak dialog, @weak parent => move |result| { |
| 2946 |
- match result { |
| 2947 |
- Ok(folder) => { |
| 2948 |
- debug!("Selected directory: {:?}", folder.path()); |
| 2949 |
- |
| 2950 |
- let session = FrgConnectionManager::default().client().session(); |
| 2951 |
- session.set_property(property_name, folder); |
| 2952 |
- |
| 2953 |
- FrgConnectionManager::default().check_directories(); |
| 2954 |
- } |
| 2955 |
- Err(err) => { |
| 2956 |
- warn!("Selected directory could not be accessed {:?}", err); |
| 2957 |
- } |
| 2958 |
+ move |result| match result { |
| 2959 |
+ Ok(folder) => { |
| 2960 |
+ debug!("Selected directory: {:?}", folder.path()); |
| 2961 |
+ |
| 2962 |
+ let session = FrgConnectionManager::default().client().session(); |
| 2963 |
+ session.set_property(property_name, folder); |
| 2964 |
+ |
| 2965 |
+ FrgConnectionManager::default().check_directories(); |
| 2966 |
+ } |
| 2967 |
+ Err(err) => { |
| 2968 |
+ warn!("Selected directory could not be accessed {:?}", err); |
| 2969 |
} |
| 2970 |
- }), |
| 2971 |
+ }, |
| 2972 |
); |
| 2973 |
} |
| 2974 |
|