1 /*
2  *  nautilus-info-provider.h - Interface for Nautilus extensions that
3  *                             provide info about files.
4  *
5  *  Copyright (C) 2003 Novell, Inc.
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Library General Public
9  *  License as published by the Free Software Foundation; either
10  *  version 2 of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Library General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Library General Public
18  *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  *
20  *  Author:  Dave Camp <dave@ximian.com>
21  *
22  */
23 
24 /* This interface is implemented by Nautilus extensions that want to
25  * provide information about files.  Extensions are called when Nautilus
26  * needs information about a file.  They are passed a NautilusFileInfo
27  * object which should be filled with relevant information */
28 
29 #pragma once
30 
31 #if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
32 #warning "Only <nautilus-extension.h> should be included directly."
33 #endif
34 
35 #include <glib-object.h>
36 #include "nautilus-file-info.h"
37 /* This should be removed at some point. */
38 #include "nautilus-extension-types.h"
39 
40 G_BEGIN_DECLS
41 
42 #define NAUTILUS_TYPE_INFO_PROVIDER (nautilus_info_provider_get_type ())
43 
44 G_DECLARE_INTERFACE (NautilusInfoProvider, nautilus_info_provider,
45                      NAUTILUS, INFO_PROVIDER,
46                      GObject)
47 
48 /* For compatibility reasons, remove this once you start introducing breaking changes. */
49 typedef NautilusInfoProviderInterface NautilusInfoProviderIface;
50 
51 /**
52  * SECTION:nautilus-info-provider
53  * @title: NautilusInfoProvider
54  * @short_description: Interface to provide additional information about files
55  *
56  * #NautilusInfoProvider allows extension to provide additional information about
57  * files. When nautilus_info_provider_update_file_info() is called by the application,
58  * extensions will know that it's time to add extra information to the provided
59  * #NautilusFileInfo.
60  */
61 
62 /**
63  * NautilusOperationHandle:
64  *
65  * Handle for asynchronous interfaces. These are opaque handles that must
66  * be unique within an extension object. These are returned by operations
67  * that return #NAUTILUS_OPERATION_IN_PROGRESS.
68  */
69 typedef struct _NautilusOperationHandle NautilusOperationHandle;
70 
71 /**
72  * NautilusOperationResult:
73  * @NAUTILUS_OPERATION_COMPLETE: the operation succeeded, and the extension
74  *  is done with the request.
75  * @NAUTILUS_OPERATION_FAILED: the operation failed.
76  * @NAUTILUS_OPERATION_IN_PROGRESS: the extension has begin an async operation.
77  *  When this value is returned, the extension must set the handle parameter
78  *  and call the callback closure when the operation is complete.
79  *
80  * Return values for asynchronous operations performed by the extension.
81  * See nautilus_info_provider_update_file_info().
82  */
83 typedef enum
84 {
85     /* Returned if the call succeeded, and the extension is done
86      * with the request */
87     NAUTILUS_OPERATION_COMPLETE,
88 
89     /* Returned if the call failed */
90     NAUTILUS_OPERATION_FAILED,
91 
92     /* Returned if the extension has begun an async operation.
93      * If this is returned, the extension must set the handle
94      * parameter and call the callback closure when the
95      * operation is complete. */
96     NAUTILUS_OPERATION_IN_PROGRESS
97 } NautilusOperationResult;
98 
99 /**
100  * NautilusInfoProviderInterface:
101  * @g_iface: The parent interface.
102  * @update_file_info: Returns a #NautilusOperationResult.
103  *                    See nautilus_info_provider_update_file_info() for details.
104  * @cancel_update: Cancels a previous call to nautilus_info_provider_update_file_info().
105  *                 See nautilus_info_provider_cancel_update() for details.
106  *
107  * Interface for extensions to provide additional information about files.
108  */
109 struct _NautilusInfoProviderInterface
110 {
111     GTypeInterface g_iface;
112 
113     NautilusOperationResult (*update_file_info) (NautilusInfoProvider     *provider,
114                                                  NautilusFileInfo         *file,
115                                                  GClosure                 *update_complete,
116                                                  NautilusOperationHandle **handle);
117     void                    (*cancel_update)    (NautilusInfoProvider     *provider,
118                                                  NautilusOperationHandle  *handle);
119 };
120 
121 /* Interface Functions */
122 NautilusOperationResult nautilus_info_provider_update_file_info       (NautilusInfoProvider     *provider,
123                                                                        NautilusFileInfo         *file,
124                                                                        GClosure                 *update_complete,
125                                                                        NautilusOperationHandle **handle);
126 void                    nautilus_info_provider_cancel_update          (NautilusInfoProvider     *provider,
127                                                                        NautilusOperationHandle  *handle);
128 
129 
130 
131 /* Helper functions for implementations */
132 void                    nautilus_info_provider_update_complete_invoke (GClosure                 *update_complete,
133                                                                        NautilusInfoProvider     *provider,
134                                                                        NautilusOperationHandle  *handle,
135                                                                        NautilusOperationResult   result);
136 
137 G_END_DECLS
138