~ubuntu-branches/ubuntu/natty/bluefish/natty-proposed

« back to all changes in this revision

Viewing changes to src/plugin_infbrowser/infb_text.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2010-06-29 21:40:10 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100629214010-2oxygudqcstn3zc6
Tags: 2.0.1-1
* New upstream release - the first release of the 2.0 series for Debian
  (closes: #570731; LP: #540126). This release fixes these reported issues:
  - Better settings handling (closes: #548272).
  - Improved filebrowser (LP: #45927).
  - Improved syntax highlighting engine (LP: #108628).
  - Improved file operations (LP: #181110).
  - Translated menu descriptions (LP: #371318, #371322). The chosen menu
    name is fine.
  - Improved browser commands and handling (LP: #158891, #348408).
* Updated and adjusted packaging files.
* debian/bluefish_icon.xpm: Renamed to debian/bluefish.xpm.
* debian/bluefish.install: Adjusted.
* debian/bluefish.menu (icon): Adjusted.
* debian/bluefish-data.install, debian/bluefish-plugins.install: Added.
* debian/control: Added bluefish-data, bluefish-dbg and bluefish-plugins.
  (Build-Depends): Dropped deprecated build-dependencies libaspell-dev,
  libgnomeui-dev, libgnomevfs2-dev, libpcre3-dev and dpatch. Added intltool,
  libtool, libenchant-dev and libgucharmap2-dev.
  (Standards-Version): Bumped to 3.8.4.
  (Depends, Suggests): Adjusted. Added gvfs-backends as dependency.
* debian/copyright: Updated.
* debian/rules: Rewritten. Dropped dpatch.
  (LDFLAGS): Dropped -Wl,-z,defs because of plugins.
  (config.status:): Adjusted configure switches.
  (install): Install to debian/tmp and list missing files.
  (binary-indep): Added for bluefish-data.
  (binary-arch): Adjusted. Put debugging symbols into bluefish-dbg.
* debian/watch: Added support for RCs.
* debian/README.Debian: Dropped (useless with 2.0).
* debian/README.source: Dropped together with dpatch.
* debian/patches/: Dropped (obsolete).
* debian/reportbug/: Dropped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Bluefish HTML Editor
 
2
 * infb_text.c - plugin for information browser
 
3
 *
 
4
 * Copyright (C) 2007 Oskar Świda
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 */
 
20
 
 
21
#include <libxml/xmlmemory.h>
 
22
#include <libxml/parser.h>
 
23
#include <libxml/hash.h>
 
24
#include <libxml/xmlschemas.h>
 
25
#include <libxml/schemasInternals.h>
 
26
#include <libxml/tree.h>
 
27
#include <string.h>
 
28
#include "infb_text.h"
 
29
#include "infbrowser.h"
 
30
#include "infb_docbook.h"
 
31
#include "infb_html.h"
 
32
 
 
33
 
 
34
void infb_set_current_type(xmlDocPtr doc) {
 
35
        xmlChar *txt;
 
36
        xmlNodePtr root;
 
37
        infb_v.currentType = INFB_DOCTYPE_UNKNOWN;
 
38
        root = xmlDocGetRootElement(doc);
 
39
        if ( root && xmlStrcmp(root->name,BAD_CAST "ref")== 0 )
 
40
        {
 
41
                txt = xmlGetProp(root,BAD_CAST "type");
 
42
                if (!txt) infb_v.currentType = INFB_DOCTYPE_FREF2;
 
43
                else {
 
44
                        if ( xmlStrcmp(txt,BAD_CAST "dtd")== 0 )
 
45
                                infb_v.currentType = INFB_DOCTYPE_DTD;
 
46
                        else if ( xmlStrcmp(txt,BAD_CAST "index")== 0 )
 
47
                                infb_v.currentType = INFB_DOCTYPE_INDEX;
 
48
                        else 
 
49
                                infb_v.currentType = INFB_DOCTYPE_FREF2;                                        
 
50
                        xmlFree(txt);
 
51
                }
 
52
        }       
 
53
        else if ( root && xmlStrcmp(root->name,BAD_CAST "book")== 0 ) 
 
54
                infb_v.currentType = INFB_DOCTYPE_DOCBOOK;
 
55
        else if ( root && xmlStrcmp(root->name,BAD_CAST "html")== 0 ) 
 
56
                infb_v.currentType = INFB_DOCTYPE_HTML;
 
57
                
 
58
 
59
 
 
60
xmlXPathObjectPtr getnodeset (xmlDocPtr doc, xmlChar *xpath,xmlNodePtr start){
 
61
        xmlXPathContextPtr context;
 
62
        xmlXPathObjectPtr result;
 
63
        context = xmlXPathNewContext(doc);
 
64
        if (context == NULL) return NULL;
 
65
        if (start!=NULL)
 
66
                context->node = start;
 
67
        else 
 
68
                context->node = xmlDocGetRootElement(doc);      
 
69
        result = xmlXPathEvalExpression(xpath, context);
 
70
        xmlXPathFreeContext(context);
 
71
        if (result == NULL) return NULL;
 
72
        if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
 
73
                xmlXPathFreeObject(result);
 
74
        return NULL;
 
75
        }
 
76
        return result;
 
77
}
 
78
 
 
79
xmlNodePtr getnode (xmlDocPtr doc, xmlChar *xpath,xmlNodePtr start){
 
80
        xmlXPathContextPtr context;
 
81
        xmlXPathObjectPtr result;
 
82
        xmlNodePtr ret=NULL;
 
83
        
 
84
        context = xmlXPathNewContext(doc);
 
85
        if (context == NULL) return NULL;
 
86
        if (start!=NULL)
 
87
                context->node = start;
 
88
        else
 
89
                context->node = xmlDocGetRootElement(doc);
 
90
        result = xmlXPathEvalExpression(xpath, context);
 
91
        xmlXPathFreeContext(context);
 
92
        if (result == NULL) return NULL;
 
93
        if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
 
94
                xmlXPathFreeObject(result);
 
95
        return NULL;
 
96
        }
 
97
        if ( result->nodesetval->nodeNr > 0 )
 
98
        {
 
99
                ret = result->nodesetval->nodeTab[0];
 
100
                xmlXPathFreeObject(result);
 
101
        }
 
102
        return ret;
 
103
}
 
104
 
 
105
gint getcount (xmlDocPtr doc, xmlChar *xpath,xmlNodePtr start) {
 
106
        xmlXPathContextPtr context;
 
107
        xmlXPathObjectPtr result;
 
108
        gint ret=0;
 
109
        
 
110
        context = xmlXPathNewContext(doc);
 
111
        if (context == NULL) return 0;
 
112
        if (start!=NULL)
 
113
                context->node = start;
 
114
        else
 
115
                context->node = xmlDocGetRootElement(doc);
 
116
        result = xmlXPathEvalExpression(BAD_CAST xpath, context);
 
117
        xmlXPathFreeContext(context);
 
118
        if (result == NULL) return 0;
 
119
        if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
 
120
                xmlXPathFreeObject(result);
 
121
        return 0;
 
122
        }       
 
123
        ret = result->nodesetval->nodeNr;
 
124
        xmlXPathFreeObject(result);
 
125
        return ret;
 
126
}
 
127
 
 
128
 
 
129
void infb_insert_message(GtkTextView *view, xmlChar *text) {
 
130
        GtkTextTag *tag;
 
131
        GtkTextIter iter,it1,it2;
 
132
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);   
 
133
        
 
134
        gtk_text_buffer_get_bounds(buff,&it1,&it2);
 
135
        gtk_text_buffer_remove_all_tags (buff,&it1,&it2);
 
136
        gtk_text_buffer_delete(buff,&it1,&it2);
 
137
        gtk_text_buffer_insert_at_cursor(buff,"\n\n",2);        
 
138
        tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_MSG,NULL);
 
139
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
140
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
141
        gtk_widget_queue_draw(GTK_WIDGET(view));
 
142
        gdk_window_process_all_updates();
 
143
                
 
144
}
 
145
 
 
146
void infb_insert_error(GtkTextView *view, xmlChar *text) {
 
147
        GtkTextTag *tag;
 
148
        GtkTextIter iter,it1,it2;
 
149
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);   
 
150
        
 
151
        gtk_text_buffer_get_bounds(buff,&it1,&it2);
 
152
        gtk_text_buffer_remove_all_tags (buff,&it1,&it2);
 
153
        gtk_text_buffer_delete(buff,&it1,&it2); 
 
154
        gtk_text_buffer_insert_at_cursor(buff,"\n\n",2);
 
155
        tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_ERR,NULL);
 
156
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
157
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
158
        gtk_widget_queue_draw(GTK_WIDGET(view));
 
159
        gdk_window_process_all_updates();
 
160
                
 
161
}
 
162
 
 
163
 
 
164
void infb_insert_text_tag(GtkTextBuffer *buff, xmlChar *text, GtkTextTag *tag, gboolean eol) {
 
165
        GtkTextIter iter;
 
166
        if (!text || !tag) return;
 
167
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
168
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
169
        if (eol)
 
170
                gtk_text_buffer_insert_at_cursor(buff,"\n",1);
 
171
}
 
172
 
 
173
void infb_insert_text(GtkTextBuffer *buff, xmlChar *text, gint type, gboolean eol) {
 
174
        GtkTextTag *tag;
 
175
        GtkTextIter iter;
 
176
        if (!text) return;
 
177
        switch (type) {
 
178
                case INFB_TT_SMALL:
 
179
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_SMALL,NULL);
 
180
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
181
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
182
                break;
 
183
                case INFB_TT_BOLD:
 
184
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_BOLD,NULL);
 
185
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
186
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
187
                break;                          
 
188
                case INFB_TT_ITALIC:
 
189
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_ITALIC,NULL);
 
