nautilus-file-info.h 11.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 *  nautilus-file-info.h - Information about a file 
 *
 *  Copyright (C) 2003 Novell, Inc.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
17
 *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 19 20 21 22 23 24
 *
 */

/* NautilusFileInfo is an interface to the NautilusFile object.  It 
 * provides access to the asynchronous data in the NautilusFile.
 * Extensions are passed objects of this type for operations. */

25
#pragma once
26

27 28 29 30
#if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
#warning "Only <nautilus-extension.h> should be included directly."
#endif

31
#include <glib-object.h>
32
#include <gio/gio.h>
33 34 35

G_BEGIN_DECLS

36
#define NAUTILUS_TYPE_FILE_INFO (nautilus_file_info_get_type ())
37

38
G_DECLARE_INTERFACE (NautilusFileInfo, nautilus_file_info, NAUTILUS, FILE_INFO, GObject)
39

40
/* For compatibility reasons; remove this once you start introducing breaking changes.
41 42 43 44 45 46
 *
 * I’ve only noticed nautilus-python depending on this, but the context is that
 * NautilusFileInfo used to be an alias for NautilusFile to make it easier to
 * implement the interface,
 */
typedef struct NautilusFile NautilusFile;
47

48 49 50 51 52 53 54 55 56
/**
 * SECTION:nautilus-file-info
 * @title: NautilusFileInfo
 * @short_description: File interface for nautilus extensions
 *
 * #NautilusFileInfo provides methods to get and modify information
 * about file objects in the file manager.
 */

57
/**
58
 * NautilusFileInfoInterface:
59 60
 * @g_iface: The parent interface.
 * @is_gone: Returns whether the file info is gone.
61
 *           See nautilus_file_info_is_gone() for details.
62
 * @get_name: Returns the file name as a string.
63
 *            See nautilus_file_info_get_name() for details.
64
 * @get_uri: Returns the file URI as a string.
65
 *           See nautilus_file_info_get_uri() for details.
66
 * @get_parent_uri: Returns the file parent URI as a string.
67
 *                  See nautilus_file_info_get_parent_uri() for details.
68
 * @get_uri_scheme: Returns the file URI scheme as a string.
69
 *                  See nautilus_file_info_get_uri_scheme() for details.
70
 * @get_mime_type: Returns the file mime type as a string.
71
 *                 See nautilus_file_info_get_mime_type() for details.
72
 * @is_mime_type: Returns whether the file is the given mime type.
73
 *                See nautilus_file_info_is_mime_type() for details.
74
 * @is_directory: Returns whether the file is a directory.
75
 *                See nautilus_file_info_is_directory() for details.
76
 * @add_emblem: Adds an emblem to this file.
77
 *              See nautilus_file_info_add_emblem() for details.
78
 * @get_string_attribute: Returns the specified file attribute as a string.
79
 *                        See nautilus_file_info_get_string_attribute() for details.
80
 * @add_string_attribute: Sets the specified string file attribute value.
81
 *                        See nautilus_file_info_add_string_attribute() for details.
82
 * @invalidate_extension_info: Invalidates information of the file provided by extensions.
83
 *                             See nautilus_file_info_invalidate_extension_info() for details.
84
 * @get_activation_uri: Returns the file activation URI as a string.
85
 *                      See nautilus_file_info_get_activation_uri() for details.
86
 * @get_file_type: Returns the file type.
87
 *                 See nautilus_file_info_get_file_type() for details.
88
 * @get_location: Returns the file location as a #GFile.
89
 *                See nautilus_file_info_get_location() for details.
90
 * @get_parent_location: Returns the file parent location as a #GFile.
91
 *                       See nautilus_file_info_get_parent_location() for details.
92
 * @get_parent_info: Returns the file parent #NautilusFileInfo.
93
 *                   See nautilus_file_info_get_parent_info() for details.
94
 * @get_mount: Returns the file mount as a #GMount.
95
 *             See nautilus_file_info_get_mount() for details.
96
 * @can_write: Returns whether the file is writable.
97
 *             See nautilus_file_info_can_write() for details.
98 99 100
 *
 * Interface for extensions to provide additional menu items.
 */
101
struct _NautilusFileInfoInterface
102
{
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    GTypeInterface g_iface;

    gboolean          (*is_gone)                   (NautilusFileInfo *file_info);

    char             *(*get_name)                  (NautilusFileInfo *file_info);
    char             *(*get_uri)                   (NautilusFileInfo *file_info);
    char             *(*get_parent_uri)            (NautilusFileInfo *file_info);
    char             *(*get_uri_scheme)            (NautilusFileInfo *file_info);

    char             *(*get_mime_type)             (NautilusFileInfo *file_info);
    gboolean          (*is_mime_type)              (NautilusFileInfo *file_info,
                                                    const char       *mime_type);
    gboolean          (*is_directory)              (NautilusFileInfo *file_info);

    void              (*add_emblem)                (NautilusFileInfo *file_info,
                                                    const char       *emblem_name);
    char             *(*get_string_attribute)      (NautilusFileInfo *file_info,
                                                    const char       *attribute_name);
    void              (*add_string_attribute)      (NautilusFileInfo *file_info,
                                                    const char       *attribute_name,
                                                    const char       *value);
    void              (*invalidate_extension_info) (NautilusFileInfo *file_info);

    char             *(*get_activation_uri)        (NautilusFileInfo *file_info);

    GFileType         (*get_file_type)             (NautilusFileInfo *file_info);
    GFile            *(*get_location)              (NautilusFileInfo *file_info);
    GFile            *(*get_parent_location)       (NautilusFileInfo *file_info);
    NautilusFileInfo *(*get_parent_info)           (NautilusFileInfo *file_info);
    GMount           *(*get_mount)                 (NautilusFileInfo *file_info);
    gboolean          (*can_write)                 (NautilusFileInfo *file_info);
134 135
};

