nautilus-3.6.3/libnautilus-private/nautilus-vfs-directory.c

No issues found

  1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
  2 
  3    nautilus-vfs-directory.c: Subclass of NautilusDirectory to help implement the
  4    virtual trash directory.
  5  
  6    Copyright (C) 1999, 2000 Eazel, Inc.
  7   
  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.
 12   
 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.
 17   
 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.
 22   
 23    Author: Darin Adler <darin@bentspoon.com>
 24 */
 25 
 26 #include <config.h>
 27 #include "nautilus-vfs-directory.h"
 28 
 29 #include "nautilus-directory-private.h"
 30 #include "nautilus-file-private.h"
 31 
 32 G_DEFINE_TYPE (NautilusVFSDirectory, nautilus_vfs_directory, NAUTILUS_TYPE_DIRECTORY);
 33 
 34 static void
 35 nautilus_vfs_directory_init (NautilusVFSDirectory *directory)
 36 {
 37 
 38 }
 39 
 40 static gboolean
 41 vfs_contains_file (NautilusDirectory *directory,
 42 		   NautilusFile *file)
 43 {
 44 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
 45 	g_assert (NAUTILUS_IS_FILE (file));
 46 
 47 	return file->details->directory == directory;
 48 }
 49 
 50 static void
 51 vfs_call_when_ready (NautilusDirectory *directory,
 52 		     NautilusFileAttributes file_attributes,
 53 		     gboolean wait_for_file_list,
 54 		     NautilusDirectoryCallback callback,
 55 		     gpointer callback_data)
 56 {
 57 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
 58 
 59 	nautilus_directory_call_when_ready_internal
 60 		(directory,
 61 		 NULL,
 62 		 file_attributes,
 63 		 wait_for_file_list,
 64 		 callback,
 65 		 NULL,
 66 		 callback_data);
 67 }
 68 
 69 static void
 70 vfs_cancel_callback (NautilusDirectory *directory,
 71 		     NautilusDirectoryCallback callback,
 72 		     gpointer callback_data)
 73 {
 74 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
 75 
 76 	nautilus_directory_cancel_callback_internal
 77 		(directory,
 78 		 NULL,
 79 		 callback,
 80 		 NULL,
 81 		 callback_data);
 82 }
 83 
 84 static void
 85 vfs_file_monitor_add (NautilusDirectory *directory,
 86 		      gconstpointer client,
 87 		      gboolean monitor_hidden_files,
 88 		      NautilusFileAttributes file_attributes,
 89 		      NautilusDirectoryCallback callback,
 90 		      gpointer callback_data)
 91 {
 92 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
 93 	g_assert (client != NULL);
 94 
 95 	nautilus_directory_monitor_add_internal
 96 		(directory, NULL,
 97 		 client,
 98 		 monitor_hidden_files,
 99 		 file_attributes,
100 		 callback, callback_data);
101 }
102 
103 static void
104 vfs_file_monitor_remove (NautilusDirectory *directory,
105 			 gconstpointer client)
106 {
107 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
108 	g_assert (client != NULL);
109 	
110 	nautilus_directory_monitor_remove_internal (directory, NULL, client);
111 }
112 
113 static void
114 vfs_force_reload (NautilusDirectory *directory)
115 {
116 	NautilusFileAttributes all_attributes;
117 
118 	g_assert (NAUTILUS_IS_DIRECTORY (directory));
119 
120 	all_attributes = nautilus_file_get_all_attributes ();
121 	nautilus_directory_force_reload_internal (directory,
122 						  all_attributes);
123 }
124 
125 static gboolean
126 vfs_are_all_files_seen (NautilusDirectory *directory)
127 {
128 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
129 	
130 	return directory->details->directory_loaded;
131 }
132 
133 static gboolean
134 vfs_is_not_empty (NautilusDirectory *directory)
135 {
136 	g_assert (NAUTILUS_IS_VFS_DIRECTORY (directory));
137 	g_assert (nautilus_directory_is_anyone_monitoring_file_list (directory));
138 
139 	return directory->details->file_list != NULL;
140 }
141 
142 static void
143 nautilus_vfs_directory_class_init (NautilusVFSDirectoryClass *klass)
144 {
145 	NautilusDirectoryClass *directory_class = NAUTILUS_DIRECTORY_CLASS (klass);
146 
147 	directory_class->contains_file = vfs_contains_file;
148 	directory_class->call_when_ready = vfs_call_when_ready;
149 	directory_class->cancel_callback = vfs_cancel_callback;
150 	directory_class->file_monitor_add = vfs_file_monitor_add;
151 	directory_class->file_monitor_remove = vfs_file_monitor_remove;
152 	directory_class->force_reload = vfs_force_reload;
153 	directory_class->are_all_files_seen = vfs_are_all_files_seen;
154 	directory_class->is_not_empty = vfs_is_not_empty;
155 }