diff --git a/src/ui.rs b/src/ui.rs index 2b8637ce..c87e78ea 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -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(); @@ -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); @@ -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(); @@ -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);