antoyo / relm

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

MessageDialog popup #211

Closed MGlolenstine closed 4 years ago

MGlolenstine commented 4 years ago

How would one construct one?

pub struct PopupModel {
    relm: Relm<Popup>,
    buttons: ButtonsType,
    message: String,
}
...
    view!{
        gtk::MessageDialog{
            message: &self.model.message,
            buttons: self.model.buttons,
        }
    }

The above doesn't appear to work, as set_message and set_buttons don't exist in the MessageDialog.

After reading #128 , I still don't know how I'd be able to supply self parameters in the constructor

view!{
        gtk::MessageDialog(self.root, DialogFlags::MODAL, MessageType::Error, ButtonsType::Ok, "TEST"){
        }
    }

My current code does mostly work, but I have no idea where I could get the parent field from, as self.root doesn't work.

antoyo commented 4 years ago

You can set parent to None. But if you truly want to set the parent, you would probably have to name it with the #[name] attribute and send it as a model parameter for the PopupModel.

MGlolenstine commented 4 years ago

That makes sense!

Thanks!