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 733660 - Let photos be deleted from the preview
Let photos be deleted from the preview
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-07-24 11:40 UTC by Debarshi Ray
Modified: 2015-11-04 19:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
added delete button (3.00 KB, patch)
2015-02-12 16:11 UTC, ankita sinha
needs-work Details | Review
changed g_signal_connect to g_signal_connect_swapped (3.44 KB, patch)
2015-02-19 18:05 UTC, ankita sinha
none Details | Review
changed the comment line (3.41 KB, patch)
2015-03-08 14:55 UTC, ankita sinha
needs-work Details | Review
added delete button in menu box (7.71 KB, patch)
2015-03-18 13:53 UTC, ankita sinha
none Details | Review
removed delete label from preview (1.04 KB, patch)
2015-03-18 13:54 UTC, ankita sinha
none Details | Review
added the delete button to the menu (6.87 KB, patch)
2015-03-18 19:23 UTC, ankita sinha
none Details | Review
Added the delete button to the menu. (7.01 KB, patch)
2015-03-19 05:57 UTC, ankita sinha
none Details | Review
added the delete button to the preview (4.34 KB, patch)
2015-03-19 18:57 UTC, ankita sinha
none Details | Review
add the delete button to the menu box in preview (8.10 KB, patch)
2015-05-09 09:52 UTC, ankita sinha
none Details | Review
add the delete button to the menu box in preview (8.15 KB, patch)
2015-05-11 04:20 UTC, ankita sinha
none Details | Review
added the delete button in the menu box of preview (8.18 KB, patch)
2015-06-08 11:53 UTC, ankita sinha
none Details | Review
added the delete button to preview menu (5.05 KB, patch)
2015-06-09 18:38 UTC, ankita sinha
none Details | Review
added the delete button in the menu box of preview. (5.10 KB, patch)
2015-06-11 06:25 UTC, ankita sinha
none Details | Review
added the delete button in preview menu (6.84 KB, patch)
2015-06-26 11:20 UTC, ankita sinha
none Details | Review
Use GActions to represent the next and previous operations (21.36 KB, patch)
2015-10-25 19:18 UTC, Debarshi Ray
committed Details | Review
application, selection-toolbar: Use a GAction for delete (5.98 KB, patch)
2015-10-25 19:19 UTC, Debarshi Ray
committed Details | Review
preview-menu, preview-nav-buttons: Support deleting from the preview (3.98 KB, patch)
2015-10-25 19:19 UTC, Debarshi Ray
committed Details | Review
Use GActions to represent the next and previous operations (20.67 KB, patch)
2015-10-26 14:22 UTC, Debarshi Ray
committed Details | Review
application, selection-toolbar: Use a GAction for delete (5.98 KB, patch)
2015-10-26 14:23 UTC, Debarshi Ray
committed Details | Review
preview-nav-buttons: Rename the parameters for clarity (3.06 KB, patch)
2015-10-26 14:24 UTC, Debarshi Ray
committed Details | Review
preview-nav-buttons: Don't touch the path if there is no model (1.11 KB, patch)
2015-10-26 14:24 UTC, Debarshi Ray
committed Details | Review
preview-nav-buttons: Track the active item across changes to the model (6.30 KB, patch)
2015-10-26 14:26 UTC, Debarshi Ray
committed Details | Review
preview-menu, preview-nav-buttons: Support deleting from the preview (6.81 KB, patch)
2015-10-26 14:26 UTC, Debarshi Ray
committed Details | Review
enums: Remove redundant header (716 bytes, patch)
2015-11-04 19:28 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2014-07-24 11:40:49 UTC
From bug 720222 - it should be possible to delete photos while previewing them.

Hint: we need to be careful about the iters and paths used to navigate within the preview while we change the data in the model underneath.
Comment 1 Pranav Kant 2014-07-29 08:28:40 UTC
s/photos/documents/g ?
Comment 2 Debarshi Ray 2014-07-29 13:27:33 UTC
Oops, yes, this should be against gnome-photos.
Comment 3 ankita sinha 2015-02-12 16:11:23 UTC
Created attachment 296686 [details] [review]
added delete button
Comment 4 Debarshi Ray 2015-02-17 09:23:17 UTC
Review of attachment 296686 [details] [review]:

Thanks for the patch.

::: src/photos-main-toolbar.c
@@ +477,3 @@
+
+static void
+photos_main_toolbar_trash_button_clicked (PhotosMainToolbar *self)

