Show a list of games in the library #64
|
@ -29,6 +29,8 @@ impl GamePreview {
|
||||||
pub fn new() -> GamePreview {
|
pub fn new() -> GamePreview {
|
||||||
let s: Self = Object::builder().build();
|
let s: Self = Object::builder().build();
|
||||||
s.set_orientation(gtk::Orientation::Horizontal);
|
s.set_orientation(gtk::Orientation::Horizontal);
|
||||||
|
s.set_homogeneous(true);
|
||||||
|
s.set_hexpand(true);
|
||||||
|
|
||||||
s.append(&s.imp().date);
|
s.append(&s.imp().date);
|
||||||
s.append(&s.imp().title);
|
s.append(&s.imp().title);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::CoreApi;
|
use crate::{ui::Library, CoreApi};
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{glib, prelude::*, subclass::prelude::*};
|
use gtk::{glib, prelude::*, subclass::prelude::*};
|
||||||
use kifu_core::{
|
use kifu_core::{
|
||||||
|
@ -7,8 +7,6 @@ use kifu_core::{
|
||||||
};
|
};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
use super::GameDatabase;
|
|
||||||
|
|
||||||
struct PlayerDataEntryPrivate {
|
struct PlayerDataEntryPrivate {
|
||||||
name: gtk::Text,
|
name: gtk::Text,
|
||||||
rank: gtk::DropDown,
|
rank: gtk::DropDown,
|
||||||
|
@ -136,7 +134,7 @@ impl Home {
|
||||||
let new_game_button = gtk::Button::builder().label(&view.start_game.label).build();
|
let new_game_button = gtk::Button::builder().label(&view.start_game.label).build();
|
||||||
s.append(&new_game_button);
|
s.append(&new_game_button);
|
||||||
|
|
||||||
let library = GameDatabase::new();
|
let library = Library::new();
|
||||||
let library_view = gtk::ScrolledWindow::builder()
|
let library_view = gtk::ScrolledWindow::builder()
|
||||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||||
.min_content_width(360)
|
.min_content_width(360)
|
||||||
|
|
|
@ -33,12 +33,12 @@ impl GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GameDatabasePrivate {
|
pub struct LibraryPrivate {
|
||||||
model: gio::ListStore,
|
model: gio::ListStore,
|
||||||
list_view: gtk::ListView,
|
list_view: gtk::ListView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GameDatabasePrivate {
|
impl Default for LibraryPrivate {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let vector: Vec<GameObject> = vec![];
|
let vector: Vec<GameObject> = vec![];
|
||||||
let model = gio::ListStore::new(glib::types::Type::OBJECT);
|
let model = gio::ListStore::new(glib::types::Type::OBJECT);
|
||||||
|
@ -75,30 +75,30 @@ impl Default for GameDatabasePrivate {
|
||||||
|
|
||||||
let selection_model = gtk::NoSelection::new(Some(model.clone()));
|
let selection_model = gtk::NoSelection::new(Some(model.clone()));
|
||||||
let list_view = gtk::ListView::new(Some(selection_model), Some(factory));
|
let list_view = gtk::ListView::new(Some(selection_model), Some(factory));
|
||||||
|
list_view.set_hexpand(true);
|
||||||
Self { model, list_view }
|
Self { model, list_view }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
impl ObjectSubclass for GameDatabasePrivate {
|
impl ObjectSubclass for LibraryPrivate {
|
||||||
const NAME: &'static str = "GameDatabase";
|
const NAME: &'static str = "Library";
|
||||||
type Type = GameDatabase;
|
type Type = Library;
|
||||||
type ParentType = gtk::Box;
|
type ParentType = gtk::Box;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for GameDatabasePrivate {}
|
impl ObjectImpl for LibraryPrivate {}
|
||||||
impl WidgetImpl for GameDatabasePrivate {}
|
impl WidgetImpl for LibraryPrivate {}
|
||||||
impl BoxImpl for GameDatabasePrivate {}
|
impl BoxImpl for LibraryPrivate {}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct GameDatabase(ObjectSubclass<GameDatabasePrivate>) @extends gtk::Widget, gtk::Box;
|
pub struct Library(ObjectSubclass<LibraryPrivate>) @extends gtk::Widget, gtk::Box;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameDatabase {
|
impl Library {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let s: Self = Object::builder().build();
|
let s: Self = Object::builder().build();
|
||||||
s.set_width_request(200);
|
s.set_hexpand(true);
|
||||||
s.set_height_request(200);
|
|
||||||
s.append(&s.imp().list_view);
|
s.append(&s.imp().list_view);
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ mod game_preview;
|
||||||
pub use game_preview::GamePreview;
|
pub use game_preview::GamePreview;
|
||||||
|
|
||||||
mod library;
|
mod library;
|
||||||
pub use library::GameDatabase;
|
pub use library::Library;
|
||||||
|
|
||||||
mod player_card;
|
mod player_card;
|
||||||
pub use player_card::PlayerCard;
|
pub use player_card::PlayerCard;
|
||||||
|
|
Loading…
Reference in New Issue