1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 CodeFactory AB
* Copyright (C) 2001 Mikael Hallendal <micke@codefactory.se>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Mikael Hallendal <micke@codefactory.se>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "yelp-book.h"
static void yelp_book_init (YelpBook *book);
static void yelp_book_class_init (YelpBookClass *klass);
GType
yelp_book_get_type (void)
{
static GType book_type = 0;
if (!book_type) {
static const GTypeInfo book_info = {
sizeof (YelpBookClass),
NULL,
NULL,
(GClassInitFunc) yelp_book_class_init,
NULL,
NULL,
sizeof (YelpBook),
0,
(GInstanceInitFunc) yelp_book_init,
};
book_type = g_type_register_static (G_TYPE_OBJECT,
"YelpBook",
&book_info, 0);
}
return book_type;
}
static void
yelp_book_init (YelpBook *book)
{
book->keywords = NULL;
}
static void
yelp_book_class_init (YelpBookClass *klass)
{
}
YelpBook *
yelp_book_new (const gchar *name, GnomeVFSURI *index_uri)
{
YelpBook *book;
book = g_object_new (YELP_TYPE_BOOK, NULL);
book->root = yelp_book_add_section (NULL, name, index_uri, NULL);
return book;
}
static YelpSection *
yelp_book_section_new (const gchar *name,
GnomeVFSURI *uri,
const gchar *reference)
{
YelpSection *section;
g_return_val_if_fail (name != NULL, NULL);
section = g_new0 (YelpSection, 1);
section->name = g_strdup (name);
if (uri) {
section->uri = gnome_vfs_uri_ref (uri);
}
section->reference = g_strdup (reference);
return section;
}
GNode *
yelp_book_add_section (GNode *parent,
const gchar *name,
GnomeVFSURI *uri,
const gchar *reference)
{
GNode *node;
g_return_val_if_fail (name != NULL, NULL);
/* g_print ("Adding section: %s\n", name); */
node = g_node_new (yelp_book_section_new (name, uri, reference));
if (!parent) {
return node;
}
return g_node_insert (parent, -1, node);
}
|