summaryrefslogtreecommitdiffstats
path: root/src/fringlib/fringrenderer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fringlib/fringrenderer.py')
-rw-r--r--src/fringlib/fringrenderer.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/fringlib/fringrenderer.py b/src/fringlib/fringrenderer.py
index 1f27de0..0f71f8a 100644
--- a/src/fringlib/fringrenderer.py
+++ b/src/fringlib/fringrenderer.py
@@ -1,7 +1,6 @@
import cairo
import pango
from math import *
-from fringwalker import sum_list
from fringutil import *
import os
@@ -51,7 +50,11 @@ class FringRenderer:
def draw_segment(self,ctx, ring, start_angle, end_angle, start_hue, end_hue, data, previouspath=""):
- assert isinstance(data, sum_list)
+ if data is None: return
+
+ dataname = data[0]
+ datacontents = data[1]
+ datasize = data[2]
if ring == 0:
self.lookup_data = []
@@ -63,24 +66,29 @@ class FringRenderer:
CENTERX, CENTERY = self.WIDTH/2, self.HEIGHT/2
ctx.move_to(CENTERX, CENTERY)
- n = len(data.data)
+ n = len(datacontents)
i = 0
accumulated = 0
last = start_angle
- for fn, d in data.data:
+ if datacontents is None: return
+ for fn, contents, d in datacontents:
+
+ if contents == None: hasContents = False
+ else: hasContents = True
+
start = last
- value = self._list_value(d)
+ value = d # third tuple element now *always* contains the size
accumulated += value
-
- if data.the_sum == 0: continue
- end = start_angle+(end_angle - start_angle)*1.0*accumulated/data.the_sum
+
+ if datasize == 0: continue
+ end = start_angle+(end_angle - start_angle)*1.0*accumulated/datasize
if end-start >= .01:
p = previouspath+os.sep+fn
- self.lookup_data[ring].append(Segment(isinstance(d, sum_list), p, value, start, end))
+ self.lookup_data[ring].append( Segment(hasContents , p, value, start, end) )
v = start_hue + (end_hue-start_hue)*1.0*i/n
color = self._choose_color(start_hue + (end_hue-start_hue)*1.0*i/n, ring)
@@ -98,9 +106,9 @@ class FringRenderer:
ctx.set_source_rgb(0, 0, 0)
ctx.stroke()
- if isinstance(d, sum_list) and ring+1 < self.RINGS_MAX:
+ if hasContents and ring+1 < self.RINGS_MAX:
self.draw_segment(ctx, ring+1, start, end, v,
- start_hue + (end_hue-start_hue)*1.0*(i+1)/n, d,
+ start_hue + (end_hue-start_hue)*1.0*(i+1)/n, (fn, contents, d),
previouspath+os.sep+fn)
r += self.RING_RADIUS/2
@@ -135,7 +143,7 @@ class FringRenderer:
ctx.move_to(x+xmod,y)
# draw the side link label
- if isinstance(d, sum_list):
+ if hasContents:
ctx.set_source_rgb(0,0,1)
width,height = self._draw_centered_text(ctx, fn + "/", align_x)
else:
@@ -145,7 +153,7 @@ class FringRenderer:
if align_x == 0:
width *= -1
- self.__register_side_link(isinstance(d, sum_list),p,value,end-start,x,y+(height/2),x+(width),y-(height/2))
+ self.__register_side_link(hasContents,p,value,end-start,x,y+(height/2),x+(width),y-(height/2))
# write disk usage on segments
if self.RING_RADIUS >= ctx.text_extents("55%")[3]:
@@ -161,7 +169,7 @@ class FringRenderer:
if ring == 0:
ctx.set_source_rgb(.3,.3,.3)
- i = format_disk_space(data.the_sum)
+ i = format_disk_space(datasize)
ctx.move_to(CENTERX, CENTERY)
width,height = self._draw_centered_text(ctx, i[0], .5, 1 )
ctx.move_to(CENTERX, CENTERY+height)
@@ -243,10 +251,6 @@ class FringRenderer:
(t,p,v),
(v,p,q))[int(h)]
- def _list_value(self,l):
- if isinstance(l, sum_list):
- return l.the_sum
- return l
def _choose_color(self,v, ring):
color = self.hsv2rgb(v, .61, 1-ring*0.1)