Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib: Re-introduce an event propagation specific type #1144

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gdk-pixbuf/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion gdk-pixbuf/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
4 changes: 2 additions & 2 deletions gio/src/auto/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,13 @@ pub trait SettingsExt: IsA<Settings> + sealed::Sealed + 'static {
}

#[doc(alias = "writable-change-event")]
fn connect_writable_change_event<F: Fn(&Self, u32) -> glib::ControlFlow + 'static>(
fn connect_writable_change_event<F: Fn(&Self, u32) -> glib::Propagation + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn writable_change_event_trampoline<
P: IsA<Settings>,
F: Fn(&P, u32) -> glib::ControlFlow + 'static,
F: Fn(&P, u32) -> glib::Propagation + 'static,
>(
this: *mut ffi::GSettings,
key: libc::c_uint,
Expand Down
2 changes: 1 addition & 1 deletion gio/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion gio/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion gir
Submodule gir updated 1 files
+1 −1 src/codegen/trampoline.rs
2 changes: 1 addition & 1 deletion glib/gobject-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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion glib/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion glib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use self::{
},
signal::{
signal_handler_block, signal_handler_disconnect, signal_handler_unblock,
signal_stop_emission_by_name, SignalHandlerId,
signal_stop_emission_by_name, Propagation, SignalHandlerId,
},
types::{ILong, Pointer, StaticType, StaticTypeExt, Type, ULong},
value::{BoxedValue, SendValue, ToSendValue, ToValue, Value},
Expand Down
78 changes: 78 additions & 0 deletions glib/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,81 @@ pub fn signal_has_handler_pending<T: ObjectType>(
))
}
}

bilelmoussaoui marked this conversation as resolved.
Show resolved Hide resolved
// rustdoc-stripper-ignore-next
/// Whether to invoke the other event handlers.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Propagation {
// Stop other handlers from being invoked for the event.
Stop,
// Propagate the event further.
Proceed,
}

impl Propagation {
// rustdoc-stripper-ignore-next
/// Returns `true` if this is a `Stop` variant.
pub fn is_stop(&self) -> bool {
matches!(self, Self::Stop)
}

// rustdoc-stripper-ignore-next
/// Returns `true` if this is a `Proceed` variant.
pub fn is_proceed(&self) -> bool {
matches!(self, Self::Proceed)
}
}

impl From<bool> for Propagation {
fn from(value: bool) -> Self {
if value {
Self::Stop
} else {
Self::Proceed
}
}
}

impl From<Propagation> for bool {
fn from(c: Propagation) -> Self {
match c {
Propagation::Stop => true,
Propagation::Proceed => false,
}
}
}

#[doc(hidden)]
impl IntoGlib for Propagation {
type GlibType = ffi::gboolean;

#[inline]
fn into_glib(self) -> ffi::gboolean {
bool::from(self).into_glib()
}
}

#[doc(hidden)]
impl FromGlib<ffi::gboolean> for Propagation {
#[inline]
unsafe fn from_glib(value: ffi::gboolean) -> Self {
bool::from_glib(value).into()
}
}

impl crate::ToValue for Propagation {
fn to_value(&self) -> crate::Value {
bool::from(*self).to_value()
}

fn value_type(&self) -> crate::Type {
<bool as crate::StaticType>::static_type()
}
}

impl From<Propagation> for crate::Value {
#[inline]
fn from(v: Propagation) -> Self {
bool::from(v).into()
}
}
2 changes: 1 addition & 1 deletion glib/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion graphene/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion graphene/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion pango/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion pango/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion pangocairo/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
2 changes: 1 addition & 1 deletion pangocairo/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 @ c88b69265102)
Generated by gir (https://github.com/gtk-rs/gir @ ef087c070d5b)
from gir-files (https://github.com/gtk-rs/gir-files @ c23f21f51d54)
Loading