!DlltQISlgRGacjtFQD:matrix.org

Relm4

214 Members
Build truly native applications with ease!39 Servers

Load older messages


SenderMessageTime
22 Mar 2024
@chfkch:matrix.orgchfkchthe suggestion is to create a let binding so it will not get dropped, but i cannot figure out how or if this works in this context at all13:33:58
@chfkch:matrix.orgchfkch *

i have a box, which should have dynamically created children. i tried to use the following

match model.active_entry.clone() {
  Some(entry) => {
    gtk::Label {
      #[watch]
      // set_text: entry.id.as_str()
      set_text: match entry.data.clone() {
        EntryData::Login { username, ..  } =>      username.unwrap_or_else(String::new).as_str(),
        EntryData::Card { ..  } => "Card",
        EntryData::Identity { ..  } => "Identity",
        EntryData::SecureNote => "Note",
      }
    }
  },
  None => gtk::Label {
    set_text: "No active entry"
  }
}

i have omitted some code for readability

13:35:40
@chfkch:matrix.orgchfkchor would it be wiser in this context to have a custom component/widget and insert it as a child here? since i think i can construct it beforehand with all necessary data?13:38:19
@aaron:matrix.aaron-erhardt.deAaron ErhardtMhh, I don't think this should happen but I have to look at the macro expansion to give you a proper answer. Maybe I'll find time for that this weekend.23:03:31
23 Mar 2024
@chfkch:matrix.orgchfkch https://codeberg.org/Chfkch/bitritter
Here is the repository, if you want to see the full code.
13:17:33
24 Mar 2024
@armadillo9425:matrix.orgarmadillo9425 When using TypedListView to build a ListView, how do I create a set_sensitive data binding for list items to disable clicking/selecting certain items? The connect_activate lives on ListView level, so while something like root.add_binding(&BoolBinding::new(self.some_boolean), "sensitive"); in the implementation of RelmListItem.bind can give an item the look of being unclickable it doesn't disable the activation event. 13:28:23
@chfkch:matrix.orgchfkch In the relm book, chapter Continuous Integration, an action actions-rs/toolchain is mentioned, the repository https://github.com/actions-rs is archived.
Is this the one the action points at and if yes, is there a successor?
Since i am using Codeberg as forge, i need to set absolute paths anyway, so i can use non-GH aswell.
14:52:33
@chfkch:matrix.orgchfkchI found this one https://github.com/crusty-pie/toolchain14:54:27
@nazar-pc:matrix.orgnazar-pc
In reply to @chfkch:matrix.org
In the relm book, chapter Continuous Integration, an action actions-rs/toolchain is mentioned, the repository https://github.com/actions-rs is archived.
Is this the one the action points at and if yes, is there a successor?
Since i am using Codeberg as forge, i need to set absolute paths anyway, so i can use non-GH aswell.
There are many fokrs, but the gist of it is that you probably do not need it at all.
If you only care about reasonably recent version being installed, it already is on GitHub Actions by default, if you need a specific version then create rust-toolchain.toml and it will be installed automatically by cargo when cargo command is called.
Either way you just run commands in the shell and it "just works".
19:21:29
@aaron:matrix.aaron-erhardt.deAaron Erhardt
In reply to @armadillo9425:matrix.org
When using TypedListView to build a ListView, how do I create a set_sensitive data binding for list items to disable clicking/selecting certain items? The connect_activate lives on ListView level, so while something like root.add_binding(&BoolBinding::new(self.some_boolean), "sensitive"); in the implementation of RelmListItem.bind can give an item the look of being unclickable it doesn't disable the activation event.
I'm haven't had this problem before, so I don't know how this would be done with regular gtk-rs, but you could try sending a PR to address the issue. The code for TypedListView is rather simple and should be easy to extend.
21:09:55
@armadillo9425:matrix.orgarmadillo9425I'm afraid I only have a few weeks of experience with Gtk, gtk4-rs and Relm4 so I'm not sure how I'd approach that yet. I'm still in a phase where I make weird architectural choices due to not having a solid understanding of the guiding design principles behind the libraries.21:33:28
@aaron:matrix.aaron-erhardt.deAaron Erhardt

That's ok. In general, Relm4 tries to provide more idiomatic abstractions on top of gtk-rs, which means you have to understand gtk-rs first in many cases if you want to solve a problem which is not already abstracted nicely by Relm4 (although TypedListView should actually be part of gtk-rs IMO). I'd look into the issue myself, but unfortunately I don't have time currently.

