2023-03-23 03:11:56 +00:00
|
|
|
use glib::Object;
|
|
|
|
use gtk::{prelude::*, subclass::prelude::*};
|
2023-04-07 02:29:15 +00:00
|
|
|
use kifu_core::ui::PlayerCardElement;
|
2023-03-23 03:11:56 +00:00
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct PlayerCardPrivate {
|
|
|
|
player_name: gtk::Label,
|
|
|
|
clock: gtk::Label,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[glib::object_subclass]
|
|
|
|
impl ObjectSubclass for PlayerCardPrivate {
|
|
|
|
const NAME: &'static str = "PlayerCard";
|
|
|
|
type Type = PlayerCard;
|
|
|
|
type ParentType = gtk::Box;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ObjectImpl for PlayerCardPrivate {}
|
|
|
|
impl WidgetImpl for PlayerCardPrivate {}
|
|
|
|
impl BoxImpl for PlayerCardPrivate {}
|
|
|
|
|
|
|
|
glib::wrapper! {
|
|
|
|
pub struct PlayerCard(ObjectSubclass<PlayerCardPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PlayerCard {
|
|
|
|
pub fn new(element: PlayerCardElement) -> PlayerCard {
|
|
|
|
let s: Self = Object::builder().build();
|
|
|
|
s.set_orientation(gtk::Orientation::Vertical);
|
|
|
|
s.imp()
|
|
|
|
.player_name
|
|
|
|
.set_text(&format!("{} ({})", element.name, element.rank));
|
|
|
|
s.imp().clock.set_text(&element.clock);
|
|
|
|
|
|
|
|
s.append(&s.imp().player_name);
|
|
|
|
s.append(&s.imp().clock);
|
|
|
|
s
|
|
|
|
}
|
|
|
|
}
|