summaryrefslogtreecommitdiff
path: root/src/glibext/gbuffersegment.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-03-08 19:30:52 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-03-08 19:30:52 (GMT)
commit68bb7efaf61e4f5ca2f2cffce84995ffd667c4cc (patch)
tree9b6a6f63ee20b08d8c2ac35849ee051d61787447 /src/glibext/gbuffersegment.c
parentdc9e68505c4cc7ad208e63dbc7d0e0e8f582d0d9 (diff)
Handle cross references as well as entry points.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@482 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/gbuffersegment.c')
-rw-r--r--src/glibext/gbuffersegment.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/glibext/gbuffersegment.c b/src/glibext/gbuffersegment.c
index 27891a8..d25d728 100644
--- a/src/glibext/gbuffersegment.c
+++ b/src/glibext/gbuffersegment.c
@@ -98,6 +98,8 @@ struct _GBufferSegment
{
GObject parent; /* A laisser en premier */
+ GObject *creator; /* Objet à l'origine du segment*/
+
char *text; /* Texte brut conservé */
fnv64_t hash; /* Empreinte pour comparaisons */
@@ -131,6 +133,12 @@ static void g_buffer_segment_class_init(GBufferSegmentClass *);
/* Procède à l'initialisation d'un fragment de texte. */
static void g_buffer_segment_init(GBufferSegment *);
+/* Supprime toutes les références externes. */
+static void g_buffer_segment_dispose(GBufferSegment *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_buffer_segment_finalize(GBufferSegment *);
+
/* Définit les dernières propriétés de rendu restantes. */
static void g_buffer_segment_prepare(GBufferSegment *, size_t);
@@ -154,6 +162,7 @@ G_DEFINE_TYPE(GBufferSegment, g_buffer_segment, G_TYPE_OBJECT);
static void g_buffer_segment_class_init(GBufferSegmentClass *class)
{
+ GObjectClass *object; /* Autre version de la classe */
GtkStyleContext *context; /* Contexte pour les styles */
GtkWidgetPath *path; /* Chemin d'accès aux thèmes */
gchar *filename; /* Accès à une image 1x1 */
@@ -164,6 +173,11 @@ static void g_buffer_segment_class_init(GBufferSegmentClass *class)
cairo_text_extents_t extents; /* Couverture des caractères */
RenderingTagType i; /* Boucle de parcours */
+ object = G_OBJECT_CLASS(class);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_buffer_segment_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_buffer_segment_finalize;
+
/* Création d'un contexte d'accès */
path = gtk_widget_path_new();
@@ -285,6 +299,47 @@ static void g_buffer_segment_init(GBufferSegment *segment)
/******************************************************************************
* *
+* Paramètres : segment = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_buffer_segment_dispose(GBufferSegment *segment)
+{
+ if (segment->creator != NULL)
+ g_object_unref(segment->creator);
+
+ G_OBJECT_CLASS(g_buffer_segment_parent_class)->dispose(G_OBJECT(segment));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : segment = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_buffer_segment_finalize(GBufferSegment *segment)
+{
+ G_OBJECT_CLASS(g_buffer_segment_parent_class)->finalize(G_OBJECT(segment));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = propriétés de la zone de texte. *
* text = chaîne de caractères à traiter. *
* length = quantité de ces caractères. *
@@ -359,6 +414,52 @@ static void g_buffer_segment_prepare(GBufferSegment *segment, size_t length)
/******************************************************************************
* *
+* Paramètres : segment = instance de segment à compléter. *
+* obj = instance GLib quelconque à mémoriser. *
+* *
+* Description : Associe à un segment un objet GLib identifié comme créateur. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_buffer_segment_set_creator(GBufferSegment *segment, GObject *obj)
+{
+ if (segment->creator != NULL)
+ g_object_unref(segment->creator);
+
+ segment->creator = obj;
+ g_object_ref(obj);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : segment = instance de segment à compléter. *
+* *
+* Description : Renvoie vers un éventuel objet lié en tant que créateur. *
+* *
+* Retour : Instance GLib quelconque ou NULL si aucune référencée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GObject *g_buffer_segment_get_creator(const GBufferSegment *segment)
+{
+ if (segment->creator != NULL)
+ g_object_ref(segment->creator);
+
+ return segment->creator;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : segment = fragment de texte à consulter. *
* ref = segment de référence servant à la comparaison. *
* *