[nautilus] vfs-file: move some vfunc overrides to NautilusFile
- From: Ernestas Kulik <ernestask src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] vfs-file: move some vfunc overrides to NautilusFile
- Date: Fri, 1 Dec 2017 11:59:48 +0000 (UTC)
commit cbcbb3ae5fc4294239b6ec846b7df2f472054f60
Author: Ernestas Kulik <ernestask gnome org>
Date: Fri Aug 25 18:23:16 2017 +0300
vfs-file: move some vfunc overrides to NautilusFile
Some method overrides are only accessing the private data of the parent
class, so those might as well live in the parent class.
https://bugzilla.gnome.org/show_bug.cgi?id=786760
src/nautilus-file.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
src/nautilus-vfs-file.c | 90 -----------------------------------------------
2 files changed, 93 insertions(+), 90 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 9a3d9487b..6b7301405 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -9439,6 +9439,97 @@ icon_theme_changed_callback (GtkIconTheme *icon_theme,
emit_change_signals_for_all_files_in_all_directories ();
}
+static gboolean
+real_get_item_count (NautilusFile *file,
+ guint *count,
+ gboolean *count_unreadable)
+{
+ if (count_unreadable != NULL)
+ {
+ *count_unreadable = file->details->directory_count_failed;
+ }
+
+ if (!file->details->got_directory_count)
+ {
+ if (count != NULL)
+ {
+ *count = 0;
+ }
+ return FALSE;
+ }
+
+ if (count != NULL)
+ {
+ *count = file->details->directory_count;
+ }
+
+ return TRUE;
+}
+
+static NautilusRequestStatus
+real_get_deep_counts (NautilusFile *file,
+ guint *directory_count,
+ guint *file_count,
+ guint *unreadable_directory_count,
+ goffset *total_size)
+{
+ GFileType type;
+
+ type = nautilus_file_get_file_type (file);
+
+ if (directory_count != NULL)
+ {
+ *directory_count = 0;
+ }
+ if (file_count != NULL)
+ {
+ *file_count = 0;
+ }
+ if (unreadable_directory_count != NULL)
+ {
+ *unreadable_directory_count = 0;
+ }
+ if (total_size != NULL)
+ {
+ *total_size = 0;
+ }
+
+ if (type != G_FILE_TYPE_DIRECTORY)
+ {
+ return NAUTILUS_REQUEST_DONE;
+ }
+
+ if (file->details->deep_counts_status != NAUTILUS_REQUEST_NOT_STARTED)
+ {
+ if (directory_count != NULL)
+ {
+ *directory_count = file->details->deep_directory_count;
+ }
+ if (file_count != NULL)
+ {
+ *file_count = file->details->deep_file_count;
+ }
+ if (unreadable_directory_count != NULL)
+ {
+ *unreadable_directory_count = file->details->deep_unreadable_count;
+ }
+ if (total_size != NULL)
+ {
+ *total_size = file->details->deep_size;
+ }
+ return file->details->deep_counts_status;
+ }
+
+ /* For directories, or before we know the type, we haven't started. */
+ if (type == G_FILE_TYPE_UNKNOWN || type == G_FILE_TYPE_DIRECTORY)
+ {
+ return NAUTILUS_REQUEST_NOT_STARTED;
+ }
+
+ /* For other types, we are done, and the zeros are permanent. */
+ return NAUTILUS_REQUEST_DONE;
+}
+
static void
real_set_metadata (NautilusFile *file,
const char *key,
@@ -9499,6 +9590,8 @@ nautilus_file_class_init (NautilusFileClass *class)
G_OBJECT_CLASS (class)->finalize = finalize;
G_OBJECT_CLASS (class)->constructor = nautilus_file_constructor;
+ class->get_item_count = real_get_item_count;
+ class->get_deep_counts = real_get_deep_counts;
class->set_metadata = real_set_metadata;
class->set_metadata_as_list = real_set_metadata_as_list;
class->can_rename = real_can_rename;
diff --git a/src/nautilus-vfs-file.c b/src/nautilus-vfs-file.c
index f00720e58..172dc0378 100644
--- a/src/nautilus-vfs-file.c
+++ b/src/nautilus-vfs-file.c
@@ -219,94 +219,6 @@ vfs_file_set_metadata_as_list (NautilusFile *file,
}
static gboolean
-vfs_file_get_item_count (NautilusFile *file,
- guint *count,
- gboolean *count_unreadable)
-{
- if (count_unreadable != NULL)
- {
- *count_unreadable = file->details->directory_count_failed;
- }
- if (!file->details->got_directory_count)
- {
- if (count != NULL)
- {
- *count = 0;
- }
- return FALSE;
- }
- if (count != NULL)
- {
- *count = file->details->directory_count;
- }
- return TRUE;
-}
-
-static NautilusRequestStatus
-vfs_file_get_deep_counts (NautilusFile *file,
- guint *directory_count,
- guint *file_count,
- guint *unreadable_directory_count,
- goffset *total_size)
-{
- GFileType type;
-
- if (directory_count != NULL)
- {
- *directory_count = 0;
- }
- if (file_count != NULL)
- {
- *file_count = 0;
- }
- if (unreadable_directory_count != NULL)
- {
- *unreadable_directory_count = 0;
- }
- if (total_size != NULL)
- {
- *total_size = 0;
- }
-
- if (!nautilus_file_is_directory (file))
- {
- return NAUTILUS_REQUEST_DONE;
- }
-
- if (file->details->deep_counts_status != NAUTILUS_REQUEST_NOT_STARTED)
- {
- if (directory_count != NULL)
- {
- *directory_count = file->details->deep_directory_count;
- }
- if (file_count != NULL)
- {
- *file_count = file->details->deep_file_count;
- }
- if (unreadable_directory_count != NULL)
- {
- *unreadable_directory_count = file->details->deep_unreadable_count;
- }
- if (total_size != NULL)
- {
- *total_size = file->details->deep_size;
- }
- return file->details->deep_counts_status;
- }
-
- /* For directories, or before we know the type, we haven't started. */
- type = nautilus_file_get_file_type (file);
- if (type == G_FILE_TYPE_UNKNOWN
- || type == G_FILE_TYPE_DIRECTORY)
- {
- return NAUTILUS_REQUEST_NOT_STARTED;
- }
-
- /* For other types, we are done, and the zeros are permanent. */
- return NAUTILUS_REQUEST_DONE;
-}
-
-static gboolean
vfs_file_get_date (NautilusFile *file,
NautilusDateType date_type,
time_t *date)
@@ -782,8 +694,6 @@ nautilus_vfs_file_class_init (NautilusVFSFileClass *klass)
file_class->call_when_ready = vfs_file_call_when_ready;
file_class->cancel_call_when_ready = vfs_file_cancel_call_when_ready;
file_class->check_if_ready = vfs_file_check_if_ready;
- file_class->get_item_count = vfs_file_get_item_count;
- file_class->get_deep_counts = vfs_file_get_deep_counts;
file_class->get_date = vfs_file_get_date;
file_class->get_where_string = vfs_file_get_where_string;
file_class->set_metadata = vfs_file_set_metadata;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]