From c161f2b17193f5f9c369b3e226820fffd7f6d86f Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 29 Apr 2024 08:55:02 -0700 Subject: [PATCH] create new page for GoHome instead of using browsing history --- ui/browsing/browsingpane.go | 15 ++------------- ui/mainwindow.go | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index 7317141..15098ce 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -75,10 +75,10 @@ type BrowsingPane struct { navBtnsPageMap map[controller.PageName]fyne.Resource } -func NewBrowsingPane(app *backend.App, contr *controller.Controller) *BrowsingPane { +func NewBrowsingPane(app *backend.App, contr *controller.Controller, onGoHome func()) *BrowsingPane { b := &BrowsingPane{app: app} b.ExtendBaseWidget(b) - b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), b.GoHome) + b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), onGoHome) b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack) b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward) b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload) @@ -269,17 +269,6 @@ func (b *BrowsingPane) updateHistoryButtons() { } } -func (b *BrowsingPane) GoHome() { - if len(b.history) > 0 { - homePage := b.history[0].Restore() - if b.CurrentPage() != homePage.Route() { - b.addPageToHistory(b.curPage, false) - b.doSetPage(homePage) - b.updateHistoryButtons() - } - } -} - func (b *BrowsingPane) GoBack() { if b.historyIdx > 0 { // due to widget reuse between pages, diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 8d20916..afd27b1 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -75,7 +75,7 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string, MainWindow: m.Window, App: app, } - m.BrowsingPane = browsing.NewBrowsingPane(app, m.Controller) + m.BrowsingPane = browsing.NewBrowsingPane(app, m.Controller, func() { m.Router.NavigateTo(m.StartupPage()) }) m.Router = browsing.NewRouter(app, m.Controller, m.BrowsingPane) // inject controller dependencies m.Controller.NavHandler = m.Router.NavigateTo