aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-node.h
blob: 1509ce126c153f10ae9de655ebac3a616c7536c5 (plain) (blame)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 *  Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
 *  Copyright © 2003 Marco Pesenti Gritti
 *  Copyright © 2003 Christian Persch
 *
 *  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
#error "Only <epiphany/epiphany.h> can be included directly."
#endif

#ifndef EPHY_NODE_H
#define EPHY_NODE_H

#include <libxml/tree.h>
#include <libxml/xmlwriter.h>

G_BEGIN_DECLS

#define EPHY_TYPE_NODE  (ephy_node_get_type ())
#define EPHY_IS_NODE(o) (o != NULL)

typedef struct _EphyNode EphyNode;

typedef enum
{
    EPHY_NODE_DESTROY,           /* EphyNode *node */
    EPHY_NODE_RESTORED,          /* EphyNode *node */
    EPHY_NODE_CHANGED,           /* EphyNode *node, guint property_id */
    EPHY_NODE_CHILD_ADDED,       /* EphyNode *node, EphyNode *child */
    EPHY_NODE_CHILD_CHANGED,     /* EphyNode *node, EphyNode *child, guint property_id */
    EPHY_NODE_CHILD_REMOVED,     /* EphyNode *node, EphyNode *child, guint old_index */
    EPHY_NODE_CHILDREN_REORDERED /* EphyNode *node, int *new_order */
} EphyNodeSignalType;

#include "ephy-node-db.h"

typedef void (*EphyNodeCallback) (EphyNode *node, ...);
typedef gboolean (*EphyNodeFilterFunc) (EphyNode *, gpointer);

GType       ephy_node_get_type          (void) G_GNUC_CONST;

EphyNode   *ephy_node_new                   (EphyNodeDb *db);

EphyNode   *ephy_node_new_with_id           (EphyNodeDb *db,
                         guint reserved_id);

EphyNodeDb *ephy_node_get_db            (EphyNode *node);

/* unique node ID */
guint       ephy_node_get_id                (EphyNode *node);

/* refcounting */
void        ephy_node_ref                   (EphyNode *node);
void        ephy_node_unref                 (EphyNode *node);

/* signals */
int         ephy_node_signal_connect_object (EphyNode *node,
                         EphyNodeSignalType type,
                         EphyNodeCallback callback,
                         GObject *object);

guint       ephy_node_signal_disconnect_object (EphyNode *node,
                         EphyNodeSignalType type,
                         EphyNodeCallback callback,
                         GObject *object);

void        ephy_node_signal_disconnect     (EphyNode *node,
                         int signal_id);

/* properties */
void        ephy_node_set_property          (EphyNode *node,
                             guint property_id,
                             const GValue *value);
gboolean    ephy_node_get_property          (EphyNode *node,
                             guint property_id,
                             GValue *value);

const char *ephy_node_get_property_string   (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_string   (EphyNode *node,
                         guint property_id,
                         const char *value);
gboolean    ephy_node_get_property_boolean  (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_boolean  (EphyNode *node,
                         guint property_id,
                         gboolean value);
long        ephy_node_get_property_long     (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_long     (EphyNode *node,
                         guint property_id,
                         long value);
int         ephy_node_get_property_int      (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_int      (EphyNode *node,
                         guint property_id,
                         int value);
double      ephy_node_get_property_double   (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_double   (EphyNode *node,
                         guint property_id,
                         double value);
float       ephy_node_get_property_float    (EphyNode *node,
                         guint property_id);
void        ephy_node_set_property_float    (EphyNode *node,
                         guint property_id,
                         float value);
EphyNode   *ephy_node_get_property_node     (EphyNode *node,
                         guint property_id);

/* xml storage */
int           ephy_node_write_to_xml        (EphyNode *node,
                         xmlTextWriterPtr writer);
EphyNode     *ephy_node_new_from_xml        (EphyNodeDb *db,
                         xmlNodePtr xml_node);

/* DAG structure */
void          ephy_node_add_child           (EphyNode *node,
                         EphyNode *child);
void          ephy_node_remove_child        (EphyNode *node,
                         EphyNode *child);
void          ephy_node_sort_children       (EphyNode *node,
                         GCompareFunc compare_func);
gboolean      ephy_node_has_child           (EphyNode *node,
                         EphyNode *child);
void          ephy_node_reorder_children    (EphyNode *node,
                         int *new_order);
GPtrArray    *ephy_node_get_children        (EphyNode *node);
int           ephy_node_get_n_children      (EphyNode *node);
EphyNode     *ephy_node_get_nth_child       (EphyNode *node,
                         guint n);
int           ephy_node_get_child_index     (EphyNode *node,
                         EphyNode *child);
EphyNode     *ephy_node_get_next_child      (EphyNode *node,
                         EphyNode *child);
EphyNode     *ephy_node_get_previous_child  (EphyNode *node,
                         EphyNode *child);
void          ephy_node_set_is_drag_source  (EphyNode *node,
                         gboolean allow);
gboolean      ephy_node_get_is_drag_source  (EphyNode *node);
void          ephy_node_set_is_drag_dest    (EphyNode *node,
                         gboolean allow);
gboolean      ephy_node_get_is_drag_dest    (EphyNode *node);

G_END_DECLS

#endif /* __EPHY_NODE_H */