mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-21 16:41:03 +00:00
ui: treeview: Add wrappable feature
This commit is contained in:
parent
39554d8d99
commit
ed697a63e9
1 changed files with 14 additions and 2 deletions
|
@ -7,10 +7,16 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::app::GPSApp;
|
||||
use gtk::prelude::TreeViewExt;
|
||||
use gtk::prelude::{Cast, CellLayoutExt, CellRendererTextExt, TreeViewExt};
|
||||
use gtk::{CellRendererText, TreeView, TreeViewColumn};
|
||||
|
||||
pub fn add_column_to_treeview(app: &GPSApp, tree_name: &str, column_name: &str, column_n: i32) {
|
||||
pub fn add_column_to_treeview(
|
||||
app: &GPSApp,
|
||||
tree_name: &str,
|
||||
column_name: &str,
|
||||
column_n: i32,
|
||||
wrappable: bool,
|
||||
) {
|
||||
let treeview: TreeView = app
|
||||
.builder
|
||||
.object(tree_name)
|
||||
|
@ -21,5 +27,11 @@ pub fn add_column_to_treeview(app: &GPSApp, tree_name: &str, column_name: &str,
|
|||
// Association of the view's column with the model's `id` column.
|
||||
column.add_attribute(&cell, "text", column_n);
|
||||
column.set_title(column_name);
|
||||
|
||||
if wrappable {
|
||||
column.set_sizing(gtk::TreeViewColumnSizing::Autosize);
|
||||
let cell: gtk::CellRendererText = column.cells()[0].clone().downcast().unwrap();
|
||||
cell.set_wrap_width(1024);
|
||||
}
|
||||
treeview.append_column(&column);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue