/[mldonkey]/mldonkey/src/gtk2/gui/guiGlobal.ml
ViewVC logotype

Diff of /mldonkey/src/gtk2/gui/guiGlobal.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by spiralvoice, Wed Mar 2 19:45:11 2005 UTC revision 1.2 by spiralvoice, Mon Oct 31 18:34:02 2005 UTC
# Line 32  let (=:=) = Options.(=:=) Line 32  let (=:=) = Options.(=:=)
32  (* The name of the client given by MLnet. *)  (* The name of the client given by MLnet. *)
33  let client_name = ref ""  let client_name = ref ""
34    
35    (* The max download rate of the client given by MLnet in ko/s. *)
36    let max_hard_download_rate = ref 64
37    
38    (* The max upload rate of the client given by MLnet in ko/s. *)
39    let max_hard_upload_rate = ref 16
40    
41    (* The time between updates of the client given by MLnet in ms. *)
42    let update_gui_delay = ref 1000
43    
44  (* Number of known servers. *)  (* Number of known servers. *)
45  let nservers = ref 0  let nservers = ref 0
46    
# Line 63  let interested_in_sources_version = 27 Line 72  let interested_in_sources_version = 27
72  (*                                                                       *)  (*                                                                       *)
73  (*************************************************************************)  (*************************************************************************)
74    
 (* Information on networks. *)  
75  let networks_filtered = ref ([] : int list)  let networks_filtered = ref ([] : int list)
76    
77  let (networks : (int, GuiTypes2.net_info) Hashtbl.t) = Hashtbl.create 13  let (networks : (int, GuiTypes2.net_info) Hashtbl.t) = Hashtbl.create 13
78    
79  (* Information on clients. *)  let (files : (int, GuiTypes2.g_file_info) Hashtbl.t) = Hashtbl.create 27
 let (sources : (int, GuiTypes2.source_info) Hashtbl.t) = Hashtbl.create 1023  
80    
81  let (results : (int, GuiTypes2.res_info) Hashtbl.t) = Hashtbl.create 103  let (servers : (int, GuiTypes.server_info) Hashtbl.t) = Hashtbl.create 207
82    
83    let (rooms : (int, GuiTypes.room_info) Hashtbl.t) = Hashtbl.create 207
84    
85    let (sources : (int, GuiTypes2.source_info) Hashtbl.t) = Hashtbl.create 1023
86    
87    let (results : (int, GuiTypes2.res_info) Hashtbl.t) = Hashtbl.create 1023
88    
 (* Information on users. *)  
89  let (users : (int, GuiTypes.user_info) Hashtbl.t) = Hashtbl.create 1023  let (users : (int, GuiTypes.user_info) Hashtbl.t) = Hashtbl.create 1023
90    
91    let (shared_files : (int, GuiTypes2.shared_file) Hashtbl.t) = Hashtbl.create 103
92    
93    let (file_by_uid : (CommonTypes.uid_type, string) Hashtbl.t) = Hashtbl.create 103
94    
95  (*************************************************************************)  (*************************************************************************)
96  (*                                                                       *)  (*                                                                       *)
97  (*                         Global functions                              *)  (*                         Global functions                              *)
# Line 92  let clear () = Line 107  let clear () =
107    search_counter := 0;    search_counter := 0;
108    use_interested_in_sources := false;    use_interested_in_sources := false;
109  (* tables    *)  (* tables    *)
   
