summaryrefslogtreecommitdiff
path: root/src/gtkext/graph
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-04-06 11:09:00 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-04-06 11:09:00 (GMT)
commit944225261e872785366d1df5377f59ea917a2195 (patch)
treefb6d2c12e22f368808bfb92557d647b1e5688a8a /src/gtkext/graph
parente108e192582aa1dbe020dfbc09bee5e6ab2cc534 (diff)
Done some refactoring in order to make the code more GObject-friendly.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@506 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/graph')
-rw-r--r--src/gtkext/graph/node-int.h16
-rw-r--r--src/gtkext/graph/node.c22
-rw-r--r--src/gtkext/graph/node.h11
-rw-r--r--src/gtkext/graph/nodes/flow.c13
-rw-r--r--src/gtkext/graph/nodes/flow.h11
-rw-r--r--src/gtkext/graph/nodes/virtual.c32
-rw-r--r--src/gtkext/graph/nodes/virtual.h11
7 files changed, 53 insertions, 63 deletions
diff --git a/src/gtkext/graph/node-int.h b/src/gtkext/graph/node-int.h
index 18b6b20..2572fce 100644
--- a/src/gtkext/graph/node-int.h
+++ b/src/gtkext/graph/node-int.h
@@ -56,14 +56,6 @@ struct _GGraphNode
{
GObject parent; /* A laisser en premier */
- get_node_rank_fc get_rank; /* Premier rang d'appartenance */
- node_reset_pos_fc reset_pos; /* Réinitialise l'emplacement */
- node_prepare_x_fc prepare_x; /* Préparation des abscisses */
- node_apply_pos_fc apply_pos; /* Applique une absisse finale */
- node_set_pos_fc set_pos; /* Définit l'emplacement */
- visit_flow_nodes_fc visit; /* Visite des noeuds d'exécut° */
- find_container_fc contain; /* Retrouve un conteneur */
-
GtkAllocation alloc; /* Emplacement du bloc rattaché*/
pending_position pending_pos; /* Indication sur la position */
PendingPositionFlags pending_flag; /* Cible le champ valide */
@@ -81,6 +73,14 @@ struct _GGraphNodeClass
{
GObjectClass parent; /* A laisser en premier */
+ get_node_rank_fc get_rank; /* Premier rang d'appartenance */
+ node_reset_pos_fc reset_pos; /* Réinitialise l'emplacement */
+ node_prepare_x_fc prepare_x; /* Préparation des abscisses */
+ node_apply_pos_fc apply_pos; /* Applique une absisse finale */
+ node_set_pos_fc set_pos; /* Définit l'emplacement */
+ visit_flow_nodes_fc visit; /* Visite des noeuds d'exécut° */
+ find_container_fc contain; /* Retrouve un conteneur */
+
};
diff --git a/src/gtkext/graph/node.c b/src/gtkext/graph/node.c
index 439d4e7..4fd7a8e 100644
--- a/src/gtkext/graph/node.c
+++ b/src/gtkext/graph/node.c
@@ -159,7 +159,7 @@ static void g_graph_node_finalize(GGraphNode *node)
unsigned int g_graph_node_get_rank(const GGraphNode *node)
{
- return node->get_rank(node);
+ return G_GRAPH_NODE_GET_CLASS(node)->get_rank(node);
}
@@ -183,8 +183,8 @@ void g_graph_node_reset_position(GGraphNode *node)
node->pending_flag = PPF_NONE;
- if (node->reset_pos != NULL)
- node->reset_pos(node);
+ if (G_GRAPH_NODE_GET_CLASS(node)->reset_pos != NULL)
+ G_GRAPH_NODE_GET_CLASS(node)->reset_pos(node);
}
@@ -204,7 +204,7 @@ void g_graph_node_reset_position(GGraphNode *node)
void g_graph_node_prepare_x_line(GGraphNode *node, GGraphNode *nodes)
{
- node->prepare_x(node, nodes);
+ G_GRAPH_NODE_GET_CLASS(node)->prepare_x(node, nodes);
}
@@ -226,8 +226,8 @@ void g_graph_node_apply_position(GGraphNode *node)
gint x_pos; /* Position de référence */
GGraphNode *ref; /* Accès rapide */
- if (node->apply_pos != NULL)
- node->apply_pos(node);
+ if (G_GRAPH_NODE_GET_CLASS(node)->apply_pos != NULL)
+ G_GRAPH_NODE_GET_CLASS(node)->apply_pos(node);
switch (node->pending_flag)
{
@@ -289,8 +289,8 @@ void g_graph_node_apply_position(GGraphNode *node)
void g_graph_node_set_x_position(GGraphNode *node, gint x)
{
- if (node->set_pos != NULL && x != GRAPH_HORIZONTAL_MARGIN)
- node->set_pos(node, x);
+ if (G_GRAPH_NODE_GET_CLASS(node)->set_pos != NULL && x != GRAPH_HORIZONTAL_MARGIN)
+ G_GRAPH_NODE_GET_CLASS(node)->set_pos(node, x);
node->alloc.x = x;
@@ -403,7 +403,7 @@ GtkAllocation g_graph_node_get_allocation(const GGraphNode *node)
bool g_graph_node_visit_nodes(GGraphNode *node, graph_node_visitor_cb callback, void *data)
{
- return node->visit(node, callback, data);
+ return G_GRAPH_NODE_GET_CLASS(node)->visit(node, callback, data);
}
@@ -427,8 +427,8 @@ GGraphNode *g_graph_node_find_container(GGraphNode *nodes, GGraphNode *target)
result = NULL;
- if (nodes->contain != NULL)
- result = nodes->contain(nodes, target);
+ if (G_GRAPH_NODE_GET_CLASS(nodes)->contain != NULL)
+ result = G_GRAPH_NODE_GET_CLASS(nodes)->contain(nodes, target);
return result;
diff --git a/src/gtkext/graph/node.h b/src/gtkext/graph/node.h
index c68719e..ab7d0da 100644
--- a/src/gtkext/graph/node.h
+++ b/src/gtkext/graph/node.h
@@ -37,11 +37,12 @@
/* -------------------------- GESTION DES NOEUDS A L'UNITE -------------------------- */
-#define G_TYPE_GRAPH_NODE g_graph_node_get_type()
-#define G_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_graph_node_get_type(), GGraphNode))
-#define G_IS_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_graph_node_get_type()))
-#define G_GRAPH_NODE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_graph_node_get_type(), GGraphNodeIface))
-#define G_GRAPH_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_GRAPH_NODE, GGraphNodeClass))
+#define G_TYPE_GRAPH_NODE (g_graph_node_get_type())
+#define G_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GRAPH_NODE, GGraphNode))
+#define G_GRAPH_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GRAPH_NODE, GGraphNodeClass))
+#define G_IS_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GRAPH_NODE))
+#define G_IS_GRAPH_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GRAPH_NODE))
+#define G_GRAPH_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_GRAPH_NODE, GGraphNodeClass))
/* Intermédiaire entre le noeud dot et la bribe de code (instance) */
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c
index d691da5..5ff21c9 100644
--- a/src/gtkext/graph/nodes/flow.c
+++ b/src/gtkext/graph/nodes/flow.c
@@ -130,12 +130,18 @@ G_DEFINE_TYPE(GFlowNode, g_flow_node, G_TYPE_GRAPH_NODE);
static void g_flow_node_class_init(GFlowNodeClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
+ GGraphNodeClass *node_class; /* Version parente de la classe*/
object = G_OBJECT_CLASS(klass);
+ node_class = G_GRAPH_NODE_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_flow_node_dispose;
object->finalize = (GObjectFinalizeFunc)g_flow_node_finalize;
+ node_class->get_rank = (get_node_rank_fc)g_flow_node_get_rank;
+ node_class->prepare_x = (node_prepare_x_fc)g_flow_node_prepare_x_line;
+ node_class->visit = (visit_flow_nodes_fc)g_flow_node_visit_flow_nodes;
+
}
@@ -153,13 +159,6 @@ static void g_flow_node_class_init(GFlowNodeClass *klass)
static void g_flow_node_init(GFlowNode *node)
{
- GGraphNode *base; /* Version basique */
-
- base = G_GRAPH_NODE(node);
-
- base->get_rank = (get_node_rank_fc)g_flow_node_get_rank;
- base->prepare_x = (node_prepare_x_fc)g_flow_node_prepare_x_line;
- base->visit = (visit_flow_nodes_fc)g_flow_node_visit_flow_nodes;
}
diff --git a/src/gtkext/graph/nodes/flow.h b/src/gtkext/graph/nodes/flow.h
index 4e34481..413a8f2 100644
--- a/src/gtkext/graph/nodes/flow.h
+++ b/src/gtkext/graph/nodes/flow.h
@@ -35,11 +35,12 @@ typedef struct _GGraphLayout GGraphLayout;
-#define G_TYPE_FLOW_NODE g_flow_node_get_type()
-#define G_FLOW_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_flow_node_get_type(), GFlowNode))
-#define G_IS_FLOW_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_flow_node_get_type()))
-#define G_FLOW_NODE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_flow_node_get_type(), GFlowNodeIface))
-#define G_FLOW_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_FLOW_NODE, GFlowNodeClass))
+#define G_TYPE_FLOW_NODE (g_flow_node_get_type())
+#define G_FLOW_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_FLOW_NODE, GFlowNode))
+#define G_FLOW_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_FLOW_NODE, GFlowNodeClass))
+#define G_IS_FLOW_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_FLOW_NODE))
+#define G_IS_FLOW_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_FLOW_NODE))
+#define G_FLOW_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_FLOW_NODE, GFlowNodeClass))
/* Type d'un accrochage pour lien */
diff --git a/src/gtkext/graph/nodes/virtual.c b/src/gtkext/graph/nodes/virtual.c
index cb46aee..894c6b6 100644
--- a/src/gtkext/graph/nodes/virtual.c
+++ b/src/gtkext/graph/nodes/virtual.c
@@ -85,9 +85,6 @@ struct _GVirtualNode
GVirtualBlock *block; /* Bloc virtuel associé */
- gint x; /* Abscisse du noeud */
- gint y; /* Ordonnée du noeud */
-
GGraphNode **children; /* Noeuds englobés */
size_t count; /* Quantité de ces noeuds */
virtual_level *levels; /* Différents étages de noeuds */
@@ -245,11 +242,6 @@ static void extend_vertical_links_spans(vert_links *links, const reserved_vspan
-
-
-
-
-
/* ---------------------------------------------------------------------------------- */
/* REPRESENTATIONS DES GROUPES LOGIQUES */
/* ---------------------------------------------------------------------------------- */
@@ -274,12 +266,22 @@ G_DEFINE_TYPE(GVirtualNode, g_virtual_node, G_TYPE_GRAPH_NODE);
static void g_virtual_node_class_init(GVirtualNodeClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
+ GGraphNodeClass *node_class; /* Version parente de la classe*/
object = G_OBJECT_CLASS(klass);
+ node_class = G_GRAPH_NODE_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_virtual_node_dispose;
object->finalize = (GObjectFinalizeFunc)g_virtual_node_finalize;
+ node_class->get_rank = (get_node_rank_fc)g_virtual_node_get_rank;
+ node_class->reset_pos = (node_reset_pos_fc)g_virtual_node_reset_position;
+ node_class->prepare_x = (node_prepare_x_fc)g_virtual_node_prepare_x_line;
+ node_class->apply_pos = (node_apply_pos_fc)g_virtual_node_apply_position;
+ node_class->set_pos = (node_set_pos_fc)g_virtual_node_set_position;
+ node_class->visit = (visit_flow_nodes_fc)g_virtual_node_visit_flow_nodes;
+ node_class->contain = (find_container_fc)g_virtual_node_find_container;
+
}
@@ -297,20 +299,6 @@ static void g_virtual_node_class_init(GVirtualNodeClass *klass)
static void g_virtual_node_init(GVirtualNode *node)
{
- GGraphNode *base; /* Version basique */
-
- base = G_GRAPH_NODE(node);
-
- base->get_rank = (get_node_rank_fc)g_virtual_node_get_rank;
- base->reset_pos = (node_reset_pos_fc)g_virtual_node_reset_position;
- base->prepare_x = (node_prepare_x_fc)g_virtual_node_prepare_x_line;
- base->apply_pos = (node_apply_pos_fc)g_virtual_node_apply_position;
- base->set_pos = (node_set_pos_fc)g_virtual_node_set_position;
- base->visit = (visit_flow_nodes_fc)g_virtual_node_visit_flow_nodes;
- base->contain = (find_container_fc)g_virtual_node_find_container;
-
- node->x = UNINITIALIZED_NODE_POS;
- node->y = UNINITIALIZED_NODE_POS;
}
diff --git a/src/gtkext/graph/nodes/virtual.h b/src/gtkext/graph/nodes/virtual.h
index c496df5..7f32591 100644
--- a/src/gtkext/graph/nodes/virtual.h
+++ b/src/gtkext/graph/nodes/virtual.h
@@ -36,11 +36,12 @@ typedef size_t vspan_slot_t;
#define UNINITIALIZED_VSPAN_SLOT (~((vspan_slot_t)0))
-#define G_TYPE_VIRTUAL_NODE g_virtual_node_get_type()
-#define G_VIRTUAL_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_virtual_node_get_type(), GVirtualNode))
-#define G_IS_VIRTUAL_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_virtual_node_get_type()))
-#define G_VIRTUAL_NODE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_virtual_node_get_type(), GVirtualNodeIface))
-#define G_VIRTUAL_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_VIRTUAL_NODE, GVirtualNodeClass))
+#define G_TYPE_VIRTUAL_NODE (g_virtual_node_get_type())
+#define G_VIRTUAL_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_VIRTUAL_NODE, GVirtualNode))
+#define G_VIRTUAL_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_VIRTUAL_NODE, GVirtualNodeClass))
+#define G_IS_VIRTUAL_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_VIRTUAL_NODE))
+#define G_IS_VIRTUAL_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_VIRTUAL_NODE))
+#define G_VIRTUAL_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_VIRTUAL_NODE, GVirtualNodeClass))
/* Encapsulation graphique d'un bloc virtuel (instance) */