After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720222 - Undo-able deletion of photos and albums
Undo-able deletion of photos and albums
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
3.10.x
Other All
: Normal enhancement
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-12-10 23:26 UTC by Marius Andreiana
Modified: 2014-08-01 16:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Enhancement: Enable deletion of photos (19.42 KB, patch)
2014-07-08 11:52 UTC, Pranav Kant
none Details | Review
Enhancement: Enable deletion of photos (21.21 KB, patch)
2014-07-09 14:12 UTC, Pranav Kant
none Details | Review
Enhancement: Enable deletion of photos (21.07 KB, patch)
2014-07-09 14:51 UTC, Pranav Kant
needs-work Details | Review
base-item: Make trash a virtual method and implement it for local items (4.55 KB, patch)
2014-07-21 14:53 UTC, Debarshi Ray
committed Details | Review
Add PhotosDeleteNotification (13.30 KB, patch)
2014-07-24 11:29 UTC, Debarshi Ray
committed Details | Review
local-item: Guard for collections (925 bytes, patch)
2014-07-30 15:20 UTC, Debarshi Ray
committed Details | Review

Description Marius Andreiana 2013-12-10 23:26:50 UTC
Please allow deletion of photos via pressing Del key. No confirmation, just move the file to Trash and show next.

Feel free to try out Picasa (using wine on Linux) for a great managing photos experience.
Comment 1 Debarshi Ray 2013-12-11 11:09:44 UTC
There is some discussion at https://bugzilla.gnome.org/show_bug.cgi?id=661599
Comment 2 Pranav Kant 2014-07-08 11:52:40 UTC
Created attachment 280138 [details] [review]
Enhancement: Enable deletion of photos
Comment 3 Pranav Kant 2014-07-09 14:12:58 UTC
Created attachment 280274 [details] [review]
Enhancement: Enable deletion of photos
Comment 4 Pranav Kant 2014-07-09 14:51:36 UTC
Created attachment 280279 [details] [review]
Enhancement: Enable deletion of photos
Comment 5 Debarshi Ray 2014-07-21 13:44:55 UTC
Review of attachment 280279 [details] [review]:

Thanks for the patch, Pranav!

::: src/photos-base-item.c
@@ +342,3 @@
+{
+  /* Subclasses must provide the implementation if they allows deletion */
+}

I would not define a default that is no-op because we should not offer the UI in the first place if an item can't be deleted, and we have can_trash to determine that.

@@ -1048,3 @@
-{
-  return self->priv->collection;
-}

Instead of using a separate virtual method, we can define it as 'PHOTOS_BASE_ITEM_GET_CLASS (self)->delete != NULL'

That would make it easier to implement new subclasses of BaseItem, and avoid logical errors. I know that gnome-documents uses virtual methods, but in C we can be slightly clever.

::: src/photos-base-item.h
@@ +77,3 @@
+  void      (*delete)                  (PhotosBaseItem *self);
+  void      (*set_favorite)            (PhotosBaseItem *self, gboolean favorite);
+  void      (*update_type_description) (PhotosBaseItem *self);

Please use a separate commit for style / formatting changes.

::: src/photos-delete-notification.c
@@ +258,3 @@
+  PhotosDeleteNotificationPrivate *priv = self->priv;
+
+  priv->deleted_objects = objects;

Please use a separate G_CONSTRUCT_ONLY property for objects and use g_list_deep_copy with g_object_ref to copy them in set_property.

@@ +259,3 @@
+
+  priv->deleted_objects = objects;
+  photos_delete_notification_display (self, _("Selected item(s) have been deleted"), NULL);

Umm... why can't this be in _init? Use _constructed if you need the value of priv->deleted_objects.
Comment 6 Debarshi Ray 2014-07-21 13:57:55 UTC
Review of attachment 280279 [details] [review]:

::: src/photos-local-item.c
@@ +125,3 @@
+  file = g_file_new_for_uri (uri);
+  g_file_trash (file, NULL, NULL);
+}

It does not handle deletion of collections.
Comment 7 Debarshi Ray 2014-07-21 14:18:10 UTC
Review of attachment 280279 [details] [review]:

