mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
add dim-label class for secondary columns
This commit is contained in:
parent
91a19c6c31
commit
12c1c80092
1 changed files with 28 additions and 19 deletions
|
|
@ -73,7 +73,7 @@ impl Column for ColumnViewColumn {
|
||||||
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
||||||
let item = list_item.item().unwrap();
|
let item = list_item.item().unwrap();
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
list_item.set_child(Some(&label(file_info.display_name())));
|
list_item.set_child(Some(&label(file_info.display_name(), &[])));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
})
|
})
|
||||||
|
|
@ -98,12 +98,14 @@ impl Column for ColumnViewColumn {
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
|
|
||||||
if !matches!(file_info.file_type(), FileType::Directory) {
|
if !matches!(file_info.file_type(), FileType::Directory) {
|
||||||
list_item
|
list_item.set_child(Some(&label(
|
||||||
.set_child(Some(&label((file_info.size() as usize).bytes().into())))
|
(file_info.size() as usize).bytes().into(),
|
||||||
|
&["dim-label"],
|
||||||
|
)))
|
||||||
} else {
|
} else {
|
||||||
use gtk::{gio::Cancellable, glib::gformat, prelude::FileExtManual};
|
use gtk::{gio::Cancellable, glib::gformat, prelude::FileExtManual};
|
||||||
use plurify::Plurify;
|
use plurify::Plurify;
|
||||||
list_item.set_child(Some(&label("loading..".into())));
|
list_item.set_child(Some(&label("loading..".into(), &["dim-label"])));
|
||||||
file_info
|
file_info
|
||||||
.attribute_object("standard::file")
|
.attribute_object("standard::file")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
@ -117,16 +119,19 @@ impl Column for ColumnViewColumn {
|
||||||
{
|
{
|
||||||
let list_item = list_item.clone();
|
let list_item = list_item.clone();
|
||||||
move |result| {
|
move |result| {
|
||||||
list_item.set_child(Some(&label(match result {
|
list_item.set_child(Some(&label(
|
||||||
Ok(i) => {
|
match result {
|
||||||
let count = i.count();
|
Ok(i) => {
|
||||||
gformat!(
|
let count = i.count();
|
||||||
"{count} {}",
|
gformat!(
|
||||||
count.plurify(&["item", "items", "items"])
|
"{count} {}",
|
||||||
)
|
count.plurify(&["item", "items", "items"])
|
||||||
}
|
)
|
||||||
Err(e) => e.to_string().into(),
|
}
|
||||||
})))
|
Err(e) => e.to_string().into(),
|
||||||
|
},
|
||||||
|
&["dim-label"],
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -149,7 +154,10 @@ impl Column for ColumnViewColumn {
|
||||||
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
||||||
let item = list_item.item().unwrap();
|
let item = list_item.item().unwrap();
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
list_item.set_child(Some(&label(file_info.format_content_type())));
|
list_item.set_child(Some(&label(
|
||||||
|
file_info.format_content_type(),
|
||||||
|
&["dim-label"],
|
||||||
|
)));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
})
|
})
|
||||||
|
|
@ -168,7 +176,7 @@ impl Column for ColumnViewColumn {
|
||||||
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
||||||
let item = list_item.item().unwrap();
|
let item = list_item.item().unwrap();
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
list_item.set_child(Some(&label(file_info.format_date_time())));
|
list_item.set_child(Some(&label(file_info.format_date_time(), &["dim-label"])));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
})
|
})
|
||||||
|
|
@ -187,7 +195,7 @@ impl Column for ColumnViewColumn {
|
||||||
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
||||||
let item = list_item.item().unwrap();
|
let item = list_item.item().unwrap();
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
list_item.set_child(Some(&label(file_info.format_date_time())));
|
list_item.set_child(Some(&label(file_info.format_date_time(), &["dim-label"])));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
})
|
})
|
||||||
|
|
@ -206,7 +214,7 @@ impl Column for ColumnViewColumn {
|
||||||
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
let list_item = this.downcast_ref::<ListItem>().unwrap();
|
||||||
let item = list_item.item().unwrap();
|
let item = list_item.item().unwrap();
|
||||||
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
let file_info = item.downcast_ref::<FileInfo>().unwrap();
|
||||||
list_item.set_child(Some(&label(file_info.format_date_time())));
|
list_item.set_child(Some(&label(file_info.format_date_time(), &["dim-label"])));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
})
|
})
|
||||||
|
|
@ -214,8 +222,9 @@ impl Column for ColumnViewColumn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn label(label: GString) -> Label {
|
fn label(label: GString, css_classes: &[&str]) -> Label {
|
||||||
Label::builder()
|
Label::builder()
|
||||||
|
.css_classes(css_classes)
|
||||||
.halign(gtk::Align::Start)
|
.halign(gtk::Align::Start)
|
||||||
.ellipsize(gtk::pango::EllipsizeMode::Middle)
|
.ellipsize(gtk::pango::EllipsizeMode::Middle)
|
||||||
.label(label)
|
.label(label)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue