antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.41k stars 79 forks source link

Updates gtk to 0.14 #291

Closed sanpii closed 3 years ago

sanpii commented 3 years ago

I made the update for new gtk-rs version, but this is not finish due to a bug I don’t understand and a dependency require an update:

antoyo commented 3 years ago

Webkit2gtk update should be coming.

To fix the panic, please apply this patch:

From a8b7c235060e8d32795aa1ec3b282f624805806c Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Wed, 30 Jun 2021 08:45:58 -0400
Subject: [PATCH] Fix context

---
 src/lib.rs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib.rs b/src/lib.rs
index 9ec0f1a..404e07c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -273,6 +273,8 @@ pub fn init_test<WIDGET>(model_param: WIDGET::ModelParam) ->
           WIDGET::Msg: DisplayVariant + 'static,
 {
     gtk::init()?;
+    let main_context = glib::MainContext::default();
+    let _context = main_context.acquire().unwrap();
     let component = create_widget_test::<WIDGET>(model_param);
     Ok(component)
 }
@@ -339,6 +341,8 @@ pub fn init<WIDGET>(model_param: WIDGET::ModelParam) -> Result<Component<WIDGET>
 pub fn run<WIDGET>(model_param: WIDGET::ModelParam) -> Result<(), glib::BoolError>
     where WIDGET: Widget + 'static,
 {
+    let main_context = glib::MainContext::default();
+    let _context = main_context.acquire().unwrap();
     gtk::init()?;
     let _component = init::<WIDGET>(model_param)?;
     gtk::main();
-- 
2.32.0
sanpii commented 3 years ago

To fix the panic, please apply this patch:

Amended, thank you.

antoyo commented 3 years ago

It seems like there are some other errors in the CI, maybe wrong imports?

antoyo commented 3 years ago

Everything sounds good, thanks! edit: Is this ready to be merged?

sanpii commented 3 years ago

Is this ready to be merged?

For me, it’s ok!