Commit c7a608b1 authored by Ernestas Kulik's avatar Ernestas Kulik 🦑

file: general cleanups

Some vfuncs are no longer required now that the desktop is gone and the
overrides that (used to) return constant values are removed.
parent 2fff34b2
......@@ -175,7 +175,6 @@ static const char *nautilus_file_peek_display_name_collation_key (NautilusFile *
static void file_mount_unmounted (GMount *mount,
gpointer data);
static void metadata_hash_free (GHashTable *hash);
static gboolean real_drag_can_accept_files (NautilusFile *drop_target_item);
G_DEFINE_TYPE_WITH_CODE (NautilusFile, nautilus_file, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_FILE_INFO,
......@@ -1670,12 +1669,6 @@ can_rename_desktop_file (NautilusFile *file)
*/
gboolean
nautilus_file_can_rename (NautilusFile *file)
{
return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->can_rename (file);
}
static gboolean
real_can_rename (NautilusFile *file)
{
gboolean can_rename;
......@@ -1808,12 +1801,6 @@ nautilus_file_get_uri_scheme (NautilusFile *file)
gboolean
nautilus_file_opens_in_view (NautilusFile *file)
{
return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->opens_in_view (file);
}
static gboolean
real_opens_in_view (NautilusFile *file)
{
return nautilus_file_is_directory (file);
}
......@@ -2029,18 +2016,6 @@ name_is (NautilusFile *file,
return strcmp (new_name, old_name) == 0;
}
void
nautilus_file_rename (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->rename (file,
new_name,
callback,
callback_data);
}
static gchar *
nautilus_file_can_rename_file (NautilusFile *file,
const char *new_name,
......@@ -2178,6 +2153,58 @@ nautilus_file_can_rename_file (NautilusFile *file,
return new_file_name;
}
void
nautilus_file_rename (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusFileOperation *op;
char *old_name;
char *new_file_name;
GFile *location;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
g_return_if_fail (callback != NULL);
new_file_name = nautilus_file_can_rename_file (file,
new_name,
callback,
callback_data);
if (new_file_name == NULL)
{
return;
}
/* Set up a renaming operation. */
op = nautilus_file_operation_new (file, callback, callback_data);
op->is_rename = TRUE;
location = nautilus_file_get_location (file);
/* Tell the undo manager a rename is taking place */
if (!nautilus_file_undo_manager_is_operating ())
{
op->undo_info = nautilus_file_undo_info_rename_new ();
old_name = nautilus_file_get_display_name (file);
nautilus_file_undo_info_rename_set_data_pre (NAUTILUS_FILE_UNDO_INFO_RENAME (op->undo_info),
location, old_name, new_file_name);
g_free (old_name);
}
/* Do the renaming. */
g_file_set_display_name_async (location,
new_file_name,
G_PRIORITY_DEFAULT,
op->cancellable,
rename_callback,
op);
g_free (new_file_name);
g_object_unref (location);
}
gboolean
nautilus_file_rename_handle_file_gone (NautilusFile *file,
NautilusFileOperationCallback callback,
......@@ -2411,58 +2438,6 @@ nautilus_file_batch_rename (GList *files,
callback_data);
}
static void
real_rename (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusFileOperation *op;
char *old_name;
char *new_file_name;
GFile *location;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
g_return_if_fail (callback != NULL);
new_file_name = nautilus_file_can_rename_file (file,
new_name,
callback,
callback_data);
if (new_file_name == NULL)
{
return;
}
/* Set up a renaming operation. */
op = nautilus_file_operation_new (file, callback, callback_data);
op->is_rename = TRUE;
location = nautilus_file_get_location (file);
/* Tell the undo manager a rename is taking place */
if (!nautilus_file_undo_manager_is_operating ())
{
op->undo_info = nautilus_file_undo_info_rename_new ();
old_name = nautilus_file_get_display_name (file);
nautilus_file_undo_info_rename_set_data_pre (NAUTILUS_FILE_UNDO_INFO_RENAME (op->undo_info),
location, old_name, new_file_name);
g_free (old_name);
}
/* Do the renaming. */
g_file_set_display_name_async (location,
new_file_name,
G_PRIORITY_DEFAULT,
op->cancellable,
rename_callback,
op);
g_free (new_file_name);
g_object_unref (location);
}
gboolean
nautilus_file_rename_in_progress (NautilusFile *file)
{
......@@ -4721,12 +4696,6 @@ nautilus_file_get_activation_location (NautilusFile *file)
char *
nautilus_file_get_target_uri (NautilusFile *file)
{
return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->get_target_uri (file);
}
static char *
real_get_target_uri (NautilusFile *file)
{
char *uri, *target_uri;
GFile *location;
......@@ -8288,18 +8257,6 @@ nautilus_file_is_user_special_directory (NautilusFile *file,
return is_special_dir;
}
gboolean
nautilus_file_is_special_link (NautilusFile *file)
{
return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->is_special_link (file);
}
static gboolean
real_is_special_link (NautilusFile *file)
{
return FALSE;
}
gboolean
nautilus_file_is_archive (NautilusFile *file)
{
......@@ -8817,13 +8774,6 @@ nautilus_file_invalidate_extension_info_internal (NautilusFile *file)
void
nautilus_file_invalidate_attributes_internal (NautilusFile *file,
NautilusFileAttributes file_attributes)
{
NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->invalidate_attributes_internal (file, file_attributes);
}
static void
real_invalidate_attributes_internal (NautilusFile *file,
NautilusFileAttributes file_attributes)
{
Request request;
......@@ -9556,13 +9506,6 @@ nautilus_file_class_init (NautilusFileClass *class)
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;
class->rename = real_rename;
class->get_target_uri = real_get_target_uri;
class->drag_can_accept_files = real_drag_can_accept_files;
class->invalidate_attributes_internal = real_invalidate_attributes_internal;
class->opens_in_view = real_opens_in_view;
class->is_special_link = real_is_special_link;
signals[CHANGED] =
g_signal_new ("changed",
......@@ -9694,12 +9637,6 @@ nautilus_file_info_providers_done (NautilusFile *file)
static gboolean
nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
{
return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (drop_target_item))->drag_can_accept_files (drop_target_item);
}
static gboolean
real_drag_can_accept_files (NautilusFile *drop_target_item)
{
if (nautilus_file_is_directory (drop_target_item))
{
......
......@@ -121,11 +121,6 @@ typedef void (*NautilusFileOperationCallback) (NautilusFile *file,
GFile *result_location,
GError *error,
gpointer callback_data);
typedef int (*NautilusWidthMeasureCallback) (const char *string,
void *context);
typedef char * (*NautilusTruncateCallback) (const char *string,
int width,
void *context);
#define NAUTILUS_FILE_ATTRIBUTES_FOR_ICON (NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO | NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL)
......@@ -213,7 +208,6 @@ gboolean nautilus_file_is_directory (Nautilu
gboolean nautilus_file_is_regular_file (NautilusFile *file);
gboolean nautilus_file_is_user_special_directory (NautilusFile *file,
GUserDirectory special_directory);
gboolean nautilus_file_is_special_link (NautilusFile *file);
gboolean nautilus_file_is_archive (NautilusFile *file);
gboolean nautilus_file_is_in_search (NautilusFile *file);
gboolean nautilus_file_is_in_trash (NautilusFile *file);
......@@ -619,27 +613,6 @@ typedef struct {
gpointer callback_data);
void (* poll_for_media) (NautilusFile *file);
gboolean (* can_rename) (NautilusFile *file);
void (* rename) (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data);
char* (* get_target_uri) (NautilusFile *file);
gboolean (* drag_can_accept_files) (NautilusFile *drop_target_item);
void (* invalidate_attributes_internal) (NautilusFile *file,
NautilusFileAttributes file_attributes);
gboolean (* opens_in_view) (NautilusFile *file);
/* Use this if the custom file class doesn't support usual operations like
* copy, delete or move.
*/
gboolean (* is_special_link) (NautilusFile *file);
} NautilusFileClass;
#endif /* NAUTILUS_FILE_H */
......@@ -4651,31 +4651,6 @@ nautilus_files_view_get_content_widget (NautilusFilesView *view)
return priv->scrolled_window;
}
static gboolean
nautilus_files_view_special_link_in_selection (NautilusFilesView *view,
GList *selection)
{
gboolean saw_link;
GList *node;
NautilusFile *file;
saw_link = FALSE;
for (node = selection; node != NULL; node = node->next)
{
file = NAUTILUS_FILE (node->data);
saw_link = nautilus_file_is_special_link (file);
if (saw_link)
{
break;
}
}
return saw_link;
}
/* desktop_or_home_dir_in_selection
*
* Return TRUE if either the desktop or the home directory is in the selection.
......@@ -7363,7 +7338,6 @@ real_update_actions_state (NautilusFilesView *view)
NautilusFile *file;
gint selection_count;
gboolean zoom_level_is_default;
gboolean selection_contains_special_link;
gboolean selection_contains_desktop_or_home_dir;
gboolean selection_contains_recent;
gboolean selection_contains_search;
......@@ -7402,7 +7376,6 @@ real_update_actions_state (NautilusFilesView *view)
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
selection_count = g_list_length (selection);
selection_contains_special_link = nautilus_files_view_special_link_in_selection (view, selection);
selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (selection);
selection_contains_recent = showing_recent_directory (view);
selection_contains_starred = showing_starred_directory (view);
......@@ -7418,15 +7391,12 @@ real_update_actions_state (NautilusFilesView *view)
can_delete_files =
can_delete_all (selection) &&
selection_count != 0 &&
!selection_contains_special_link &&
!selection_contains_desktop_or_home_dir;
can_trash_files =
can_trash_all (selection) &&
selection_count != 0 &&
!selection_contains_special_link &&
!selection_contains_desktop_or_home_dir;
can_copy_files = selection_count != 0
&& !selection_contains_special_link;
can_copy_files = selection_count != 0;
can_move_files = can_delete_files && !selection_contains_recent &&
!selection_contains_starred;
can_paste_files_into = (!selection_contains_recent &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment