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