190
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
191
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
192
                break;                          
 
193
                case INFB_TT_TITLE:
 
194
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_TITLE,NULL);
 
195
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
196
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
197
                break;                          
 
198
                case INFB_TT_DESC:
 
199
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_DESC,NULL);
 
200
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
201
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
202
                break;                          
 
203
                case INFB_TT_SECTION:
 
204
                                tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_SECTION,NULL);
 
205
                                gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
206
                                gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
207
                break;                                                                          
 
208
                default:
 
209
                        gtk_text_buffer_insert_at_cursor(buff,(const gchar*)text,xmlStrlen(text));                      
 
210
        }       
 
211
        if (eol)
 
212
                gtk_text_buffer_insert_at_cursor(buff,"\n",1);
 
213
}
 
214
 
 
215
 
 
216
void infb_insert_icon(GtkTextView *view, GtkWidget *icon, gchar *prepend) {
 
217
        GtkTextChildAnchor *anchor;
 
218
        GtkTextIter iter;
 
219
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
 
220
        if ( prepend )
 
221
                gtk_text_buffer_insert_at_cursor(buff,prepend,-1);      
 
222
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
223
        anchor = gtk_text_buffer_create_child_anchor (buff, &iter);
 
224
        gtk_text_buffer_insert_at_cursor(buff," ",1);
 
225
        gtk_text_view_add_child_at_anchor (view,icon,anchor);
 
226
        gtk_widget_show_all(icon);                                                                      
 
227
}
 
