summaryrefslogtreecommitdiff
path: root/src/gtkext/gtksourceview.c
blob: 254f798b5178658d31283c35ec4680c007e823b3 (plain)
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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * gtksourceview.c - affichage de code source
 *
 * Copyright (C) 2010-2012 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  OpenIDA 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  OpenIDA 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "gtksourceview.h"


#include "gtkbufferview-int.h"



/* -------------------------- INTERACTION DIRECTE AVEC GTK -------------------------- */


/* Composant d'affichage de code source (instance) */
struct _GtkSourceView
{
    GtkBufferView parent;                   /* A laisser en premier        */

};

/* Composant d'affichage de code source (classe) */
struct _GtkSourceViewClass
{
    GtkBufferViewClass parent;              /* A laisser en premier        */

};


/* Procède à l'initialisation de l'afficheur de code source. */
static void gtk_source_view_class_init(GtkSourceViewClass *);

/* Procède à l'initialisation de l'afficheur de code source. */
static void gtk_source_view_init(GtkSourceView *);

/* Prend acte de l'association d'un binaire chargé. */
static void gtk_source_view_attach_binary(GtkSourceView *, GLoadedBinary *);



/* ---------------------------------------------------------------------------------- */
/*                            INTERACTION DIRECTE AVEC GTK                            */
/* ---------------------------------------------------------------------------------- */


/* Détermine le type du composant d'affichage de code source. */
G_DEFINE_TYPE(GtkSourceView, gtk_source_view, GTK_TYPE_BUFFER_VIEW)


/******************************************************************************
*                                                                             *
*  Paramètres  : class = classe GTK à initialiser.                            *
*                                                                             *
*  Description : Procède à l'initialisation de l'afficheur de code source.    *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void gtk_source_view_class_init(GtkSourceViewClass *class)
{
    GtkViewPanelClass *panel_class;         /* Classe parente              */

    panel_class = GTK_VIEW_PANEL_CLASS(class);

    panel_class->attach = (attach_binary_fc)gtk_source_view_attach_binary;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : view = composant GTK à initialiser.                          *
*                                                                             *
*  Description : Procède à l'initialisation de l'afficheur de code source.    *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void gtk_source_view_init(GtkSourceView *view)
{

}


/******************************************************************************
*                                                                             *
*  Paramètres  : -                                                            *
*                                                                             *
*  Description : Crée un nouveau composant pour l'affichage de code source.   *
*                                                                             *
*  Retour      : Composant GTK créé.                                          *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GtkWidget *gtk_source_view_new(void)
{
    GtkSourceView *result;                  /* Composant à retourner       */

    result = g_object_new(GTK_TYPE_SOURCE_VIEW, NULL);

    return GTK_WIDGET(result);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : view   = composant GTK à mettre à jour.                      *
*                binary = binaire associé à intégrer.                         *
*                                                                             *
*  Description : Prend acte de l'association d'un binaire chargé.             *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void gtk_source_view_attach_binary(GtkSourceView *view, GLoadedBinary *binary)
{
    GCodeBuffer *buffer;                    /* Tampon par défaut           */

    buffer = g_loaded_binary_get_decompiled_buffer(binary, -1);

    /* Si une source existe... */
    if (buffer != NULL)
        gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer, NULL));

}