1 /*
2  *  caja-file-info.h - Information about a file
3  *
4  *  Copyright (C) 2003 Novell, Inc.
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Library General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2 of the License, or (at your option) any later version.
10  *
11  *  This library 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  *  Library General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Library General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 /* CajaFileInfo is an interface to the CajaFile object.  It
23  * provides access to the asynchronous data in the CajaFile.
24  * Extensions are passed objects of this type for operations. */
25 
26 #ifndef CAJA_FILE_INFO_H
27 #define CAJA_FILE_INFO_H
28 
29 #include <glib-object.h>
30 #include <gio/gio.h>
31 
32 G_BEGIN_DECLS
33 
34 #define CAJA_TYPE_FILE_INFO           (caja_file_info_get_type ())
35 #define CAJA_FILE_INFO(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_FILE_INFO, CajaFileInfo))
36 #define CAJA_IS_FILE_INFO(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_FILE_INFO))
37 #define CAJA_FILE_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CAJA_TYPE_FILE_INFO, CajaFileInfoIface))
38 
39 #ifndef CAJA_FILE_DEFINED
40 #define CAJA_FILE_DEFINED
41 /* Using CajaFile for the vtable to make implementing this in
42  * CajaFile easier */
43 typedef struct CajaFile            CajaFile;
44 #endif
45 
46 typedef CajaFile                   CajaFileInfo;
47 typedef struct _CajaFileInfoIface  CajaFileInfoIface;
48 
49 /**
50  * CajaFileInfoIface:
51  * @g_iface: The parent interface.
52  * @is_gone: Returns whether the file info is gone.
53  *   See caja_file_info_is_gone() for details.
54  * @get_name: Returns the file name as a string.
55  *   See caja_file_info_get_name() for details.
56  * @get_uri: Returns the file URI as a string.
57  *   See caja_file_info_get_uri() for details.
58  * @get_parent_uri: Returns the file parent URI as a string.
59  *   See caja_file_info_get_parent_uri() for details.
60  * @get_uri_scheme: Returns the file URI scheme as a string.
61  *   See caja_file_info_get_uri_scheme() for details.
62  * @get_mime_type: Returns the file mime type as a string.
63  *   See caja_file_info_get_mime_type() for details.
64  * @is_mime_type: Returns whether the file is the given mime type.
65  *   See caja_file_info_is_mime_type() for details.
66  * @is_directory: Returns whether the file is a directory.
67  *   See caja_file_info_is_directory() for details.
68  * @add_emblem: Adds an emblem to this file.
69  *   See caja_file_info_add_emblem() for details.
70  * @get_string_attribute: Returns the specified file attribute as a string.
71  *   See caja_file_info_get_string_attribute() for details.
72  * @add_string_attribute: Sets the specified string file attribute value.
73  *   See caja_file_info_add_string_attribute() for details.
74  * @invalidate_extension_info: Invalidates information of the file provided by extensions.
75  *   See caja_file_info_invalidate_extension_info() for details.
76  * @get_activation_uri: Returns the file activation URI as a string.
77  *   See caja_file_info_get_activation_uri() for details.
78  * @get_file_type: Returns the file type.
79  *   See caja_file_info_get_file_type() for details.
80  * @get_location: Returns the file location as a #GFile.
81  *   See caja_file_info_get_location() for details.
82  * @get_parent_location: Returns the file parent location as a #GFile.
83  *   See caja_file_info_get_parent_location() for details.
84  * @get_parent_info: Returns the file parent #CajaFileInfo.
85  *   See caja_file_info_get_parent_info() for details.
86  * @get_mount: Returns the file mount as a #GMount.
87  *   See caja_file_info_get_mount() for details.
88  * @can_write: Returns whether the file is writable.
89  *   See caja_file_info_can_write() for details.
90  *
91  * Interface for extensions to get and modify information
92  * about file objects.
93  */
94 
95 struct _CajaFileInfoIface {
96     GTypeInterface g_iface;
97 
98     gboolean      (*is_gone)              (CajaFileInfo *file);
99 
100     char         *(*get_name)             (CajaFileInfo *file);
101     char         *(*get_uri)              (CajaFileInfo *file);
102     char         *(*get_parent_uri)       (CajaFileInfo *file);
103     char         *(*get_uri_scheme)       (CajaFileInfo *file);
104 
105     char         *(*get_mime_type)        (CajaFileInfo *file);
106     gboolean      (*is_mime_type)         (CajaFileInfo *file,
107                                            const char   *mime_Type);
108     gboolean      (*is_directory)         (CajaFileInfo *file);
109 
110     void          (*add_emblem)           (CajaFileInfo *file,
111                                            const char   *emblem_name);
112     char         *(*get_string_attribute) (CajaFileInfo *file,
113                                            const char   *attribute_name);
114     void          (*add_string_attribute) (CajaFileInfo *file,
115                                            const char   *attribute_name,
116                                            const char   *value);
117     void          (*invalidate_extension_info) (CajaFileInfo *file);
118 
119     char         *(*get_activation_uri)   (CajaFileInfo *file);
120 
121     GFileType     (*get_file_type)        (CajaFileInfo *file);
122     GFile        *(*get_location)         (CajaFileInfo *file);
123     GFile        *(*get_parent_location)  (CajaFileInfo *file);
124     CajaFileInfo *(*get_parent_info)      (CajaFileInfo *file);
125     GMount       *(*get_mount)            (CajaFileInfo *file);
126     gboolean      (*can_write)            (CajaFileInfo *file);
127 };
128 
129 GList       *caja_file_info_list_copy             (GList        *files);
130 void         caja_file_info_list_free             (GList        *files);
131 GType        caja_file_info_get_type              (void);
132 
133 /* Return true if the file has been deleted */
134 gboolean     caja_file_info_is_gone               (CajaFileInfo *file);
135 
136 /* Name and Location */
137 GFileType    caja_file_info_get_file_type         (CajaFileInfo *file);
138 GFile        *caja_file_info_get_location         (CajaFileInfo *file);
139 char         *caja_file_info_get_name             (CajaFileInfo *file);
140 char         *caja_file_info_get_uri              (CajaFileInfo *file);
141 char         *caja_file_info_get_activation_uri   (CajaFileInfo *file);
142 GFile        *caja_file_info_get_parent_location  (CajaFileInfo *file);
143 char         *caja_file_info_get_parent_uri       (CajaFileInfo *file);
144 GMount       *caja_file_info_get_mount            (CajaFileInfo *file);
145 char         *caja_file_info_get_uri_scheme       (CajaFileInfo *file);
146 /* It's not safe to call this recursively multiple times, as it works
147  * only for files already cached by Caja.
148  */
149 CajaFileInfo *caja_file_info_get_parent_info      (CajaFileInfo *file);
150 
151 /* File Type */
152 char         *caja_file_info_get_mime_type        (CajaFileInfo *file);
153 gboolean      caja_file_info_is_mime_type         (CajaFileInfo *file,
154                                                    const char   *mime_type);
155 gboolean      caja_file_info_is_directory         (CajaFileInfo *file);
156 gboolean      caja_file_info_can_write            (CajaFileInfo *file);
157 
158 
159 /* Modifying the CajaFileInfo */
160 void          caja_file_info_add_emblem           (CajaFileInfo *file,
161                                                    const char   *emblem_name);
162 char         *caja_file_info_get_string_attribute (CajaFileInfo *file,
163                                                    const char   *attribute_name);
164 void          caja_file_info_add_string_attribute (CajaFileInfo *file,
165                                                    const char   *attribute_name,
166                                                    const char   *value);
167 
168 /* Invalidating file info */
169 void          caja_file_info_invalidate_extension_info (CajaFileInfo *file);
170 
171 CajaFileInfo *caja_file_info_lookup                (GFile       *location);
172 CajaFileInfo *caja_file_info_create                (GFile       *location);
173 CajaFileInfo *caja_file_info_lookup_for_uri        (const char  *uri);
174 CajaFileInfo *caja_file_info_create_for_uri        (const char  *uri);
175 
176 G_END_DECLS
177 
178 #endif
179