Updating branch refs/heads/master to 7cb75bbe8c7d27d8286b8f2da8e019d51dced5ad (commit) from 3045a75dd0274bb316346cee6cd513a2459e757a (commit)
commit 7cb75bbe8c7d27d8286b8f2da8e019d51dced5ad Author: Stephan Arts <step...@xfce.org> Date: Sat Mar 10 22:29:40 2012 +0100 Make a difference between delete and move-to-trash src/main_window.c | 70 ++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/main_window.c b/src/main_window.c index 3f962b1..7aae06d 100644 --- a/src/main_window.c +++ b/src/main_window.c @@ -477,6 +477,7 @@ rstto_main_window_init (RsttoMainWindow *window) GClosure *next_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_next_image, window, NULL); GClosure *previous_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_previous_image, window, NULL); GClosure *quit_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_quit, window, NULL); + GClosure *delete_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_delete, window, NULL); guint navigationbar_position = 3; guint thumbnail_size = 3; @@ -549,6 +550,7 @@ rstto_main_window_init (RsttoMainWindow *window) gtk_accel_group_connect_by_path (accel_group, "<Window>/next-image", next_image_closure); gtk_accel_group_connect_by_path (accel_group, "<Window>/previous-image", previous_image_closure); gtk_accel_group_connect_by_path (accel_group, "<Window>/quit", quit_closure); + gtk_accel_group_connect_by_path (accel_group, "<Window>/delete", delete_closure); /* Set default accelerators */ gtk_accel_map_change_entry ("<Window>/fullscreen", GDK_F, 0, FALSE); @@ -556,6 +558,8 @@ rstto_main_window_init (RsttoMainWindow *window) gtk_accel_map_change_entry ("<Window>/next-image", GDK_Page_Down, 0, FALSE); gtk_accel_map_change_entry ("<Window>/previous-image", GDK_Page_Up, 0, FALSE); gtk_accel_map_change_entry ("<Window>/quit", GDK_q, 0, FALSE); + + gtk_accel_map_change_entry ("<Window>/delete", GDK_Delete, GDK_SHIFT_MASK, FALSE); if (gtk_accel_map_lookup_entry ("<Actions>/RsttoWindow/play", NULL) == FALSE) { gtk_accel_map_change_entry ("<Actions>/RsttoWindow/play", GDK_F5, 0, FALSE); @@ -3274,29 +3278,67 @@ cb_rstto_main_window_delete ( RsttoFile *file = rstto_image_list_iter_get_file (window->priv->iter); const gchar *file_basename = rstto_file_get_display_name(file); GtkWidget *dialog; + GdkModifierType state; + gboolean delete_file = FALSE; + g_return_if_fail (rstto_image_list_get_n_images (window->priv->image_list) > 0); - dialog = gtk_message_dialog_new (GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK_CANCEL, - _("Are you sure you want to delete image '%s' from disk?"), - file_basename); + if (gtk_get_current_event_state (&state)) + { + if (state & GDK_SHIFT_MASK) + { + delete_file = TRUE; + } + } - g_object_ref (file); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) + if (delete_file) { - if (g_file_trash (rstto_file_get_file(file), NULL, NULL) == TRUE) + dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK_CANCEL, + _("Are you sure you want to delete image '%s' from disk?"), + file_basename); + + g_object_ref (file); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { - rstto_image_list_remove_file (window->priv->image_list, file); + if (g_file_delete (rstto_file_get_file(file), NULL, NULL) == TRUE) + { + rstto_image_list_remove_file (window->priv->image_list, file); + } + else + { + + } } - else + gtk_widget_destroy (dialog); + g_object_unref (file); + } + else + { + dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK_CANCEL, + _("Are you sure you want to send image '%s' to trash?"), + file_basename); + + g_object_ref (file); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { - + if (g_file_trash (rstto_file_get_file(file), NULL, NULL) == TRUE) + { + rstto_image_list_remove_file (window->priv->image_list, file); + } + else + { + + } } + gtk_widget_destroy (dialog); + g_object_unref (file); } - gtk_widget_destroy (dialog); - g_object_unref (file); } static gboolean _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits