App: Fix some refference cycles.
This commit is contained in:
parent
d43fc268f4
commit
17da62d53b
@ -81,10 +81,14 @@ impl App {
|
|||||||
|
|
||||||
let window = gtk::ApplicationWindow::new(application);
|
let window = gtk::ApplicationWindow::new(application);
|
||||||
window.set_title("Podcasts");
|
window.set_title("Podcasts");
|
||||||
window.connect_delete_event(clone!(settings => move |window, _| {
|
|
||||||
WindowGeometry::from_window(&window).write(&settings);
|
let weak_s = settings.downgrade();
|
||||||
|
window.connect_delete_event(move |window, _| {
|
||||||
|
weak_s
|
||||||
|
.upgrade()
|
||||||
|
.map(|settings| WindowGeometry::from_window(&window).write(&settings));
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
}));
|
});
|
||||||
|
|
||||||
// Create a content instance
|
// Create a content instance
|
||||||
let content = Content::new(&sender).expect("Content Initialization failed.");
|
let content = Content::new(&sender).expect("Content Initialization failed.");
|
||||||
@ -131,8 +135,6 @@ impl App {
|
|||||||
app.setup_gactions();
|
app.setup_gactions();
|
||||||
app.setup_timed_callbacks();
|
app.setup_timed_callbacks();
|
||||||
|
|
||||||
app.instance.connect_activate(move |_| ());
|
|
||||||
|
|
||||||
// Retrieve the previous window position and size.
|
// Retrieve the previous window position and size.
|
||||||
WindowGeometry::from_settings(&app.settings).apply(&app.window);
|
WindowGeometry::from_settings(&app.settings).apply(&app.window);
|
||||||
|
|
||||||
@ -298,17 +300,23 @@ impl App {
|
|||||||
let application = gtk::Application::new(APP_ID, ApplicationFlags::empty())
|
let application = gtk::Application::new(APP_ID, ApplicationFlags::empty())
|
||||||
.expect("Application Initialization failed...");
|
.expect("Application Initialization failed...");
|
||||||
|
|
||||||
application.connect_startup(clone!(application => move |_| {
|
let weak_app = application.downgrade();
|
||||||
info!("CONNECT STARTUP RUN");
|
application.connect_startup(move |_| {
|
||||||
|
info!("GApplication::startup");
|
||||||
|
weak_app.upgrade().map(|application| {
|
||||||
let app = Self::new(&application);
|
let app = Self::new(&application);
|
||||||
Self::init(&app);
|
Self::init(&app);
|
||||||
info!("Init complete");
|
|
||||||
application.connect_activate(clone!(app => move |_| {
|
let weak = Rc::downgrade(&app);
|
||||||
|
application.connect_activate(move |_| {
|
||||||
info!("GApplication::activate");
|
info!("GApplication::activate");
|
||||||
app.window.activate();
|
weak.upgrade().map(|app| app.window.activate());
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
info!("Init complete");
|
||||||
app.window.show_all();
|
app.window.show_all();
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Weird magic I copy-pasted that sets the Application Name in the Shell.
|
// Weird magic I copy-pasted that sets the Application Name in the Shell.
|
||||||
glib::set_application_name("Podcasts");
|
glib::set_application_name("Podcasts");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user