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

Simplify BackButton #304

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 6 additions & 15 deletions internal/window/backbutton/backbutton.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,20 @@ const BackButtonIcon = "sidebar-show-symbolic"
// BackButton is a button that toggles whether or not the fold's sidebar
// should be revealed.
type BackButton struct {
*gtk.Revealer
Button *gtk.ToggleButton
*gtk.ToggleButton
}

// New creates a new fold reveal button. The button is hidden by default until a
// sidebar is connected to it.
func New() *BackButton {
button := gtk.NewToggleButton()
button.SetIconName(BackButtonIcon)
button.SetSensitive(false)
button.SetVisible(false)
button.SetHAlign(gtk.AlignCenter)
button.SetVAlign(gtk.AlignCenter)

revealer := gtk.NewRevealer()
revealer.AddCSSClass("adaptive-sidebar-reveal-button")
revealer.SetTransitionType(gtk.RevealerTransitionTypeCrossfade)
revealer.SetChild(button)
revealer.SetRevealChild(false)

return &BackButton{
Revealer: revealer,
Button: button,
ToggleButton: button,
}
}

Expand All @@ -45,18 +37,17 @@ func (b *BackButton) SetIconName(icon string) {
// sidebar.
func (b *BackButton) ConnectSplitView(view *adw.OverlaySplitView) {
view.NotifyProperty("show-sidebar", func() {
b.Button.SetActive(view.ShowSidebar())
b.SetActive(view.ShowSidebar())
})

view.NotifyProperty("collapsed", func() {
collapsed := view.Collapsed()
b.SetRevealChild(collapsed)
b.Button.SetSensitive(collapsed)
b.Button.SetVisible(collapsed)
})

// Specifically bind to "clicked" rather than notifying on "active" to
// prevent infinite recursion.
b.Button.ConnectClicked(func() {
view.SetShowSidebar(b.Button.Active())
view.SetShowSidebar(b.Active())
})
}
8 changes: 0 additions & 8 deletions internal/window/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ var chatPageCSS = cssutil.Applier("window-chatpage", `
border-radius: 0;
box-shadow: none;
}
.right-header .adaptive-sidebar-reveal-button {
margin: 0;
}
.right-header .adaptive-sidebar-reveal-button button {
margin-left: 8px;
margin-right: 4px;
}
.right-header-label {
font-weight: bold;
}
Expand Down Expand Up @@ -119,7 +112,6 @@ func NewChatPage(ctx context.Context, w *Window) *ChatPage {
p.rightTitle.SetHExpand(true)

back := backbutton.New()
back.SetTransitionType(gtk.RevealerTransitionTypeSlideRight)

newTabButton := gtk.NewButtonFromIconName("list-add-symbolic")
newTabButton.SetTooltipText("Open a New Tab")
Expand Down
Loading