228
 
 
229
void infb_insert_anchor(GtkTextView *view, xmlChar *text) {
 
230
        GtkTextIter iter;
 
231
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
 
232
        if (!text) return;
 
233
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
234
        gtk_text_buffer_create_mark(buff,(gchar*)text,&iter,TRUE);
 
235
}
 
236
 
 
237
void infb_insert_widget(GtkTextView *view, GtkWidget *widget,gint size) {
 
238
        GtkTextChildAnchor *anchor;
 
239
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
 
240
        GtkTextIter iter;
 
241
        GdkColor gc;
 
242
        
 
243
        gdk_color_parse("#FF0000",&gc);
 
244
        gtk_widget_modify_bg(widget,GTK_STATE_NORMAL,&gc);
 
245
        
 
246
/*      gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
247
        gtk_misc_set_padding(GTK_MISC(label), 2, 2);*/
 
248
        if (size>0)
 
249
                gtk_widget_set_size_request(widget,size,-1);
 
250
        /*gtk_label_set_line_wrap(GTK_LABEL(label),TRUE);
 
251
        gtk_label_set_line_wrap(GTK_LABEL(label),PANGO_WRAP_CHAR);*/ 
 
252
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff));
 
253
        anchor = gtk_text_buffer_create_child_anchor (buff, &iter);
 
254
        gtk_text_view_add_child_at_anchor (view,widget,anchor);
 
255
        gtk_widget_show_all(widget);                                                                    
 
256
}
 
257
 
 
258
void infb_insert_fileref(GtkTextBuffer *buff, xmlChar *text, xmlChar *fname,xmlChar *desc) {
 
259
        GtkTextTag *tag;
 
260
        GtkTextIter iter;
 
261
        if (!text) return;
 
262
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff)); 
 
263
        tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_FILEREF,NULL);
 
264
        g_object_set_data (G_OBJECT (tag), "type", &infb_v.nt_fileref);
 
265
        g_object_set_data (G_OBJECT (tag), "file", g_strdup((const gchar*)fname));                              
 
266
        if ( desc && xmlStrcmp(desc,BAD_CAST"")!=0 )
 
267
                g_object_set_data (G_OBJECT (tag), "tip", g_strdup((gchar*)desc));
 
268
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
269
        gtk_text_buffer_insert_at_cursor(buff,"\n",1);
 
270
}
 
271
 
 
272
 
 
273
void infb_insert_node(GtkTextBuffer *buff, xmlChar *text, xmlNodePtr node,gboolean endline) {
 
274
        GtkTextTag *tag;
 
275
        GtkTextIter iter;
 
276
        if (!text) return;
 
277
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff)); 
 
278
        tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_NODE,NULL);
 
279
        g_object_set_data (G_OBJECT (tag), "type", &infb_v.nt_node);
 
280
        g_object_set_data (G_OBJECT (tag), "node", node);                                       
 
281
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
282
        if (endline)
 
283
                gtk_text_buffer_insert_at_cursor(buff,"\n",1);
 
284
}
 
285
 
 
286
void infb_insert_group(GtkTextView *view, xmlChar *text, xmlNodePtr node) {
 
287
        GtkTextTag *tag;
 
288
        GtkTextIter iter;
 
289
        GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
 
290
        xmlChar *text2;
 
291
        if (!text) return;
 
292
        /* text2 doesn't appear to be used. Can it be removed? */
 
293
        text2 = xmlGetProp(node,BAD_CAST "expanded");
 
294
        infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_DIRECTORY,GTK_ICON_SIZE_MENU),NULL);           
 
295
        gtk_text_buffer_get_iter_at_mark (buff,&iter,gtk_text_buffer_get_insert(buff)); 
 
296
        tag = gtk_text_buffer_create_tag(buff,NULL,INFB_STYLE_GROUP,NULL);
 
297
        g_object_set_data (G_OBJECT (tag), "type", &infb_v.nt_group);
 
298
        g_object_set_data (G_OBJECT (tag), "node", node);                                       
 
299
        gtk_text_buffer_insert_with_tags(buff,&iter,(const gchar*)text,xmlStrlen(text),tag,NULL);
 
300
        gtk_text_buffer_insert_at_cursor(buff,"\n",1);
 
301
        xmlFree(text2);
 
302
}
 
