diff --git a/src/app.rs b/src/app.rs index f2402d9..ed42193 100644 --- a/src/app.rs +++ b/src/app.rs @@ -21,8 +21,8 @@ use gtk::gdk::Rectangle; use gtk::prelude::*; use gtk::{ gdk::BUTTON_SECONDARY, AboutDialog, Application, ApplicationWindow, Builder, Button, - CellRendererText, FileChooserAction, FileChooserDialog, ListStore, PopoverMenu, ResponseType, - Statusbar, TreeView, TreeViewColumn, Viewport, + CellRendererText, FileChooserAction, FileChooserDialog, ListStore, Paned, PopoverMenu, + ResponseType, Statusbar, TreeView, TreeViewColumn, Viewport, }; use gtk::{gio, glib, graphene}; use once_cell::unsync::OnceCell; @@ -81,7 +81,19 @@ impl GPSApp { let window: ApplicationWindow = builder.object("mainwindow").expect("Couldn't get window"); window.set_application(Some(application)); window.set_title(Some("GstPipelineStudio")); - window.set_size_request(800, 600); + let settings = Settings::load_settings(); + window.set_size_request(settings.app_width, settings.app_height); + let paned: Paned = builder + .object("graph_logs-paned") + .expect("Couldn't get window"); + paned.set_position(settings.app_graph_logs_paned_pos); + let paned: Paned = builder + .object("graph_favorites-paned") + .expect("Couldn't get window"); + paned.set_position(settings.app_graph_favorites_paned_pos); + if settings.app_maximized { + window.maximize(); + } let pipeline = Pipeline::new().expect("Unable to initialize the pipeline"); let app = GPSApp(Rc::new(GPSAppInner { window, @@ -120,6 +132,25 @@ impl GPSApp { .borrow_mut() .take() .expect("Shutdown called multiple times"); + let window: ApplicationWindow = app + .builder + .object("mainwindow") + .expect("Couldn't get window"); + let mut settings = Settings::load_settings(); + settings.app_maximized = window.is_maximized(); + settings.app_width = window.width(); + settings.app_height = window.height(); + let paned: Paned = app + .builder + .object("graph_logs-paned") + .expect("Couldn't get window"); + settings.app_graph_logs_paned_pos = paned.position(); + let paned: Paned = app + .builder + .object("graph_favorites-paned") + .expect("Couldn't get window"); + settings.app_graph_favorites_paned_pos = paned.position(); + Settings::save_settings(&settings); app.drop(); }); } @@ -134,10 +165,13 @@ impl GPSApp { ok_button = "Save"; action = FileChooserAction::Save; } - + let window: ApplicationWindow = app + .builder + .object("mainwindow") + .expect("Couldn't get window"); let file_chooser: FileChooserDialog = FileChooserDialog::new( Some(message), - Some(&app.window), + Some(&window), action, &[ (ok_button, ResponseType::Ok), @@ -191,6 +225,7 @@ impl GPSApp { dialog.set_resizable(false); dialog.show(); } + fn reset_logger_list(&self, logger_list: &TreeView) { let model = ListStore::new(&[String::static_type()]); logger_list.set_model(Some(&model)); @@ -298,7 +333,11 @@ impl GPSApp { app.reset_favorite_list(&favorite_list); pop_menu.unparent(); })); - if let Some(application) = app.window.application() { + let window: ApplicationWindow = app + .builder + .object("mainwindow") + .expect("Couldn't get window"); + if let Some(application) = window.application() { application.add_action(&action); } diff --git a/src/gps.ui b/src/gps.ui index d8104eb..f0adc73 100644 --- a/src/gps.ui +++ b/src/gps.ui @@ -231,47 +231,52 @@ - - 600 - True - True - True - - - True - True - - + + vertical + 400 + + + 600 + True + True + True + + + True + True + + + + + + + + + + + + True + True + + - + + fav_menu + - - - - - - - True - True - - - - - fav_menu - - - - - - - - - - - end - - - + + + + + + + + + + + + + diff --git a/src/settings.rs b/src/settings.rs index 31e33da..03936b6 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -9,6 +9,11 @@ use crate::logger; #[derive(Debug, Serialize, Deserialize, Default)] pub struct Settings { pub favorites: Vec, + pub app_maximized: bool, + pub app_width: i32, + pub app_height: i32, + pub app_graph_logs_paned_pos: i32, + pub app_graph_favorites_paned_pos: i32, } impl Settings { @@ -81,7 +86,13 @@ impl Settings { } } } else { - Settings::default() + Settings { + app_width: 800, + app_height: 600, + app_graph_logs_paned_pos: 400, + app_graph_favorites_paned_pos: 600, + ..Default::default() + } } } }