[meld/ui-next] ui.statusbar: Set a reasonable cursor label width
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/ui-next] ui.statusbar: Set a reasonable cursor label width
- Date: Sun, 24 Mar 2019 00:03:45 +0000 (UTC)
commit 1917b750876421c3147f8544f6fb89db99a4a5e3
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Mar 24 09:55:41 2019 +1000
ui.statusbar: Set a reasonable cursor label width
The initial cursor label allocation is almost always enough to hold a
couple of digits for line and a single digit for column... that's just
where we expect initial cursors to end up. Having the allocation change
when the cursor moves makes the statusbar feel dodgy, and it's frankly
much nicer if all of the widgets stay in a constant place.
The calculation here is a trade-off between line count + length that we
expect users might hit vs. not wanting too much blank space between
the cursor button and other statusbar widgets. The calculation is
essentially the formatted version of having <10000 lines at <1000
characters long... and the -2 is from practical testing, since the
allocated space _easily_ fits more than the desired line counts with
normal system fonts.
meld/ui/statusbar.py | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index 8a0062af..f00a30bb 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -72,6 +72,7 @@ class MeldStatusMenuButton(Gtk.MenuButton):
label.props.single_line_mode = True
label.props.halign = Gtk.Align.START
label.props.valign = Gtk.Align.BASELINE
+ label.props.xalign = 1.0
arrow = Gtk.Image.new_from_icon_name(
'pan-down-symbolic', Gtk.IconSize.SMALL_TOOLBAR)
@@ -88,6 +89,9 @@ class MeldStatusMenuButton(Gtk.MenuButton):
self._label = label
+ def set_label_width(self, width):
+ self._label.set_width_chars(width)
+
class MeldStatusBar(Gtk.Statusbar):
__gtype_name__ = "MeldStatusBar"
@@ -209,6 +213,9 @@ class MeldStatusBar(Gtk.Statusbar):
format_cursor_position)
self.connect('start-go-to-line', lambda *args: button.clicked())
button.set_popover(pop)
+ # Set a label width to avoid other widgets moving on cursor change
+ reasonable_width = len(format_cursor_position(None, (1000, 100))) - 2
+ button.set_label_width(reasonable_width)
button.show()
return button
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]