Skip to content

Commit

Permalink
Merge pull request #90 from martinling/column-view
Browse files Browse the repository at this point in the history
Switch from `ListView` to `ColumnView`
  • Loading branch information
miek authored Feb 26, 2024
2 parents ea74f06 + 0bcc3ba commit f05c9cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use gtk::{
DropDown,
Label,
ListItem,
ListView,
ColumnView,
ColumnViewColumn,
ProgressBar,
ScrolledWindow,
Separator,
Expand Down Expand Up @@ -383,10 +384,11 @@ pub fn activate(application: &Application) -> Result<(), Error> {
}

fn create_view<Item, Model, RowData>(
title: &str,
capture: &CaptureReader,
#[cfg(any(feature="test-ui-replay", feature="record-ui-test"))]
recording_args: (&Rc<RefCell<Recording>>, &'static str))
-> (Model, ListView)
-> (Model, ColumnView)
where
Item: Copy + 'static,
Model: GenericModel<Item> + IsA<ListModel> + IsA<Object>,
Expand Down Expand Up @@ -494,7 +496,10 @@ fn create_view<Item, Model, RowData>(
factory.connect_bind(move |_, item| display_error(bind(item)));
factory.connect_unbind(move |_, item| display_error(unbind(item)));

let view = ListView::new(Some(selection_model), Some(factory));
let view = ColumnView::new(Some(selection_model));
let column = ColumnViewColumn::new(Some(title), Some(factory));
view.append_column(&column);
view.add_css_class("data-table");

#[cfg(any(feature="test-ui-replay", feature="record-ui-test"))]
model.connect_items_changed(move |model, position, removed, added|
Expand All @@ -509,12 +514,14 @@ pub fn reset_capture() -> Result<CaptureWriter, Error> {
with_ui(|ui| {
let (traffic_model, traffic_view) =
create_view::<TrafficItem, TrafficModel, TrafficRowData>(
"Traffic",
&reader,
#[cfg(any(feature="test-ui-replay", feature="record-ui-test"))]
(&ui.recording, "traffic")
);
let (device_model, device_view) =
create_view::<DeviceItem, DeviceModel, DeviceRowData>(
"Devices",
&reader,
#[cfg(any(feature="test-ui-replay", feature="record-ui-test"))]
(&ui.recording, "devices")
Expand Down

0 comments on commit f05c9cc

Please sign in to comment.