303
 
 
304
 
 
305
 
 
306
static void infb_fill_node(GtkTextView *view,xmlDocPtr doc,xmlNodePtr node,gint level) {
 
307
        GtkTextBuffer *buff;
 
308
        gchar *levstr=NULL;
 
309
        xmlChar *text,*text2;
 
310
        xmlNodePtr auxn;
 
311
                
 
312
        if ( view==NULL || doc==NULL || node==NULL ) return;
 
313
        buff = gtk_text_view_get_buffer(view);
 
314
        if ( level > 0 ) 
 
315
                levstr = g_strnfill(2*level,' ');
 
316
        else
 
317
                levstr = "";    
 
318
        switch ( infb_v.currentType ) { 
 
319
                case INFB_DOCTYPE_INDEX:
 
320
                        if ( xmlStrcmp(node->name,BAD_CAST "ref") ==0 ) {  /* reference index */
 
321
                                text = xmlGetProp(node,BAD_CAST "name");
 
322
                                if ( text ) {
 
323
                                                infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
 
324
                                                xmlFree(text);
 
325
                                                infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
 
326
                                }
 
327
                                auxn = node->xmlChildrenNode;
 
328
                                while ( auxn ) {
 
329
                                        infb_fill_node(view,doc,auxn,level+1);
 
330
                                        auxn = auxn->next;
 
331
                                }
 
332
                        } /* reference index */ 
 
333
                        else    if ( xmlStrcmp(node->name,BAD_CAST "group") ==0 ) { /* fileref group  - this will link child */
 
334
                                text = xmlGetProp(node,BAD_CAST "name");
 
335
                                text2 = xmlGetProp(node,BAD_CAST "expanded");
 
336
                                if ( text ) {                                   
 
337
                                        infb_insert_group(view,text,node);                                                                                                                                                                      
 
338
                                        xmlFree(text);
 
339
                                }                                               
 
340
                                if ( text2 && xmlStrcmp(text2,BAD_CAST "1")==0 ) {
 
341
                                        auxn = node->xmlChildrenNode;
 
342
                                        while ( auxn ) {
 
343
                                                text = xmlGetProp(auxn,BAD_CAST "name");
 
344
                                                if ( text ) {
 
345
                                                        xmlChar *text3,*text4;
 
346
                                                        infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_FILE,GTK_ICON_SIZE_MENU),"  ");
 
347
                                                        text4 = xmlNodeGetContent(auxn);
 
348
                                                        text3 = xmlGetProp(auxn,BAD_CAST "description");
 
349
                                                        infb_insert_fileref(buff,text,text4,text3);                                     
 
350
                                                        xmlFree(text);
 
351
                                                        xmlFree(text4);
 
352
                                                }       
 
353
                                                auxn = auxn->next;
 
354
                                        }
 
355
                                        xmlFree(text2);
 
356
                                }                                                                               
 
357
                        } /* fileref */                         
 
358
                break; /* index document */
 
359
/**************************  DOCBOOK file ******************************/               
 
360
                case INFB_DOCTYPE_DOCBOOK:  /* DOCBOOK file */
 
361
                        infb_db_fill_node(view,doc,node,level);
 
362
                break;
 
363
/**************************  DOCBOOK file END ******************************/
 
364
/**************************  HTML file ******************************/          
 
365
                case INFB_DOCTYPE_HTML: {
 
366
                        infb_html_fill_node(view,doc,node,level,NULL,FALSE);
 
367
                }       
 
368
                break;
 
369
/**************************  HTML file END ******************************/      
 
370
        
 
371
                default: /* fref2 document */
 
372
                        if ( xmlStrcmp(node->name,BAD_CAST "ref") ==0 ) { /* reference top */
 
373
                                text = xmlGetProp(node,BAD_CAST "name");
 
374
                                if ( text ) {
 
375
                                        infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
 
376
                                        xmlFree(text);
 
377
                                }
 
378
                                text = xmlGetProp(node,BAD_CAST "description");
 
379
                                if ( text ) {
 
380
                                        infb_insert_text(buff,text,INFB_TT_DESC,TRUE);
 
381
                                        xmlFree(text);
 
382
                                }
 
383
                                
 
384
                                auxn = node->xmlChildrenNode;
 
385
                                while ( auxn ) {
 
386
                                        infb_fill_node(view,doc,auxn,level+1);
 
387
                                        auxn = auxn->next;
 
388
                                }
 
389
                        }
 
390
                        else    if ( xmlStrcmp(node->name,BAD_CAST "note") ==0 ) { /* note */
 
391
                                if ( level == 0 ) {
 
392
                                        text = xmlGetProp(node,BAD_CAST "title");
 
393
                                        if ( text ) {
 
394
                                                infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
 
395
                                                xmlFree(text);
 
396
                                        }       
 
397
                                        text = xmlNodeGetContent(node);
 
398
                                        if (text) {
 
399
                                                infb_insert_text(buff,text,INFB_TT_NONE,TRUE);
 
400
                                                xmlFree(text);
 
401
                                        }       
 
402
                                }
 
403
                                else 
 
404
                                {
 
405
                                        text = xmlGetProp(node,BAD_CAST "title");
 
406
                                        if ( text ) {
 
407
                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_EDIT,GTK_ICON_SIZE_MENU),levstr);
 
408
                                                infb_insert_node(buff,text,node,TRUE);                                                                                  
 
409
                                                xmlFree(text);
 
410
                                        }
 
411
                                }               
 
412
                        } /* note */
 
413
                        else    if ( xmlStrcmp(node->name,BAD_CAST "search_result") ==0 ) { /* search result */
 
414
                                if ( level == 0 ) {
 
415
                                        text = xmlGetProp(node,BAD_CAST "title");
 
416
                                        if ( text ) {
 
417
                                                infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
 
418
                                                xmlFree(text);
 
419
                                        }
 
420
                                        auxn = node->xmlChildrenNode;
 
421
                                        while ( auxn ) {
 
422
                                                infb_fill_node(view,doc,auxn,level+1);
 
423
                                                auxn = auxn->next;
 
424
                                        }
 
425
                                }
 
426
                                else 
 
427
                                {
 
428
                                        text = xmlGetProp(node,BAD_CAST "title");
 
429
                                        if ( text ) {
 
430
                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,GTK_ICON_SIZE_MENU),levstr);
 
431
                                                infb_insert_node(buff,text,node,TRUE);                                                                                  
 
432
                                                xmlFree(text);
 
433
                                        }
 
