[pitivi] widgets: Use the zoom slider tooltip to display the duration of the displayed timeline
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] widgets: Use the zoom slider tooltip to display the duration of the displayed timeline
- Date: Fri, 28 Feb 2014 03:12:45 +0000 (UTC)
commit f0e557da2f049192a05cb9d0a8017266a42991f0
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sat Feb 15 08:39:55 2014 +0100
widgets: Use the zoom slider tooltip to display the duration of the displayed timeline
pitivi/utils/widgets.py | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 7222061..5910656 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -42,7 +42,8 @@ from gettext import gettext as _
from pitivi.utils.loggable import Loggable
from pitivi.configure import get_ui_dir
-from pitivi.utils.ui import unpack_color, pack_color_32, pack_color_64, \
+from pitivi.utils.ui import beautify_length, \
+ unpack_color, pack_color_32, pack_color_64, \
time_to_string, SPACING, CONTROL_WIDTH
from pitivi.utils.timeline import Zoomable
@@ -1013,9 +1014,10 @@ class ZoomBox(Gtk.HBox, Zoomable):
# zoom slider, otherwise the slider remains at the leftmost position.
self._zoomAdjustment.set_value(Zoomable.getCurrentZoomLevel())
zoomslider.props.draw_value = False
- zoomslider.set_tooltip_text(_("Zoom Timeline"))
zoomslider.connect("scroll-event", self._zoomSliderScrollCb)
zoomslider.connect("value-changed", self._zoomAdjustmentChangedCb)
+ zoomslider.connect("query-tooltip", self._sliderTooltipCb)
+ zoomslider.set_has_tooltip(True)
zoomslider.set_size_request(100, 0) # At least 100px wide for precision
self.pack_start(zoomslider, expand=True, fill=True, padding=ZOOM_SLIDER_PADDING)
@@ -1047,3 +1049,16 @@ class ZoomBox(Gtk.HBox, Zoomable):
zoomLevel = self.getCurrentZoomLevel()
if int(self._zoomAdjustment.get_value()) != zoomLevel:
self._zoomAdjustment.set_value(zoomLevel)
+
+ def _sliderTooltipCb(self, unused_slider, unused_x, unused_y, unused_keyboard_mode, tooltip):
+ # We assume the width of the ruler is exactly the width of the timeline.
+ width_px = self.timeline.ruler.get_allocated_width()
+ timeline_width_ns = Zoomable.pixelToNs(width_px)
+ if timeline_width_ns >= Gst.SECOND:
+ # Translators: %s represents a duration, for example "10 minutes"
+ tip = _("%s displayed") % beautify_length(timeline_width_ns)
+ else:
+ # Translators: This is a tooltip
+ tip = _("%d nanoseconds displayed, because we can") % timeline_width_ns
+ tooltip.set_text(tip)
+ return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]