53 |
(*************************************************************************) |
(*************************************************************************) |
54 |
|
|
55 |
let (downloaders : int list ref) = ref [] |
let (downloaders : int list ref) = ref [] |
56 |
|
let current_selection = ref [] |
57 |
|
|
58 |
(*************************************************************************) |
(*************************************************************************) |
59 |
(* *) |
(* *) |
63 |
|
|
64 |
let downloaders_timerID = ref (GMain.Timeout.add ~ms:2000 ~callback:(fun _ -> true)) |
let downloaders_timerID = ref (GMain.Timeout.add ~ms:2000 ~callback:(fun _ -> true)) |
65 |
let (view_context : GPango.context option ref) = ref None |
let (view_context : GPango.context option ref) = ref None |
66 |
let (razorback_progress_box : (GMisc.label * GRange.progress_bar) option ref) = ref None |
let (razorback_boxes : (GPack.box * GPack.box * GMisc.label * GRange.progress_bar) option ref) = ref None |
67 |
let interested_in_sources = ref false |
let interested_in_sources = ref false |
68 |
let expanded_rows = ref 0 |
let expanded_rows = ref 0 |
69 |
|
|
985 |
GuiCom.send (GetFile_info f.g_file_num) |
GuiCom.send (GetFile_info f.g_file_num) |
986 |
) files |
) files |
987 |
|
|
988 |
|
let show_razorback_stats file (hbox_stats : GPack.box) (hbox_progress : GPack.box) = |
989 |
|
match file.g_file_razorback_stats with |
990 |
|
None -> |
991 |
|
begin |
992 |
|
List.iter (fun w -> w#destroy ()) hbox_stats#children; |
993 |
|
List.iter (fun w -> w#misc#hide ()) hbox_progress#children; |
994 |
|
end |
995 |
|
| Some stats -> |
996 |
|
begin |
997 |
|
try |
998 |
|
List.iter (fun w -> w#destroy ()) hbox_stats#children; |
999 |
|
List.iter (fun w -> w#misc#hide ()) hbox_progress#children; |
1000 |
|
let filename = stats.razorback_file_history in |
1001 |
|
let pixb = GdkPixbuf.from_file filename in |
1002 |
|
let razorback_history = |
1003 |
|
GMisc.image ~packing:(hbox_stats#pack ~expand:false ~fill:true) () |
1004 |
|
in |
1005 |
|
let vbox_razorback_stats = |
1006 |
|
GPack.vbox ~homogeneous:false ~border_width:6 ~spacing:12 |
1007 |
|
~packing:(hbox_stats#pack ~expand:false ~fill:true) () |
1008 |
|
in |
1009 |
|
let label_rating = |
1010 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1011 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1012 |
|
in |
1013 |
|
let label_availability = |
1014 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1015 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1016 |
|
in |
1017 |
|
let label_completed = |
1018 |
|
GMisc.label ~xalign:0. ~yalign:0. |
1019 |
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
1020 |
|
in |
1021 |
|
let rating = U.utf8_of ( |
1022 |
|
Printf.sprintf "%s %s" |
1023 |
|
!M.dT_lb_razorback2_stats_rate stats.razorback_file_rating) in |
1024 |
|
let availability = U.utf8_of ( |
1025 |
|
Printf.sprintf "%s %d" |
1026 |
|
!M.dT_lb_razorback2_stats_available stats.razorback_file_avalaibility) in |
1027 |
|
let completed = U.utf8_of ( |
1028 |
|
Printf.sprintf "%s %d" |
1029 |
|
!M.dT_lb_razorback2_stats_complete stats.razorback_file_completed) in |
1030 |
|
razorback_history#set_pixbuf pixb; |
1031 |
|
label_rating#set_label rating; |
1032 |
|
label_availability#set_label availability; |
1033 |
|
label_completed#set_label completed |
1034 |
|
with _ -> () |
1035 |
|
end |
1036 |
|
|
1037 |
let razorback2_stats k () = |
let razorback2_stats k () = |
1038 |
try |
try |
1039 |
let file = file_of_key k in |
let file = file_of_key k in |
1040 |
|
let on_completed () = |
1041 |
|
match !current_selection with |
1042 |
|
key :: _ when key = k -> |
1043 |
|
begin |
1044 |
|
match !razorback_boxes with |
1045 |
|
Some (hbox_stats, hbox_progress, label, pbar) -> |
1046 |
|
begin |
1047 |
|
match file.g_file_razorback_stats with |
1048 |
|
Some stats -> |
1049 |
|
begin |
1050 |
|
if Sys.file_exists stats.razorback_file_history |
1051 |
|
then begin |
1052 |
|
show_razorback_stats file hbox_stats hbox_progress |
1053 |
|
end |
1054 |
|
end |
1055 |
|
| None -> () |
1056 |
|
end |
1057 |
|
| None -> () |
1058 |
|
end |
1059 |
|
| _ -> () |
1060 |
|
in |
1061 |
let t1 = ref 0. in |
let t1 = ref 0. in |
1062 |
let t2 = ref 0. in |
let t2 = ref 0. in |
1063 |
let progress t md4 desc n m = |
let progress t md4 desc n m = |
1071 |
in |
in |
1072 |
let v = int_of_float (p *. 100.) in |
let v = int_of_float (p *. 100.) in |
1073 |
let percent = U.simple_utf8_of (Printf.sprintf "%d%%" v) in |
let percent = U.simple_utf8_of (Printf.sprintf "%d%%" v) in |
1074 |
Printf2.lprintf_nl2 "%s: %s" s percent; |
(if !!verbose then lprintf' "%s: %s\n" s percent); |
1075 |
match !razorback_progress_box with |
match !razorback_boxes with |
1076 |
Some (label, pbar) -> |
Some (hbox_stats, hbox_progress, label, pbar) -> |
1077 |
begin |
begin |
1078 |
label#set_label s; |
label#set_label s; |
1079 |
pbar#set_fraction p; |
pbar#set_fraction p; |
1080 |
pbar#set_text percent; |
pbar#set_text percent; |
1081 |
label#misc#show (); |
label#misc#show (); |
1082 |
pbar#misc#show () |
pbar#misc#show (); |
1083 |
end |
end |
1084 |
| _ -> () |
| _ -> () |
1085 |
in |
in |
1086 |
GuiHtml.get_razorback2_stats file (progress t1) (progress t2) |
GuiHtml.get_razorback2_stats file (progress t1) on_completed (progress t2) |
1087 |
with _ -> () |
with _ -> () |
1088 |
|
|
1089 |
|
|
1090 |
(*************************************************************************) |
(*************************************************************************) |
1091 |
(* *) |
(* *) |
1092 |
(* Download Menu *) |
(* Download Menu *) |
1229 |
let clear () = |
let clear () = |
1230 |
downloadstore#clear (); |
downloadstore#clear (); |
1231 |
downloaders := []; |
downloaders := []; |
1232 |
|
current_selection := []; |
1233 |
expanded_rows := 0; |
expanded_rows := 0; |
1234 |
clean_avail_bars () |
clean_avail_bars () |
1235 |
|
|
1443 |
ignore (vbox#connect#destroy ~callback: |
ignore (vbox#connect#destroy ~callback: |
1444 |
(fun _ -> |
(fun _ -> |
1445 |
view_context := None; |
view_context := None; |
1446 |
razorback_progress_box := None; |
razorback_boxes := None; |
1447 |
|
current_selection := []; |
1448 |
expanded_rows := 0; |
expanded_rows := 0; |
1449 |
Timeout.remove (!downloaders_timerID) |
Timeout.remove (!downloaders_timerID) |
1450 |
)); |
)); |
1483 |
GRange.progress_bar ~pulse_step:0.01 ~show:false |
GRange.progress_bar ~pulse_step:0.01 ~show:false |
1484 |
~packing:(hbox_razorback_progress#pack ~expand:false ~fill:true) () |
~packing:(hbox_razorback_progress#pack ~expand:false ~fill:true) () |
1485 |
in |
in |
1486 |
razorback_progress_box := Some (label_razorback_progress, pbar_razorback_progress); |
razorback_boxes := Some (hbox_razorback_stats, hbox_razorback_progress, |
1487 |
|
label_razorback_progress, pbar_razorback_progress); |
1488 |
let on_select_files keys = |
let on_select_files keys = |
1489 |
|
current_selection := keys; |
1490 |
match keys with |
match keys with |
1491 |
k :: _ when (is_file k) -> |
k :: _ when (is_file k) -> |
1492 |
begin |
begin |
1493 |
try |
try |
1494 |
let file = file_of_key k in |
let file = file_of_key k in |
1495 |
match file.g_file_razorback_stats with |
show_razorback_stats file hbox_razorback_stats hbox_razorback_progress |
|
None -> |
|
|
begin |
|
|
List.iter (fun w -> w#destroy ()) hbox_razorback_stats#children; |
|
|
List.iter (fun w -> w#misc#hide ()) hbox_razorback_progress#children; |
|
|
end |
|
|
| Some stats -> |
|
|
begin |
|
|
try |
|
|
List.iter (fun w -> w#destroy ()) hbox_razorback_stats#children; |
|
|
List.iter (fun w -> w#misc#hide ()) hbox_razorback_progress#children; |
|
|
let razorback_history = |
|
|
GMisc.image ~packing:(hbox_razorback_stats#pack ~expand:false ~fill:true) () |
|
|
in |
|
|
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) () |
|
|
in |
|
|
let label_availability = |
|
|
GMisc.label ~xalign:0. ~yalign:0. |
|
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
|
|
in |
|
|
let label_completed = |
|
|
GMisc.label ~xalign:0. ~yalign:0. |
|
|
~packing:(vbox_razorback_stats#pack ~expand:false ~fill:true) () |
|
|
in |
|
|
let filename = stats.razorback_file_history in |
|
|
Printf2.lprintf_nl2 "image: %s" filename; |
|
|
let pixb = GdkPixbuf.from_file filename in |
|
|
razorback_history#set_pixbuf pixb; |
|
|
let rating = U.utf8_of ( |
|
|
Printf.sprintf "%s %s" |
|
|
!M.dT_lb_razorback2_stats_rate stats.razorback_file_rating) in |
|
|
let availability = U.utf8_of ( |
|
|
Printf.sprintf "%s %d" |
|
|
!M.dT_lb_razorback2_stats_available stats.razorback_file_avalaibility) in |
|
|
let completed = U.utf8_of ( |
|
|
Printf.sprintf "%s %d" |
|
|
!M.dT_lb_razorback2_stats_complete stats.razorback_file_completed) in |
|
|
label_rating#set_label rating; |
|
|
label_availability#set_label availability; |
|
|
label_completed#set_label completed |
|
|
with _ -> () |
|
|
end |
|
1496 |
with _ -> () |
with _ -> () |
1497 |
end |
end |
1498 |
| _ -> () |
| _ -> () |