22:10:10
25 Mar 2024
@bilelmoussaoui:gnome.org@bilelmoussaoui:gnome.org left the room.00:04:37
@chfkch:matrix.orgchfkch i know we had this topic before regarding ListBox/FactoryVecDequeue versus TypedListView.
I started with TypedListView, which lacked some signaling features i guess, so i switched to ListBox. I was fine that those cannot use filters, since they are ususally not to manipulate the data once it is inserted.
But today i stumbled upon the invalidate_filtersand set_filter_func methods of ListBox.
14:26:57
@chfkch:matrix.orgchfkchI struggle get the data of the ListBoxItem inside the set_filter_func, since downcast was my only approach. Has anybody used anything i mentioned and has more experience?14:28:01
@chfkch:matrix.orgchfkch
In reply to @nazar-pc:matrix.org
There are many fokrs, but the gist of it is that you probably do not need it at all.
If you only care about reasonably recent version being installed, it already is on GitHub Actions by default, if you need a specific version then create rust-toolchain.toml and it will be installed automatically by cargo when cargo command is called.
Either way you just run commands in the shell and it "just works".
I got it working, though i had to manually install nodejs in the container since i do not use Github. It is required with forgejo runner for the actions i think.
19:03:02
26 Mar 2024
@kdwk:matrix.orgKdwkIs it possible to call a method on a widget (that does not accept any input) without using update_with_view()? Something in view!{} maybe?06:27:04
@chfkch:matrix.orgchfkch
In reply to @kdwk:matrix.org
Is it possible to call a method on a widget (that does not accept any input) without using update_with_view()? Something in view!{} maybe?
I think you can put a reference to the widget in your app model and then call methods of it in the update()
07:26:33
@aaron:matrix.aaron-erhardt.deAaron Erhardt You can actually do method: (), in the view macro IIRC. You can combine that with watch or track as well. 07:27:53
@kdwk:matrix.orgKdwk
In reply to @aaron:matrix.aaron-erhardt.de
You can actually do method: (), in the view macro IIRC. You can combine that with watch or track as well.
Ah that is what I was looking for. Thanks
08:37:55
@chfkch:matrix.orgchfkch
In reply to @aaron:matrix.aaron-erhardt.de
You can actually do method: (), in the view macro IIRC. You can combine that with watch or track as well.
That sounds interesting. I have not seen it in the examples/documemtation so far.
Do you know if it is there? Or should we work out an example together?
08:57:10
@aaron:matrix.aaron-erhardt.deAaron Erhardt

I think there might be some examples using this trick, but I think it should rather be documented in the book here

10:22:26
@armadillo9425:matrix.orgarmadillo9425 perhaps also an interesting example: https://github.com/Relm4/Relm4/blob/b2792fb597060d2b4c6dd4650ff0c1b92a6cd2b7/examples/message_stream.rs#L32 you can add present: () to pop open a MessageBox 20:25:45
27 Mar 2024
@horvbalint:matrix.org@horvbalint:matrix.org left the room.19:18:45
28 Mar 2024
@chfkch:matrix.orgchfkch say i have a gtk::Box with a name specified with #[name = "detail_anchor"]
and i want to append a child to it.
i currently use widgets.detail_anchor.append() in my update_with_view() and it works fine, but how can i remove previous childs from it, of which i do not have context.
since these children are all SimpleAsyncComponents i thoght i store a reference in a model attribute, but i don't know of which type it would be.
11:02:55
@chfkch:matrix.orgchfkchhhm i reduced the similarities of the children to be contained in a gtk::Box and now added an attribute detail_box of type Option<Box> to my AppModel. That seems to work for now.11:16:25
@aaron:matrix.aaron-erhardt.deAaron Erhardt

I guess you can't use factories because you want to add different types of components, right? In this case, you can upcast their root widgets to gtk::Widget and store them somewhere so you can remove them later.

11:19:52
@chfkch:matrix.orgchfkchyes, different components. Ok i will see if i need the upcast, i did not think of this11:20:30
@chfkch:matrix.orgchfkchbut i think they will all share a box as root, maybe i will already suffice.11:21:13
@aaron:matrix.aaron-erhardt.deAaron ErhardtYeah, if they all use a box, then there's no need to cast anything. It's just good to know that's possible when you need it.11:22:00

Show newer messages


Back to Room ListRoom Version: 6