From 81b3a4567dbfc1a0163b9791600b58aea741457f Mon Sep 17 00:00:00 2001 From: "g@localhost.localdomain" Date: Sun, 26 Nov 2006 00:04:32 +0100 Subject: [PATCH] If the size changed, instead of rescheduling the building in the UI, let the tree creation be done another time. This way, all UI benefit from the detection. --- pysize/core/pysize_fs_tree.py | 11 +++++++++-- pysize/ui/gtk/pysize_widget.py | 6 +----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pysize/core/pysize_fs_tree.py b/pysize/core/pysize_fs_tree.py index 1afd453..9b90034 100644 --- a/pysize/core/pysize_fs_tree.py +++ b/pysize/core/pysize_fs_tree.py @@ -41,9 +41,16 @@ class pysize_tree(object): min_size < 1.0 => ratio to total size.""" def __init__(self, paths, max_depth, min_size, options): self.fullpaths = paths - if paths and min_size <= 1.0: - min_size *= compute_size.slow_sum(paths, options.cross_device) + auto_min_size = min_size <= 1.0 + estimated_size = compute_size.slow_sum(paths, options.cross_device) + if auto_min_size: + min_size_ratio = min_size + min_size = estimated_size * min_size_ratio self.root = create_node(None, paths, max_depth, min_size, options) + if auto_min_size and estimated_size != self.root.size: + estimated_size = self.root.size + min_size = estimated_size * min_size_ratio + self.root = create_node(None, paths, max_depth, min_size, options) self.height = self.root.compute_height() def get_next_sibling(self, node): diff --git a/pysize/ui/gtk/pysize_widget.py b/pysize/ui/gtk/pysize_widget.py index a1f2f97..fa216fd 100644 --- a/pysize/ui/gtk/pysize_widget.py +++ b/pysize/ui/gtk/pysize_widget.py @@ -58,10 +58,9 @@ class PysizeWidget(gtk.DrawingArea, PysizeWidget_Draw, self.options = options self.selected_nodes = [] self.paths = args - self.tree = pysize_tree(None, None, None, self.options) + self.tree = pysize_tree([], 0, 0, self.options) self.tree_builder = threaded_pysize_tree() self.tree_builder.completion.add_observer(self._new_tree_callback) - self.current_size = None def _realize(self): events = self.window.get_events() @@ -100,8 +99,6 @@ class PysizeWidget(gtk.DrawingArea, PysizeWidget_Draw, if tree: if self.options.min_size == 'auto': height = self.get_parent().allocation.height - 2 - if self.current_size and self.current_size != tree.root.size: - self.schedule_new_tree() else: height = int(self._get_requested_height()) self.set_size_request(-1, height) @@ -120,7 +117,6 @@ class PysizeWidget(gtk.DrawingArea, PysizeWidget_Draw, self.schedule_new_tree() def schedule_new_tree(self): - self.current_size = self.tree.root.size self.tree_builder.schedule(self.paths, self.options.max_depth, self.min_size_requested(), self.options) -- 2.11.4.GIT