2008-04-30 A. Walton <awalton@gnome.org>
[nautilus.git] / libnautilus-private / nautilus-vfs-directory.c
blobe18031d25d38bdd3ddbe77140261dfaaf7a76a64
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
3 nautilus-vfs-directory.c: Subclass of NautilusDirectory to help implement the
4 virtual trash directory.
6 Copyright (C) 1999, 2000 Eazel, Inc.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public
19 License along with this program; if not, write to the
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
23 Author: Darin Adler <darin@bentspoon.com>
26 #include <config.h>
27 #include "nautilus-vfs-directory.h"
29 #include "nautilus-directory-private.h"
30 #include <eel/eel-gtk-macros.h>
31 #include "nautilus-file-private.h"
33 static void nautilus_vfs_directory_init (gpointer object,
34 gpointer klass);
35 static void nautilus_vfs_directory_class_init (gpointer klass);
37 EEL_CLASS_BOILERPLATE (NautilusVFSDirectory,
38 nautilus_vfs_directory,
39 NAUTILUS_TYPE_DIRECTORY)
41 static void
42 nautilus_vfs_directory_init (gpointer object, gpointer klass)
44 NautilusVFSDirectory *directory;
46 directory = NAUTILUS_VFS_DIRECTORY (object);
49 static gboolean
50 vfs_contains_file (NautilusDirectory *directory,
51 NautilusFile *file)
53 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
54 g_assert (NAUTILUS_IS_FILE (file));
56 return file->details->directory == directory;
59 static void
60 vfs_call_when_ready (NautilusDirectory *directory,
61 NautilusFileAttributes file_attributes,
62 gboolean wait_for_file_list,
63 NautilusDirectoryCallback callback,
64 gpointer callback_data)
66 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
68 nautilus_directory_call_when_ready_internal
69 (directory,
70 NULL,
71 file_attributes,
72 wait_for_file_list,
73 callback,
74 NULL,
75 callback_data);
78 static void
79 vfs_cancel_callback (NautilusDirectory *directory,
80 NautilusDirectoryCallback callback,
81 gpointer callback_data)
83 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
85 nautilus_directory_cancel_callback_internal
86 (directory,
87 NULL,
88 callback,
89 NULL,
90 callback_data);
93 static void
94 vfs_file_monitor_add (NautilusDirectory *directory,
95 gconstpointer client,
96 gboolean monitor_hidden_files,
97 gboolean monitor_backup_files,
98 NautilusFileAttributes file_attributes,
99 NautilusDirectoryCallback callback,
100 gpointer callback_data)
102 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
103 g_assert (client != NULL);
105 nautilus_directory_monitor_add_internal
106 (directory, NULL,
107 client,
108 monitor_hidden_files,
109 monitor_backup_files,
110 file_attributes,
111 callback, callback_data);
114 static void
115 vfs_file_monitor_remove (NautilusDirectory *directory,
116 gconstpointer client)
118 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
119 g_assert (client != NULL);
121 nautilus_directory_monitor_remove_internal (directory, NULL, client);
124 static void
125 vfs_force_reload (NautilusDirectory *directory)
127 NautilusFileAttributes all_attributes;
129 g_assert (NAUTILUS_IS_DIRECTORY (directory));
131 all_attributes = nautilus_file_get_all_attributes ();
132 nautilus_directory_force_reload_internal (directory,
133 all_attributes);
136 static gboolean
137 vfs_are_all_files_seen (NautilusDirectory *directory)
139 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
141 return directory->details->directory_loaded;
144 static gboolean
145 vfs_is_not_empty (NautilusDirectory *directory)
147 g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
148 g_assert (nautilus_directory_is_anyone_monitoring_file_list (directory));
150 return directory->details->file_list != NULL;
153 static void
154 nautilus_vfs_directory_class_init (gpointer klass)
156 GObjectClass *object_class;
157 NautilusDirectoryClass *directory_class;
159 object_class = G_OBJECT_CLASS (klass);
160 directory_class = NAUTILUS_DIRECTORY_CLASS (klass);
162 directory_class->contains_file = vfs_contains_file;
163 directory_class->call_when_ready = vfs_call_when_ready;
164 directory_class->cancel_callback = vfs_cancel_callback;
165 directory_class->file_monitor_add = vfs_file_monitor_add;
166 directory_class->file_monitor_remove = vfs_file_monitor_remove;
167 directory_class->force_reload = vfs_force_reload;
168 directory_class->are_all_files_seen = vfs_are_all_files_seen;
169 directory_class->is_not_empty = vfs_is_not_empty;