Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added home icon in BrowsingPane #187

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ui/browsing/browsingpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type BrowsingPane struct {

curPage Page

home *widget.Button
forward *widget.Button
back *widget.Button
reload *widget.Button
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down