136 137 138 139 140 141 142
/**
 * nautilus_file_info_list_copy:
 * @files: (element-type NautilusFileInfo): the files to copy
 *
 * Returns: (element-type NautilusFileInfo) (transfer full): a copy of @files.
 *  Use #nautilus_file_info_list_free to free the list and unref its contents.
 */
143
GList            *nautilus_file_info_list_copy            (GList            *files);
144 145 146 147 148
/**
 * nautilus_file_info_list_free:
 * @files: (element-type NautilusFileInfo): a list created with #nautilus_file_info_list_copy
 *
 */
149 150
void              nautilus_file_info_list_free            (GList            *files);

151 152 153 154 155 156
/**
 * nautilus_file_info_is_gone:
 * @file_info: a #NautilusFileInfo
 *
 * Returns: whether the file has been deleted
 */
157
gboolean          nautilus_file_info_is_gone              (NautilusFileInfo *file_info);
158 159

/* Name and Location */
160
GFileType         nautilus_file_info_get_file_type        (NautilusFileInfo *file_info);
161 162 163 164 165 166
/**
 * nautilus_file_info_get_location:
 * @file_info: a #NautilusFileInfo
 *
 * Returns: (transfer full): a #GFile for the location of @file_info
 */
167 168 169 170
GFile            *nautilus_file_info_get_location         (NautilusFileInfo *file_info);
char             *nautilus_file_info_get_name             (NautilusFileInfo *file_info);
char             *nautilus_file_info_get_uri              (NautilusFileInfo *file_info);
char             *nautilus_file_info_get_activation_uri   (NautilusFileInfo *file_info);
171 172 173 174 175 176 177
/**
 * nautilus_file_info_get_parent_location:
 * @file_info: a #NautilusFileInfo
 *
 * Returns: (allow-none) (transfer full): a #GFile for the parent location of @file_info,
 *   or %NULL if @file_info has no parent
 */
178 179
GFile            *nautilus_file_info_get_parent_location  (NautilusFileInfo *file_info);
char             *nautilus_file_info_get_parent_uri       (NautilusFileInfo *file_info);
180 181 182 183 184 185 186
/**
 * nautilus_file_info_get_mount:
 * @file_info: a #NautilusFileInfo
 *
 * Returns: (nullable) (transfer full): a #GMount for the mount of @file_info,
 *                                      or %NULL if @file_info has no mount
 */
187 188
GMount           *nautilus_file_info_get_mount            (NautilusFileInfo *file_info);
char             *nautilus_file_info_get_uri_scheme       (NautilusFileInfo *file_info);
189 190 191 192 193
/**
 * nautilus_file_info_get_parent_info:
 * @file_info: a #NautilusFileInfo
 *
 * It's not safe to call this recursively multiple times, as it works
194
 * only for files already cached by Nautilus.
195 196 197
 *
 * Returns: (nullable) (transfer full): a #NautilusFileInfo for the parent of @file_info,
 *                                      or %NULL if @file_info has no parent.
198
 */
199
NautilusFileInfo *nautilus_file_info_get_parent_info      (NautilusFileInfo *file_info);
200

201
/**
202
 * nautilus_file_info_get_mime_type:
203 204 205 206
 * @file_info: a #NautilusFileInfo
 *
 * Returns: (transfer full): the MIME type of @file_info
 */
207 208 209 210 211
char *            nautilus_file_info_get_mime_type        (NautilusFileInfo *file_info);
gboolean          nautilus_file_info_is_mime_type         (NautilusFileInfo *file_info,
                                                           const char       *mime_type);
gboolean          nautilus_file_info_is_directory         (NautilusFileInfo *file_info);
gboolean          nautilus_file_info_can_write            (NautilusFileInfo *file_info);
212 213 214


/* Modifying the NautilusFileInfo */
215 216 217 218 219 220 221
void              nautilus_file_info_add_emblem           (NautilusFileInfo *file_info,
                                                           const char       *emblem_name);
char             *nautilus_file_info_get_string_attribute (NautilusFileInfo *file_info,
                                                           const char       *attribute_name);
void              nautilus_file_info_add_string_attribute (NautilusFileInfo *file_info,
                                                           const char       *attribute_name,
                                                           const char       *value);
222

Dave Camp's avatar
Dave Camp committed
223
/* Invalidating file info */
224
void              nautilus_file_info_invalidate_extension_info (NautilusFileInfo *file_info);
Dave Camp's avatar
Dave Camp committed
225

226 227 228 229 230 231
/**
 * nautilus_file_info_lookup:
 * @location: the location for which to look up a corresponding #NautilusFileInfo object
 *
 * Returns: (transfer full): a #NautilusFileInfo
 */
232
NautilusFileInfo *nautilus_file_info_lookup                (GFile *location);
233 234 235 236 237 238
/**
 * nautilus_file_info_create:
 * @location: the location to create the file info for
 *
 * Returns: (transfer full): a #NautilusFileInfo
 */
239
NautilusFileInfo *nautilus_file_info_create                (GFile *location);
240 241 242 243 244 245
/**
 * nautilus_file_info_lookup_for_uri:
 * @uri: the URI to lookup the file info for
 *
 * Returns: (transfer full): a #NautilusFileInfo
 */
246
NautilusFileInfo *nautilus_file_info_lookup_for_uri        (const char *uri);
247 248 249 250 251 252
/**
 * nautilus_file_info_create_for_uri:
 * @uri: the URI to lookup the file info for
 *
 * Returns: (transfer full): a #NautilusFileInfo
 */
253
NautilusFileInfo *nautilus_file_info_create_for_uri        (const char *uri);
254

255
G_END_DECLS