summaryrefslogtreecommitdiff
path: root/src/gtkext/graph
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-05 19:36:17 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-05 19:36:17 (GMT)
commit405698182c46a82d92ccd50baa43fea5e40b1f6a (patch)
treedacf2a26ef9c32339f777a301e3cce9d1e8fbeed /src/gtkext/graph
parentd626276398a3cdd3cd6432e073a8866aa91418ce (diff)
Removed dot warnings and connected all edges to the panel views.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@318 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/graph')
-rw-r--r--src/gtkext/graph/dot.c4
-rw-r--r--src/gtkext/graph/node.c89
2 files changed, 73 insertions, 20 deletions
diff --git a/src/gtkext/graph/dot.c b/src/gtkext/graph/dot.c
index 0e7091e..64ca2b5 100644
--- a/src/gtkext/graph/dot.c
+++ b/src/gtkext/graph/dot.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* dot.c - interactions avec le système dot
*
- * Copyright (C) 2009-2012 Cyrille Bagard
+ * Copyright (C) 2009-2013 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -60,6 +60,8 @@ graph_layout *create_graph_layout(char *cmds)
result = (graph_layout *)calloc(1, sizeof(graph_layout));
+ agseterr(AGMAX);
+
result->context = gvContext();
result->graph = agmemread(cmds);
diff --git a/src/gtkext/graph/node.c b/src/gtkext/graph/node.c
index d9b0eca..879139a 100644
--- a/src/gtkext/graph/node.c
+++ b/src/gtkext/graph/node.c
@@ -71,6 +71,12 @@ static void g_graph_node_class_init(GGraphNodeClass *);
/* Initialise la classe des intermédiaires avec les noeuds dot. */
static void g_graph_node_init(GGraphNode *);
+/* Supprime toutes les références externes. */
+static void g_graph_node_dispose(GGraphNode *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_graph_node_finalize(GGraphNode *);
+
/* ---------------------------------------------------------------------------------- */
@@ -96,12 +102,20 @@ G_DEFINE_TYPE(GGraphNode, g_graph_node, G_TYPE_OBJECT);
static void g_graph_node_class_init(GGraphNodeClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
GdkScreen *screen; /* Ecran par défaut */
gint width; /* Largeur d'écran en pixels */
gint height; /* Hauteur d'écran en pixels */
gint width_mm; /* Largeur d'écran en mm. */
gint height_mm; /* Hauteur d'écran en mm. */
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_graph_node_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_graph_node_finalize;
+
+ /* Calcul des résolutions */
+
screen = gdk_screen_get_default();
width = gdk_screen_get_width(screen);
@@ -158,6 +172,48 @@ static void g_graph_node_init(GGraphNode *node)
/******************************************************************************
* *
+* Paramètres : node = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_graph_node_dispose(GGraphNode *node)
+{
+ g_object_unref(G_OBJECT(node->view));
+
+ G_OBJECT_CLASS(g_graph_node_parent_class)->dispose(G_OBJECT(node));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : node = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_graph_node_finalize(GGraphNode *node)
+{
+ free(node->name);
+
+ G_OBJECT_CLASS(g_graph_node_parent_class)->finalize(G_OBJECT(node));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : view = morceau d'affichage à représenter. *
* *
* Description : Constitue un intermédiaire entre un noeud dot et du code. *
@@ -176,6 +232,7 @@ GGraphNode *g_graph_node_new(GtkWidget *view)
result = g_object_new(G_TYPE_GRAPH_NODE, NULL);
result->view = view;
+ g_object_ref(G_OBJECT(view));
len = 3 + sizeof(GtkWidget *) * 2 + 1;
@@ -305,34 +362,28 @@ void g_graph_node_connect(const GGraphNode *node, gint x, gint y, GdkPoint **poi
*points = (GdkPoint *)realloc(*points, ++(*count) * sizeof(GdkPoint));
/* Si le point est sur la gauche... */
- if (alloc->y <= y && y < (alloc->y + alloc->height) && x < alloc->x)
- {
+ if (x < alloc->x)
(*points)[*count - 1].x = alloc->x;
- (*points)[*count - 1].y = y;
- }
- /* Si le point est sur la droite... */
- else if (alloc->y <= y && y < (alloc->y + alloc->height) && x > (alloc->x + alloc->width))
- {
+ /* Ou s'il est sur la droite... */
+ else if (x > (alloc->x + alloc->width))
(*points)[*count - 1].x = alloc->x + alloc->width;
- (*points)[*count - 1].y = y;
- }
- /* Si le point est au dessus... */
- else if (alloc->x <= x && x < (alloc->x + alloc->width) && y < alloc->y)
- {
+ /* Ou s'il se trouve déjà bien placé... */
+ else
(*points)[*count - 1].x = x;
+
+ /* Si le point est au dessus... */
+ if (y < alloc->y)
(*points)[*count - 1].y = alloc->y;
- }
- /* Si le point est en dessous... */
- else if (alloc->x <= x && x < (alloc->x + alloc->width) && y > (alloc->y + alloc->height))
- {
- (*points)[*count - 1].x = x;
+ /* Ou s'il est en dessous... */
+ else if (y > (alloc->y + alloc->height))
(*points)[*count - 1].y = alloc->y + alloc->height;
- }
- else (*count)--;
+ /* Ou s'il se trouve déjà bien placé... */
+ else
+ (*points)[*count - 1].y = y;
}