1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
4 * Copyright (C) 2011 Sébastien Granjoux
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
27 #include "amp-object.h"
30 #include "am-scanner.h"
31 #include "am-properties.h"
32 #include "am-writer.h"
35 #include <libanjuta/interfaces/ianjuta-project.h>
37 #include <libanjuta/anjuta-debug.h>
39 #include <glib/gi18n.h>
46 *---------------------------------------------------------------------------*/
48 struct _AmpObjectNode
{
49 AnjutaProjectNode base
;
56 *---------------------------------------------------------------------------*/
59 amp_object_node_new (GFile
*file
, AnjutaProjectNodeType type
)
61 AmpObjectNode
*node
= NULL
;
63 node
= g_object_new (AMP_TYPE_OBJECT_NODE
, NULL
);
64 node
->base
.file
= g_object_ref (file
);
65 node
->base
.type
= ANJUTA_PROJECT_OBJECT
| type
;
67 return ANJUTA_PROJECT_NODE (node
);
71 amp_object_node_new_valid (GFile
*file
, AnjutaProjectNodeType type
, GError
**error
)
73 return amp_object_node_new (file
, type
);
77 amp_object_node_free (AmpObjectNode
*node
)
79 g_object_unref (G_OBJECT (node
));
82 /* AmpNode implementation
83 *---------------------------------------------------------------------------*/
86 amp_object_node_update (AmpNode
*node
, AmpNode
*new_node
)
93 amp_object_node_write (AmpNode
*node
, AmpNode
*parent
, AmpProject
*project
, GError
**error
)
99 amp_object_node_erase (AmpNode
*node
, AmpNode
*parent
, AmpProject
*project
, GError
**error
)
107 /* GObjet implementation
108 *---------------------------------------------------------------------------*/
110 typedef struct _AmpObjectNodeClass AmpObjectNodeClass
;
112 struct _AmpObjectNodeClass
{
113 AmpNodeClass parent_class
;
116 G_DEFINE_DYNAMIC_TYPE (AmpObjectNode
, amp_object_node
, AMP_TYPE_NODE
);
119 amp_object_node_init (AmpObjectNode
*node
)
121 node
->base
.type
= ANJUTA_PROJECT_OBJECT
;
122 node
->base
.properties_info
= NULL
;
123 node
->base
.state
= 0;
127 amp_object_node_finalize (GObject
*object
)
129 AmpObjectNode
*node
= AMP_OBJECT_NODE (object
);
131 G_OBJECT_CLASS (amp_object_node_parent_class
)->finalize (object
);
135 amp_object_node_class_init (AmpObjectNodeClass
*klass
)
137 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
138 AmpNodeClass
* node_class
;
140 object_class
->finalize
= amp_object_node_finalize
;
142 node_class
= AMP_NODE_CLASS (klass
);
143 node_class
->update
= amp_object_node_update
;
144 node_class
->write
= amp_object_node_write
;
145 node_class
->erase
= amp_object_node_erase
;
149 amp_object_node_class_finalize (AmpObjectNodeClass
*klass
)
154 amp_object_node_register (GTypeModule
*module
)
156 amp_object_node_register_type (module
);