Since you have used g_signal_connect, the prototype or signature of this function should have been:
    void func (GtkButton *button, gpointer user_data);

See: https://developer.gnome.org/gtk3/unstable/GtkButton.html#GtkButton-clicked

However, if you want to PhotosMainToolbar * to be the first parameter of the callback, then you need to use g_signal_connect_swapped below.

@@ +677,3 @@
+                    "clicked",
+                    G_CALLBACK (photos_main_toolbar_trash_button_clicked),
+                    self); 

If you use g_signal_connect_swapped here, then self will be the first parameter in your callback, otherwise it will be a GtkButton *, which in this case will be the same as priv->trash_button.
Comment 5 ankita sinha 2015-02-19 18:05:19 UTC
Created attachment 297293 [details] [review]
changed g_signal_connect to g_signal_connect_swapped
Comment 6 ankita sinha 2015-03-08 14:55:13 UTC
Created attachment 298814 [details] [review]
changed the comment line
Comment 7 Debarshi Ray 2015-03-11 10:10:27 UTC
Review of attachment 298814 [details] [review]:

Ok, this one doesn't crash.

The commit message needs some work. Most importantly it is missing the URL of this bug, and the subject doesn't represent what this patch is about. See https://wiki.gnome.org/Git/CommitMessages

Some more comments ...

::: src/photos-main-toolbar.c
@@ +483,3 @@
+  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object(self->priv->item_mngr));
+  items = g_list_prepend (items, g_object_ref (item));
+  photos_base_manager_remove_object (self->priv->item_mngr, G_OBJECT (item));

Removing an item from the manager also modifies the model, which can mess up the path/iter from underneath you. I think it might be easier to adjust the path/iter before touching the manager.

@@ +485,3 @@
+  photos_base_manager_remove_object (self->priv->item_mngr, G_OBJECT (item));
+  photos_delete_notification_new (items);
+  gtk_tree_path_next (self->priv->current_path);

You have not initialized priv->current_path anywhere, which causes:
  Gtk-CRITICAL **: gtk_tree_path_next: assertion 'path != NULL' failed

@@ +669,3 @@
                            self,
                            G_CONNECT_SWAPPED);
+   priv->trash_button=gtk_button_new_with_label (_("Delete"));

Instead of using a button like this, try to move this to the menu (ie. the one with print, properties, etc..).
Comment 8 ankita sinha 2015-03-18 13:53:54 UTC
Created attachment 299713 [details] [review]
added delete button in menu box
Comment 9 ankita sinha 2015-03-18 13:54:54 UTC
Created attachment 299714 [details] [review]
removed delete label from preview
Comment 10 Debarshi Ray 2015-03-18 15:36:51 UTC
Review of attachment 299714 [details] [review]:

Could you please combine everything into one patch? Try git commit --amend. As mentioned before, the commit message still needs work. eg., the bug URL is missing. See https://wiki.gnome.org/Git/CommitMessages
Comment 11 ankita sinha 2015-03-18 19:23:15 UTC
Created attachment 299753 [details] [review]
added the delete button to the menu
Comment 12 ankita sinha 2015-03-19 05:57:04 UTC
Created attachment 299785 [details] [review]
Added the delete button to the menu.
Comment 13 Debarshi Ray 2015-03-19 08:32:35 UTC
Review of attachment 299785 [details] [review]:

Thanks for the new patch. Could you please mark the older versions as 'obsolete' when you attach a new patch?

::: src/photos-app-menu.ui
@@ +20,3 @@
+        <attribute name="label" translatable="yes">Delete</attribute>
+        <attribute name="accel">&lt;Primary&gt;p</attribute>
+      </item>

This is the app menu, not "the one with print, properties, etc.".

::: src/photos-application.c
@@ +73,3 @@
   GSimpleAction *open_action;
+  GtkTreeModel *model;
+  PhotosBaseManager *item_mngr;

item_mngr is already a part of PhotosApplication. See how it is used elsewhere in the file.

@@ +369,3 @@
+  GList *items = NULL;
+  
+  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object(self->priv->item_mngr));

This will most likely [1] crash because priv->item_mngr has not been initialized and is NULL. See how item_mngr is used elsewhere in the file.

[1] I say "most likely" because the code doesn't compile.

::: src/photos-main-toolbar.h
@@ +87,2 @@
 void                   photos_main_toolbar_set_stack              (PhotosMainToolbar *self, GtkStack *stack);
