slave: Use slightly modified event_callback.
[guestfs-browser.git] / op_file_information.ml
1 (* Guestfs Browser.
2  * Copyright (C) 2011 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 open Utils
20
21 let rec file_information tree path =
22   let model = tree#model in
23   let row = model#get_iter path in
24   let src, pathname = tree#get_pathname row in
25   debug "file_information %s" pathname;
26
27   (* See if this node already has an Info "file_information" child
28    * node.  If so they don't recreate it.
29    *)
30   let info_text = "file_information" in
31   if not (tree#has_child_info_node path info_text) then (
32     tree#set_child_info_node path info_text
33       "<i>Calculating file information ...</i>";
34
35     Slave.file_information src pathname
36       (when_file_information tree path pathname)
37   )
38
39 and when_file_information tree path pathname fileinfo =
40   let model = tree#model in
41   let row = model#get_iter path in
42   tree#set_visited row;
43
44   (* Find the child node added above, and replace the text. *)
45   let info_text = "file_information" in
46   let msg = markup_escape fileinfo in
47   tree#set_child_info_node path info_text msg