Merge pull request #187 from natilou/home

Added home icon in BrowsingPane
This commit is contained in:
Drew Weymouth
2023-06-10 11:21:15 -07:00
committed by GitHub
+14 -1
View File
@@ -50,6 +50,7 @@ type BrowsingPane struct {
curPage Page
home *widget.Button
forward *widget.Button
back *widget.Button
reload *widget.Button
@@ -66,6 +67,7 @@ type BrowsingPane struct {
func NewBrowsingPane(app *backend.App) *BrowsingPane {
b := &BrowsingPane{app: app}
b.ExtendBaseWidget(b)
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), b.GoHome)
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
@@ -84,7 +86,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
b.container = container.NewBorder(container.New(
&layouts.MaxPadLayout{PadLeft: -5, PadRight: -5},
container.New(layouts.NewLeftMiddleRightLayout(0),
container.NewHBox(b.back, b.forward, b.reload), b.navBtnsContainer,
container.NewHBox(b.home, b.back, b.forward, b.reload), b.navBtnsContainer,
container.NewHBox(layout.NewSpacer(), b.settingsBtn))),
nil, nil, nil, b.pageContainer)
b.updateHistoryButtons()
@@ -218,6 +220,17 @@ 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 {
b.addPageToHistory(b.curPage, false)