I am using Rust stable 1.30 and Relm. I figured out how to set up the default window size, but don't know how to set up the icon, at least inside the view! macro.
This is my main.rs
extern crate gtk;
extern crate chessground;
#[macro_use]
extern crate relm;
extern crate relm_attributes;
#[macro_use]
extern crate relm_derive;
extern crate shakmaty;
extern crate rsvg;
use gtk::prelude::*;
use gtk::GtkWindowExt;
use relm::Widget;
use relm_attributes::widget;
use shakmaty::{Square, Board};
use chessground::{Ground, UserMove, SetBoard};
use rsvg::{Handle};
use self::Msg::*;
#[derive(Msg)]
pub enum Msg {
Quit,
PieceMoved(Square, Square),
}
#[widget]
impl Widget for Win {
fn model() -> Board {
Board::default()
}
fn update(&mut self, event: Msg) {
match event {
Quit => gtk::main_quit(),
PieceMoved(orig, dest) => {
if let Some(piece) = self.model.remove_piece_at(orig) {
self.model.set_piece_at(dest, piece, false);
self.ground.emit(SetBoard(self.model.clone()));
}
}
}
}
view! {
gtk::Window {
title: "Chessground",
property_default_width: 600,
property_default_height: 600,
#[name="ground"]
Ground {
UserMove(orig, dest, _) => PieceMoved(orig, dest),
},
delete_event(_, _) => (Quit, Inhibit(false)),
}
}
}
fn main() {
let icon = Handle::new_from_str(include_str!("wQ.svg")).expect("Could not find icon !");
// how to set up the given icon ?
Win::run(()).expect("initialized gtk");
}
I mean, how to set up the icon defined in main to the window as its icon ? Notice that the icon has been instantiated with rsvg crate.