From 20012c3d333d21c0cf94598b70496d3c9ea5f703 Mon Sep 17 00:00:00 2001 From: x0rloser Date: Tue, 17 Sep 2024 23:53:37 +1000 Subject: [PATCH 1/2] make traffic and device windows display correctly --- src/ui.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 2b8637ce..ed86bb86 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -369,8 +369,6 @@ pub fn activate(application: &Application) -> Result<(), Error> { use FileAction::*; let window = gtk::ApplicationWindow::builder() - .default_width(320) - .default_height(480) .application(application) .title("Packetry") .build(); @@ -468,15 +466,13 @@ pub fn activate(application: &Application) -> Result<(), Error> { let (_, capture) = create_capture()?; let traffic_window = gtk::ScrolledWindow::builder() - .hscrollbar_policy(gtk::PolicyType::Automatic) - .min_content_height(480) .min_content_width(640) + .min_content_height(480) .build(); let device_window = gtk::ScrolledWindow::builder() - .hscrollbar_policy(gtk::PolicyType::Automatic) - .min_content_height(480) .min_content_width(240) + .min_content_height(480) .build(); let detail_text = gtk::TextBuffer::new(None); @@ -489,8 +485,6 @@ pub fn activate(application: &Application) -> Result<(), Error> { .build(); let detail_window = gtk::ScrolledWindow::builder() - .hscrollbar_policy(gtk::PolicyType::Automatic) - .min_content_width(640) .min_content_height(120) .child(&detail_view) .build(); @@ -500,15 +494,17 @@ pub fn activate(application: &Application) -> Result<(), Error> { .wide_handle(true) .start_child(&traffic_window) .end_child(&device_window) - .vexpand(true) - .build(); + .shrink_start_child(false) + .shrink_end_child(false) + .build(); let vertical_panes = gtk::Paned::builder() .orientation(Orientation::Vertical) .wide_handle(true) .start_child(&horizontal_panes) .end_child(&detail_window) - .hexpand(true) + .shrink_start_child(false) + .shrink_end_child(false) .build(); let separator = gtk::Separator::new(Orientation::Horizontal); From eafc401c7c330459f1be9c98307e72e8553d077f Mon Sep 17 00:00:00 2001 From: x0rloser Date: Wed, 18 Sep 2024 11:14:41 +1000 Subject: [PATCH 2/2] removed explicit min content sizes, added initial pane positional divider values --- src/ui.rs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index ed86bb86..c87e78ea 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -368,7 +368,23 @@ macro_rules! button_action { pub fn activate(application: &Application) -> Result<(), Error> { use FileAction::*; + // These are used to set initial size of the main application window, + // as well as the positions for the window pane dividers. + // "non_pane_height" is the approx height of non Paned widgets, + // eg action_bar + status bar. + // These don't need to be pixel perfect, just close enough to just generate + // acceptable values. + let app_width = 800; + let app_height = 600; + let non_pane_height = 100; + let hori_pane_width = app_width; + let vert_pane_height = app_height - non_pane_height; + let traffic_width_percent = 70; + let traffic_height_percent = 75; + let window = gtk::ApplicationWindow::builder() + .default_width(app_width) + .default_height(app_height) .application(application) .title("Packetry") .build(); @@ -466,13 +482,9 @@ pub fn activate(application: &Application) -> Result<(), Error> { let (_, capture) = create_capture()?; let traffic_window = gtk::ScrolledWindow::builder() - .min_content_width(640) - .min_content_height(480) - .build(); + .build(); let device_window = gtk::ScrolledWindow::builder() - .min_content_width(240) - .min_content_height(480) .build(); let detail_text = gtk::TextBuffer::new(None); @@ -485,7 +497,6 @@ pub fn activate(application: &Application) -> Result<(), Error> { .build(); let detail_window = gtk::ScrolledWindow::builder() - .min_content_height(120) .child(&detail_view) .build(); @@ -496,6 +507,9 @@ pub fn activate(application: &Application) -> Result<(), Error> { .end_child(&device_window) .shrink_start_child(false) .shrink_end_child(false) + .hexpand(true) + .vexpand(true) + .position((hori_pane_width * traffic_width_percent) / 100) .build(); let vertical_panes = gtk::Paned::builder() @@ -505,6 +519,9 @@ pub fn activate(application: &Application) -> Result<(), Error> { .end_child(&detail_window) .shrink_start_child(false) .shrink_end_child(false) + .hexpand(true) + .vexpand(true) + .position((vert_pane_height * traffic_height_percent) / 100) .build(); let separator = gtk::Separator::new(Orientation::Horizontal);