1 /*
2  * Nautilus-Actions
3  * A Nautilus extension which offers configurable context menu actions.
4  *
5  * Copyright (C) 2005 The GNOME Foundation
6  * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7  * Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8  *
9  * Nautilus-Actions is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * Nautilus-Actions is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Nautilus-Actions; see the file COPYING. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  * Authors:
24  *   Frederic Ruaudel <grumz@grumz.net>
25  *   Rodrigo Moya <rodrigo@gnome-db.org>
26  *   Pierre Wieser <pwieser@trychlos.org>
27  *   ... and many others (see AUTHORS)
28  */
29 
30 #ifndef __NAUTILUS_ACTIONS_API_NA_OBJECT_H__
31 #define __NAUTILUS_ACTIONS_API_NA_OBJECT_H__
32 
33 /**
34  * SECTION: object
35  * @title: NAObject
36  * @short_description: The Deepest Base Class Definition
37  * @include: nautilus-actions/na-object.h
38  *
39  * This is the base class of all our data object hierarchy. #NAObject is
40  * supposed to be used as a pure virtual base class, i.e. should only be
41  * derived.
42  *
43  * All the API described here is rather private. External code should
44  * use the API described in <filename>nautilus-actions/na-object-api.h</filename>.
45  */
46 
47 #include <glib-object.h>
48 
49 G_BEGIN_DECLS
50 
51 #define NA_TYPE_OBJECT                ( na_object_object_get_type())
52 #define NA_OBJECT( object )           ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_TYPE_OBJECT, NAObject ))
53 #define NA_OBJECT_CLASS( klass )      ( G_TYPE_CHECK_CLASS_CAST( klass, NA_TYPE_OBJECT, NAObjectClass ))
54 #define NA_IS_OBJECT( object )        ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_TYPE_OBJECT ))
55 #define NA_IS_OBJECT_CLASS( klass )   ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_TYPE_OBJECT ))
56 #define NA_OBJECT_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_TYPE_OBJECT, NAObjectClass ))
57 
58 typedef struct _NAObjectPrivate       NAObjectPrivate;
59 
60 typedef struct {
61 	/*< private >*/
62 	GObject          parent;
63 	NAObjectPrivate *private;
64 }
65 	NAObject;
66 
67 typedef struct _NAObjectClassPrivate  NAObjectClassPrivate;
68 
69 /**
70  * NAObjectClass:
71  * @dump:      Dumps the #NAObject -part of the #NAObject -derived object.
72  * @copy:      Copies a #NAObject to another.
73  * @are_equal: Tests if two #NAObject are equal.
74  * @is_valid:  Tests if a #NAObject is valid.
75  *
76  * The #NAObjectClass defines some methods available to derived classes.
77  */
78 typedef struct {
79 	/*< private >*/
80 	GObjectClass          parent;
81 	NAObjectClassPrivate *private;
82 
83 	/*< public >*/
84 	/**
85 	 * dump:
86 	 * @object: the NAObject-derived object to be dumped.
87 	 *
88 	 * Dumps via g_debug the content of the object.
89 	 *
90 	 * The derived class should call its parent class at the end of the
91 	 * dump of its own datas.
92 	 *
93 	 * Since: 2.30
94 	 */
95 	void     ( *dump )     ( const NAObject *object );
96 
97 	/**
98 	 * copy:
99 	 * @target: the NAObject-derived object which will receive data.
100 	 * @source: the NAObject-derived object which provides data.
101 	 * @mode: the copy mode.
102 	 *
103 	 * Copies data and properties from @source to @target.
104 	 *
105 	 * The derived class should call its parent class at the end of the
106 	 * copy of its own datas.
107 	 *
108 	 * Since: 2.30
109 	 */
110 	void     ( *copy )     ( NAObject *target, const NAObject *source, guint mode );
111 
112 	/**
113 	 * are_equal:
114 	 * @a: a first NAObject object.
115 	 * @b: a second NAObject object to be compared to the first one.
116 	 *
117 	 * Compares the two objects.
118 	 *
119 	 * When testing for the modification status of an object, @a stands for
120 	 * the original object, while @b stands for the duplicated one.
121 	 *
122 	 * As long as no difference is detected, the derived class should call
123 	 * its parent class at the end of its comparison.
124 	 * As soon as a difference is detected, the calling sequence should
125 	 * be stopped, and the result returned.
126 	 *
127 	 * Returns: TRUE if @a and @b are identical, FALSE else.
128 	 *
129 	 * Since: 2.30
130 	 */
131 	gboolean ( *are_equal )( const NAObject *a, const NAObject *b );
132 
133 	/**
134 	 * is_valid:
135 	 * @object: the NAObject object to be checked.
136 	 *
137 	 * Checks @object for validity.
138 	 *
139 	 * A NAObject is valid if its internal identifier is set.
140 	 *
141 	 * As long as the item is valid, the derived class should call its parent
142 	 * at the end of its checks.
143 	 * As soon as an error is detected, the calling sequence should be stopped,
144 	 * and the result returned.
145 	 *
146 	 * Returns: TRUE if @object is valid, FALSE else.
147 	 *
148 	 * Since: 2.30
149 	 */
150 	gboolean ( *is_valid ) ( const NAObject *object );
151 }
152 	NAObjectClass;
153 
154 GType     na_object_object_get_type( void );
155 
156 void      na_object_object_check_status_rec( const NAObject *object );
157 
158 void      na_object_object_reset_origin   ( NAObject *object, const NAObject *origin );
159 
160 NAObject *na_object_object_ref  ( NAObject *object );
161 void      na_object_object_unref( NAObject *object );
162 
163 void      na_object_object_dump      ( const NAObject *object );
164 void      na_object_object_dump_norec( const NAObject *object );
165 void      na_object_object_dump_tree ( GList *tree );
166 
167 #ifdef NA_ENABLE_DEPRECATED
168 GList    *na_object_get_hierarchy( const NAObject *object );
169 void      na_object_free_hierarchy( GList *hierarchy );
170 #endif
171 
172 void      na_object_object_debug_invalid( const NAObject *object, const gchar *reason );
173 
174 G_END_DECLS
175 
176 #endif /* __NAUTILUS_ACTIONS_API_NA_OBJECT_H__ */
177