Skip to content

Commit

Permalink
drop more manual functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Dec 29, 2021
1 parent b8cfd58 commit aef4337
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 82 deletions.
2 changes: 1 addition & 1 deletion gdk4-wayland/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 7ca0cbfc850e)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
2 changes: 1 addition & 1 deletion gdk4-wayland/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 7ca0cbfc850e)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
2 changes: 1 addition & 1 deletion gdk4-x11/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 7ca0cbfc850e)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
2 changes: 1 addition & 1 deletion gdk4-x11/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 7ca0cbfc850e)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
11 changes: 0 additions & 11 deletions gdk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,6 @@ manual_traits = ["DisplayExtManual"]
[[object.function]]
pattern = "map_key(code|val)"
manual = true # make use of Key
[[object.function]]
name = "put_event"
manual = true # event is a fundemental type

[[object]]
name = "Gdk.DisplayManager"
Expand Down Expand Up @@ -691,14 +688,6 @@ manual_traits = ["TextureExtManual"]
name = "Gdk.Toplevel"
status = "generate"
manual_traits = ["ToplevelExtManual"]
[[object.function]]
name = "inhibit_system_shortcuts"
manual = true # event is a fundemental type
doc_trait_name = "ToplevelExtManual"
[[object.function]]
name = "show_window_menu"
manual = true # event is a fundemental type
doc_trait_name = "ToplevelExtManual"
[[object.signal]]
name = "compute-size"
manual = true
Expand Down
13 changes: 13 additions & 0 deletions gdk4/src/auto/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::AppLaunchContext;
use crate::Clipboard;
use crate::Device;
use crate::Event;
#[cfg(any(feature = "v4_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v4_6")))]
use crate::GLContext;
Expand Down Expand Up @@ -127,6 +128,9 @@ pub trait DisplayExt: 'static {
#[doc(alias = "gdk_display_prepare_gl")]
fn prepare_gl(&self) -> Result<(), glib::Error>;

#[doc(alias = "gdk_display_put_event")]
fn put_event(&self, event: impl AsRef<Event>);

#[doc(alias = "gdk_display_supports_input_shapes")]
fn supports_input_shapes(&self) -> bool;

Expand Down Expand Up @@ -313,6 +317,15 @@ impl<O: IsA<Display>> DisplayExt for O {
}
}

fn put_event(&self, event: impl AsRef<Event>) {
unsafe {
ffi::gdk_display_put_event(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
);
}
}

