pluginlist: avoid mulitple init

Allow only one initialization of the plugin
list.
This commit is contained in:
Stéphane Cerveau 2021-12-17 12:50:28 +01:00
parent 914fc1f077
commit c16102928b
2 changed files with 53 additions and 45 deletions

View file

@ -24,6 +24,7 @@ use gtk::{
AboutDialog, Application, ApplicationWindow, Builder, Button, FileChooserAction, AboutDialog, Application, ApplicationWindow, Builder, Button, FileChooserAction,
FileChooserDialog, PopoverMenu, ResponseType, Statusbar, Viewport, FileChooserDialog, PopoverMenu, ResponseType, Statusbar, Viewport,
}; };
use once_cell::unsync::OnceCell;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
@ -40,6 +41,7 @@ pub struct GPSAppInner {
pub graphview: RefCell<GraphView>, pub graphview: RefCell<GraphView>,
pub builder: Builder, pub builder: Builder,
pub pipeline: RefCell<Pipeline>, pub pipeline: RefCell<Pipeline>,
pub plugin_list_initialized: OnceCell<bool>,
} }
// This represents our main application window. // This represents our main application window.
@ -82,6 +84,7 @@ impl GPSApp {
graphview: RefCell::new(GraphView::new()), graphview: RefCell::new(GraphView::new()),
builder, builder,
pipeline: RefCell::new(pipeline), pipeline: RefCell::new(pipeline),
plugin_list_initialized: OnceCell::new(),
})); }));
Ok(app) Ok(app)
} }

View file

@ -62,6 +62,7 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
.object("dialog-plugin-list") .object("dialog-plugin-list")
.expect("Couldn't get window"); .expect("Couldn't get window");
if app.plugin_list_initialized.get().is_none() {
dialog.set_title(Some("Plugin list")); dialog.set_title(Some("Plugin list"));
dialog.set_default_size(640, 480); dialog.set_default_size(640, 480);
@ -118,6 +119,10 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
} }
}), }),
); );
app.plugin_list_initialized
.set(true)
.expect("Should never happen");
}
dialog.show(); dialog.show();
} }