434
                                }               
 
435
                        } /* search result */                   
 
436
                        else    if ( xmlStrcmp(node->name,BAD_CAST "group") ==0 ) { /* group */
 
437
                                text = xmlGetProp(node,BAD_CAST "name");
 
438
                                text2 = xmlGetProp(node,BAD_CAST "expanded");
 
439
                                if ( text ) {
 
440
                                        if (level>0) gtk_text_buffer_insert_at_cursor(buff,levstr,2*level);
 
441
                                        infb_insert_group(view,text,node);                                                                                                                                                                      
 
442
                                        xmlFree(text);
 
443
                                }                                               
 
444
                                if ( text2 && xmlStrcmp(text2,BAD_CAST "1")==0 ) {
 
445
                                        auxn = node->xmlChildrenNode;
 
446
                                        while ( auxn ) {
 
447
                                                infb_fill_node(view,doc,auxn,level+1);
 
448
                                                auxn = auxn->next;
 
449
                                        }
 
450
                                }                       
 
451
                                if (text2) xmlFree(text2);
 
452
                        } /* group */
 
453
/* ************************** ELEMENT **************************************/                   
 
454
                        else    if ( xmlStrcmp(node->name,BAD_CAST "element") ==0 ) { /* element */
 
455
                          if ( level == 0 ){
 
456
                                        xmlNodeSetPtr nodeset,nodeset2;
 
457
                                        xmlXPathObjectPtr result,result2;
 
458
                                        gint i,j;
 
459
                                        gchar *str;
 
460
                                        xmlNodePtr an,an2;
 
461
                                        gboolean attr_section=FALSE, param_section = FALSE, ret_section=FALSE;
 
462
                                        xmlChar *text3;
 
463
                                                                                          
 
464
                                        text = xmlGetProp(node,BAD_CAST "name");
 
465
                                        infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
 
466
                                        xmlFree(text);                                  
 
467
                                        
 
468
                                        result = getnodeset(doc,BAD_CAST "child::description",node);
 
469
                                        if (result) {
 
470
                                                        nodeset = result->nodesetval;
 
471
                                                        if ( nodeset->nodeNr > 0 ) {
 
472
                                                                text = xmlNodeGetContent(nodeset->nodeTab[0]);
 
473
                                                                infb_insert_text(buff,text,INFB_TT_DESC,TRUE);
 
474
                                                                xmlFree(text);
 
475
                                                        }
 
476
                                                        xmlXPathFreeObject (result);
 
477
                                        }
 
478
                                        
 
479
                                        /* PROPLISTS */
 
480
                                        result = getnodeset(doc,BAD_CAST "child::properties/proplist",node);
 
481
                                        if (result && result->nodesetval->nodeNr > 0) {
 
482
                                                        nodeset = result->nodesetval;
 
483
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
484
                                                                text = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "ref");
 
485
                                                                if (text) {
 
486
                                                                        str = g_strdup_printf("//def[@deftype='proplist' and @id='%s']",text);
 
487
                                                                        an = getnode(doc,BAD_CAST str,NULL);
 
488
                                                                        g_free(str);
 
489
                                                                        xmlFree(text);                                                                  
 
490
                                                                        if (an) {
 
491
                                                                                /* attributes */
 
492
                                                                                result2 = getnodeset(doc,BAD_CAST "child::property[@kind='attribute']",an);
 
493
                                                                                if (result2 && result2->nodesetval->nodeNr > 0) {
 
494
                                                                                                if (!attr_section) {
 
495
                                                                                                        infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
 
496
                                                                                                        attr_section = TRUE;
 
497
                                                                                                }       
 
498
                                                                                                nodeset2 = result2->nodesetval;
 
499
                                                                                                for (j=0;j< nodeset2->nodeNr;j++  ) {
 
500
                                                                                                        text = xmlGetProp(nodeset2->nodeTab[j],BAD_CAST "name");
 
501
                                                                                                        text2 = xmlGetProp(nodeset2->nodeTab[j],BAD_CAST "type");
 
502
                                                                                                        if (text) {
 
503
                                                                                                                if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0) 
 
504
                                                                                                                        str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
 
505
                                                                                                                else 
 
506
                                                                                                                        str = g_strdup((gchar*)text);
 
507
                                                                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                                                       
 
508
                                                                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
509
                                                                                                                g_free(str);
 
510
                                                                                                                xmlFree(text);
 
511
                                                                                                        }       
 
512
                                                                                                        if (text2) xmlFree(text2);
 
513
                                                                                                        an2 = getnode(doc,BAD_CAST "child::description",nodeset2->nodeTab[j]);
 
514
                                                                                                        if ( an2 ) {
 
515
                                                                                                                text = xmlNodeGetContent(an2);
 
516
                                                                                                                if (text) {
 
517
                                                                                                                        infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
518
                                                                                                                        xmlFree(text);
 
519
                                                                                                                }       
 
520
                                                                                                        }
 
521
                                                                                                }
 
522
                                                                                                xmlXPathFreeObject (result2);
 
523
                                                                                } /* attributes */
 
524
                                                                                /* parameters */
 
525
                                                                                result2 = getnodeset(doc,BAD_CAST "child::property[@kind='parameter']",an);
 
526
                                                                                if (result2 && result2->nodesetval->nodeNr > 0) {
 
527
                                                                                                if (!param_section) {
 
528
                                                                                                        infb_insert_text(buff,BAD_CAST "Parameters",INFB_TT_SECTION,TRUE);
 
529
                                                                                                        param_section = TRUE;
 
530
                                                                                                }       
 
531
                                                                                                nodeset2 = result2->nodesetval;
 
532
                                                                                                for (j=0;j< nodeset2->nodeNr;j++  ) {
 
533
                                                                                                        text = xmlGetProp(nodeset2->nodeTab[j],BAD_CAST "name");
 
534
                                                                                                        text2 = xmlGetProp(nodeset2->nodeTab[j],BAD_CAST "type");
 
535
                                                                                                        if (text) {
 
536
                                                                                                                if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0) 
 
537
                                                                                                                        str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
 
538
                                                                                                                else 
 
539
                                                                                                                        str = g_strdup((gchar*)text);                   
 
540
                                                                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                               
 
541
                                                                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
542
                                                                                                                g_free(str);
 
543
                                                                                                                xmlFree(text);
 
544
                                                                                                        }       
 
545
                                                                                                        if (text2) xmlFree(text2);
 
546
                                                                                                        an2 = getnode(doc,BAD_CAST "child::description",nodeset2->nodeTab[j]);
 
547
                                                                                                        if ( an2 ) {
 
548
                                                                                                                text = xmlNodeGetContent(an2);
 
549
                                                                                                                if (text) {
 
550
                                                                                                                        infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
551
                                                                                                                        xmlFree(text);
 
552
                                                                                                                }       
 
553
                                                                                                        }
 
554
                                                                                                }
 
555
                                                                                                xmlXPathFreeObject (result2);
 
556
                                                                                } /* parameters */
 
557
                                                                                
 
558
                                                                        } /* proplist found */
 
559
                                                                }
 
