Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make traffic and device windows display correctly #191

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +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(320)
.default_height(480)
.default_width(app_width)
.default_height(app_height)
.application(application)
.title("Packetry")
.build();
Expand Down Expand Up @@ -468,15 +482,9 @@ 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)
.build();
.build();

let device_window = gtk::ScrolledWindow::builder()
.hscrollbar_policy(gtk::PolicyType::Automatic)
.min_content_height(480)
.min_content_width(240)
.build();

let detail_text = gtk::TextBuffer::new(None);
Expand All @@ -489,9 +497,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();

Expand All @@ -500,15 +505,23 @@ pub fn activate(application: &Application) -> Result<(), Error> {
.wide_handle(true)
.start_child(&traffic_window)
.end_child(&device_window)
.shrink_start_child(false)
.shrink_end_child(false)
.hexpand(true)
.vexpand(true)
.build();
.position((hori_pane_width * traffic_width_percent) / 100)
.build();

let vertical_panes = gtk::Paned::builder()
.orientation(Orientation::Vertical)
.wide_handle(true)
.start_child(&horizontal_panes)
.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);
Expand Down
Loading