From b0a6a8b231444bcde4f637a7601e03dbb1c8f5ef Mon Sep 17 00:00:00 2001 From: Harish Fulara Date: Sun, 18 Mar 2018 03:05:01 +0530 Subject: [PATCH] timeline: Show vertical scrollbar only when needed Fixes #1811 --- pitivi/timeline/timeline.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py index b953645fb..6da65be18 100644 --- a/pitivi/timeline/timeline.py +++ b/pitivi/timeline/timeline.py @@ -1290,11 +1290,15 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable): self.ges_timeline = None self.__copied_group = None + # Vertical Scrollbar. It will be displayed only when needed. + self.vscrollbar = None + self._createUi() self._createActions() self.app.project_manager.connect("new-project-loaded", self._projectLoadedCb) + self.timeline.connect("size-allocate", self.__size_allocate_cb) # Public API @@ -1441,9 +1445,10 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable): self.timeline = Timeline(self.app, left_size_group) - vscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL, + self.vscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL, adjustment=self.timeline.vadj) - vscrollbar.get_style_context().add_class("background") + self.vscrollbar.get_style_context().add_class("background") + hscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.HORIZONTAL, adjustment=self.timeline.hadj) hscrollbar.get_style_context().add_class("background") @@ -1464,7 +1469,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable): self.attach(zoom_box, 0, 0, 1, 1) self.attach(self.ruler, 1, 0, 1, 1) self.attach(self.timeline, 0, 1, 2, 1) - self.attach(vscrollbar, 2, 1, 1, 1) + self.attach(self.vscrollbar, 2, 1, 1, 1) self.attach(hscrollbar, 1, 2, 1, 1) self.attach(self.toolbar, 3, 1, 1, 1) @@ -1884,6 +1889,12 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable): self._framerate = videorate self.ruler.setProjectFrameRate(self._framerate) + def __size_allocate_cb(self, unused_widget, allocation): + if self.timeline.layout.props.height > allocation.height: + self.vscrollbar.show() + else: + self.vscrollbar.hide() + def _projectLoadedCb(self, unused_project_manager, project): """Connects to the project's timeline and pipeline.""" if self._project: -- GitLab