[gnome-flashback/nautilus-file-operations2: 4/4] desktop: implement file deletion
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback/nautilus-file-operations2: 4/4] desktop: implement file deletion
- Date: Fri, 31 Jan 2020 15:38:20 +0000 (UTC)
commit 4392d29cebc99eca223d29cc86e61d637e642d09
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Jan 31 17:34:55 2020 +0200
desktop: implement file deletion
https://gitlab.gnome.org/GNOME/gnome-flashback/issues/28
gnome-flashback/libdesktop/gf-icon-view.c | 64 +++++++++++++++++++++++++++++++
gnome-flashback/libdesktop/gf-icon-view.h | 4 ++
2 files changed, 68 insertions(+)
---
diff --git a/gnome-flashback/libdesktop/gf-icon-view.c b/gnome-flashback/libdesktop/gf-icon-view.c
index 3462897..caf5d17 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.c
+++ b/gnome-flashback/libdesktop/gf-icon-view.c
@@ -615,6 +615,25 @@ trash_files2_cb (GObject *object,
}
}
+static void
+delete_files_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+
+ error = NULL;
+ gf_nautilus2_gen_call_delete_files_finish (GF_NAUTILUS2_GEN (object),
+ res, &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Error deleting files: %s", error->message);
+ g_error_free (error);
+ }
+}
+
static void
rename_file_cb (GObject *object,
GAsyncResult *res,
@@ -2327,6 +2346,35 @@ static void
delete_cb (GfIconView *self,
gpointer user_data)
{
+ gboolean can_delete;
+ GList *l;
+ char **uris;
+
+ if (self->selected_icons == NULL)
+ return;
+
+ can_delete = TRUE;
+ for (l = self->selected_icons; l != NULL; l = l->next)
+ {
+ if (!GF_ICON_GET_CLASS (l->data)->can_delete (GF_ICON (l->data)))
+ {
+ can_delete = FALSE;
+ break;
+ }
+ }
+
+ if (!can_delete)
+ return;
+
+ uris = get_selected_uris (self);
+ if (uris == NULL)
+ return;
+
+ gf_icon_view_delete (self,
+ (const char * const *) uris,
+ gtk_get_current_event_time ());
+
+ g_strfreev (uris);
}
static void
@@ -3418,6 +3466,22 @@ gf_icon_view_move_to_trash (GfIconView *self,
}
}
+void
+gf_icon_view_delete (GfIconView *self,
+ const char * const *uris,
+ guint32 timestamp)
+{
+ if (self->nautilus2 == NULL)
+ return;
+
+ gf_nautilus2_gen_call_delete_files (self->nautilus2,
+ uris,
+ get_platform_data (self, timestamp),
+ self->cancellable,
+ delete_files_cb,
+ NULL);
+}
+
void
gf_icon_view_rename_file (GfIconView *self,
const char *uri,
diff --git a/gnome-flashback/libdesktop/gf-icon-view.h b/gnome-flashback/libdesktop/gf-icon-view.h
index 697ee00..455ba05 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.h
+++ b/gnome-flashback/libdesktop/gf-icon-view.h
@@ -59,6 +59,10 @@ void gf_icon_view_move_to_trash (GfIconView *
const char * const *uris,
guint32 timestamp);
+void gf_icon_view_delete (GfIconView *self,
+ const char * const *uris,
+ guint32 timestamp);
+
void gf_icon_view_rename_file (GfIconView *self,
const char *uri,
const char *new_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]