svg_converted: fix build (zlib2 split)
[mldonkey.git] / src / gtk / gui / gui_global.ml
blob77fec8a5f73232f167ab19efe8b6dab8347a07ec
1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
2 (*
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 open Printf2
21 (** Global variables. *)
23 (** Number of known servers. *)
24 let nservers = ref 0
26 (** Number of connected servers. *)
27 let nconnected_servers = ref 0
29 (** Number of friends. *)
30 let nfriends = ref 0
32 (** Number of query results. *)
33 let nresults = ref 0
35 (** Number of locations for selected downloading file. *)
36 let nlocations = ref 0
38 (** Number of connected locations for selected downloading file. *)
39 let nclocations = ref 0
41 (** Number of downloaded files *)
42 let ndownloaded = ref 0
44 (** Number of downloading files *)
45 let ndownloads = ref 0
47 (** Information on locations. *)
48 let (locations : (int, GuiTypes.client_info) Hashtbl.t) = Hashtbl.create 103
50 (** Information on locations. *)
51 let (results : (int, CommonTypes.result_info) Hashtbl.t) = Hashtbl.create 103
53 (** Search counter. *)
54 let search_counter = ref 0
56 type net_info = {
57 net_num : int;
58 net_name : string;
59 mutable net_enabled : bool;
60 net_menu_item : GMenu.check_menu_item;
61 mutable net_displayed : bool;
64 let networks_filtered = ref ([] : int list)
66 open GuiTypes
68 let (networks : (int, net_info) Hashtbl.t) = Hashtbl.create 13
70 let network_name num = try
71 match (Hashtbl.find networks num).net_name with
72 | "Direct Connect" -> "DC"
73 | "Donkey" -> "eDK"
74 | "OpenFT" -> "oFT"
75 | "OpenNapster" -> "NAP"
76 | "LimeWire" -> "GTL"
77 | "Gnutella" -> "GTL"
78 | "Fasttrack" -> "FT"
79 | "Soulseek" -> "SLSK"
80 | n -> n
81 with _ -> "?"
83 let (users : (int, GuiTypes.user_info) Hashtbl.t) = Hashtbl.create 1023
86 let (client_sections : (string * (string * GuiTypes.option_widget * string) list ref) list ref) = ref []
87 let (plugins_sections : (string * (string * GuiTypes.option_widget * string) list ref) list ref) = ref []
89 type mldonkey_option = {
90 mutable option_old_value : string;
91 option_value : string ref;
94 let (options_values : (string, mldonkey_option) Hashtbl.t) = Hashtbl.create 100
96 let (availabilities : (string * file_info) Intmap.t ref
97 Intmap.t ref) = ref Intmap.empty
100 let clear () =
101 nservers := 0;
102 nconnected_servers := 0;
103 nfriends := 0;
104 nresults := 0;
105 nlocations := 0;
106 nclocations := 0;
107 ndownloads := 0;
108 ndownloaded := 0;
109 Hashtbl.clear locations;
110 Hashtbl.clear networks;
111 Hashtbl.clear results;
112 Hashtbl.clear users;
113 search_counter := 0;
114 Hashtbl.clear options_values;
115 client_sections := [];
116 plugins_sections := []
118 let console_message = ref (fun s ->
119 lprintf "CONSOLE: %s" s;
120 lprint_newline () )
123 let gtk_handler timer =
124 while Glib.Main.pending () do
125 ignore (Glib.Main.iteration false)
126 done
128 external setncnumeric : unit -> unit = "ml_setlcnumeric" "noalloc"
130 let _ =
131 ignore (GMain.Main.init ~setlocale: true ());
132 setncnumeric ();
133 BasicSocket.add_infinite_timer 0.1 gtk_handler
135 let top_menus = ref ([]: (string * (GMenu.menu -> unit)) list)
137 let scanned_ports = ref ([] : ((string * int) list))
138 let new_scanned_port = ref true
141 let networks_combo all_possible =
142 let nets = ref [] in
143 Hashtbl.iter (fun num net ->
144 if net.net_enabled then
145 nets := (net.net_name, num) :: !nets
146 ) networks;
147 let nets = if all_possible then
148 ("All Networks", 0) :: !nets
149 else !nets in
150 let wcombo = GEdit.combo
151 ~popdown_strings: (List.map fst nets)
152 ~value_in_list: true
153 ~ok_if_empty: false
154 ~width: 120 ()
156 nets, wcombo