Browse Source

fix tab append on initial application startup

master
yggverse 2 months ago
parent
commit
ef227f276d
  1. 2
      Cargo.toml
  2. 4
      src/app.rs
  3. 4
      src/app/browser.rs
  4. 4
      src/app/browser/window.rs
  5. 14
      src/app/browser/window/tab.rs

2
Cargo.toml

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[package]
name = "Yoda"
version = "0.5.0"
version = "0.4.1"
edition = "2021"
license = "MIT"
readme = "README.md"

4
src/app.rs

@ -119,6 +119,7 @@ impl App { @@ -119,6 +119,7 @@ impl App {
// Restore previous session from DB
match Database::records(&transaction) {
Ok(records) => {
// Restore child components
for record in records {
if let Err(e) =
browser.restore(&transaction, &record.id)
@ -126,6 +127,9 @@ impl App { @@ -126,6 +127,9 @@ impl App {
todo!("{e}")
}
}
// Run initial features
browser.init();
}
Err(e) => todo!("{e}"),
}

4
src/app/browser.rs

@ -236,6 +236,10 @@ impl Browser { @@ -236,6 +236,10 @@ impl Browser {
Ok(())
}
pub fn init(&self) {
self.window.init();
}
// Getters
pub fn gobject(&self) -> &ApplicationWindow {
&self.widget.gobject()

4
src/app/browser/window.rs

@ -160,6 +160,10 @@ impl Window { @@ -160,6 +160,10 @@ impl Window {
Ok(())
}
pub fn init(&self) {
self.tab.init();
}
// Getters
pub fn gobject(&self) -> &Box {
&self.widget.gobject()

14
src/app/browser/window/tab.rs

@ -217,11 +217,6 @@ impl Tab { @@ -217,11 +217,6 @@ impl Tab {
// Register dynamically created tab item in the HashMap index
self.index.borrow_mut().insert(item.id(), item.clone());
}
// Append just one blank page if nothing to restore
if self.index.borrow().is_empty() {
self.append();
}
}
Err(e) => return Err(e.to_string()),
}
@ -260,6 +255,15 @@ impl Tab { @@ -260,6 +255,15 @@ impl Tab {
Ok(())
}
pub fn init(&self) {
// Append just one blank page if no tabs available after last session restore
if self.index.borrow().is_empty() {
self.append();
}
// @TODO other/child features..
}
// Getters
pub fn gobject(&self) -> &TabView {
self.widget.gobject()

Loading…
Cancel
Save