Skip to content

Commit

Permalink
Upgrade gtk-rs to 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
idanarye committed Aug 19, 2023
1 parent 9490e0e commit 6147ace
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- [**BREAKING**] Upgraded gtk-rs to version 0.18. This is a breaking change
because gtk-rs' API had some changes in this release:
- Instead of `gtk::Inhibit`, use `glib::Propagation`. `Inhibit(false)` should
become `Propagation::Stop` and `Inhibit(true)` should become
`Propagation::Proceed`.

## 0.7.0 - 2022-09-06
### Changed
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ keywords = ["gtk", "gui", "actix", "actor"]
categories = ["gui"]

[dependencies]
gtk = "^0.15"
glib = "^0.15"
gdk = "^0.15"
gtk = "^0.18"
glib = "^0.18"
gdk = "^0.18"
actix = { version = "^0.13", default-features = false }
tokio = { version = "^1", features = ["sync"] }
woab-macros = { version = "0.7.0", path = "macros" }
quick-xml = "0.30.0"
thiserror = "1.0.32"
hashbrown = "0.14.0"
send_wrapper = "0.6.0"
gio = "^0.15"
gio = "^0.18"

[dev-dependencies]
futures-util = "0.3.23"
# gtk-test = "0.6.1"
anyhow = "1.0.62"
cairo-rs = "0.15.12"
cairo-rs = "0.18"
4 changes: 2 additions & 2 deletions examples/example_canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ impl actix::Handler<woab::Signal> for WindowActor {
);
draw_ctx.set_source_rgb(0.5, 0.5, 0.5);
draw_ctx.fill().unwrap();
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
"configure_draw_area" => {
let event: gdk::EventConfigure = msg.event_param()?;
let (width, height) = event.size();
self.area_size = [width as f64, height as f64];
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
_ => msg.cant_handle()?,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/example_continuous_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl actix::Handler<woab::Signal> for WindowActor {
self.widgets
.size_descr
.set_text(&format!("Left: {}, Top: {}\rWidth: {}, Height: {}", left, top, width, height));
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
"decrease_width" => {
let (width, height) = self.widgets.win_app.size();
Expand Down
8 changes: 4 additions & 4 deletions examples/example_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl actix::Handler<woab::Signal> for PressCountingActor {
if let Some(idx) = button_to_idx(&event) {
self.press_times[idx] = Some(Instant::now());
}
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
"release" => {
let event: gdk::EventButton = msg.event_param()?;
Expand All @@ -86,7 +86,7 @@ impl actix::Handler<woab::Signal> for PressCountingActor {
self.update_pressed_time_display();
}
}
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
_ => msg.cant_handle()?,
})
Expand Down Expand Up @@ -118,10 +118,10 @@ impl actix::Handler<woab::Signal> for CharacterMoverActor {
let mut text = self.widgets.only_digits.text().as_str().to_owned();
text.push(character);
self.widgets.only_digits.set_text(&text);
return Ok(Some(gtk::Inhibit(true)));
return Ok(Some(glib::Propagation::Proceed));
}
}
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
_ => msg.cant_handle()?,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/example_heavy_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl actix::Handler<woab::Signal> for RowActor {
);
draw_ctx.set_source_rgb(0.5, 0.5, 0.5);
draw_ctx.fill().unwrap();
Some(gtk::Inhibit(false))
Some(glib::Propagation::Stop)
}
_ => msg.cant_handle()?,
})
Expand Down
2 changes: 1 addition & 1 deletion src/event_loops_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn run_actix_inside_gtk_event_loop() {
})
.map_err(|_| "`idle_add` function called inside Actix context")
.unwrap();
glib::source::Continue(true)
glib::ControlFlow::Continue
});
*woab_runtime = Some(WoabRuntime {
actix_system_runner: actix::System::new(),
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! actor which will receive the signals defined in the Glade GTK or connect them to an existing
//! actor and tag the signals (so that multiple instances can be added - e.g. with `GtkListBox` -
//! and the signal handler can know from which one the event came). The actors receive the signals
//! as Actix messages, and the `Handler` returns the inhibitness decision (if the signal requires
//! as Actix messages, and the `Handler` returns the propagation decision (if the signal requires
//! it)
//!
//! To remove widget-bound actors at runtime, see [`woab::Remove`](Remove).
Expand Down Expand Up @@ -73,7 +73,7 @@
//! "sig2" => {
//! let woab::params!(text_buffer: gtk::TextBuffer, _) = msg.params()?;
//! // Behavior for sig2 that uses the signal parameters.
//! Some(gtk::Inhibit(false)) // GTK expects sig2 to return its inhibitness decision
//! Some(glib::Propagation::Stop) // GTK expects sig2 to return its propagation decision
//! },
//! _ => msg.cant_handle()?,
//! })
Expand Down
2 changes: 1 addition & 1 deletion src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use send_wrapper::SendWrapper;
pub struct Signal<T = ()>(SendWrapper<SignalData<T>>);

/// Result type for Actix handlers that handle [`woab::Signal`](Signal).
pub type SignalResult = Result<Option<gtk::Inhibit>, crate::Error>;
pub type SignalResult = Result<Option<glib::Propagation>, crate::Error>;

impl<T> actix::Message for Signal<T> {
type Result = SignalResult;
Expand Down
6 changes: 3 additions & 3 deletions src/signal_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ fn panic_if_signal_cannot_be_queued(signal_name: &str, parameters: &[glib::Value
}

fn run_signal_routing_future(
future: impl core::future::Future<Output = Result<Result<Option<gtk::Inhibit>, crate::Error>, actix::MailboxError>> + 'static,
future: impl core::future::Future<Output = Result<Result<Option<glib::Propagation>, crate::Error>, actix::MailboxError>> + 'static,
signal_name: &Rc<String>,
parameters: &[glib::Value],
) -> Option<glib::Value> {
match crate::try_block_on(future) {
Ok(result) => {
let result = result.unwrap().unwrap();
if let Some(gtk::Inhibit(inhibit)) = result {
if let Some(propagation) = result {
use glib::value::ToValue;
Some(inhibit.to_value())
Some(propagation.is_proceed().to_value())
} else {
None
}
Expand Down
4 changes: 2 additions & 2 deletions src/waking_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub async fn wake_from_signal<T>(
///
/// If operation that generate GTK signals are executed inside the Actix runtime, they'll be
/// queued to run later by the Actix event loop. This may be a problem if the signal is expecting
/// an inhibit decision, because the handler will not be able to generate it before the signal
/// an propagation decision, because the handler will not be able to generate it before the signal
/// returns. This may also be a problem for signals that use a context parameter (like `draw`),
/// because by the time the handler is invoked the context will already expire. In such cases, the
/// code that triggers the signal must run outside.
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn spawn_outside(fut: impl Future<Output = ()> + 'static) {
///
/// If operation that generate GTK signals are executed inside the Actix runtime, they'll be
/// queued to run later by the Actix event loop. This may be a problem if the signal is expecting
/// an inhibit decision, because the handler will not be able to generate it before the signal
/// an propagation decision, because the handler will not be able to generate it before the signal
/// returns. This may also be a problem for signals that use a context parameter (like `draw`),
/// because by the time the handler is invoked the context will already expire. In such cases, the
/// code that triggers the signal must run outside.
Expand Down

0 comments on commit 6147ace

Please sign in to comment.