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 763096 - Add notification when user clicks Done
Add notification when user clicks Done
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Rafael Fonseca
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-03-04 13:11 UTC by Rafael Fonseca
Modified: 2016-03-10 08:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add notification for edited item (11.35 KB, patch)
2016-03-04 14:50 UTC, Rafael Fonseca
none Details | Review
Add notification for edited item (12.06 KB, patch)
2016-03-06 20:35 UTC, Rafael Fonseca
accepted-commit_now Details | Review
Add a GAction to redraw the current PhotosImageView (6.53 KB, patch)
2016-03-07 15:29 UTC, Debarshi Ray
committed Details | Review
Add notification when an item is edited (12.59 KB, patch)
2016-03-07 15:30 UTC, Debarshi Ray
committed Details | Review
Screenshot (2.31 MB, image/png)
2016-03-07 15:45 UTC, Debarshi Ray
  Details

Description Rafael Fonseca 2016-03-04 13:11:03 UTC
After editing a photo and clicking Done, we should show a notification with an undo button to revert to the original photo.
Comment 1 Rafael Fonseca 2016-03-04 14:50:19 UTC
Created attachment 323095 [details] [review]
Add notification for edited item
Comment 2 Debarshi Ray 2016-03-05 19:15:17 UTC
Review of attachment 323095 [details] [review]:

Thanks for the nice patch!

::: po/POTFILES.in
@@ +8,3 @@
 src/photos-delete-notification.c
 [type: gettext/glade]src/photos-dlna-renderers-dialog.ui
+src/photos-done-notification.c

Nice!

::: src/photos-done-notification.c
@@ +107,3 @@
+
+  photos_done_notification_destroy (self);
+  g_application_release (app);

We can't release the app, yet. Since edit_done saves the pipeline, any kind of revert needs to call photos_base_item_pipeline_save_async too.

@@ +119,3 @@
+  g_application_hold (app);
+
+  photos_base_item_operations_revert (self->item);

If you had already clicked "done" a few times before, then photos_base_item_operation_revert will revert it to the last snapshot, not the original. That is the same as clicking the "cancel" button.

Here we want to revert to the original. Thinking of it, it is probably better to have a "Discard all edits" button for reverting to the original, and an "Undo" to go back to the previous snapshot, as you have done here. That means one more new string (thinking of the String Freeze), but it can be shared with the properties dialog. I don't know. Let's see how it goes. :)

Anyway, for reverting to the original, we need a revert_to_original method that will clean self->hash, call photos_utils_remove_children_from_node and connect the input and output proxies.
Comment 3 Debarshi Ray 2016-03-05 19:16:11 UTC
Related to this, jimmac mocked up this "discard all edits" UI for the properties dialog: https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/photos/wires-revert-to-original.png
Comment 4 Debarshi Ray 2016-03-05 19:22:43 UTC
(In reply to Debarshi Ray from comment #2)
> Review of attachment 323095 [details] [review] [review]:
> @@ +119,3 @@
> +  g_application_hold (app);
> +
> +  photos_base_item_operations_revert (self->item);
> 
> If you had already clicked "done" a few times before, then
> photos_base_item_operation_revert will revert it to the last snapshot, not
> the original. That is the same as clicking the "cancel" button.
> 
> Here we want to revert to the original. Thinking of it, it is probably
> better to have a "Discard all edits" button for reverting to the original,
> and an "Undo" to go back to the previous snapshot, as you have done here.
> That means one more new string (thinking of the String Freeze), but it can
> be shared with the properties dialog. I don't know. Let's see how it goes. :)
> 
> Anyway, for reverting to the original, we need a revert_to_original method
> that will clean self->hash, call photos_utils_remove_children_from_node and
> connect the input and output proxies.

I re-read my past conversation with jimmac, and I realize that your implementation is fine. Here is what he had written:
  "As it's not something you'd be doing all that often, I'd imagine having         
that 'revert all edits' in the properties modal as we discussed with the        
GIMP editing. The case where this wouldn't be so nice is doing some edits       
and mistakenly applying them instead of canceling. We could trigger a           
notification about applying edits and provide an undo button there, like we     
do in other apps."

So, what you have here should satisfy the "mistakenly clicked done instead of canceling" case. The revert_to_original method would be needed to implement the "Discard all edits" hammer in the properties dialog. There is no need for "Discard all edits" in the notification.

