Skip to content
Permalink
Browse files
Stop overflow of marks
When many marks are made, the window grows beyond display width, and
there is no way to clear the marks.

- place the marks into a scrolled window (Anessh),

- display latest marks only; remove the scroll bar (Cameron),

- restrict displayed marks to the last 16 (Cameron).

Clearing the marks is not possible with the DObject.AddOnlySet class.

Fix for #3280.
https://bugs.sugarlabs.org/ticket/3280

Based on work by Aneesh.
https://git.sugarlabs.org/~lionaneesh/stopwatch/lionaneeshs-stopwatch/commit/8b5246ff396602f1490d2d465c2e3c09fdde22b5

Signed-off-by: James Cameron <quozl@laptop.org>
  • Loading branch information
Aneesh Dogra authored and quozl committed Jun 23, 2017
1 parent 22dfc05 commit c8b3594
Showing 1 changed file with 13 additions and 2 deletions.
@@ -243,9 +243,13 @@ def __init__(self, mywatch, myname, mymarks, timer, activity, number, group):
eb2.add(self._marks_label)
eb2.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white"))

self._sw = Gtk.ScrolledWindow()
self._sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
self._sw.add_with_viewport(eb2)

filler0 = Gtk.VBox()
filler0.pack_start(self.box, False, False, 0)
filler0.pack_start(eb2, False, False, 0)
filler0.pack_start(self._sw, False, False, 0)

filler = Gtk.VBox()
filler.pack_start(filler0, True, False, 0)
@@ -391,12 +395,19 @@ def _mark_cb(self, widget):
self._marks_model.add(tval)
self._update_marks()

def _update_sw(self):
a = self._sw.get_hadjustment()
a.set_value(a.get_upper())
return False

def _update_marks(self, diffset=None):
L = list(self._marks_model)
L.sort()
s = [self._format(num) for num in L]
s = [self._format(num) for num in L[-16:]]
p = " ".join(s)
self._marks_label.set_text(p)
if hasattr(self, '_sw'):
GObject.idle_add(self._update_sw)

def _name_cb(self, widget):
self._name_model.set_value(widget.get_text())

0 comments on commit c8b3594

Please sign in to comment.