::: src/photos-local-item.c
@@ +123,3 @@
+
+  uri = photos_base_item_get_uri (item);
+  file = g_file_new_for_uri (uri);

This needs to be unref-ed and we should use the async API to minimize blocking. Think of /home mounted over the network, slow disks, etc..
Comment 8 Debarshi Ray 2014-07-21 14:53:54 UTC
Created attachment 281318 [details] [review]
base-item: Make trash a virtual method and implement it for local items

I split out the back-end portions of the previous patch. Instead of defining a separate delete vfunc, I reused the existing trash method, and defined can_trash in terms of whether trash is implemented or not.
Comment 9 Debarshi Ray 2014-07-22 21:31:34 UTC
Review of attachment 280279 [details] [review]:

::: src/photos-delete-notification.c
@@ +122,3 @@
+static gboolean
+photos_delete_notification_timeout (PhotosDeleteNotification *self)
+{

The self needs to be typecast from a gpointer. See below.

@@ +137,3 @@
+
+  if (priv->on_display)
+    photos_delete_notification_delete_objects (self);

Is priv->on_display really useful?

@@ +140,3 @@
+
+  if (priv->closed)
+    return;

Ditto. Doesn't look useful.

@@ +148,3 @@
+  priv->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+                                                 DELETE_TIMEOUT,
+                                                 photos_delete_notification_timeout,

This will generate a warning.

@@ +212,3 @@
+  context = gtk_widget_get_style_context (priv->secondary_label);
+  gtk_style_context_add_class (context, "dim-label");
+  gtk_container_add (GTK_CONTAINER (labels), priv->secondary_label);

The secondary label is unused. I don't think Boxes uses it either, so lets drop it.

::: src/photos-selection-toolbar.c
@@ +384,2 @@
   selection = photos_selection_controller_get_selection (priv->sel_cntrlr);
+  tmp_list = g_list_copy_deep (selection, (GCopyFunc) g_strdup, NULL);

Do you really need tmp_list?
Comment 10 Debarshi Ray 2014-07-24 10:01:48 UTC
Review of attachment 280279 [details] [review]:

A few more comments while playing with your patch.

::: src/photos-delete-notification.c
@@ +219,3 @@
+  gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
+
+  close = gtk_button_new ();

The properties 'relief' and 'focus-on-click' should be turned off.

Actually, I wonder, why we don't use GdNotification for each notification, instead of packing them into one big GdNotification. Something to talk about during the BoF.

@@ +227,3 @@
+  gtk_button_set_label (undo, _("Undo"));
+  gtk_widget_set_valign (undo, GTK_ALIGN_CENTER);
+  gtk_container_add (GTK_CONTAINER (self), undo);

The undo button should be on the left of the close button.

@@ +259,3 @@
+
+  priv->deleted_objects = objects;
+  photos_delete_notification_display (self, _("Selected item(s) have been deleted"), NULL);

Use ngettext to solve the singular vs. plural problem.
Comment 11 Debarshi Ray 2014-07-24 11:27:56 UTC
(In reply to comment #9)
> ::: src/photos-selection-toolbar.c
> @@ +384,2 @@
>    selection = photos_selection_controller_get_selection (priv->sel_cntrlr);
> +  tmp_list = g_list_copy_deep (selection, (GCopyFunc) g_strdup, NULL);
> 
> Do you really need tmp_list?

You were right, Pranav. We need it because removing items from item_mngr changes selection. Adding a comment would be nice.
Comment 12 Debarshi Ray 2014-07-24 11:29:15 UTC
Created attachment 281570 [details] [review]
Add PhotosDeleteNotification
Comment 13 Debarshi Ray 2014-07-24 11:41:40 UTC
Now that we have undo-able deletion of photos, we need to allow doing it from the preview. Let's use a separate bug for that. Small bite-sized bugs are easier for new contributors. I filed bug 733660
Comment 14 Debarshi Ray 2014-07-30 15:20:26 UTC
Created attachment 282081 [details] [review]
local-item: Guard for collections