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_IFACTORY_OBJECT_H__ 31 #define __NAUTILUS_ACTIONS_API_NA_IFACTORY_OBJECT_H__ 32 33 /** 34 * SECTION: ifactory-object 35 * @title: NAIFactoryObject 36 * @short_description: The #NAObjectItem Interface v 1 37 * @include: nautilus-actions/na-ifactory_object.h 38 * 39 * This interface is implemented by #NAObjectItem derived objects so that they 40 * can take advantage of our data factory management system. 41 * 42 * A #NAObjectItem derived object which would implement this #NAIFactoryObject 43 * interface must meet following conditions: 44 * <itemizedlist> 45 * <listitem> 46 * <para> 47 * accept an empty constructor 48 * </para> 49 * </listitem> 50 * </itemizedlist> 51 * 52 * <refsect2> 53 * <title>Versions historic</title> 54 * <table> 55 * <title>Historic of the versions of the #NAIFactoryObject interface</title> 56 * <tgroup rowsep="1" colsep="1" align="center" cols="3"> 57 * <colspec colname="na-version" /> 58 * <colspec colname="api-version" /> 59 * <colspec colname="current" /> 60 * <thead> 61 * <row> 62 * <entry>&prodname; version</entry> 63 * <entry>#NAIFactoryObject interface version</entry> 64 * <entry></entry> 65 * </row> 66 * </thead> 67 * <tbody> 68 * <row> 69 * <entry>since 2.30</entry> 70 * <entry>1</entry> 71 * <entry>current version</entry> 72 * </row> 73 * </tbody> 74 * </tgroup> 75 * </table> 76 * </refsect2> 77 */ 78 79 #include "na-data-def.h" 80 #include "na-data-boxed.h" 81 #include "na-ifactory-provider-provider.h" 82 83 G_BEGIN_DECLS 84 85 #define NA_TYPE_IFACTORY_OBJECT ( na_ifactory_object_get_type()) 86 #define NA_IFACTORY_OBJECT( instance ) ( G_TYPE_CHECK_INSTANCE_CAST( instance, NA_TYPE_IFACTORY_OBJECT, NAIFactoryObject )) 87 #define NA_IS_IFACTORY_OBJECT( instance ) ( G_TYPE_CHECK_INSTANCE_TYPE( instance, NA_TYPE_IFACTORY_OBJECT )) 88 #define NA_IFACTORY_OBJECT_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_TYPE_IFACTORY_OBJECT, NAIFactoryObjectInterface )) 89 90 typedef struct _NAIFactoryObject NAIFactoryObject; 91 typedef struct _NAIFactoryObjectInterfacePrivate NAIFactoryObjectInterfacePrivate; 92 93 /** 94 * NAIFactoryObjectInterface: 95 * @get_version: returns the version of this interface the NAObjectItem implements. 96 * @get_groups: returns a pointer to the NADataGroup which defines this object. 97 * @copy: post copy callback. 98 * @are_equal: tests if two NAObjectItem are equals. 99 * @is_valid: tests if one NAObjectItem is valid. 100 * @read_start: triggered before serializing a NAObjectItem. 101 * @read_done: triggered after a NAObjectItem has been serialized. 102 * @write_start: triggered before unserializing a NAObjectItem. 103 * @write_done: triggered after a NAObjectItem has been unserialized. 104 * 105 * In order to take full advantage of our data managament system, 106 * NAObjectItem-derived objects all implement this #NAIFactoryObject 107 * interface. 108 */ 109 typedef struct { 110 /*< private >*/ 111 GTypeInterface parent; 112 NAIFactoryObjectInterfacePrivate *private; 113 114 /*< public >*/ 115 /** 116 * get_version: 117 * @instance: this #NAIFactoryObject instance. 118 * 119 * Defaults to 1. 120 * 121 * Returns: the version of this interface supported by @instance implementation. 122 * 123 * Since: 2.30 124 */ 125 guint ( *get_version )( const NAIFactoryObject *instance ); 126 127 /** 128 * get_groups: 129 * @instance: this #NAIFactoryObject instance. 130 * 131 * Returns: a pointer to the NADataGroup which defines this object. 132 * 133 * Since: 2.30 134 */ 135 NADataGroup * ( *get_groups ) ( const NAIFactoryObject *instance ); 136 137 /** 138 * copy: 139 * @instance: the target #NAIFactoryObject instance. 140 * @source: the source #NAIFactoryObject instance. 141 * 142 * This function is triggered after having copied @source to 143 * @instance target. This later may take advantage of this call 144 * to do some particular copy tasks. 145 * 146 * Since: 2.30 147 */ 148 void ( *copy ) ( NAIFactoryObject *instance, const NAIFactoryObject *source ); 149 150 /** 151 * are_equal: 152 * @a: the first #NAIFactoryObject instance. 153 * @b: the second #NAIFactoryObject instance. 154 * 155 * This function is triggered after all elementary data comparisons 156 * have been sucessfully made. 157 * 158 * Returns: %TRUE if @a is equal to @b. 159 * 160 * Since: 2.30 161 */ 162 gboolean ( *are_equal ) ( const NAIFactoryObject *a, const NAIFactoryObject *b ); 163 164 /** 165 * is_valid: 166 * @object: the #NAIFactoryObject instance whose validity is to be checked. 167 * 168 * This function is triggered after all elementary data comparisons 169 * have been sucessfully made. 170 * 171 * Returns: %TRUE if @object is valid. 172 * 173 * Since: 2.30 174 */ 175 gboolean ( *is_valid ) ( const NAIFactoryObject *object ); 176 177 /** 178 * read_start: 179 * @instance: this #NAIFactoryObject instance. 180 * @reader: the instance which has provided read services. 181 * @reader_data: the data associated to @reader. 182 * @messages: a pointer to a #GSList list of strings; the instance 183 * may append messages to this list, but shouldn't reinitialize it. 184 * 185 * Called just before the object is unserialized. 186 * 187 * Since: 2.30 188 */ 189 void ( *read_start ) ( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages ); 190 191 /** 192 * read_done: 193 * @instance: this #NAIFactoryObject instance. 194 * @reader: the instance which has provided read services. 195 * @reader_data: the data associated to @reader. 196 * @messages: a pointer to a #GSList list of strings; the instance 197 * may append messages to this list, but shouldn't reinitialize it. 198 * 199 * Called when the object has been unserialized. 200 * 201 * Since: 2.30 202 */ 203 void ( *read_done ) ( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages ); 204 205 /** 206 * write_start: 207 * @instance: this #NAIFactoryObject instance. 208 * @writer: the instance which has provided writing services. 209 * @writer_data: the data associated to @writer. 210 * @messages: a pointer to a #GSList list of strings; the instance 211 * may append messages to this list, but shouldn't reinitialize it. 212 * 213 * Called just before the object is serialized. 214 * 215 * Returns: a NAIIOProvider operation return code. 216 * 217 * Since: 2.30 218 */ 219 guint ( *write_start )( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages ); 220 221 /** 222 * write_done: 223 * @instance: this #NAIFactoryObject instance. 224 * @writer: the instance which has provided writing services. 225 * @writer_data: the data associated to @writer. 226 * @messages: a pointer to a #GSList list of strings; the instance 227 * may append messages to this list, but shouldn't reinitialize it. 228 * 229 * Called when the object has been serialized. 230 * 231 * Returns: a NAIIOProvider operation return code. 232 * 233 * Since: 2.30 234 */ 235 guint ( *write_done ) ( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages ); 236 } 237 NAIFactoryObjectInterface; 238 239 GType na_ifactory_object_get_type( void ); 240 241 NADataBoxed *na_ifactory_object_get_data_boxed ( const NAIFactoryObject *object, const gchar *name ); 242 NADataGroup *na_ifactory_object_get_data_groups( const NAIFactoryObject *object ); 243 void *na_ifactory_object_get_as_void ( const NAIFactoryObject *object, const gchar *name ); 244 void na_ifactory_object_set_from_void ( NAIFactoryObject *object, const gchar *name, const void *data ); 245 246 G_END_DECLS 247 248 #endif /* __NAUTILUS_ACTIONS_API_NA_IFACTORY_OBJECT_H__ */ 249