- (* This partition occupies pixels 8+y .. 8+y+h-1 *)
- let yb = 8 + int_of_float y
- and yt = 8 + int_of_float (y +. h) in
-
- ds.draw#set_foreground `WHITE;
- ds.draw#rectangle ~x:8 ~y:yb ~width:(width-16) ~height:(yt-yb)
- ~filled:true ();
-
- let col =
- if used < 0.6 then `NAME "grey"
- else if used < 0.8 then `NAME "pink"
- else if used < 0.9 then `NAME "hot pink"
- else `NAME "red" in
- ds.draw#set_foreground col;
- let w = int_of_float (used *. (float width -. 16.)) in
- ds.draw#rectangle ~x:8 ~y:yb ~width:w ~height:(yt-yb) ~filled:true ();
-
- ds.draw#set_foreground `BLACK;
- ds.draw#rectangle ~x:8 ~y:yb ~width:(width-16) ~height:(yt-yb) ();
-
- (* Large text - the device name. *)
- let txt = ds.pango_large_context#create_layout in
- Pango.Layout.set_text txt part.Slave.pt_name;
- let fore = `NAME "dark slate grey" in
- ds.draw#put_layout ~x:12 ~y:(yb+4) ~fore txt;
-
- let { Pango.height = txtheight; Pango.width = txtwidth } =
- Pango.Layout.get_pixel_extent txt in
-
- (* Small text below - the content. *)
- let txt = ds.pango_small_context#create_layout in
- Pango.Layout.set_text txt part.Slave.pt_content;
- let fore = `BLACK in
- ds.draw#put_layout ~x:12 ~y:(yb+4+txtheight) ~fore txt;
-
- (* Small text right - size. *)
- let size =
- match part.Slave.pt_statvfs with
- | None -> printable_size part.Slave.pt_size
- | Some { G.blocks = blocks; bsize = bsize } ->
- let bytes = Int64.mul blocks bsize in
- let pc = 100. *. used in
- sprintf "%s (%.1f%% used)" (printable_size bytes) pc in
- let txt = ds.pango_small_context#create_layout in
- Pango.Layout.set_text txt size;
- ds.draw#put_layout ~x:(16+txtwidth) ~y:(yb+4) ~fore txt;
-
- (y +. h)
+ (* This partition occupies pixels 8+y .. 8+y+h-1 *)
+ let yb = 8 + int_of_float y
+ and yt = 8 + int_of_float (y +. h) in
+
+ ds.draw#set_foreground `WHITE;
+ ds.draw#rectangle ~x:8 ~y:yb ~width:(width-16) ~height:(yt-yb)
+ ~filled:true ();
+
+ let col =
+ if used < 0.6 then `NAME "grey"
+ else if used < 0.8 then `NAME "pink"
+ else if used < 0.9 then `NAME "hot pink"
+ else `NAME "red" in
+ ds.draw#set_foreground col;
+ let w = int_of_float (used *. (float width -. 16.)) in
+ ds.draw#rectangle ~x:8 ~y:yb ~width:w ~height:(yt-yb) ~filled:true ();
+
+ ds.draw#set_foreground `BLACK;
+ ds.draw#rectangle ~x:8 ~y:yb ~width:(width-16) ~height:(yt-yb) ();
+
+ (* Large text - the device name. *)
+ let txt = ds.pango_large_context#create_layout in
+ Pango.Layout.set_text txt part.Slave.pt_name;
+ let fore = `NAME "dark slate grey" in
+ ds.draw#put_layout ~x:12 ~y:(yb+4) ~fore txt;
+
+ let { Pango.height = txtheight; Pango.width = txtwidth } =
+ Pango.Layout.get_pixel_extent txt in
+
+ (* Small text below - the content. *)
+ let txt = ds.pango_small_context#create_layout in
+ Pango.Layout.set_text txt part.Slave.pt_content;
+ let fore = `BLACK in
+ ds.draw#put_layout ~x:12 ~y:(yb+4+txtheight) ~fore txt;
+
+ (* Small text right - size. *)
+ let size =
+ match part.Slave.pt_statvfs with
+ | None -> printable_size part.Slave.pt_size
+ | Some { G.blocks = blocks; bsize = bsize } ->
+ let bytes = Int64.mul blocks bsize in
+ let pc = 100. *. used in
+ sprintf "%s (%.1f%% used)" (printable_size bytes) pc in
+ let txt = ds.pango_small_context#create_layout in
+ Pango.Layout.set_text txt size;
+ ds.draw#put_layout ~x:(16+txtwidth) ~y:(yb+4) ~fore txt;
+
+ (y +. h)