110    Hashtbl.clear networks;    Hashtbl.clear networks;
111      Hashtbl.clear files;
112      Hashtbl.clear servers;
113      Hashtbl.clear rooms;
114    Hashtbl.clear sources;    Hashtbl.clear sources;
115    Hashtbl.clear results;    Hashtbl.clear results;
116    Hashtbl.clear users    Hashtbl.clear users;
117      Hashtbl.clear shared_files;
118      Hashtbl.clear file_by_uid;
119      Gc.compact ()
120    
121  let console_message = ref (fun s ->  let console_message = ref (fun s ->
122        lprintf "CONSOLE: %s" s;        lprintf "CONSOLE: %s" s;
# Line 110  let gtk_handler timer = Line 129  let gtk_handler timer =
129    done    done
130    
131  external setncnumeric : unit -> unit = "ml_setlcnumeric" "noalloc"  external setncnumeric : unit -> unit = "ml_setlcnumeric" "noalloc"
132        
133  let _ =  let _ =
134    ignore (GMain.Main.init ~setlocale: true ());    ignore (GMain.Main.init ~setlocale: true ());
135    setncnumeric ();    setncnumeric ();
# Line 124  let get_metrics_from_gtk_font_list () = Line 143  let get_metrics_from_gtk_font_list () =
143    label#misc#modify_font (Pango.Font.from_string !!O.gtk_font_list);    label#misc#modify_font (Pango.Font.from_string !!O.gtk_font_list);
144    let font_metrics = label#misc#pango_context#get_metrics () in    let font_metrics = label#misc#pango_context#get_metrics () in
145    char_width := GPango.to_pixels font_metrics#approx_char_width;    char_width := GPango.to_pixels font_metrics#approx_char_width;
146    digit_width := GPango.to_pixels font_metrics#approx_digit_width;    digit_width := GPango.to_pixels font_metrics#approx_digit_width
   Printf.printf "char_width : %d digit_width : %d\n" !char_width !digit_width;  
   flush stdout  
147    
148  let get_files = ref (fun (l : int list) -> ([] : GuiTypes.file_info list))  let get_files list =
149      let l = ref [] in
150      List.iter (fun file_num ->
151        try
152          let f = Hashtbl.find files file_num in
153          l := f :: !l
154        with _ -> ()
155      ) list;
156      !l
157    
158  let is_docked = ref false  let is_docked = ref false
159    
# Line 141  let (tray : GuiTypes2.tray) = Line 166  let (tray : GuiTypes2.tray) =
166    }    }
167    
168  let (set_systray_callback : ((GuiTypes2.button_types -> unit) -> unit) ref) = ref (fun _ -> ())  let (set_systray_callback : ((GuiTypes2.button_types -> unit) -> unit) ref) = ref (fun _ -> ())
169    
170    open GuiTypes2
171    open CommonTypes
172    
173    let check_usefull_source s =
174      let is_not_source = if s.source_files_requested = [] then true else false in
175      let is_not_friend = if client_browsed_tag land s.source_type = 0 then false else true in
176      let is_not_uploader = if source_only land s.source_has_upload = 1 then true else false in
177      if is_not_source && is_not_friend && is_not_uploader
178        then (Hashtbl.remove sources s.source_num; false)
179        else true
180    
181    
182    let hashtbl_update_sources s s_new =
183      s.source_kind <- s_new.source_kind;
184      s.source_state <- s_new.source_state;
185      s.source_type <- s_new.source_type;
186      s.source_tags <- s_new.source_tags;
187      s.source_name <- s_new.source_name;
188      s.source_files <- s_new.source_files;
189      s.source_rating <- s_new.source_rating;
190      s.source_chat_port <- s_new.source_chat_port;
191      s.source_connect_time <- s_new.source_connect_time;
192      s.source_last_seen <- s_new.source_last_seen;
193      s.source_software <- s_new.source_software;
194      s.source_downloaded <- s_new.source_downloaded;
195      s.source_uploaded <- s_new.source_uploaded;
196      s.source_upload_rate <- s_new.source_upload_rate;
197      s.source_download_rate <- s_new.source_download_rate;
198      s.source_upload <- s_new.source_upload;
199      s.source_has_upload <- s_new.source_has_upload;
200      s.source_availability <- s_new.source_availability;
201      s.source_files_requested <- s_new.source_files_requested

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26