Skip to content

Commit

Permalink
Scroll to last segment in path bar automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Dec 22, 2023
1 parent d6b498f commit 3c80bd9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions hyperplane/gtk/path-bar.blp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ using Gtk 4.0;
template $HypPathBar : ScrolledWindow {
vscrollbar-policy: never;
hscrollbar-policy: external;
overflow: hidden;
window-placement: bottom_right;
Box segments_box {}

Viewport viewport {
Box segments_box {}
}

styles [
"undershoot-start",
Expand Down
2 changes: 2 additions & 0 deletions hyperplane/gtk/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ rubberband {
.path-bar > undershoot.left {
background: linear-gradient(to right, alpha(@headerbar_shade_color, 0.5) 6px, alpha(@headerbar_shade_color, 0) 32px);
border-left: solid 1px @borders;
border-radius: 6px 0px 0px 6px;
}
.path-bar > undershoot.right {
background: linear-gradient(to left, alpha(@headerbar_shade_color, 0.5) 6px, alpha(@headerbar_shade_color, 0) 32px);
border-right: solid 1px @borders;
border-radius: 0px 6px 6px 0px;
}
.path-bar > viewport > box > revealer > button {
padding: 2px 9px;
Expand Down
10 changes: 9 additions & 1 deletion hyperplane/path_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class HypPathBar(Gtk.ScrolledWindow):

__gtype_name__ = "HypPathBar"

viewport: Gtk.Viewport = Gtk.Template.Child()
segments_box: Gtk.Box = Gtk.Template.Child()

segments: list
separators: dict
tags: bool # Whether the path bar represents tags or a file
Expand Down Expand Up @@ -114,8 +116,14 @@ def append(
if self.tags:
return

segment = self.segments[-1]
segment.remove_css_class("inactive-segment")

GLib.timeout_add(
segment.get_transition_duration(), self.viewport.scroll_to, segment
)

try:
self.segments[-1].remove_css_class("inactive-segment")
self.segments[-2].add_css_class("inactive-segment")
except IndexError:
return
Expand Down

0 comments on commit 3c80bd9

Please sign in to comment.