summaryrefslogtreecommitdiffstats
path: root/src/fringlib/fringui.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fringlib/fringui.py')
-rw-r--r--src/fringlib/fringui.py78
1 files changed, 37 insertions, 41 deletions
diff --git a/src/fringlib/fringui.py b/src/fringlib/fringui.py
index a6c606d..068fd97 100644
--- a/src/fringlib/fringui.py
+++ b/src/fringlib/fringui.py
@@ -37,14 +37,6 @@ ui = """
<separator />
<menuitem action="Quit"/>
</menu>
-
- <menu action="TreeWalker">
- <menuitem action="Python"/>
- <menuitem action="Python gnomevfs"/>
- <menuitem action="c++"/>
- </menu>
-
-
<menu action="View">
<menuitem action="Show Hidden Files"/>
<separator />
@@ -71,6 +63,7 @@ class UI( gtk.Window ):
self.zoomfactor = 1.0
self.renderer = FringRenderer()
self.walker = FringWalker();
+ self.scan_active = False
# create gui
gtk.Window.__init__(self)
@@ -91,7 +84,6 @@ class UI( gtk.Window ):
self.add_accel_group(accelgroup)
ag_global = gtk.ActionGroup('ag_global')
ag_global.add_actions([
- ('TreeWalker', None, "TreeWalker"),
('FRing', None, "_Folder"),
('View', None, "_View"),
('Help', None, "_Help"),
@@ -108,15 +100,6 @@ class UI( gtk.Window ):
action.set_active(True)
action.connect("toggled",self.__hidden_files_toggled)
ag_global.add_action(action)
-
- # add a menu with radio buttons to choose the walking method
- ag_global.add_radio_actions([
- ('Python', None, "Python", None, None, WALKER_CLASSIC),
- ('Python gnomevfs', None, "Python gnomevfs", None, None, WALKER_GNOMEVFS),
- ('c++', None, "c++", None, None, WALKER_CPP),
- ], 1)
- self.methodaction = ag_global.get_action("c++")
-
uimanager.insert_action_group(ag_global, 0)
uimanager.add_ui_from_string(ui)
menubar = uimanager.get_widget('/MenuBar')
@@ -130,6 +113,8 @@ class UI( gtk.Window ):
b.set_property("image", img)
uimanager.get_action("/MenuBar/FRing/OpenParent").connect_proxy(b)
toolbar.pack_start( b, False )
+ b.connect("enter-notify-event",self.__enter_parent_button)
+ b.connect("leave-notify-event",self.__leave_parent_button)
b = gtk.FileChooserButton('Select a Folder')
b.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
@@ -194,9 +179,7 @@ class UI( gtk.Window ):
gtk.main_quit()
def open_parent(self,widget):
- p = os.path.split(self.uri)
- p = os.path.join(p[:-1])
- self.open_folder(p[0])
+ self.open_folder(self.__get_parent(self.uri))
def zoom(self,widget,factor):
self.zoomfactor += factor
@@ -242,12 +225,19 @@ class UI( gtk.Window ):
#----------------------------------------------------------- private methods
+ def __get_parent(self,uri):
+ """ Get the parent folder from an uri """
+ p = os.path.split(uri)
+ p = os.path.join(p[:-1])
+ return p[0]
+
def __set_uri(self,uri):
""" Set a path and start parsing. Also used to refresh or reset. """
self.uri = uri
self.walker.stop()
if uri:
- self.walker.walk(uri,self.methodaction.get_current_value())
+ self.walker.walk(uri)
+ self.scan_active = True
self.__show_busy_cursor(1)
def __selectfolder(self,widget):
@@ -263,27 +253,30 @@ class UI( gtk.Window ):
self.walker.showhidden = widget.get_active()
self.__set_uri(self.uri)
- def __move_event(self, widget, event):
-
+ def __move_event(self, widget, event):
f = self.renderer.get_hotspot_at(event.x, event.y)
- if f is None:
- self.label.set_text("Ready.")
- else:
- self.label.set_markup("Path <b>%s</b>, %s, %0.1f%%" % (f.path, pretty_size(f.size), f.value*100))
+ self.label.set_text("")
+ if f:
+
+ markup = "<b>%s</b>, %s, %0.1f%%" % (f.path, pretty_size(f.sumlist.size), f.value*100)
+ self.label.set_markup(markup)
- if f is None or not f.is_dir:
- if self.busy_cursor > 0: cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
- else: cursor = None
- self.eventbox.window.set_cursor(cursor)
- else:
- # always display a hand when hovering a link
- self.eventbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+ if f.sumlist.children is not None:
+ self.eventbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+ return
+
+ self.eventbox.window.set_cursor(None)
def __click_event(self, widget, event):
f = self.renderer.get_hotspot_at(event.x, event.y)
- if f is not None:
- if f.is_dir:
- self.open_folder(f.path)
+ 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.__set_uri(f.path)
+ #else:
+ # if we are sure that the sumlist is complete, jump there directly
+ #self.__list_changed(None,f.sumlist)
def __scroll_event(self, widget, event):
if event.direction is gtk.gdk.SCROLL_UP:
@@ -306,11 +299,11 @@ class UI( gtk.Window ):
def __list_changed(self,widget,data):
self.data = data
self.redraw()
- #print data.name
def __walker_finished(self, widget, data):
self.__list_changed(widget, data)
self.__show_busy_cursor(-1)
+ self.scan_active = False
def __on_resize(self, widget, event):
r = self.eventbox.get_allocation()
@@ -321,13 +314,16 @@ class UI( gtk.Window ):
def __show_busy_cursor(self, value):
if self.busy_cursor <= 0 and self.busy_cursor+value >= 0:
if self.window: self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
- self.label.set_markup("Busy...")
elif self.busy_cursor > 0 and self.busy_cursor+value <= 0:
if self.window: self.window.set_cursor(None)
- self.label.set_text("Ready.")
self.busy_cursor += value
#print "busy state:",self.busy_cursor
+ def __enter_parent_button(self,widget,event):
+ markup = "<b>%s</b>" %self.__get_parent(self.uri)
+ self.label.set_markup(markup)
+ def __leave_parent_button(self,widget,event):
+ self.label.set_markup("")