antoyo / relm

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

Trying to use relm with gtk-layer-shell-rs #252

Open catpreneur opened 3 years ago

catpreneur commented 3 years ago

Trying to build a an application using https://github.com/subgraph/gtk-layer-shell-rs

If you're not familiar with, it's basically a library to allow GTK to use a Wayland protocol known as layer shell protocol, which will allow windows to be anchored to corners of the screen.

The code for the app is simple: https://gist.github.com/oofdog/4625c3dad79736a638209c8f31e266f2 However, I'm getting these errors when the app boots image and the app does not render correctly (i'm expecting to see margins of 10px from all sides from these lines) image

Did some digging and found here that after init_view, relm will clone the app? Could this be the cause of the problems? Btw this is what the gtk-layer-shell init function does

catpreneur commented 3 years ago

Btw here's a code example for gtk-layer-shell-rs https://github.com/subgraph/gtk-layer-shell-rs/blob/master/examples/example.rs

catpreneur commented 3 years ago

And as a reference, this is what it should look like. Notice I'm setting sway background to light blue, and the empty GTK box has 10 margin all around image

antoyo commented 3 years ago

I'm not sure, but my guess is that it doesn't work because the window is already shown (by the view macro) when init_layer_shell() is called. You'll probably have to not use the #[widget] attribute.

Now that I think of it, maybe it would be useful to have an attribute to specify to not show the widget immediately in the view! macro. What do you think?

catpreneur commented 3 years ago

Now that I think of it, maybe it would be useful to have an attribute to specify to not show the widget immediately in the view! macro. What do you think?

If that would solve this issue then sure. it would be nice to have a hook called before_view (just like init_view) but it is called before it is shown, so I can call init_layer_shell(). It shouldn't be too much code right? If you could provide a small snippet, I can try it out locally and let you know if it worked.

Also, is there a IRC channel or discord to chat about relm?

antoyo commented 3 years ago

I'm not sure about the before_view() idea. As I understand, you would need the widgets in that method, right? But the widgets are currently created in the view! macro (view() function under the hood). If we were to have a useful before_view(), that would probably require separating the widget creation from widget show, thus adding two methods: before_show() and show(). I think that would work but it's more involved than what you suggest.

There's a gitter to chat about relm and I'm often on #rust on irc.gnome.org.

LucaCoduriV commented 3 months ago

Hi, has this been implemented ?

antoyo commented 3 months ago

There was no progress made on this issue.