+void                   photos_main_toolbar_trash_button_clicked    (PhotosMainToolbar *self)

Lack of a trailing semi-colon prevents the code from compiling.
Comment 14 ankita sinha 2015-03-19 18:57:52 UTC
Created attachment 299867 [details] [review]
added the delete button to the preview
Comment 15 Debarshi Ray 2015-03-20 15:44:43 UTC
Review of attachment 299867 [details] [review]:

Please learn how to use git commit --amend and submit one coherent patch. Also see:
https://wiki.gnome.org/GnomeLove/CodeContributionWorkflow#Follow_Up_on_the_Feedback
Comment 16 ankita sinha 2015-05-09 09:52:58 UTC
Created attachment 303117 [details] [review]
add the delete button to the menu box in preview
Comment 17 ankita sinha 2015-05-11 04:20:29 UTC
Created attachment 303196 [details] [review]
add the delete button to the menu box in preview
Comment 18 ankita sinha 2015-06-08 11:53:15 UTC
Created attachment 304766 [details] [review]
added the delete button in the menu box of preview
Comment 19 ankita sinha 2015-06-09 18:38:04 UTC
Created attachment 304884 [details] [review]
added the delete button to preview menu
Comment 20 Pranav Kant 2015-06-09 19:06:03 UTC
Review of attachment 304884 [details] [review]:

::: src/photos-application.c
@@ +820,3 @@
   const gchar *gear_menu_accels[2] = {"F10", NULL};
   const gchar *print_current_accels[2] = {"<Primary>p", NULL};
+  const gchar *delete_current_accels[2] = {"<Primary>p", NULL};

This is wrong. You are having same shortcut key to do two actions.
Comment 21 ankita sinha 2015-06-11 06:25:22 UTC
Created attachment 305046 [details] [review]
added the delete button in the menu box of preview.

Made primary key "d" as shortcut key for deletion.
Comment 22 Debarshi Ray 2015-06-11 11:01:35 UTC
Review of attachment 305046 [details] [review]:

Thanks for the new patch, Ankita.

It compiles and doesn't crash, which is good. However, it has a few shortcomings:
(a) There is no notification and it is not possible to undo the action.
(b) The preview doesn't switch to the next available item. 

The combination of the above two also means that the user has no way of knowing if the item actually got deleted or not.

Some of the earlier patches did attempt to do (b). Why did you remove that? :)

For (a), see how PhotosDeleteNotification is used in photos-selection-toolbar.c
Comment 23 ankita sinha 2015-06-26 11:20:43 UTC
Created attachment 306158 [details] [review]
added the delete button in preview menu

added the undo button for delete
Comment 24 Debarshi Ray 2015-10-25 19:18:31 UTC
Created attachment 314094 [details] [review]
Use GActions to represent the next and previous operations
Comment 25 Debarshi Ray 2015-10-25 19:19:15 UTC
Created attachment 314095 [details] [review]
application, selection-toolbar: Use a GAction for delete
Comment 26 Debarshi Ray 2015-10-25 19:19:39 UTC
Created attachment 314096 [details] [review]
preview-menu, preview-nav-buttons: Support deleting from the preview
Comment 27 Debarshi Ray 2015-10-26 14:22:55 UTC
Created attachment 314131 [details] [review]
Use GActions to represent the next and previous operations
Comment 28 Debarshi Ray 2015-10-26 14:23:29 UTC
Created attachment 314132 [details] [review]
application, selection-toolbar: Use a GAction for delete
Comment 29 Debarshi Ray 2015-10-26 14:24:05 UTC
Created attachment 314133 [details] [review]
preview-nav-buttons: Rename the parameters for clarity
Comment 30 Debarshi Ray 2015-10-26 14:24:43 UTC
Created attachment 314134 [details] [review]
preview-nav-buttons: Don't touch the path if there is no model
Comment 31 Debarshi Ray 2015-10-26 14:26:19 UTC
Created attachment 314135 [details] [review]
preview-nav-buttons: Track the active item across changes to the model
Comment 32 Debarshi Ray 2015-10-26 14:26:54 UTC
Created attachment 314136 [details] [review]
preview-menu, preview-nav-buttons: Support deleting from the preview
Comment 33 Debarshi Ray 2015-11-04 19:28:26 UTC
Created attachment 314852 [details] [review]
enums: Remove redundant header