Note that we still need to save the pipeline (as I mentioned earlier) after revert.
Comment 5 Rafael Fonseca 2016-03-05 23:53:32 UTC
(In reply to Debarshi Ray from comment #3)
> Related to this, jimmac mocked up this "discard all edits" UI for the
> properties dialog:
> https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/
> photos/wires-revert-to-original.png

Nice. I will open a new bug for this.
Comment 6 Rafael Fonseca 2016-03-06 20:35:38 UTC
Created attachment 323209 [details] [review]
Add notification for edited item

Addressing raised points.
Comment 7 Debarshi Ray 2016-03-07 15:29:04 UTC
Review of attachment 323209 [details] [review]:

Thanks for the new patch, Rafael. It looks really good apart from some minor details:

::: src/photos-done-notification.c
@@ +57,3 @@
+enum
+{
+  DELETE_TIMEOUT = 10 /* s */

s/DELETE/DONE/ :)

@@ +105,3 @@
+    }
+
+  photos_done_notification_destroy (self);

Since we are going to call photos_done_notification_destroy irrespective of whether there is an error or not, I would move this to photos_done_notification_undo_clicked instead of having to deal with it twice. That's similar to what what ExportNotification does in the "empty trash" code path.

@@ +128,3 @@
+    }
+
+  photos_base_item_pipeline_save_async (item, NULL, photos_done_notification_pipeline_save_finish, self);

I think we should do a gtk_widget_queue_draw on the current PhotosImageView widget to ensure that the visible pixels are refreshed to match the state of the pipeline. I see that gtk+ master somehow queues a draw itself, but that is not the case with gtk-3-18. As far as I can tell, this is just a happy coincidence with gtk+ master. There is no guarantee that it won't change.

Since the PhotosImageView widget is entrenched deep inside PhotosPreviewView, a GAction might be an easy way to wire up the redraw.

@@ +141,3 @@
+
+  photos_base_item_operations_revert (self->item);
+  photos_base_item_process_async (self->item, NULL, photos_done_notification_edit_undo_process, self);

It will probably never hurt us, but, still, I would sleep better if we took a ref on self when starting the async operation and unreffed it in the callback. That way we are sure that self won't disappear behind our back.

Having said that, the memory management in all the notification classes are a bit sub-optimal. It would be better to use self->cancellable with all the async operations instead of doing the ref/unref trick. Then we would cancel self->cancellable during destruction, and teach each callback to be careful about G_IO_ERROR_CANCELLED. This is better because we won't be holding extra references to self behind the caller's back, and in-flight operations would be nicely cleaned up once the callers drops its ref. But, we are on the verge of a release, so let's not destabilize things by making such changes right now. :)

@@ +159,3 @@
+
+  name = photos_base_item_get_name_with_fallback (PHOTOS_BASE_ITEM (self->item));
+  msg = g_strdup_printf (_("%s edited"), name);

The %s should be enclosed in “” marks like it is in DeleteNotification and ExportNotification.

@@ +256,3 @@
+photos_done_notification_new (PhotosBaseItem *item)
+{
+  g_return_if_fail (item != NULL);

It would be more strict to assert PHOTOS_IS_BASE_ITEM (item), instead of 'item != NULL'.

@@ +263,3 @@
+                "margin-start", 12,
+                "margin-end", 12,
+                "orientation", GTK_ORIENTATION_HORIZONTAL,

I know where you copied this style from, but it is an anti-pattern. :) I would prefer to pass only those properties to g_object_new that were passed by the client code, because a direct g_object_new call should match the C wrapper as much as possible. The rest should be set "inside" in _init, _constructed, etc..
Comment 8 Debarshi Ray 2016-03-07 15:29:40 UTC
Created attachment 323291 [details] [review]
Add a GAction to redraw the current PhotosImageView
Comment 9 Debarshi Ray 2016-03-07 15:30:27 UTC
Created attachment 323292 [details] [review]
Add notification when an item is edited

I took the liberty to update the patch, and reformatted the commit message to not exceed 72 characters per line.
Comment 10 Debarshi Ray 2016-03-07 15:43:50 UTC
We need permission to commit because we are in String and UI Freeze: https://wiki.gnome.org/ThreePointNineteen
Comment 11 Debarshi Ray 2016-03-07 15:45:20 UTC
Created attachment 323293 [details]
Screenshot

New user facing string:
  "“%s” edited"
Comment 12 Debarshi Ray 2016-03-10 08:30:56 UTC
Approved by the release and translation teams! Pushed to master.