560
                                                        }                                               
 
561
                                        } /* proplist */
 
562
                                        if (result)     xmlXPathFreeObject(result);
 
563
                                        
 
564
                                        /* SINGLE PROPERTY REF */
 
565
                                        result = getnodeset(doc,BAD_CAST "child::properties/property[@ref]",node);
 
566
                                        if (result && result->nodesetval->nodeNr > 0) {
 
567
                                                        nodeset = result->nodesetval;
 
568
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
569
                                                                text = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "ref");
 
570
                                                                if (text) {
 
571
                                                                        str = g_strdup_printf("//def[@deftype='property' and @id='%s']",text);
 
572
                                                                        an = getnode(doc,BAD_CAST str,NULL);
 
573
                                                                        g_free(str);
 
574
                                                                        xmlFree(text);          
 
575
                                                                        text = xmlGetProp(an,BAD_CAST "kind");
 
576
                                                                        if (text) {
 
577
                                                                                if (xmlStrcmp(text,BAD_CAST "attribute")==0) {
 
578
                                                                                                if (!attr_section) {
 
579
                                                                                                        infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
 
580
                                                                                                        attr_section = TRUE;
 
581
                                                                                                }       
 
582
                                                                                                text2 = xmlGetProp(an,BAD_CAST "name");
 
583
                                                                                                text3 = xmlGetProp(an,BAD_CAST "type");
 
584
                                                                                                if (text2) {
 
585
                                                                                                                if ( text3 && xmlStrcmp(text3,BAD_CAST "")!=0) 
 
586
                                                                                                                        str = g_strconcat((gchar*)text2," (",(gchar*)text3,")",NULL);
 
587
                                                                                                                else 
 
588
                                                                                                                        str = g_strdup((gchar*)text2);          
 
589
                                                                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                                       
 
590
                                                                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
591
                                                                                                                g_free(str);
 
592
                                                                                                                xmlFree(text2);
 
593
                                                                                                        }       
 
594
                                                                                                        if (text3) xmlFree(text3);
 
595
                                                                                                        an2 = getnode(doc,BAD_CAST "child::description",an);
 
596
                                                                                                        if ( an2 ) {
 
597
                                                                                                                text2 = xmlNodeGetContent(an2);
 
598
                                                                                                                if (text2) {
 
599
                                                                                                                        infb_insert_text(buff,text2,INFB_TT_SMALL,TRUE);
 
600
                                                                                                                        xmlFree(text2);
 
601
                                                                                                                }       
 
602
                                                                                                        }
 
603
                                                                                } /* attribute */
 
604
                                                                                else if (xmlStrcmp(text,BAD_CAST "parameter")==0) {
 
605
                                                                                                if (!param_section) {
 
606
                                                                                                        infb_insert_text(buff,BAD_CAST "Parameters",INFB_TT_SECTION,TRUE);
 
607
                                                                                                        param_section = TRUE;
 
608
                                                                                                }       
 
609
                                                                                                text2 = xmlGetProp(an,BAD_CAST "name");
 
610
                                                                                                text3 = xmlGetProp(an,BAD_CAST "type");
 
611
                                                                                                if (text2) {
 
612
                                                                                                                if ( text3 && xmlStrcmp(text3,BAD_CAST "")!=0) 
 
613
                                                                                                                        str = g_strconcat((gchar*)text2," (",(gchar*)text3,")",NULL);
 
614
                                                                                                                else 
 
615
                                                                                                                        str = g_strdup((gchar*)text2);          
 
616
                                                                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                                       
 
617
                                                                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
618
                                                                                                                g_free(str);
 
619
                                                                                                                xmlFree(text2);
 
620
                                                                                                        }       
 
621
                                                                                                        if (text3) xmlFree(text3);
 
622
                                                                                                        an2 = getnode(doc,BAD_CAST "child::description",an);
 
623
                                                                                                        if ( an2 ) {
 
624
                                                                                                                text2 = xmlNodeGetContent(an2);
 
625
                                                                                                                if (text2) {
 
626
                                                                                                                        infb_insert_text(buff,text2,INFB_TT_SMALL,TRUE);
 
627
                                                                                                                        xmlFree(text2);
 
628
                                                                                                                }       
 
629
                                                                                                        }
 
630
                                                                                } /* parameter */
 
631
                                                                                else if (xmlStrcmp(text,BAD_CAST "return")==0) {
 
632
                                                                                                if (!ret_section) {
 
633
                                                                                                        text2 = xmlGetProp(an,BAD_CAST "type");
 
634
                                                                                                        if ( text2 ) {
 
635
                                                                                                                str = g_strconcat("Returned type: ",(gchar*)text2,NULL);
 
636
                                                                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_SECTION,TRUE);
 
637
                                                                                                                g_free(str);
 
638
                                                                                                                ret_section = TRUE;
 
639
                                                                                                                xmlFree(text2);
 
640
                                                                                                                infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
 
641
                                                                                                        }       
 
642
                                                                                                }       
 
643
                                                                                } /* return */                                                                          
 
644
                                                                                                                                                                
 
645
                                                                        }                                                       
 
