Skip to content

Commit

Permalink
gtk4: Manually implement GraphicsOffload constructor for now
Browse files Browse the repository at this point in the history
Needs to be transfer-none instead of transfer-full
  • Loading branch information
sdroege committed Apr 20, 2024
1 parent 5c1f37a commit 41072f2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
10 changes: 9 additions & 1 deletion gtk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ generate = [
"Gtk.GestureRotate",
"Gtk.GestureSwipe",
"Gtk.GestureZoom",
"Gtk.GraphicsOffload",
"Gtk.GraphicsOffloadEnabled",
"Gtk.Grid",
"Gtk.GridLayout",
Expand Down Expand Up @@ -1370,6 +1369,15 @@ status = "generate"
[object.signal.return]
nullable = true

[[object]]
name = "Gtk.GraphicsOffload"
status = "generate"
[[object.function]]
name = "new"
# transfer none
# https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7159
manual = true

[[object]]
name = "Gtk.GridLayoutChild"
status = "generate"
Expand Down
19 changes: 0 additions & 19 deletions gtk4/src/auto/graphics_offload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ glib::wrapper! {
}

impl GraphicsOffload {
#[doc(alias = "gtk_graphics_offload_new")]
pub fn new(child: Option<&impl IsA<Widget>>) -> GraphicsOffload {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_full(ffi::gtk_graphics_offload_new(
child.map(|p| p.as_ref()).to_glib_none().0,
))
.unsafe_cast()
}
}

// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`GraphicsOffload`] objects.
///
Expand Down Expand Up @@ -122,14 +111,6 @@ impl GraphicsOffload {
}
}

#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
impl Default for GraphicsOffload {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`GraphicsOffload`] objects.
///
Expand Down
26 changes: 26 additions & 0 deletions gtk4/src/graphics_offload.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;

use crate::{prelude::*, GraphicsOffload};

impl GraphicsOffload {
#[doc(alias = "gtk_graphics_offload_new")]
pub fn new(child: Option<&impl IsA<Widget>>) -> GraphicsOffload {

Check failure on line 9 in gtk4/src/graphics_offload.rs

View workflow job for this annotation

GitHub Actions / Windows MSVC

cannot find type `Widget` in this scope
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_graphics_offload_new(

Check failure on line 12 in gtk4/src/graphics_offload.rs

View workflow job for this annotation

GitHub Actions / Windows MSVC

failed to resolve: use of undeclared type `Widget`
child.map(|p| p.as_ref()).to_glib_none().0,
))
.unsafe_cast()
}

Check failure on line 16 in gtk4/src/graphics_offload.rs

View workflow job for this annotation

GitHub Actions / build

cannot find type `Widget` in this scope
}
}

#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
impl Default for GraphicsOffload {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}
3 changes: 3 additions & 0 deletions gtk4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ mod font_chooser;
mod font_dialog;
mod functions;
mod gesture_stylus;
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
mod graphics_offload;
mod icon_theme;
mod im_context_simple;
mod info_bar;
Expand Down

0 comments on commit 41072f2

Please sign in to comment.