Skip to content

Commit 42c72aa

Browse files
committed
SimpleAction: take state by value
1 parent b54cb5f commit 42c72aa

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

gio/Gir.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,21 @@ status = "generate"
11351135
name = "state"
11361136
#value glib::VariantTy
11371137
ignore = true
1138+
[[object.function]]
1139+
name = "new_stateful"
1140+
[[object.function.parameter]]
1141+
name = "state"
1142+
move = true
1143+
[[object.function]]
1144+
name = "set_state"
1145+
[[object.function.parameter]]
1146+
name = "value"
1147+
move = true
1148+
[[object.function]]
1149+
name = "set_state_hint"
1150+
[[object.function.parameter]]
1151+
name = "state_hint"
1152+
move = true
11381153

11391154
[[object]]
11401155
name = "Gio.SimpleIOStream"

gio/src/action_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<O: IsA<ActionMap>> ActionMapExtManual for O {
1515
fn add_action_entries(&self, entries: impl IntoIterator<Item = ActionEntry<Self>>) {
1616
for entry in entries.into_iter() {
1717
let action = if let Some(state) = entry.state() {
18-
SimpleAction::new_stateful(entry.name(), entry.parameter_type(), &state)
18+
SimpleAction::new_stateful(entry.name(), entry.parameter_type(), state.clone())
1919
} else {
2020
SimpleAction::new(entry.name(), entry.parameter_type())
2121
};

gio/src/auto/simple_action.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ impl SimpleAction {
3434
pub fn new_stateful(
3535
name: &str,
3636
parameter_type: Option<&glib::VariantTy>,
37-
state: &glib::Variant,
37+
state: glib::Variant,
3838
) -> SimpleAction {
3939
unsafe {
4040
from_glib_full(ffi::g_simple_action_new_stateful(
4141
name.to_glib_none().0,
4242
parameter_type.to_glib_none().0,
43-
state.to_glib_none().0,
43+
state.into_glib_ptr(),
4444
))
4545
}
4646
}
@@ -53,16 +53,16 @@ impl SimpleAction {
5353
}
5454

5555
#[doc(alias = "g_simple_action_set_state")]
56-
pub fn set_state(&self, value: &glib::Variant) {
56+
pub fn set_state(&self, value: glib::Variant) {
5757
unsafe {
58-
ffi::g_simple_action_set_state(self.to_glib_none().0, value.to_glib_none().0);
58+
ffi::g_simple_action_set_state(self.to_glib_none().0, value.into_glib_ptr());
5959
}
6060
}
6161

6262
#[doc(alias = "g_simple_action_set_state_hint")]
63-
pub fn set_state_hint(&self, state_hint: Option<&glib::Variant>) {
63+
pub fn set_state_hint(&self, state_hint: Option<glib::Variant>) {
6464
unsafe {
65-
ffi::g_simple_action_set_state_hint(self.to_glib_none().0, state_hint.to_glib_none().0);
65+
ffi::g_simple_action_set_state_hint(self.to_glib_none().0, state_hint.into_glib_ptr());
6666
}
6767
}
6868

0 commit comments

Comments
 (0)