646
                                                                }
 
647
                                                        }                       
 
648
                                        } /* single property */                                                                                 
 
649
                                        if (result)     xmlXPathFreeObject(result);
 
650
                                        
 
651
                                        /* ATTRIBUTES */
 
652
                                        result = getnodeset(doc,BAD_CAST "child::properties/property[@kind='attribute']",node);
 
653
                                        if (result && result->nodesetval->nodeNr > 0) {
 
654
                                                        if (!attr_section) {
 
655
                                                                infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
 
656
                                                                attr_section = TRUE;    
 
657
                                                        }       
 
658
                                                        nodeset = result->nodesetval;
 
659
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
660
                                                                text = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "name");
 
661
                                                                text2 = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "type");
 
662
                                                                if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0) 
 
663
                                                                        str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
 
664
                                                                else 
 
665
                                                                        str = g_strdup((gchar*)text);
 
666
                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                                                       
 
667
                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
668
                                                                g_free(str);
 
669
                                                                xmlFree(text);
 
670
                                                                if (text2) xmlFree(text2);
 
671
                                                                an = getnode(doc,BAD_CAST "child::description",nodeset->nodeTab[i]);
 
672
                                                                if ( an ) {
 
673
                                                                        text = xmlNodeGetContent(an);
 
674
                                                                        infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
675
                                                                        xmlFree(text);
 
676
                                                                }
 
677
                                                        }
 
678
                                        } /* attributes */
 
679
                                        if (result)     xmlXPathFreeObject(result);
 
680
                                        
 
681
                                        /* PARAMETERS */
 
682
                                        result = getnodeset(doc,BAD_CAST "child::properties/property[@kind='parameter']",node);
 
683
                                        if (result && result->nodesetval->nodeNr > 0) {
 
684
                                                        if (!param_section) {
 
685
                                                                infb_insert_text(buff,BAD_CAST "Parameters",INFB_TT_SECTION,TRUE);
 
686
                                                                param_section = TRUE;   
 
687
                                                        }       
 
688
                                                        nodeset = result->nodesetval;
 
689
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
690
                                                                text = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "name");
 
691
                                                                text2 = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "type");
 
692
                                                                if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0) 
 
693
                                                                        str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
 
694
                                                                else 
 
695
                                                                        str = g_strdup((gchar*)text);                   
 
696
                                                                infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),NULL);                                                               
 
697
                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_NONE,TRUE);
 
698
                                                                g_free(str);
 
699
                                                                xmlFree(text);
 
700
                                                                if (text2) xmlFree(text2);
 
701
                                                                an = getnode(doc,BAD_CAST "child::description",nodeset->nodeTab[i]);
 
702
                                                                if ( an ) {
 
703
                                                                        text = xmlNodeGetContent(an);
 
704
                                                                        infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
705
                                                                        xmlFree(text);
 
706
                                                                }
 
707
                                                        }
 
708
                                        } /* parameters */
 
709
                                        if (result)     xmlXPathFreeObject(result);
 
710
                                        
 
711
                                        /* RETURN */
 
712
                                        an = getnode(doc,BAD_CAST "child::properties/property[@kind='return']",node);
 
713
                                        if ( an ) {
 
714
                                                if (!ret_section) {
 
715
                                                        text2 = xmlGetProp(an,BAD_CAST "type");
 
716
                                                        if ( text2 ) {
 
717
                                                                str = g_strconcat("Returned type: ",(gchar*)text2,NULL);
 
718
                                                                infb_insert_text(buff,BAD_CAST str,INFB_TT_SECTION,TRUE);
 
719
                                                                g_free(str);
 
720
                                                                ret_section = TRUE;
 
721
                                                                xmlFree(text2);
 
722
                                                                infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
 
723
                                                        }       
 
724
                                                }                                               
 
725
                                        } /* return */
 
726
                                        /* EXAMPLES */
 
727
                                        result = getnodeset(doc,BAD_CAST "child::properties/property[@kind='example']",node);
 
