diff options
author | Frederic Back <fredericback@gmail.com> | 2006-10-03 11:02:22 +0000 |
---|---|---|
committer | Frederic Back <fredericback@gmail.com> | 2006-10-03 11:02:22 +0000 |
commit | 03ad44ccf9bd1fdbc2fd89adb494289d5623d47f (patch) | |
tree | 2db0091b99d83693ea0d95be9aa536396fbd7d6b /src/fringlib/fringui.py | |
parent | 9f5926851fab9e3e5129a62efd1044214691b531 (diff) |
* Put sumlists in a central repository. Load from memory if a path
is already walked.
git-svn-id: file:///home/lennart/svn/public/fring/trunk@62 d0d2c35f-0a1e-0410-abeb-dabff30a67ee
Diffstat (limited to 'src/fringlib/fringui.py')
-rw-r--r-- | src/fringlib/fringui.py | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/fringlib/fringui.py b/src/fringlib/fringui.py index 49e60ff..e27c9a2 100644 --- a/src/fringlib/fringui.py +++ b/src/fringlib/fringui.py @@ -7,6 +7,7 @@ import unicodedata from fringwalker import * from fringrenderer import FringRenderer from fringutil import * +from fringdata import SumListCollection CURSOR_NONE = 0 CURSOR_BUSY = 1 @@ -52,13 +53,12 @@ class UI( gtk.Window ): self.data = None self.zoomfactor = 1.0 self.renderer = FringRenderer() - self.walker = FringWalker(); + self.collection = SumListCollection() + self.walker = FringWalker(self.collection); self.scan_active = False self.cursor = None self.maxrings = 4 - self.folder_memory = {} # remember some folders - # create gui gtk.Window.__init__(self) self.set_title("fring"); @@ -247,6 +247,7 @@ class UI( gtk.Window ): def refresh_tree(self,widget): """ Refresh the current folder """ self.walker.stop() + self.collection.clear() self.walker.walk(self.uri) self.scan_active = True self.__show_busy_cursor(1) @@ -254,11 +255,15 @@ class UI( gtk.Window ): #----------------------------------------------------------- private methods def __set_uri(self,uri): - if uri in self.folder_memory: - self.data = self.folder_memory[uri] + print "requested:",uri, + d = self.collection.get_sumlist(uri) + if d is not None: + print "(load from collection)" + self.data = self.collection.get_sumlist(uri) self.uri = uri self.redraw() else: + print "(walk)" self.uri = uri self.walker.stop() if uri: @@ -299,7 +304,7 @@ class UI( gtk.Window ): def __event_togglehidden(self,widget): if self.walker.showhidden == widget.get_active(): return self.walker.showhidden = widget.get_active() - self.__set_uri(self.uri) + self.refresh_tree() def __event_move(self, widget, event): f = self.renderer.get_hotspot_at(event.x, event.y) @@ -309,7 +314,7 @@ class UI( gtk.Window ): markup = "%s, %s, %0.1f%%" % (format_uri(f.path), pretty_size(f.sumlist.size), f.value*100) self.label.set_text(markup) - if f.sumlist.children is not None: + if f.sumlist.has_children(): self.__set_cursor(CURSOR_LINK) return @@ -319,21 +324,22 @@ class UI( gtk.Window ): f = self.renderer.get_hotspot_at(event.x, event.y) if f and f.sumlist.children: - if self.scan_active: - # if we are still walking the tree, start a new scan on the path - self.open_folder(f.path) + self.open_folder(f.path) - else: - # if we are sure that the sumlist is complete, jump there directly + #if self.scan_active: + # if we are still walking the tree, FORCE a new scan on the path + # because we CANNOT guarantee that the path we point at is ready. + # self.open_folder(f.path) - self.folder_memory[self.uri] = self.data # remember current data + #else: + # if we are sure that the sumlist is complete, jump there directly # block filechooser callbacks while changing it - self.filechooserbutton.handler_block(self.filechooserbutton.handler_folderchanged) - self.uri = f.path - self.__event_walker_progress(None,f.sumlist) - self.filechooserbutton.set_current_folder_uri(f.path) - self.filechooserbutton.handler_unblock(self.filechooserbutton.handler_folderchanged) + # self.filechooserbutton.handler_block(self.filechooserbutton.handler_folderchanged) + # self.uri = f.path + # self.__event_walker_progress(None,f.sumlist) + # self.filechooserbutton.set_current_folder_uri(f.path) + # self.filechooserbutton.handler_unblock(self.filechooserbutton.handler_folderchanged) def __event_scroll(self, widget, event): if event.direction is gtk.gdk.SCROLL_UP: |