Skip to content

Commit

Permalink
Adapt to removal of glib::Inhibit
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Jul 6, 2023
1 parent 4b8ff9f commit af9f9ad
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
5 changes: 2 additions & 3 deletions examples/dialog/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use gtk::glib::signal::Inhibit;
use gtk::glib::{self, clone};
use gtk::glib::{self, clone, ControlFlow};
use gtk::prelude::*;

use std::rc::Rc;
Expand Down Expand Up @@ -41,7 +40,7 @@ fn build_ui(application: &gtk::Application) {
if let Some(application) = window.application() {
application.remove_window(window);
}
Inhibit(false)
ControlFlow::Break
});
}

Expand Down
4 changes: 2 additions & 2 deletions gtk4/src/event_controller_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use std::{boxed::Box as Box_, mem::transmute};

impl EventControllerKey {
pub fn connect_key_pressed<
F: Fn(&EventControllerKey, Key, u32, gdk::ModifierType) -> glib::signal::Inhibit + 'static,
F: Fn(&EventControllerKey, Key, u32, gdk::ModifierType) -> glib::ControlFlow + 'static,
>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn key_pressed_trampoline<
F: Fn(&EventControllerKey, Key, u32, gdk::ModifierType) -> glib::signal::Inhibit + 'static,
F: Fn(&EventControllerKey, Key, u32, gdk::ModifierType) -> glib::ControlFlow + 'static,
>(
this: *mut ffi::GtkEventControllerKey,
keyval: libc::c_uint,
Expand Down
1 change: 0 additions & 1 deletion gtk4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ pub use css_location::CssLocation;
pub use enums::Align;
pub use expression_watch::ExpressionWatch;
pub use functions::*;
pub use glib::signal::Inhibit;
pub use keyval_trigger::KeyvalTrigger;
pub use mnemonic_trigger::MnemonicTrigger;
pub use pad_action_entry::PadActionEntry;
Expand Down
10 changes: 5 additions & 5 deletions gtk4/src/subclass/text_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait TextViewImpl: TextViewImplExt + WidgetImpl {
location: &TextIter,
start: &mut TextIter,
end: &mut TextIter,
) -> glib::signal::Inhibit {
) -> glib::ControlFlow {
self.parent_extend_selection(granularity, location, start, end)
}

Expand Down Expand Up @@ -121,20 +121,20 @@ pub trait TextViewImplExt: sealed::Sealed + ObjectSubclass {
location: &TextIter,
start: &mut TextIter,
end: &mut TextIter,
) -> glib::signal::Inhibit {
) -> glib::ControlFlow {
unsafe {
let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkTextViewClass;
if let Some(f) = (*parent_class).extend_selection {
glib::signal::Inhibit(from_glib(f(
glib::ControlFlow::from_glib(f(
self.obj().unsafe_cast_ref::<TextView>().to_glib_none().0,
granularity.into_glib(),
location.to_glib_none().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
)))
))
} else {
glib::signal::Inhibit(false)
glib::ControlFlow::Break
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions gtk4/src/subclass/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub trait WindowImpl: WindowImplExt + WidgetImpl {
self.parent_enable_debugging(toggle)
}

fn close_request(&self) -> glib::signal::Inhibit {
fn close_request(&self) -> glib::ControlFlow {
self.parent_close_request()
}
}
Expand Down Expand Up @@ -81,18 +81,14 @@ pub trait WindowImplExt: sealed::Sealed + ObjectSubclass {
}
}

fn parent_close_request(&self) -> glib::signal::Inhibit {
fn parent_close_request(&self) -> glib::ControlFlow {
unsafe {
let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWindowClass;
let f = (*parent_class)
.close_request
.expect("No parent class impl for \"close_request\"");
glib::signal::Inhibit(from_glib(f(self
.obj()
.unsafe_cast_ref::<Window>()
.to_glib_none()
.0)))
glib::ControlFlow::from_glib(f(self.obj().unsafe_cast_ref::<Window>().to_glib_none().0))
}
}
}
Expand Down

0 comments on commit af9f9ad

Please sign in to comment.