fn supports_input_shapes(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_input_shapes(
Expand Down
25 changes: 25 additions & 0 deletions gdk4/src/auto/toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// DO NOT EDIT

use crate::Device;
use crate::Event;
use crate::FullscreenMode;
use crate::Surface;
use crate::SurfaceEdge;
Expand Down Expand Up @@ -58,6 +59,9 @@ pub trait ToplevelExt: 'static {
#[doc(alias = "get_state")]
fn state(&self) -> ToplevelState;

#[doc(alias = "gdk_toplevel_inhibit_system_shortcuts")]
fn inhibit_system_shortcuts(&self, event: Option<impl AsRef<Event>>);

#[doc(alias = "gdk_toplevel_lower")]
fn lower(&self) -> bool;

Expand Down Expand Up @@ -91,6 +95,9 @@ pub trait ToplevelExt: 'static {
#[doc(alias = "gdk_toplevel_set_transient_for")]
fn set_transient_for(&self, parent: &impl IsA<Surface>);

#[doc(alias = "gdk_toplevel_show_window_menu")]
fn show_window_menu(&self, event: impl AsRef<Event>) -> bool;

#[doc(alias = "gdk_toplevel_supports_edge_constraints")]
fn supports_edge_constraints(&self) -> bool;

Expand Down Expand Up @@ -202,6 +209,15 @@ impl<O: IsA<Toplevel>> ToplevelExt for O {
unsafe { from_glib(ffi::gdk_toplevel_get_state(self.as_ref().to_glib_none().0)) }
}

fn inhibit_system_shortcuts(&self, event: Option<impl AsRef<Event>>) {
unsafe {
ffi::gdk_toplevel_inhibit_system_shortcuts(
self.as_ref().to_glib_none().0,
event.as_ref().map(|p| p.as_ref()).to_glib_none().0,
);
}
}

fn lower(&self) -> bool {
unsafe { from_glib(ffi::gdk_toplevel_lower(self.as_ref().to_glib_none().0)) }
}
Expand Down Expand Up @@ -273,6 +289,15 @@ impl<O: IsA<Toplevel>> ToplevelExt for O {
}
}

fn show_window_menu(&self, event: impl AsRef<Event>) -> bool {
unsafe {
from_glib(ffi::gdk_toplevel_show_window_menu(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
))
}
}

fn supports_edge_constraints(&self) -> bool {
unsafe {
from_glib(ffi::gdk_toplevel_supports_edge_constraints(
Expand Down
2 changes: 1 addition & 1 deletion gdk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 96c8585aed36)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
14 changes: 1 addition & 13 deletions gdk4/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::prelude::*;
use crate::{Display, Event, Key, KeymapKey, ModifierType};
use crate::{Display, Key, KeymapKey, ModifierType};
use glib::translate::*;
use glib::IsA;
use std::{mem, ptr};
Expand Down Expand Up @@ -72,9 +72,6 @@ pub trait DisplayExtManual: 'static {
#[doc(alias = "gdk_display_map_keycode")]
fn map_keycode(&self, keycode: u32) -> Option<Vec<(KeymapKey, Key)>>;

#[doc(alias = "gdk_display_put_event")]
fn put_event<P: AsRef<Event>>(&self, event: &P);

// rustdoc-stripper-ignore-next
/// Get the currently used display backend
fn backend(&self) -> Backend;
Expand Down Expand Up @@ -181,15 +178,6 @@ impl<O: IsA<Display>> DisplayExtManual for O {
}
}

fn put_event<P: AsRef<Event>>(&self, event: &P) {
unsafe {
ffi::gdk_display_put_event(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
);
}
}

fn backend(&self) -> Backend {
match self.as_ref().type_().name() {
"GdkWaylandDisplay" => Backend::Wayland,
Expand Down
25 changes: 1 addition & 24 deletions gdk4/src/toplevel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{Event, Toplevel, ToplevelSize};
use crate::{Toplevel, ToplevelSize};
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
Expand All @@ -11,11 +11,6 @@ use std::mem::transmute;
// rustdoc-stripper-ignore-next
/// Trait containing manually implemented methods of [`Toplevel`](crate::Toplevel).
pub trait ToplevelExtManual {
#[doc(alias = "gdk_toplevel_inhibit_system_shortcuts")]
fn inhibit_system_shortcuts<P: AsRef<Event>>(&self, event: Option<&P>);

#[doc(alias = "gdk_toplevel_show_window_menu")]
fn show_window_menu<P: AsRef<Event>>(&self, event: &P) -> bool;
fn connect_compute_size<F: Fn(&Toplevel, &mut ToplevelSize) + 'static>(
&self,
f: F,
Expand Down Expand Up @@ -49,22 +44,4 @@ impl<O: IsA<Toplevel>> ToplevelExtManual for O {
)
}
}

fn inhibit_system_shortcuts<P: AsRef<Event>>(&self, event: Option<&P>) {
unsafe {
ffi::gdk_toplevel_inhibit_system_shortcuts(
self.as_ref().to_glib_none().0,
event.map(|e| e.as_ref()).to_glib_none().0,
);
}
}

fn show_window_menu<P: AsRef<Event>>(&self, event: &P) -> bool {
unsafe {
from_glib(ffi::gdk_toplevel_show_window_menu(
self.as_ref().to_glib_none().0,
event.as_ref().to_glib_none().0,
))
}
}
}
2 changes: 1 addition & 1 deletion gdk4/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 96c8585aed36)
Generated by gir (https://github.com/gtk-rs/gir @ 090cd5db90ac)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 898f6c1fb177)
3 changes: 0 additions & 3 deletions gtk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,6 @@ generate_builder = false
[[object.function]]
name = "get_current_object"
manual = true # don't ref_sink the object
[[object.function]]
name = "value_from_string"
manual = true # ParamSpec is a fundemental type

[[object]]
name = "Gtk.BuilderListItemFactory"
Expand Down
25 changes: 25 additions & 0 deletions gtk4/src/auto/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,31 @@ impl Builder {
}
}

#[doc(alias = "gtk_builder_value_from_string")]
pub fn value_from_string(
&self,
pspec: impl AsRef<glib::ParamSpec>,
string: &str,
) -> Result<glib::Value, glib::Error> {
unsafe {
let mut value = glib::Value::uninitialized();
let mut error = ptr::null_mut();
let is_ok = ffi::gtk_builder_value_from_string(
self.to_glib_none().0,
pspec.as_ref().to_glib_none().0,
string.to_glib_none().0,
value.to_glib_none_mut().0,
&mut error,
);
assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(value)
} else {
Err(from_glib_full(error))
}
}
}

#[doc(alias = "gtk_builder_value_from_string_type")]
pub fn value_from_string_type(
&self,
Expand Down
24 changes: 0 additions & 24 deletions gtk4/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,6 @@ impl Builder {
}
}

#[doc(alias = "gtk_builder_value_from_string")]
pub fn value_from_string(
&self,
pspec: &glib::ParamSpec,
string: &str,
) -> Result<glib::Value, glib::Error> {
unsafe {
let mut value = glib::Value::uninitialized();
let mut error = std::ptr::null_mut();
let _ = ffi::gtk_builder_value_from_string(
self.to_glib_none().0,
pspec.to_glib_none().0,
string.to_glib_none().0,
value.to_glib_none_mut().0,
&mut error,
);
if error.is_null() {
Ok(value)
} else {
Err(from_glib_full(error))
}
}
}

#[doc(alias = "gtk_builder_add_from_file")]
pub fn add_from_file<T: AsRef<Path>>(&self, file_path: T) -> Result<(), glib::Error> {
unsafe {
Expand Down

0 comments on commit aef4337

Please sign in to comment.