You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/src/todo_3.md
+43-94
Original file line number
Diff line number
Diff line change
@@ -35,19 +35,13 @@ Your browser does not support the video tag.
35
35
</div>
36
36
37
37
38
-
## Start using Libadwaita widgets
38
+
## Boxed lists
39
39
40
40
Of course Libadwaita is more than just a couple of stylesheets and a [`StyleManager`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.StyleManager.html).
41
41
But before we get to the interesting stuff, we will make our lives easier for the future by replacing all occurrences of `gtk::prelude` and `gtk::subclass::prelude` with [`adw::prelude`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/prelude/index.html) and [`adw::subclass::prelude`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/subclass/prelude/index.html).
42
42
This works because the `adw` preludes, in addition to the Libadwaita-specific traits, re-export the corresponding `gtk` preludes.
43
43
44
-
In the remainder of this chapter we are going to follow a couple of patterns of GNOME's HIG.
45
-
Let's start by [adapting](https://developer.gnome.org/hig/patterns/containers/header-bars.html) the header bar.
46
-
We do that by replacing [`gtk::ApplicationWindow`](../docs/gtk4/struct.ApplicationWindow.html) with [`adw::ApplicationWindow`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ApplicationWindow.html).
47
-
We also use [`adw::HeaderBar`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.HeaderBar.html) as the title bar.
48
-
Finally, we add [tooltips](https://developer.gnome.org/hig/patterns/feedback/tooltips.html).
49
-
50
-
The second pattern we are going to follow are [boxed lists](https://developer.gnome.org/hig/patterns/containers/boxed-lists.html).
44
+
Now we are going let our tasks follow the [boxed lists pattern](https://developer.gnome.org/hig/patterns/containers/boxed-lists.html).
51
45
The HIG does not require us to use this style and there's a good reason for that: it is incompatible with recycling lists.
52
46
This means they cannot be used with [list views](https://developer.gnome.org/hig/patterns/containers/list-column-views.html) and are therefore only appropriate for relatively small lists.
53
47
@@ -58,110 +52,65 @@ We can use boxed lists by using [`gtk::ListBox`](../docs/gtk4/struct.ListBox.htm
58
52
We will also add the [`boxed-list`](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/boxed-lists.html) style class provided by Libadwaita.
59
53
60
54
Let's implement all these changes in the `window.ui` file.
61
-
You can find the relevant subset of the diff below.
62
-
To see the complete file, just click on the link after "Filename:".
55
+
All of the changes are confined within the second child of the `ApplicationWindow`.
56
+
To see the complete file, just click on the link after "Filename".
We've replaced the `gtk::ApplicationWindow` with `adw::ApplicationWindow` and added an `adw::HeaderBar` to it.
136
100
In order to follow the boxed list pattern, we switched to [`gtk::ListBox`](../docs/gtk4/struct.ListBox.html), set its property "selection-mode" to "none" and added the `boxed-list` style class.
137
101
138
102
Let's continue with `window/imp.rs`.
139
103
The member variable `tasks_list` now describes a `ListBox` rather than a `ListView`.
140
-
We also need to change the `ParentType` from `gtk::ApplicationWindow` to `adw::ApplicationWindow`.
0 commit comments