1 #include "poem.h"
2 
parse_fb2_stanza(APP * app,xmlNode * parent_node,GtkTextIter * text_buff_end)3 int parse_fb2_stanza(APP* app, xmlNode* parent_node, GtkTextIter* text_buff_end)
4 {
5 	g_return_val_if_fail(parent_node != NULL,	EXIT_FAILURE);
6 	g_return_val_if_fail(text_buff_end != NULL,	EXIT_FAILURE);
7 
8 	GtkTextBuffer* text_buff	= app->text_buff;
9 	xmlNode* node				= parent_node->children;
10 
11 	gtk_text_buffer_insert(text_buff, text_buff_end, "\n", -1);
12 
13 	GtkTextMark* start_tag_mark	= gtk_text_buffer_create_mark(text_buff, NULL, text_buff_end, TRUE);
14 
15 	while(node != NULL)
16 	{
17 		if(node->type == XML_ELEMENT_NODE)
18 		{
19 			if(strcmp((char*)node->name, "title") == 0)
20 				parse_fb2_title(app, node, text_buff_end);
21 			else if(strcmp((char*)node->name, "subtitle") == 0)
22 				parse_fb2_subtitle(app, node, text_buff_end);
23 			else if(strcmp((char*)node->name, "v") == 0)
24 			{
25 				parse_fb2_v(app, node, text_buff_end);
26 				//gtk_text_buffer_insert(text_buff, text_buff_end, "\n", -1);
27 			}
28 
29 		}
30 
31 		node = node->next;
32 	}
33 
34 	//gtk_text_buffer_insert(text_buff, text_buff_end, "\n", -1);
35 
36 	GtkTextIter start_tag_iter;
37 	gtk_text_buffer_get_iter_at_mark(text_buff, &start_tag_iter, start_tag_mark);
38 	gtk_text_buffer_delete_mark(text_buff, start_tag_mark);
39 	//g_object_unref(G_OBJECT(start_tag_mark));
40 	gtk_text_buffer_apply_tag_by_name(text_buff, "stanza_tag", &start_tag_iter, text_buff_end);
41 
42 	return EXIT_SUCCESS;
43 }
44