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}; use gtk::{gio::File, ScrolledWindow};
pub struct Directory; pub struct Directory; // @TODO save settings
impl Directory { impl Directory {
// Constructors // Constructors
@ -32,12 +32,17 @@ impl Directory {
) )
.build(); .build();
column_view.append_column(&Column::icon()); let icon = Column::icon();
let name = Column::name(); 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(&name);
column_view.append_column(&Column::size()); column_view.append_column(&size);
column_view.append_column(&Column::content_type()); column_view.append_column(&content_type);
//column_view.append_column(&Column::modification_date_time()); //column_view.append_column(&modification_date_time);
column_view.sort_by_column(Some(&name), gtk::SortType::Ascending); column_view.sort_by_column(Some(&name), gtk::SortType::Ascending);
column_view column_view

View file

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