Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
PixbufExt: allow creating a surface without a for_window
Browse files Browse the repository at this point in the history
Per the C API docs here https://developer.gnome.org/gdk3/stable/gdk3-Cairo-Interaction.html
gdk_cairo_surface_create_from_pixbuf the for_window param can be NULL
  • Loading branch information
bilelmoussaoui committed Dec 31, 2019
1 parent 4d4968f commit 2e14ec9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cairo_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ impl GdkSurfaceExt for Surface {
}

pub trait GdkPixbufExt {
fn create_surface<W: IsA<Window>>(&self, scale: i32, for_window: &W) -> Option<Surface>;
fn create_surface<W: IsA<Window>>(&self, scale: i32, for_window: Option<&W>)
-> Option<Surface>;
}

impl GdkPixbufExt for Pixbuf {
fn create_surface<W: IsA<Window>>(&self, scale: i32, for_window: &W) -> Option<Surface> {
fn create_surface<W: IsA<Window>>(
&self,
scale: i32,
for_window: Option<&W>,
) -> Option<Surface> {
unsafe {
from_glib_full(gdk_sys::gdk_cairo_surface_create_from_pixbuf(
self.to_glib_none().0,
scale,
for_window.as_ref().to_glib_none().0,
for_window.map(std::convert::AsRef::as_ref).to_glib_none().0,
))
}
}
Expand Down

0 comments on commit 2e14ec9

Please sign in to comment.