Commit 1b14e1cc authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

desktop: implement file deletion

#28
parent 227affcf
Pipeline #168036 passed with stages
in 14 minutes and 37 seconds
......@@ -574,6 +574,25 @@ trash_uris_cb (GObject *object,
}
}
static void
delete_uris_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
error = NULL;
gf_nautilus2_gen_call_delete_uris_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_uri_cb (GObject *object,
GAsyncResult *res,
......@@ -2105,6 +2124,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
......@@ -3182,6 +3230,22 @@ gf_icon_view_move_to_trash (GfIconView *self,
NULL);
}
void
gf_icon_view_delete (GfIconView *self,
const char * const *uris,
guint32 timestamp)
{
if (self->nautilus == NULL)
return;
gf_nautilus2_gen_call_delete_uris (self->nautilus,
uris,
get_platform_data (self, timestamp),
self->cancellable,
delete_uris_cb,
NULL);
}
void
gf_icon_view_rename_file (GfIconView *self,
const char *uri,
......
......@@ -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,
......
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