From e5d0b7d20f45a774c41b4958985814c752d0a856 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 20 Aug 2023 12:40:46 -0400 Subject: [PATCH] Improve formatting. Rename GameDatabase to Library --- kifu/gtk/src/ui/game_preview.rs | 2 ++ kifu/gtk/src/ui/home.rs | 6 ++---- kifu/gtk/src/ui/library.rs | 24 ++++++++++++------------ kifu/gtk/src/ui/mod.rs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/kifu/gtk/src/ui/game_preview.rs b/kifu/gtk/src/ui/game_preview.rs index 4c8d61b..99ec42c 100644 --- a/kifu/gtk/src/ui/game_preview.rs +++ b/kifu/gtk/src/ui/game_preview.rs @@ -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); diff --git a/kifu/gtk/src/ui/home.rs b/kifu/gtk/src/ui/home.rs index 3777454..c9a166b 100644 --- a/kifu/gtk/src/ui/home.rs +++ b/kifu/gtk/src/ui/home.rs @@ -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) diff --git a/kifu/gtk/src/ui/library.rs b/kifu/gtk/src/ui/library.rs index 6deedd5..9fc24ce 100644 --- a/kifu/gtk/src/ui/library.rs +++ b/kifu/gtk/src/ui/library.rs @@ -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 = 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) @extends gtk::Widget, gtk::Box; + pub struct Library(ObjectSubclass) @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 } diff --git a/kifu/gtk/src/ui/mod.rs b/kifu/gtk/src/ui/mod.rs index f43273c..ae70aa6 100644 --- a/kifu/gtk/src/ui/mod.rs +++ b/kifu/gtk/src/ui/mod.rs @@ -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;