728
                                        if (result && result->nodesetval->nodeNr > 0) {                                                 
 
729
                                                        nodeset = result->nodesetval;
 
730
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
731
                                                                infb_insert_text(buff,BAD_CAST "Example",INFB_TT_SECTION,TRUE);
 
732
                                                                an = getnode(doc,BAD_CAST "child::description",nodeset->nodeTab[i]);
 
733
                                                                if ( an ) {
 
734
                                                                        text = xmlNodeGetContent(an);
 
735
                                                                        infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
736
                                                                        xmlFree(text);
 
737
                                                                }
 
738
                                                        }
 
739
                                        } /* examples */
 
740
                                        if (result)     xmlXPathFreeObject(result);
 
741
                                        
 
742
                                        /* NOTES */
 
743
                                        result = getnodeset(doc,BAD_CAST "child::note",node);
 
744
                                        if (result && result->nodesetval->nodeNr > 0) {                                                 
 
745
                                                        nodeset = result->nodesetval;
 
746
                                                        for (i=0;i< nodeset->nodeNr;i++  ) {
 
747
                                                                text = xmlGetProp(nodeset->nodeTab[i],BAD_CAST "title");
 
748
                                                                infb_insert_text(buff,text,INFB_TT_SECTION,TRUE);
 
749
                                                                xmlFree(text);
 
750
                                                                text = xmlNodeGetContent(nodeset->nodeTab[i]);
 
751
                                                                infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
 
752
                                                                xmlFree(text);
 
753
                                                        }
 
754
                                        } /* notes */
 
755
                                        if (result)     xmlXPathFreeObject(result);                                     
 
756
                          }
 
757
                          else {
 
758
                                text = xmlGetProp(node,BAD_CAST "name");
 
759
                                if ( text ) {
 
760
                                        infb_insert_icon(view,gtk_image_new_from_stock(GTK_STOCK_ABOUT,GTK_ICON_SIZE_MENU),levstr);
 
761
                                        infb_insert_node(buff,text,node,TRUE);                                  
 
762
                                        xmlFree(text);
 
763
                                }
 
764
                          }                     
 
765
                        } /* element */
 
766
                
 
767
                break;
 
768
        } /* switch */ 
 
769
        if ( level > 0 ) g_free(levstr);        
 
770
}
 
771
 
 
772
 
 
773
 
 
774
void infb_fill_doc(Tbfwin *bfwin,xmlNodePtr root) {
 
775
        GtkTextView *view;
 
776
        gpointer auxp;
 
777
        GtkTextBuffer *buff;
 
778
        GtkTextIter it1,it2;
 
779
        xmlNodePtr node;
 
780
        
 
781
        auxp = g_hash_table_lookup(infb_v.windows,bfwin);
 
782
        if ( !auxp ) return;
 
783
        view = GTK_TEXT_VIEW(((Tinfbwin*)auxp)->view);
 
784
        if ( infb_v.currentDoc == NULL || view==NULL ) return;
 
785
 
 
786
        
 
787
        if ( infb_v.currentDoc != infb_v.homeDoc ) {
 
788
                /*gtk_widget_set_sensitive(((Tinfbwin*)auxp)->btn_add,FALSE);
 
789
                gtk_widget_set_sensitive(GTK_WIDGET(((Tinfbwin*)auxp)->btn_del),FALSE);*/
 
790
                gtk_widget_set_sensitive(GTK_WIDGET(((Tinfbwin*)auxp)->btn_home),TRUE);
 
791
                gtk_widget_set_sensitive(((Tinfbwin*)auxp)->sentry,TRUE);
 
792
        } else
 
793
        {
 
794
                /*gtk_widget_set_sensitive(((Tinfbwin*)auxp)->btn_add,TRUE);
 
795
                gtk_widget_set_sensitive(((Tinfbwin*)auxp)->btn_del,TRUE);*/
 
796
                gtk_widget_set_sensitive(GTK_WIDGET(((Tinfbwin*)auxp)->btn_home),FALSE);
 
797
                gtk_widget_set_sensitive(((Tinfbwin*)auxp)->sentry,FALSE);
 
798
        }
 
799
 
 
800
                
 
801
        buff = gtk_text_view_get_buffer(view);
 
802
        gtk_text_buffer_get_bounds(buff,&it1,&it2);
 
803
        gtk_text_buffer_remove_all_tags (buff,&it1,&it2);
 
804
        gtk_text_buffer_delete(buff,&it1,&it2);
 
805
        
 
806
        infb_set_current_type(infb_v.currentDoc);
 
807
                
 
808
        if ( infb_v.currentType == INFB_DOCTYPE_UNKNOWN ) {
 
809
                infb_insert_error(view,BAD_CAST _("Unknown document type"));
 
810
                return;
 
811
        }       
 
812
        if ( root == NULL ){
 
813
                node = xmlDocGetRootElement(infb_v.currentDoc);
 
814
                infb_v.currentNode = node;
 
815
                infb_fill_node(view,infb_v.currentDoc,node,0);
 
816
        } else 
 
817
        {
 
818
                infb_v.currentNode = root;      
 
819
                infb_fill_node(view,infb_v.currentDoc,root,0);
 
820
        }
 
821
        gtk_widget_set_sensitive(GTK_WIDGET(((Tinfbwin*)auxp)->btn_up),
 
822
                                                                         (infb_v.currentNode->parent != NULL && 
 
823
                                                                          (void*)infb_v.currentNode->parent != (void*)infb_v.currentNode->doc ) );
 
824
        node = xmlDocGetRootElement(infb_v.currentDoc);
 
825
        gtk_widget_set_sensitive(GTK_WIDGET(((Tinfbwin*)auxp)->btn_idx),(node!=infb_v.currentNode));
 
826
                                                  
 
827
}
 
828
 
 
829