Skip to content

Commit d0094d7

Browse files
authored
book: Disable playground globally (#1518)
Also remove annotation from code blocks
1 parent b9f3d73 commit d0094d7

17 files changed

+128
-127
lines changed

book/book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ default-theme = "Rust"
1111
git-repository-url = "https://github.com/gtk-rs/gtk4-rs/tree/master/book"
1212
git-repository-icon = "fa-github"
1313
additional-css = ["theme/style.css"]
14+
playground.runnable = false

book/src/actions.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If that had not been the case, we would have to add the action group manually vi
3737

3838
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/2/main.rs">listings/actions/2/main.rs</a>
3939

40-
```rust ,no_run,noplayground
40+
```rust
4141
{{#rustdoc_include ../listings/actions/2/main.rs:action_group}}
4242
```
4343

@@ -57,7 +57,7 @@ Let's see how this works.
5757

5858
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/3/main.rs">listings/actions/3/main.rs</a>
5959

60-
```rust ,no_run,noplayground
60+
```rust
6161
{{#rustdoc_include ../listings/actions/3/main.rs:build_ui}}
6262
```
6363

@@ -83,7 +83,7 @@ With [`ButtonBuilder`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/builde
8383

8484
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/4/main.rs">listings/actions/4/main.rs</a>
8585

86-
```rust ,no_run,noplayground
86+
```rust
8787
{{#rustdoc_include ../listings/actions/4/main.rs:button_builder}}
8888
```
8989

@@ -101,15 +101,15 @@ We will connect the actions and add them to the window in the `Window::setup_act
101101

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

104-
```rust ,no_run,noplayground
104+
```rust
105105
{{#rustdoc_include ../listings/actions/5/window/mod.rs:impl_window}}
106106
```
107107

108108
Finally, `setup_actions` will be called within `constructed`.
109109

110110
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/5/window/imp.rs">listings/actions/5/window/imp.rs</a>
111111

112-
```rust ,no_run,noplayground
112+
```rust
113113
{{#rustdoc_include ../listings/actions/5/window/imp.rs:object_impl}}
114114
```
115115

@@ -135,7 +135,7 @@ This means that the caller can expect the boolean state to toggle after activati
135135

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

138-
```rust ,no_run,noplayground
138+
```rust
139139
{{#rustdoc_include ../listings/actions/6/window/mod.rs:action_button_frame}}
140140
```
141141

@@ -153,7 +153,7 @@ We don't need the action state to implement orientation switching, however it is
153153

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

156-
```rust ,no_run,noplayground
156+
```rust
157157
{{#rustdoc_include ../listings/actions/6/window/mod.rs:action_orientation}}
158158
```
159159

@@ -255,15 +255,15 @@ Since [`gio::Settings`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/st
255255

256256
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>
257257

258-
```rust ,no_run,noplayground
258+
```rust
259259
{{#rustdoc_include ../listings/actions/7/window/imp.rs:imp_struct}}
260260
```
261261

262262
Now we create functions to make it easier to access settings.
263263

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

266-
```rust ,no_run,noplayground
266+
```rust
267267
{{#rustdoc_include ../listings/actions/7/window/mod.rs:settings}}
268268
```
269269

@@ -273,7 +273,7 @@ We create actions with the[ `create_action`](https://gtk-rs.org/gtk-rs-core/stab
273273

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

276-
```rust ,no_run,noplayground
276+
```rust
277277
{{#rustdoc_include ../listings/actions/7/window/mod.rs:settings_create_actions}}
278278
```
279279

@@ -285,15 +285,15 @@ For the stateful actions, instead of adding callbacks to their "activate" signal
285285

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

288-
```rust ,no_run,noplayground
288+
```rust
289289
{{#rustdoc_include ../listings/actions/7/window/mod.rs:bind_settings}}
290290
```
291291

292292
Finally, we make sure that `bind_settings` is called within `constructed`.
293293

294294
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>
295295

296-
```rust ,no_run,noplayground
296+
```rust
297297
{{#rustdoc_include ../listings/actions/7/window/imp.rs:object_impl}}
298298
```
299299

book/src/composite_templates.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Until now, whenever we constructed pre-defined widgets we relied on the [builder
44
As a reminder, that is how we used it to build our trusty "Hello World!" app.
55

66
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/hello_world/3/main.rs">listings/hello_world/3/main.rs</a>
7-
```rust ,no_run,noplayground
7+
```rust
88
{{#rustdoc_include ../listings/hello_world/3/main.rs:all}}
99
```
1010

@@ -57,7 +57,7 @@ Then, we create a `build.rs` at the root of our package with the following conte
5757
This will compile the resources whenever we trigger a build with cargo and then statically link our executable to them.
5858

5959
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/build.rs">listings/build.rs</a>
60-
```rust ,no_run,noplayground
60+
```rust
6161
fn main() {
6262
glib_build_tools::compile_resources(
6363
&["composite_templates/1/resources"],
@@ -71,13 +71,13 @@ Finally, we register and include the resources by calling the macro [`gio::resou
7171
In your own apps take care to register the resources before creating the `gtk::Application`.
7272

7373
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/1/main.rs">listings/composite_templates/1/main.rs</a>
74-
```rust ,no_run,noplayground
74+
```rust
7575
{{#rustdoc_include ../listings/composite_templates/1/main.rs}}
7676
```
7777

7878
Within our code we create a custom widget inheriting from `gtk::ApplicationWindow` to make use of our template.
7979
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/1/window/mod.rs">listings/composite_templates/1/window/mod.rs</a>
80-
```rust ,no_run,noplayground
80+
```rust
8181
{{#rustdoc_include ../listings/composite_templates/1/window/mod.rs}}
8282
```
8383

@@ -90,23 +90,23 @@ You use it by adding a struct member with the same name as one `id` attribute in
9090
This will be useful later, when we want to add a callback to our button.
9191

9292
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/1/window/imp.rs">listings/composite_templates/1/window/imp.rs</a>
93-
```rust ,no_run,noplayground
93+
```rust
9494
{{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:object}}
9595
```
9696

9797
Within the `ObjectSubclass` trait, we make sure that `NAME` corresponds to `class` in the template and `ParentType` corresponds to `parent` in the template.
9898
We also bind and initialize the template in `class_init` and `instance_init`.
9999

100100
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/1/window/imp.rs">listings/composite_templates/1/window/imp.rs</a>
101-
```rust ,no_run,noplayground
101+
```rust
102102
{{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:subclass}}
103103
```
104104

105105
Finally, we connect the callback to the "clicked" signal of `button` within `constructed`.
106106
The button is easily available thanks to the stored reference in `self`.
107107

108108
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/1/window/imp.rs">listings/composite_templates/1/window/imp.rs</a>
109-
```rust ,no_run,noplayground
109+
```rust
110110
{{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:object_impl}}
111111
```
112112

@@ -118,21 +118,21 @@ As usual, we define the implementation struct within `imp.rs`.
118118
Note the `NAME` we define here, we will need it later to refer to it in the template.
119119

120120
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/2/custom_button/imp.rs">listings/composite_templates/2/custom_button/imp.rs</a>
121-
```rust ,no_run,noplayground
121+
```rust
122122
{{#rustdoc_include ../listings/composite_templates/2/custom_button/imp.rs:imp}}
123123
```
124124

125125
We also define the public struct in `mod.rs`.
126126

127127
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/2/custom_button/mod.rs">listings/composite_templates/2/custom_button/mod.rs</a>
128-
```rust ,no_run,noplayground
128+
```rust
129129
{{#rustdoc_include ../listings/composite_templates/2/custom_button/mod.rs:mod}}
130130
```
131131

132132
Since we want to refer to a `CustomButton` now we also have to change the type of the template child to it.
133133

134134
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/2/window/imp.rs">listings/composite_templates/2/window/imp.rs</a>
135-
```rust ,no_run,noplayground
135+
```rust
136136
{{#rustdoc_include ../listings/composite_templates/2/window/imp.rs:object}}
137137
```
138138

@@ -162,23 +162,23 @@ It takes a function of type `Fn(&Self)`.
162162
This means that `handle_button_clicked` has a single parameter of type `&CustomButton`.
163163

164164
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/3/window/imp.rs">listings/composite_templates/3/window/imp.rs</a>
165-
```rust ,no_run,noplayground
165+
```rust
166166
{{#rustdoc_include ../listings/composite_templates/3/window/imp.rs:template_callbacks}}
167167
```
168168

169169
Then we have to bind the template callbacks with [`bind_template_callbacks`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/subclass/widget/trait.CompositeTemplateCallbacksClass.html#tymethod.bind_template_callbacks).
170170
We also need to remove the `button.connect_clicked` callback implemented in `window/imp.rs`.
171171

172172
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/3/window/imp.rs">listings/composite_templates/3/window/imp.rs</a>
173-
```rust ,no_run,noplayground
173+
```rust
174174
{{#rustdoc_include ../listings/composite_templates/3/window/imp.rs:subclass}}
175175
```
176176

177177
We can also access the state of our widget.
178178
Let's say we want to manipulate a `number` stored in `imp::Window`.
179179

180180
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/4/window/imp.rs">listings/composite_templates/4/window/imp.rs</a>
181-
```rust ,no_run,noplayground
181+
```rust
182182
{{#rustdoc_include ../listings/composite_templates/4/window/imp.rs:object}}
183183
```
184184

@@ -193,7 +193,7 @@ Now we can add `&self` as first parameter to `handle_button_clicked`.
193193
This lets us access the state of the window and therefore manipulate `number`.
194194

195195
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/4/window/imp.rs">listings/composite_templates/4/window/imp.rs</a>
196-
```rust ,no_run,noplayground
196+
```rust
197197
{{#rustdoc_include ../listings/composite_templates/4/window/imp.rs:template_callbacks}}
198198
```
199199

@@ -203,7 +203,7 @@ Now that we use template callbacks we don't access the template child anymore.
203203
Let's remove it.
204204

205205
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/5/window/imp.rs">listings/composite_templates/5/window/imp.rs</a>
206-
```rust ,no_run,noplayground
206+
```rust
207207
{{#rustdoc_include ../listings/composite_templates/5/window/imp.rs:object}}
208208
```
209209

@@ -220,7 +220,7 @@ It also ensures that the widget type is registered.
220220
Luckily we can also do that by ourselves.
221221

222222
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/composite_templates/6/window/imp.rs">listings/composite_templates/6/window/imp.rs</a>
223-
```rust ,no_run,noplayground
223+
```rust
224224
{{#rustdoc_include ../listings/composite_templates/6/window/imp.rs:subclass}}
225225
```
226226

book/src/css.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ As usual, the widgets are created during the "activate" step.
2222

2323
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/css/1/main.rs">listings/css/1/main.rs</a>
2424

25-
```rust ,no_run,noplayground
25+
```rust
2626
{{#rustdoc_include ../listings/css/1/main.rs:main}}
2727
```
2828

@@ -71,7 +71,7 @@ Which is why we add the style class `button-1` to the first one.
7171

7272
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/css/3/main.rs">listings/css/3/main.rs</a>
7373

74-
```rust ,no_run,noplayground
74+
```rust
7575
{{#rustdoc_include ../listings/css/3/main.rs:buttons}}
7676
```
7777

@@ -100,7 +100,7 @@ We set the name of the first one with [`set_widget_name`](https://gtk-rs.org/gtk
100100

101101
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/css/4/main.rs">listings/css/4/main.rs</a>
102102

103-
```rust ,no_run,noplayground
103+
```rust
104104
{{#rustdoc_include ../listings/css/4/main.rs:buttons}}
105105
```
106106

@@ -127,7 +127,7 @@ Most widgets will document these rules in their documentation under [CSS nodes](
127127

128128
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/css/5/main.rs">listings/css/5/main.rs</a>
129129

130-
```rust ,no_run,noplayground
130+
```rust
131131
{{#rustdoc_include ../listings/css/5/main.rs:buttons}}
132132
```
133133

@@ -232,7 +232,7 @@ In our case, the widget `TaskRow` then corresponds to the node `task-row`.
232232

233233
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/todo/3/task_row/imp.rs">listings/todo/3/task_row/imp.rs</a>
234234

235-
```rust ,no_run,noplayground
235+
```rust
236236
{{#rustdoc_include ../listings/todo/3/task_row/imp.rs:object_subclass}}
237237
```
238238

@@ -274,14 +274,14 @@ Additionally, we call `load_css()` in `connect_startup`.
274274

275275
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/todo/3/main.rs">listings/todo/3/main.rs</a>
276276

277-
```rust ,no_run,noplayground
277+
```rust
278278
{{#rustdoc_include ../listings/todo/3/main.rs:connect_startup}}
279279
```
280280

281281
`load_css()` is very similar to the one shown at the beginning of the chapter.
282282
However, this time we load styles using `load_from_resource()`.
283283

284-
```rust ,no_run,noplayground
284+
```rust
285285
{{#rustdoc_include ../listings/todo/3/main.rs:load_css}}
286286
```
287287

book/src/g_object_memory_management.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ We need a data type with interior mutability like [`std::cell::Cell`](https://do
156156
157157
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/2/main.rs">listings/g_object_memory_management/1/main.rs</a>
158158

159-
```rust ,no_run,noplayground
159+
```rust
160160
{{#rustdoc_include ../listings/g_object_memory_management/1/main.rs:build_ui}}
161161
```
162162

@@ -172,7 +172,7 @@ we can again use the [`Cell`](https://doc.rust-lang.org/std/cell/struct.Cell.htm
172172

173173
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/2/main.rs">listings/g_object_memory_management/2/main.rs</a>
174174

175-
```rust ,no_run,noplayground
175+
```rust
176176
{{#rustdoc_include ../listings/g_object_memory_management/2/main.rs:callback}}
177177
```
178178

@@ -181,7 +181,7 @@ We can improve that by using the [`glib::clone!`](https://gtk-rs.org/gtk-rs-core
181181

182182
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/3/main.rs">listings/g_object_memory_management/3/main.rs</a>
183183

184-
```rust ,no_run,noplayground
184+
```rust
185185
{{#rustdoc_include ../listings/g_object_memory_management/3/main.rs:callback}}
186186
```
187187

@@ -190,7 +190,7 @@ Therefore, we can pass the buttons the same way to the closure as we did with `n
190190

191191
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/4/main.rs">listings/g_object_memory_management/4/main.rs</a>
192192

193-
```rust ,no_run,noplayground
193+
```rust
194194
{{#rustdoc_include ../listings/g_object_memory_management/4/main.rs:callback}}
195195
```
196196

@@ -207,7 +207,7 @@ Since we want our apps to free unneeded memory, we should use weak references fo
207207

208208
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/5/main.rs">listings/g_object_memory_management/5/main.rs</a>
209209

210-
```rust ,no_run,noplayground
210+
```rust
211211
{{#rustdoc_include ../listings/g_object_memory_management/5/main.rs:callback}}
212212
```
213213

@@ -224,15 +224,15 @@ Who then keeps the buttons alive?
224224

225225
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/5/main.rs">listings/g_object_memory_management/5/main.rs</a>
226226

227-
```rust ,no_run,noplayground
227+
```rust
228228
{{#rustdoc_include ../listings/g_object_memory_management/5/main.rs:box_append}}
229229
```
230230

231231
When we append the buttons to the `gtk_box`, `gtk_box` keeps a strong reference to them.
232232

233233
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_memory_management/5/main.rs">listings/g_object_memory_management/5/main.rs</a>
234234

235-
```rust ,no_run,noplayground
235+
```rust
236236
{{#rustdoc_include ../listings/g_object_memory_management/5/main.rs:window_child}}
237237
```
238238

0 commit comments

Comments
 (0)