Skip to content

Commit

Permalink
book: Document remove_done_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Oct 30, 2023
1 parent b825e35 commit a42af08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions book/listings/todo/2/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ impl Window {
}
// ANCHOR_END: setup_actions

// ANCHOR: remove_done_tasks
fn remove_done_tasks(&self) {
let tasks = self.tasks();
let mut position = 0;
Expand All @@ -241,4 +242,5 @@ impl Window {
}
}
}
// ANCHOR_END: remove_done_tasks
}
9 changes: 9 additions & 0 deletions book/src/todo_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master
{{#rustdoc_include ../listings/todo/2/window/imp.rs:object_subclass}}
```

This is the implementation of `remove_done_tasks`.
We iterate through the `gio::ListStore` and remove all completed task objects.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/todo/2/window/mod.rs">listings/todo/2/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/todo/2/window/mod.rs:remove_done_tasks}}
```

After activating the action "win.filter", the corresponding setting will be changed.
So we need a method which translates this setting into a filter that the [`gtk::FilterListModel`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.FilterListModel.html) understands.
The possible states are "All", "Open" and "Done".
Expand Down

0 comments on commit a42af08

Please sign in to comment.