patch #7318
[mldonkey.git] / src / gtk / newgui / gui_window_base.ml
blob4a72eb81961776186a5c85e8df2ae5c16ff4696f
2 open Gettext
4 module M = Gui_messages
6 (* icon_on icon_off menu_icon wlabel *)
8 let main_nbk_data =
10 (M.o_xpm_nbk_networks_on, M.o_xpm_nbk_networks_off, M.o_xpm_nbk_networks_menu, M.mW_lb_networks);
11 (M.o_xpm_nbk_servers_on, M.o_xpm_nbk_servers_off, M.o_xpm_nbk_servers_menu, M.mW_lb_servers);
12 (M.o_xpm_nbk_downloads_on, M.o_xpm_nbk_downloads_off, M.o_xpm_nbk_downloads_menu, M.mW_lb_downloads);
13 (M.o_xpm_nbk_friends_on, M.o_xpm_nbk_friends_off, M.o_xpm_nbk_friends_menu, M.mW_lb_friends);
14 (M.o_xpm_nbk_search_on, M.o_xpm_nbk_search_off, M.o_xpm_nbk_search_menu, M.mW_lb_search);
15 (M.o_xpm_nbk_rooms_on, M.o_xpm_nbk_rooms_off, M.o_xpm_nbk_rooms_menu, M.mW_lb_rooms);
16 (M.o_xpm_nbk_uploads_on, M.o_xpm_nbk_uploads_off, M.o_xpm_nbk_uploads_menu, M.mW_lb_uploads);
17 (M.o_xpm_nbk_console_on, M.o_xpm_nbk_console_off, M.o_xpm_nbk_console_menu, M.mW_lb_console);
18 (M.o_xpm_nbk_graphs_on, M.o_xpm_nbk_graphs_off, M.o_xpm_nbk_graphs_menu, M.mW_lb_graph);
21 let tab_box n str data =
22 let (icon_on, icon_off, _, wlabel) = List.nth data n in
23 let wpix = if str then icon_on else icon_off in
24 let hbox = GPack.hbox ~homogeneous:false () in
25 let main_pix = Gui_options.gdk_pix wpix in
26 ignore (GMisc.pixmap main_pix ~packing:hbox#add ());
27 let label = GMisc.label ~text:wlabel ~packing:hbox#add () in
28 let style = label#misc#style#copy in
29 style#set_font (Gdk.Font.load_fontset (Options.(!!) Gui_options.font_main_tab));
30 let fg_col = if str then (Options.(!!) Gui_options.color_tab_selected)
31 else (Options.(!!) Gui_options.color_tab_not_selected)
33 style#set_fg [(`NORMAL, `NAME fg_col)];
34 label#misc#set_style style;
35 hbox
37 let menu_label_box n data =
38 let hbox = GPack.hbox ~homogeneous:false ~spacing:2 () in
39 let ( _, _, icon, menu_text) = List.nth data n in
40 let menu_pix = Gui_options.gdk_pix icon in
41 ignore (GMisc.pixmap menu_pix ~packing:hbox#pack ());
42 ignore (GMisc.label ~text:menu_text ~justify:`LEFT ~packing:hbox#pack ());
43 hbox
45 class window () =
47 let window =
48 GWindow.window ~width:(Options.( !! ) Gui_options.gui_width)
49 ~height:(Options.( !! ) Gui_options.gui_height)
50 ~title:(Gui_messages.mW_wt_software) ~allow_shrink:true ~allow_grow:true
51 ~auto_shrink:true ~modal:false ()
53 let box =
54 GPack.vbox ~homogeneous:false ~packing:(window#add) () in
55 let hbox_w = GPack.hbox ~packing:box#add () in
56 let notebook =
57 GPack.notebook ~tab_pos:(Options.( !! ) Gui_options.notebook_tab)
58 ~show_tabs:true ~homogeneous_tabs:false ~show_border:true
59 ~scrollable:true ~popup:true ~packing:(hbox_w#pack~expand:true ~fill:true) ()
61 let tab_networks = new Gui_networks.networks_box () in
62 let _ = notebook#append_page
63 ~tab_label:(tab_box 0 false main_nbk_data)#coerce
64 ~menu_label:(menu_label_box 0 main_nbk_data)#coerce
65 tab_networks#coerce
67 let tab_servers = new Gui_servers.pane_servers () in
68 let _ = notebook#append_page
69 ~tab_label:(tab_box 1 false main_nbk_data)#coerce
70 ~menu_label:(menu_label_box 1 main_nbk_data)#coerce
71 tab_servers#coerce
73 let tab_downloads = new Gui_downloads.pane_downloads () in
74 let _ = notebook#append_page
75 ~tab_label:(tab_box 2 false main_nbk_data)#coerce
76 ~menu_label:(menu_label_box 2 main_nbk_data)#coerce
77 tab_downloads#coerce
79 let tab_friends = new Gui_friends.pane_friends () in
80 let _ = notebook#append_page
81 ~tab_label:(tab_box 3 false main_nbk_data)#coerce
82 ~menu_label:(menu_label_box 3 main_nbk_data)#coerce
83 tab_friends#coerce
85 let tab_queries = new Gui_queries.paned () in
86 let _ = notebook#append_page
87 ~tab_label:(tab_box 4 false main_nbk_data)#coerce
88 ~menu_label:(menu_label_box 4 main_nbk_data)#coerce
89 tab_queries#coerce
91 let tab_rooms = new Gui_rooms.pane_rooms () in
92 let _ = notebook#append_page
93 ~tab_label:(tab_box 5 false main_nbk_data)#coerce
94 ~menu_label:(menu_label_box 5 main_nbk_data)#coerce
95 tab_rooms#coerce
97 let tab_uploads = new Gui_uploads.upstats_box () in
98 let _ = notebook#append_page
99 ~tab_label:(tab_box 6 false main_nbk_data)#coerce
100 ~menu_label:(menu_label_box 6 main_nbk_data)#coerce
101 tab_uploads#coerce
103 let tab_console = new Gui_console.box () in
104 let _ = notebook#append_page
105 ~tab_label:(tab_box 7 false main_nbk_data)#coerce
106 ~menu_label:(menu_label_box 7 main_nbk_data)#coerce
107 tab_console#coerce
109 let tab_graph = new Gui_graph.box () in
110 let _ = notebook#append_page
111 ~tab_label:(tab_box 8 false main_nbk_data)#coerce
112 ~menu_label:(menu_label_box 8 main_nbk_data)#coerce
113 tab_graph#coerce
115 let vbox = GPack.vbox ~homogeneous:false ~packing:(hbox_w#pack~expand:false ~fill:false) () in
116 let wtool1 =
117 GButton.toolbar ~orientation:`VERTICAL ~style:`BOTH
118 ~tooltips:true ~button_relief:`NORMAL
119 ~packing:(vbox#pack ~expand:true ~fill:true) ()
121 let buttonAbout = wtool1#insert_button
122 ~tooltip:(Gui_messages.mW_ti_about)
123 ~icon: (Gui_options.pixmap Gui_messages.o_xpm_about)#coerce
126 let buttonOptions = wtool1#insert_button
127 ~tooltip:(Gui_messages.mW_ti_settings)
128 ~icon: (Gui_options.pixmap Gui_messages.o_xpm_settings)#coerce
131 let buttonQuit = wtool1#insert_button
132 ~tooltip:(Gui_messages.mW_ti_exit)
133 ~icon: (Gui_options.pixmap Gui_messages.o_xpm_exit)#coerce
136 let buttonGui = wtool1#insert_button
137 ~tooltip:(Gui_messages.mW_ti_gui)
138 ~icon: (Gui_options.pixmap Gui_messages.o_xpm_gui)#coerce
141 let buttonKill = wtool1#insert_button
142 ~tooltip:(Gui_messages.mW_ti_kill_core)
143 ~icon: (Gui_options.pixmap Gui_messages.o_xpm_kill_core)#coerce
146 let hbox_status =
147 GPack.hbox ~homogeneous:false ~spacing:10
148 ~packing:(box#pack ~expand:false ~fill:true) ()
150 let label_connect_status =
151 GMisc.label ~text:(Gui_messages.mW_lb_not_connected)
152 ~justify:`LEFT ~line_wrap:true ~xalign:(-1.0) ~yalign:(-1.0)
153 ~packing:(hbox_status#pack ~expand:true ~fill:true) ()
155 object
156 val window = window
157 val box = box
158 val notebook = notebook
159 val buttonAbout = buttonAbout
160 val buttonOptions = buttonOptions
161 val buttonQuit = buttonQuit
162 val buttonGui = buttonGui
163 val buttonKill = buttonKill
164 val tab_networks = tab_networks
165 val tab_servers = tab_servers
166 val tab_downloads = tab_downloads
167 val tab_friends = tab_friends
168 val tab_queries = tab_queries
169 val tab_rooms = tab_rooms
170 val tab_uploads = tab_uploads
171 val tab_console = tab_console
172 val tab_graph = tab_graph
173 val hbox_status = hbox_status
174 val label_connect_status = label_connect_status
175 method window = window
176 method box = box
178 method notebook = notebook
179 method buttonAbout = buttonAbout
180 method buttonOptions = buttonOptions
181 method buttonQuit = buttonQuit
182 method buttonGui = buttonGui
183 method buttonKill = buttonKill
184 method tab_networks = tab_networks
185 method tab_servers = tab_servers
186 method tab_downloads = tab_downloads
187 method tab_friends = tab_friends
188 method tab_queries = tab_queries
189 method tab_rooms = tab_rooms
190 method tab_uploads = tab_uploads
191 method tab_console = tab_console
192 method tab_graph = tab_graph
193 method hbox_status = hbox_status
194 method label_connect_status = label_connect_status