1
/* Bluefish HTML Editor
2
* infb_text.c - plugin for information browser
4
* Copyright (C) 2007 Oskar Świda
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.
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.
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.
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>
28
#include "infb_text.h"
29
#include "infbrowser.h"
30
#include "infb_docbook.h"
31
#include "infb_html.h"
34
void infb_set_current_type(xmlDocPtr doc) {
37
infb_v.currentType = INFB_DOCTYPE_UNKNOWN;
38
root = xmlDocGetRootElement(doc);
39
if ( root && xmlStrcmp(root->name,BAD_CAST "ref")== 0 )
41
txt = xmlGetProp(root,BAD_CAST "type");
42
if (!txt) infb_v.currentType = INFB_DOCTYPE_FREF2;
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;
49
infb_v.currentType = INFB_DOCTYPE_FREF2;
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;
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;
66
context->node = start;
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);
79
xmlNodePtr getnode (xmlDocPtr doc, xmlChar *xpath,xmlNodePtr start){
80
xmlXPathContextPtr context;
81
xmlXPathObjectPtr result;
84
context = xmlXPathNewContext(doc);
85
if (context == NULL) return NULL;
87
context->node = start;
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);
97
if ( result->nodesetval->nodeNr > 0 )
99
ret = result->nodesetval->nodeTab[0];
100
xmlXPathFreeObject(result);
105
gint getcount (xmlDocPtr doc, xmlChar *xpath,xmlNodePtr start) {
106
xmlXPathContextPtr context;
107
xmlXPathObjectPtr result;
110
context = xmlXPathNewContext(doc);
111
if (context == NULL) return 0;
113
context->node = start;
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);
123
ret = result->nodesetval->nodeNr;
124
xmlXPathFreeObject(result);
129
void infb_insert_message(GtkTextView *view, xmlChar *text) {
131
GtkTextIter iter,it1,it2;
132
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
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();
146
void infb_insert_error(GtkTextView *view, xmlChar *text) {
148
GtkTextIter iter,it1,it2;
149
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
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();
164
void infb_insert_text_tag(GtkTextBuffer *buff, xmlChar *text, GtkTextTag *tag, gboolean eol) {
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);
170
gtk_text_buffer_insert_at_cursor(buff,"\n",1);
173
void infb_insert_text(GtkTextBuffer *buff, xmlChar *text, gint type, gboolean eol) {
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);
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);
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);
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);
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);
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);
209
gtk_text_buffer_insert_at_cursor(buff,(const gchar*)text,xmlStrlen(text));
212
gtk_text_buffer_insert_at_cursor(buff,"\n",1);
216
void infb_insert_icon(GtkTextView *view, GtkWidget *icon, gchar *prepend) {
217
GtkTextChildAnchor *anchor;
219
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
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);
229
void infb_insert_anchor(GtkTextView *view, xmlChar *text) {
231
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
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);
237
void infb_insert_widget(GtkTextView *view, GtkWidget *widget,gint size) {
238
GtkTextChildAnchor *anchor;
239
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
243
gdk_color_parse("#FF0000",&gc);
244
gtk_widget_modify_bg(widget,GTK_STATE_NORMAL,&gc);
246
/* gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
247
gtk_misc_set_padding(GTK_MISC(label), 2, 2);*/
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);
258
void infb_insert_fileref(GtkTextBuffer *buff, xmlChar *text, xmlChar *fname,xmlChar *desc) {
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);
273
void infb_insert_node(GtkTextBuffer *buff, xmlChar *text, xmlNodePtr node,gboolean endline) {
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);
283
gtk_text_buffer_insert_at_cursor(buff,"\n",1);
286
void infb_insert_group(GtkTextView *view, xmlChar *text, xmlNodePtr node) {
289
GtkTextBuffer *buff = gtk_text_view_get_buffer(view);
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);
306
static void infb_fill_node(GtkTextView *view,xmlDocPtr doc,xmlNodePtr node,gint level) {
309
xmlChar *text,*text2;
312
if ( view==NULL || doc==NULL || node==NULL ) return;
313
buff = gtk_text_view_get_buffer(view);
315
levstr = g_strnfill(2*level,' ');
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");
323
infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
325
infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
327
auxn = node->xmlChildrenNode;
329
infb_fill_node(view,doc,auxn,level+1);
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");
337
infb_insert_group(view,text,node);
340
if ( text2 && xmlStrcmp(text2,BAD_CAST "1")==0 ) {
341
auxn = node->xmlChildrenNode;
343
text = xmlGetProp(auxn,BAD_CAST "name");
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);
358
break; /* index document */
359
/************************** DOCBOOK file ******************************/
360
case INFB_DOCTYPE_DOCBOOK: /* DOCBOOK file */
361
infb_db_fill_node(view,doc,node,level);
363
/************************** DOCBOOK file END ******************************/
364
/************************** HTML file ******************************/
365
case INFB_DOCTYPE_HTML: {
366
infb_html_fill_node(view,doc,node,level,NULL,FALSE);
369
/************************** HTML file END ******************************/
371
default: /* fref2 document */
372
if ( xmlStrcmp(node->name,BAD_CAST "ref") ==0 ) { /* reference top */
373
text = xmlGetProp(node,BAD_CAST "name");
375
infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
378
text = xmlGetProp(node,BAD_CAST "description");
380
infb_insert_text(buff,text,INFB_TT_DESC,TRUE);
384
auxn = node->xmlChildrenNode;
386
infb_fill_node(view,doc,auxn,level+1);
390
else if ( xmlStrcmp(node->name,BAD_CAST "note") ==0 ) { /* note */
392
text = xmlGetProp(node,BAD_CAST "title");
394
infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
397
text = xmlNodeGetContent(node);
399
infb_insert_text(buff,text,INFB_TT_NONE,TRUE);
405
text = xmlGetProp(node,BAD_CAST "title");
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);
413
else if ( xmlStrcmp(node->name,BAD_CAST "search_result") ==0 ) { /* search result */
415
text = xmlGetProp(node,BAD_CAST "title");
417
infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
420
auxn = node->xmlChildrenNode;
422
infb_fill_node(view,doc,auxn,level+1);
428
text = xmlGetProp(node,BAD_CAST "title");
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);
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");
440
if (level>0) gtk_text_buffer_insert_at_cursor(buff,levstr,2*level);
441
infb_insert_group(view,text,node);
444
if ( text2 && xmlStrcmp(text2,BAD_CAST "1")==0 ) {
445
auxn = node->xmlChildrenNode;
447
infb_fill_node(view,doc,auxn,level+1);
451
if (text2) xmlFree(text2);
453
/* ************************** ELEMENT **************************************/
454
else if ( xmlStrcmp(node->name,BAD_CAST "element") ==0 ) { /* element */
456
xmlNodeSetPtr nodeset,nodeset2;
457
xmlXPathObjectPtr result,result2;
461
gboolean attr_section=FALSE, param_section = FALSE, ret_section=FALSE;
464
text = xmlGetProp(node,BAD_CAST "name");
465
infb_insert_text(buff,text,INFB_TT_TITLE,TRUE);
468
result = getnodeset(doc,BAD_CAST "child::description",node);
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);
476
xmlXPathFreeObject (result);
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");
486
str = g_strdup_printf("//def[@deftype='proplist' and @id='%s']",text);
487
an = getnode(doc,BAD_CAST str,NULL);
492
result2 = getnodeset(doc,BAD_CAST "child::property[@kind='attribute']",an);
493
if (result2 && result2->nodesetval->nodeNr > 0) {
495
infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
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");
503
if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0)
504
str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
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);
512
if (text2) xmlFree(text2);
513
an2 = getnode(doc,BAD_CAST "child::description",nodeset2->nodeTab[j]);
515
text = xmlNodeGetContent(an2);
517
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
522
xmlXPathFreeObject (result2);
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;
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");
536
if ( text2 && xmlStrcmp(text2,BAD_CAST "")!=0)
537
str = g_strconcat((gchar*)text," (",(gchar*)text2,")",NULL);
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);
545
if (text2) xmlFree(text2);
546
an2 = getnode(doc,BAD_CAST "child::description",nodeset2->nodeTab[j]);
548
text = xmlNodeGetContent(an2);
550
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
555
xmlXPathFreeObject (result2);
558
} /* proplist found */
562
if (result) xmlXPathFreeObject(result);
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");
571
str = g_strdup_printf("//def[@deftype='property' and @id='%s']",text);
572
an = getnode(doc,BAD_CAST str,NULL);
575
text = xmlGetProp(an,BAD_CAST "kind");
577
if (xmlStrcmp(text,BAD_CAST "attribute")==0) {
579
infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
582
text2 = xmlGetProp(an,BAD_CAST "name");
583
text3 = xmlGetProp(an,BAD_CAST "type");
585
if ( text3 && xmlStrcmp(text3,BAD_CAST "")!=0)
586
str = g_strconcat((gchar*)text2," (",(gchar*)text3,")",NULL);
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);
594
if (text3) xmlFree(text3);
595
an2 = getnode(doc,BAD_CAST "child::description",an);
597
text2 = xmlNodeGetContent(an2);
599
infb_insert_text(buff,text2,INFB_TT_SMALL,TRUE);
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;
609
text2 = xmlGetProp(an,BAD_CAST "name");
610
text3 = xmlGetProp(an,BAD_CAST "type");
612
if ( text3 && xmlStrcmp(text3,BAD_CAST "")!=0)
613
str = g_strconcat((gchar*)text2," (",(gchar*)text3,")",NULL);
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);
621
if (text3) xmlFree(text3);
622
an2 = getnode(doc,BAD_CAST "child::description",an);
624
text2 = xmlNodeGetContent(an2);
626
infb_insert_text(buff,text2,INFB_TT_SMALL,TRUE);
631
else if (xmlStrcmp(text,BAD_CAST "return")==0) {
633
text2 = xmlGetProp(an,BAD_CAST "type");
635
str = g_strconcat("Returned type: ",(gchar*)text2,NULL);
636
infb_insert_text(buff,BAD_CAST str,INFB_TT_SECTION,TRUE);
640
infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
648
} /* single property */
649
if (result) xmlXPathFreeObject(result);
652
result = getnodeset(doc,BAD_CAST "child::properties/property[@kind='attribute']",node);
653
if (result && result->nodesetval->nodeNr > 0) {
655
infb_insert_text(buff,BAD_CAST "Attributes",INFB_TT_SECTION,TRUE);
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);
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);
670
if (text2) xmlFree(text2);
671
an = getnode(doc,BAD_CAST "child::description",nodeset->nodeTab[i]);
673
text = xmlNodeGetContent(an);
674
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
679
if (result) xmlXPathFreeObject(result);
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;
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);
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);
700
if (text2) xmlFree(text2);
701
an = getnode(doc,BAD_CAST "child::description",nodeset->nodeTab[i]);
703
text = xmlNodeGetContent(an);
704
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
709
if (result) xmlXPathFreeObject(result);
712
an = getnode(doc,BAD_CAST "child::properties/property[@kind='return']",node);
715
text2 = xmlGetProp(an,BAD_CAST "type");
717
str = g_strconcat("Returned type: ",(gchar*)text2,NULL);
718
infb_insert_text(buff,BAD_CAST str,INFB_TT_SECTION,TRUE);
722
infb_insert_text(buff,BAD_CAST "",INFB_TT_NONE,TRUE);
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]);
734
text = xmlNodeGetContent(an);
735
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
740
if (result) xmlXPathFreeObject(result);
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);
750
text = xmlNodeGetContent(nodeset->nodeTab[i]);
751
infb_insert_text(buff,text,INFB_TT_SMALL,TRUE);
755
if (result) xmlXPathFreeObject(result);
758
text = xmlGetProp(node,BAD_CAST "name");
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);
769
if ( level > 0 ) g_free(levstr);
774
void infb_fill_doc(Tbfwin *bfwin,xmlNodePtr root) {
781
auxp = g_hash_table_lookup(infb_v.windows,bfwin);
783
view = GTK_TEXT_VIEW(((Tinfbwin*)auxp)->view);
784
if ( infb_v.currentDoc == NULL || view==NULL ) return;
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);
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);
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);
806
infb_set_current_type(infb_v.currentDoc);
808
if ( infb_v.currentType == INFB_DOCTYPE_UNKNOWN ) {
809
infb_insert_error(view,BAD_CAST _("Unknown document type"));
813
node = xmlDocGetRootElement(infb_v.currentDoc);
814
infb_v.currentNode = node;
815
infb_fill_node(view,infb_v.currentDoc,node,0);
818
infb_v.currentNode = root;
819
infb_fill_node(view,infb_v.currentDoc,root,0);
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));