replace column expand with configurable size value

This commit is contained in:
yggverse 2025-02-15 00:22:42 +02:00
parent 339c33a14f
commit df9e039dd2
2 changed files with 24 additions and 19 deletions

View File

@ -2,7 +2,7 @@ mod column;
use gtk::{gio::File, ScrolledWindow};
pub struct Directory;
pub struct Directory; // @TODO save settings
impl Directory {
// Constructors
@ -32,12 +32,17 @@ impl Directory {
)
.build();
column_view.append_column(&Column::icon());
let name = Column::name();
let icon = Column::icon();
let name = Column::name(360);
let size = Column::size(120);
let content_type = Column::content_type(180);
//let modification_date_time = Column::modification_date_time();
column_view.append_column(&icon);
column_view.append_column(&name);
column_view.append_column(&Column::size());
column_view.append_column(&Column::content_type());
//column_view.append_column(&Column::modification_date_time());
column_view.append_column(&size);
column_view.append_column(&content_type);
//column_view.append_column(&modification_date_time);
column_view.sort_by_column(Some(&name), gtk::SortType::Ascending);
column_view

View File

@ -1,11 +1,12 @@
const DEFAULT: &str = "-";
const WIDTH: i32 = 360;
pub trait Column {
fn icon() -> Self;
fn name() -> Self;
fn size() -> Self;
fn content_type() -> Self;
fn modification_date_time() -> Self;
fn name(width: i32) -> Self;
fn size(width: i32) -> Self;
fn content_type(width: i32) -> Self;
fn modification_date_time(width: i32) -> Self;
}
impl Column for gtk::ColumnViewColumn {
@ -18,7 +19,6 @@ impl Column for gtk::ColumnViewColumn {
ColumnViewColumn::builder()
.title("Type")
.resizable(false)
.factory(&{
let factory = SignalListItemFactory::new();
factory.connect_bind(|_, this| {
@ -59,9 +59,9 @@ impl Column for gtk::ColumnViewColumn {
.build()
}
fn name() -> Self {
fn name(width: i32) -> Self {
gtk::ColumnViewColumn::builder()
.expand(true)
.fixed_width(width)
.resizable(true)
.title("Name")
.factory(&{
@ -95,9 +95,9 @@ impl Column for gtk::ColumnViewColumn {
.build()
}
fn size() -> Self {
fn size(width: i32) -> Self {
gtk::ColumnViewColumn::builder()
.expand(true)
.fixed_width(width)
.resizable(true)
.title("Size")
.factory(&{
@ -121,9 +121,9 @@ impl Column for gtk::ColumnViewColumn {
.build()
}
fn content_type() -> Self {
fn content_type(width: i32) -> Self {
gtk::ColumnViewColumn::builder()
.expand(true)
.fixed_width(width)
.resizable(true)
.title("Content Type")
.factory(&{
@ -164,9 +164,9 @@ impl Column for gtk::ColumnViewColumn {
.build()
}
fn modification_date_time() -> Self {
fn modification_date_time(width: i32) -> Self {
gtk::ColumnViewColumn::builder()
.expand(true)
.fixed_width(width)
.resizable(true)
.title("Modified")
.factory(&{