Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

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 8, 2023
1 parent 3091725 commit 81da6d6
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 114 deletions.
8 changes: 4 additions & 4 deletions examples/cairo_test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn build_ui(application: &gtk::Application) {
cr.arc(0.5 + eye_dx, eye_y, 0.05, 0.0, PI * 2.);
cr.fill().expect("Invalid cairo surface state");

Inhibit(false)
glib::ControlFlow::Break
});

drawable(application, 500, 500, |_, cr| {
Expand All @@ -82,7 +82,7 @@ fn build_ui(application: &gtk::Application) {
cr.arc(0.27, 0.65, 0.02, 0.0, PI * 2.);
cr.fill().expect("Invalid cairo surface state");

Inhibit(false)
glib::ControlFlow::Break
});
}

Expand All @@ -99,10 +99,10 @@ fn main() {

pub fn drawable<F>(application: &gtk::Application, width: i32, height: i32, draw_fn: F)
where
F: Fn(&DrawingArea, &Context) -> Inhibit + 'static,
F: Fn(&DrawingArea, &Context) -> glib::ControlFlow + 'static,
{
let window = gtk::ApplicationWindow::new(application);
let drawing_area = Box::new(DrawingArea::new)();
let drawing_area = DrawingArea::new();

drawing_area.connect_draw(draw_fn);

Expand Down
4 changes: 2 additions & 2 deletions examples/cairo_threads/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn build_ui(application: &gtk::Application) {
// Whenever the drawing area has to be redrawn, render the latest images in the correct
// locations
area.connect_draw(
glib::clone!(@weak workspace => @default-return Inhibit(false), move |_, cr| {
glib::clone!(@weak workspace => @default-return glib::ControlFlow::Break, move |_, cr| {
let (ref images, ref origins, _) = *workspace;

for (image, origin) in images.iter().zip(origins.iter()) {
Expand All @@ -113,7 +113,7 @@ fn build_ui(application: &gtk::Application) {
});
}

Inhibit(false)
glib::ControlFlow::Break
}),
);

Expand Down
2 changes: 1 addition & 1 deletion examples/clipboard_simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn build_ui(application: &gtk::Application) {
window.set_title("gtk::Clipboard Simple Example");
window.connect_delete_event(|window, _| {
window.close();
Inhibit(false)
glib::ControlFlow::Break
});

// Create the button grid
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk_builder_basics/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn build_ui(application: &gtk::Application) {

dialog.connect_delete_event(|dialog, _| {
dialog.hide();
gtk::Inhibit(true)
glib::ControlFlow::Continue
});

bigbutton.connect_clicked(glib::clone!(@weak dialog => move |_| dialog.show_all()));
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk_builder_signal/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn build_ui(application: &gtk::Application) {
.expect("Couldn't get messagedialog1");
dialog.connect_delete_event(|dialog, _| {
dialog.hide();
gtk::Inhibit(true)
glib::ControlFlow::Continue
});

builder.connect_signals(move |_, handler_name| {
Expand Down
6 changes: 3 additions & 3 deletions examples/gtk_test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn build_ui(application: &gtk::Application) {
button_about.connect_clicked(move |x| about_clicked(x, &dialog));

window.connect_key_press_event(
glib::clone!(@weak entry => @default-return Inhibit(false), move |_, key| {
glib::clone!(@weak entry => @default-return glib::ControlFlow::Break, move |_, key| {
let keyval = key.keyval();
let keystate = key.state();

Expand All @@ -166,7 +166,7 @@ fn build_ui(application: &gtk::Application) {
println!("You pressed Ctrl!");
}

Inhibit(false)
glib::ControlFlow::Break
}),
);

Expand All @@ -182,7 +182,7 @@ fn about_clicked(button: &Button, dialog: &AboutDialog) {
// as otherwise we can't show it again a second time.
dialog.connect_delete_event(|dialog, _| {
dialog.hide();
gtk::Inhibit(true)
glib::ControlFlow::Continue
});

println!("Authors: {:?}", dialog.authors());
Expand Down
4 changes: 2 additions & 2 deletions examples/multi_window/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ fn create_sub_window(
window.set_default_size(400, 200);

window.connect_delete_event(
glib::clone!(@weak windows => @default-return Inhibit(false), move |_, _| {
glib::clone!(@weak windows => @default-return glib::ControlFlow::Break, move |_, _| {
windows.borrow_mut().remove(&id);
Inhibit(false)
glib::ControlFlow::Break
}),
);

Expand Down
2 changes: 1 addition & 1 deletion examples/progress_tracker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Widgets {
window.set_default_size(500, 250);
window.connect_delete_event(move |window, _| {
window.close();
Inhibit(false)
glib::ControlFlow::Break
});

Self {
Expand Down
4 changes: 2 additions & 2 deletions examples/transparent_main_window/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ fn set_visual(window: &ApplicationWindow, _screen: Option<&gdk::Screen>) {
}
}

fn draw(_window: &ApplicationWindow, ctx: &cairo::Context) -> Inhibit {
fn draw(_window: &ApplicationWindow, ctx: &cairo::Context) -> glib::ControlFlow {
// crucial for transparency
ctx.set_source_rgba(1.0, 0.0, 0.0, 0.4);
ctx.set_operator(cairo::Operator::Screen);
ctx.paint().expect("Invalid cairo surface state");
Inhibit(false)
glib::ControlFlow::Break
}
8 changes: 3 additions & 5 deletions gtk/src/signal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use gdk::Rectangle;
pub use glib::signal::Inhibit;
use glib::signal::SignalHandlerId;

use crate::{ScrollType, Widget};
Expand Down Expand Up @@ -141,7 +140,7 @@ pub trait SpinButtonSignals: 'static {
F: Fn(&Self) -> Option<Result<f64, ()>> + 'static;
fn connect_output<F>(&self, output_func: F) -> SignalHandlerId
where
F: Fn(&Self) -> Inhibit + 'static;
F: Fn(&Self) -> glib::ControlFlow + 'static;
fn connect_value_changed<F>(&self, value_changed_func: F) -> SignalHandlerId
where
F: Fn(&Self) + 'static;
Expand All @@ -151,7 +150,6 @@ pub trait SpinButtonSignals: 'static {
}

mod spin_button {
use crate::Inhibit;
use crate::ScrollType;
use crate::SpinButton;
use ffi::{GtkScrollType, GtkSpinButton, GTK_INPUT_ERROR};
Expand Down Expand Up @@ -202,7 +200,7 @@ mod spin_button {

fn connect_output<F>(&self, output_func: F) -> SignalHandlerId
where
F: Fn(&Self) -> Inhibit + 'static,
F: Fn(&Self) -> glib::ControlFlow + 'static,
{
unsafe {
let f: Box<F> = Box::new(output_func);
Expand Down Expand Up @@ -283,7 +281,7 @@ mod spin_button {
}
}

unsafe extern "C" fn output_trampoline<T, F: Fn(&T) -> Inhibit + 'static>(
unsafe extern "C" fn output_trampoline<T, F: Fn(&T) -> glib::ControlFlow + 'static>(
this: *mut GtkSpinButton,
f: &F,
) -> gboolean
Expand Down
11 changes: 5 additions & 6 deletions gtk/src/subclass/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ use glib::Cast;

use super::container::ContainerImpl;

use crate::Inhibit;
use crate::Socket;

pub trait SocketImpl: SocketImplExt + ContainerImpl {
fn plug_added(&self) {
self.parent_plug_added()
}

fn plug_removed(&self) -> Inhibit {
fn plug_removed(&self) -> glib::ControlFlow {
self.parent_plug_removed()
}
}
Expand All @@ -35,18 +34,18 @@ pub trait SocketImplExt: ObjectSubclass + sealed::Sealed {
}
}
}
fn parent_plug_removed(&self) -> Inhibit {
fn parent_plug_removed(&self) -> glib::ControlFlow {
unsafe {
let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkSocketClass;
if let Some(f) = (*parent_class).plug_removed {
Inhibit(from_glib(f(self
glib::ControlFlow::from_glib(f(self
.obj()
.unsafe_cast_ref::<Socket>()
.to_glib_none()
.0)))
.0))
} else {
Inhibit(false)
glib::ControlFlow::Break
}
}
}
Expand Down
Loading

0 comments on commit 81da6d6

Please sign in to comment.