Skip to content

Commit 2dcdfd0

Browse files
committed
Adapt for gtk 0.7.0
1 parent 965bb56 commit 2dcdfd0

File tree

26 files changed

+227
-230
lines changed

26 files changed

+227
-230
lines changed

book/listings/Cargo.lock

Lines changed: 182 additions & 167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/listings/actions/3/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn build_ui(app: &Application) {
6262
let action_count = SimpleAction::new_stateful(
6363
"count",
6464
Some(&i32::static_variant_type()),
65-
original_state.to_variant(),
65+
&original_state.to_variant(),
6666
);
6767
action_count.connect_activate(clone!(@weak label => move |action, parameter| {
6868
// Get state
@@ -80,7 +80,7 @@ fn build_ui(app: &Application) {
8080

8181
// Increase state by parameter and store state
8282
state += parameter;
83-
action.set_state(state.to_variant());
83+
action.set_state(&state.to_variant());
8484

8585
// Update label with new state
8686
label.set_label(&format!("Counter: {state}"));

book/listings/actions/4/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn build_ui(app: &Application) {
5858
let action_count = SimpleAction::new_stateful(
5959
"count",
6060
Some(&i32::static_variant_type()),
61-
original_state.to_variant(),
61+
&original_state.to_variant(),
6262
);
6363
action_count.connect_activate(clone!(@weak label => move |action, parameter| {
6464
// Get state
@@ -76,7 +76,7 @@ fn build_ui(app: &Application) {
7676

7777
// Increase state by parameter and save state
7878
state += parameter;
79-
action.set_state(state.to_variant());
79+
action.set_state(&state.to_variant());
8080

8181
// Update label with new state
8282
label.set_label(&format!("Counter: {state}"));

book/listings/actions/5/window/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Window {
2828
let action_count = SimpleAction::new_stateful(
2929
"count",
3030
Some(&i32::static_variant_type()),
31-
original_state.to_variant(),
31+
&original_state.to_variant(),
3232
);
3333

3434
action_count.connect_activate(clone!(@weak label => move |action, parameter| {
@@ -47,7 +47,7 @@ impl Window {
4747

4848
// Increase state by parameter and save state
4949
state += parameter;
50-
action.set_state(state.to_variant());
50+
action.set_state(&state.to_variant());
5151

5252
// Update label with new state
5353
label.set_label(&format!("Counter: {state}"));

book/listings/actions/6/window/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Window {
2929
let action_count = SimpleAction::new_stateful(
3030
"count",
3131
Some(&i32::static_variant_type()),
32-
original_state.to_variant(),
32+
&original_state.to_variant(),
3333
);
3434

3535
action_count.connect_activate(clone!(@weak label => move |action, parameter| {
@@ -48,7 +48,7 @@ impl Window {
4848

4949
// Increase state by parameter and save state
5050
state += parameter;
51-
action.set_state(state.to_variant());
51+
action.set_state(&state.to_variant());
5252

5353
// Update label with new state
5454
label.set_label(&format!("Counter: {state}"));
@@ -70,7 +70,7 @@ impl Window {
7070
let action_orientation = SimpleAction::new_stateful(
7171
"orientation",
7272
Some(&String::static_variant_type()),
73-
"Vertical".to_variant(),
73+
&"Vertical".to_variant(),
7474
);
7575

7676
action_orientation.connect_activate(clone!(@weak gtk_box =>
@@ -89,7 +89,7 @@ impl Window {
8989

9090
// Set orientation and save state
9191
gtk_box.set_orientation(orientation);
92-
action.set_state(parameter.to_variant());
92+
action.set_state(&parameter.to_variant());
9393
}));
9494
self.add_action(&action_orientation);
9595
//ANCHOR_END: action_orientation

book/listings/actions/7/window/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Window {
4747
let action_count = SimpleAction::new_stateful(
4848
"count",
4949
Some(&i32::static_variant_type()),
50-
original_state.to_variant(),
50+
&original_state.to_variant(),
5151
);
5252

5353
action_count.connect_activate(clone!(@weak label => move |action, parameter| {
@@ -66,7 +66,7 @@ impl Window {
6666

6767
// Increase state by parameter and save state
6868
state += parameter;
69-
action.set_state(state.to_variant());
69+
action.set_state(&state.to_variant());
7070

7171
// Update label with new state
7272
label.set_label(&format!("Counter: {state}"));

book/listings/css/1/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use gdk::Display;
22
use gtk::prelude::*;
3-
use gtk::{
4-
gdk, glib, Application, ApplicationWindow, Button, CssProvider, StyleContext,
5-
};
3+
use gtk::{gdk, glib, Application, ApplicationWindow, Button, CssProvider};
64

75
// ANCHOR: main
86
const APP_ID: &str = "org.gtk_rs.Css1";
@@ -25,7 +23,7 @@ fn load_css() {
2523
provider.load_from_data(include_str!("style.css"));
2624

2725
// Add the provider to the default screen
28-
StyleContext::add_provider_for_display(
26+
gtk::style_context_add_provider_for_display(
2927
&Display::default().expect("Could not connect to a display."),
3028
&provider,
3129
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,

book/listings/css/2/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use gdk::Display;
22
use gtk::prelude::*;
3-
use gtk::{
4-
gdk, glib, Application, ApplicationWindow, Button, CssProvider, StyleContext,
5-
};
3+
use gtk::{gdk, glib, Application, ApplicationWindow, Button, CssProvider};
64

75
const APP_ID: &str = "org.gtk_rs.Css2";
86

@@ -24,7 +22,7 @@ fn load_css() {
2422
provider.load_from_data(include_str!("style.css"));
2523

2624
// Add the provider to the default screen
27-
StyleContext::add_provider_for_display(
25+
gtk::style_context_add_provider_for_display(
2826
&Display::default().expect("Could not connect to a display."),
2927
&provider,
3028
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,

book/listings/css/3/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use gdk::Display;
22
use gtk::prelude::*;
3-
use gtk::{
4-
gdk, glib, Application, ApplicationWindow, Button, CssProvider, StyleContext,
5-
};
3+
use gtk::{gdk, glib, Application, ApplicationWindow, Button, CssProvider};
64

75
const APP_ID: &str = "org.gtk_rs.Css3";
86

@@ -24,7 +22,7 @@ fn load_css() {
2422
provider.load_from_data(include_str!("style.css"));
2523

2624
// Add the provider to the default screen
27-
StyleContext::add_provider_for_display(
25+
gtk::style_context_add_provider_for_display(
2826
&Display::default().expect("Could not connect to a display."),
2927
&provider,
3028
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,

book/listings/css/4/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use gdk::Display;
22
use gtk::prelude::*;
3-
use gtk::{
4-
gdk, glib, Application, ApplicationWindow, Button, CssProvider, StyleContext,
5-
};
3+
use gtk::{gdk, glib, Application, ApplicationWindow, Button, CssProvider};
64

75
const APP_ID: &str = "org.gtk_rs.Css4";
86

@@ -24,7 +22,7 @@ fn load_css() {
2422
provider.load_from_data(include_str!("style.css"));
2523

2624
// Add the provider to the default screen
27-
StyleContext::add_provider_for_display(
25+
gtk::style_context_add_provider_for_display(
2826
&Display::default().expect("Could not connect to a display."),
2927
&provider,
3028
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,

0 commit comments

Comments
 (0)