62 |
|
|
63 |
let downloaders_timerID = ref (GMain.Timeout.add ~ms:2000 ~callback:(fun _ -> true)) |
let downloaders_timerID = ref (GMain.Timeout.add ~ms:2000 ~callback:(fun _ -> true)) |
64 |
let (view_context : GPango.context option ref) = ref None |
let (view_context : GPango.context option ref) = ref None |
65 |
|
let (razorback_progress_box : (GMisc.label * GRange.progress_bar) option ref) = ref None |
66 |
let interested_in_sources = ref false |
let interested_in_sources = ref false |
67 |
let expanded_rows = ref 0 |
let expanded_rows = ref 0 |
68 |
|
|
560 |
Some pb when width > 0 -> |
Some pb when width > 0 -> |
561 |
begin |
begin |
562 |
let w = GdkPixbuf.get_width pb in |
let w = GdkPixbuf.get_width pb in |
563 |
let pixb = GdkPixbuf.create ~width ~height ~has_alpha:false () in |
let pixb = GdkPixbuf.create ~width ~height ~has_alpha:true () in |
564 |
let scale_x = (float_of_int width) /. (float_of_int w) in |
let scale_x = (float_of_int width) /. (float_of_int w) in |
565 |
(if !!verbose then lprintf' "Resizing pixbuf using scale %5.2f width:%d old_width:%d\n" |
(if !!verbose then lprintf' "Resizing pixbuf using scale %5.2f width:%d old_width:%d\n" |
566 |
scale_x width w); |
scale_x width w); |
988 |
let razorback2_stats k () = |
let razorback2_stats k () = |
989 |
try |
try |
990 |
let file = file_of_key k in |
let file = file_of_key k in |
991 |
GuiHtml.get_razorback2_stats file |
let t1 = ref 0. in |
992 |
|
let t2 = ref 0. in |
993 |
|
let progress t md4 desc n m = |
994 |
|
let s = U.utf8_of (Printf.sprintf "%s %s:" desc md4) in |
995 |
|
let tt = !t in |
996 |
|
t := !t +. float_of_int n; |
997 |
|
let p = |
998 |
|
if m > 0 |
999 |
|
then min 1. (!t /. float_of_int m) |
1000 |
|
else if !t > 0. then tt /. !t else 0. |
1001 |
|
in |
1002 |
|
let v = int_of_float (p *. 100.) in |
1003 |
|
let percent = U.simple_utf8_of (Printf.sprintf "%d%%" v) in |
1004 |
|
Printf2.lprintf_nl2 "%s: %s" s percent; |
1005 |
|
match !razorback_progress_box with |
1006 |
|
Some (label, pbar) -> |
1007 |
|
begin |
1008 |
|
label#set_label s; |
1009 |
|
pbar#set_fraction p; |
1010 |
|
pbar#set_text percent; |
1011 |
|
label#misc#show (); |
1012 |
|
pbar#misc#show () |
1013 |
|
end |
1014 |
|
| _ -> () |
1015 |
|
in |
1016 |
|
GuiHtml.get_razorback2_stats file (progress t1) (progress t2) |
1017 |
with _ -> () |
with _ -> () |
1018 |
|
|
1019 |
(*************************************************************************) |
(*************************************************************************) |
1371 |
ignore (vbox#connect#destroy ~callback: |
ignore (vbox#connect#destroy ~callback: |
1372 |
(fun _ -> |
(fun _ -> |
1373 |
view_context := None; |
view_context := None; |
1374 |
|
razorback_progress_box := None; |
1375 |
expanded_rows := 0; |
expanded_rows := 0; |
1376 |
Timeout.remove (!downloaders_timerID) |
Timeout.remove (!downloaders_timerID) |
1377 |
)); |
)); |
1395 |
~packing:(vbox#pack ~expand:true ~fill:true) () |
~packing:(vbox#pack ~expand:true ~fill:true) () |
1396 |
in |
in |
1397 |
let hbox_razorback_stats = |
let hbox_razorback_stats = |
1398 |
GPack.hbox ~homogeneous:false ~border_width:6 |
GPack.hbox ~homogeneous:false ~border_width:6 ~spacing:12 |
|
~spacing:12 |
|
1399 |
~packing:(vbox#pack ~expand:false ~fill:true) () |
~packing:(vbox#pack ~expand:false ~fill:true) () |
1400 |
in |
in |
1401 |
let razorback_history = |
let hbox_razorback_progress = |
1402 |
GMisc.image ~packing:(hbox_razorback_stats#pack ~expand:false ~fill:true) () |
GPack.hbox ~homogeneous:false ~border_width:6 ~spacing:12 |
1403 |
in |
~packing:(vbox#pack ~expand:false ~fill:true) () |
|
let vbox_razorback_stats = |
|
|
GPack.vbox ~homogeneous:false ~border_width:6 |
|
|
~spacing:12 |
|
|
~packing:(hbox_razorback_stats#pack ~expand:false ~fill:true) () |
|
|
in |
|
|
let label_rating = |
|
|
GMisc.label ~xalign:0. ~yalign:0. |
|
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
|
1404 |
in |
in |
1405 |
let label_availability = |
let label_razorback_progress = |
1406 |
GMisc.label ~xalign:0. ~yalign:0. |
GMisc.label ~xalign:0. ~yalign:0.5 ~show:false |
1407 |
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
~packing:(hbox_razorback_progress#pack ~expand:false ~fill:true) () |
1408 |
in |
in |
1409 |
let label_completed = |
let pbar_razorback_progress = |
1410 |
GMisc.label ~xalign:0. ~yalign:0. |
GRange.progress_bar ~pulse_step:0.01 ~show:false |
1411 |
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
~packing:(hbox_razorback_progress#pack ~expand:false ~fill:true) () |
1412 |
in |
in |
1413 |
|
razorback_progress_box := Some (label_razorback_progress, pbar_razorback_progress); |
1414 |
let on_select_files keys = |
let on_select_files keys = |
1415 |
match keys with |
match keys with |
1416 |
k :: _ when (is_file k) -> |
k :: _ when (is_file k) -> |
1420 |
match file.g_file_razorback_stats with |
match file.g_file_razorback_stats with |
1421 |
None -> |
None -> |
1422 |
begin |
begin |
1423 |
let pixb = A.get_icon ~icon:M.icon_mime_unknown ~size:A.LARGE () in |
List.iter (fun w -> w#destroy ()) hbox_razorback_stats#children; |
1424 |
razorback_history#set_pixbuf pixb; |
List.iter (fun w -> w#misc#hide ()) hbox_razorback_progress#children; |
|
label_rating#set_label "Razorback Stats not available" |
|
1425 |
end |
end |
1426 |
| Some stats -> |
| Some stats -> |
1427 |
begin |
begin |
1428 |
try |
try |
1429 |
|
List.iter (fun w -> w#destroy ()) hbox_razorback_stats#children; |
1430 |
|
List.iter (fun w -> w#misc#hide ()) hbox_razorback_progress#children; |
1431 |
|
let razorback_history = |
1432 |
|
GMisc.image ~packing:(hbox_razorback_stats#pack ~expand:false ~fill:true) () |
1433 |
|
in |
1434 |
|
let vbox_razorback_stats = |
1435 |
|
GPack.vbox ~homogeneous:false ~border_width:6 ~spacing:12 |
1436 |
|
~packing:(hbox_razorback_stats#pack ~expand:false ~fill:true) () |
1437 |
|
in |
1438 |
|
let label_rating = |
1439 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1440 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1441 |
|
in |
1442 |
|
let label_availability = |
1443 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1444 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1445 |
|
in |
1446 |
|
let label_completed = |
1447 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1448 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1449 |
|
in |
1450 |
let filename = stats.razorback_file_history in |
let filename = stats.razorback_file_history in |
1451 |
Printf2.lprintf_nl2 "image: %s" filename; |
Printf2.lprintf_nl2 "image: %s" filename; |
1452 |
let pixb = GdkPixbuf.from_file filename in |
let pixb = GdkPixbuf.from_file filename in |
1453 |
razorback_history#set_pixbuf pixb; |
razorback_history#set_pixbuf pixb; |
1454 |
label_rating#set_label (Printf.sprintf "Rating: %s" stats.razorback_file_rating); |
let rating = U.utf8_of ( |
1455 |
label_availability#set_label (Printf.sprintf "Available: %d" stats.razorback_file_avalaibility); |
Printf.sprintf "%s %s" |
1456 |
label_completed#set_label (Printf.sprintf "Completed: %d" stats.razorback_file_completed); |
!M.dT_lb_razorback2_stats_rate stats.razorback_file_rating) in |
1457 |
GuiHtml.get_razorback2_stats file |
let availability = U.utf8_of ( |
1458 |
|
Printf.sprintf "%s %d" |
1459 |
|
!M.dT_lb_razorback2_stats_available stats.razorback_file_avalaibility) in |
1460 |
|
let completed = U.utf8_of ( |
1461 |
|
Printf.sprintf "%s %d" |
1462 |
|
!M.dT_lb_razorback2_stats_complete stats.razorback_file_completed) in |
1463 |
|
label_rating#set_label rating; |
1464 |
|
label_availability#set_label availability; |
1465 |
|
label_completed#set_label completed |
1466 |
with _ -> () |
with _ -> () |
1467 |
end |
end |
1468 |
with _ -> () |
with _ -> () |