Description: Add delete confirmation Add a delete confirmation option to the options dialog. If set (default) a delete confirmation dialog is displayed whenever a file is to be deleted. Conversely if unset, the delete confirmation dialog is suppressed, and the file to be deleted is immediately moved to the wastebasket. . ristretto (0.6.3-2mkw1) UNRELEASED; urgency=medium . * Make delete confirmation optional. Author: Michael Werle --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: , Bug: Bug-Debian: http://bugs.debian.org/ Bug-Ubuntu: https://launchpad.net/bugs/ Forwarded: Reviewed-By: Last-Update: --- ristretto-0.6.3.orig/src/preferences_dialog.c +++ ristretto-0.6.3/src/preferences_dialog.c @@ -58,6 +58,11 @@ cb_invert_zoom_direction_check_button_to gpointer ); static void +cb_delete_confirmation_check_button_toggled ( + GtkToggleButton *, + gpointer ); + +static void cb_hide_thumbnails_fullscreen_check_button_toggled ( GtkToggleButton *button, gpointer user_data); @@ -131,6 +136,7 @@ struct _RsttoPreferencesDialogPriv GtkWidget *scroll_frame; GtkWidget *scroll_vbox; GtkWidget *zoom_invert_check_button; + GtkWidget *delete_confirmation_check_button; } control_tab; struct @@ -221,6 +227,7 @@ rstto_preferences_dialog_init ( RsttoPre /* Variable Section */ gboolean bool_invert_zoom_direction; + gboolean bool_delete_confirmation; gboolean bool_bgcolor_override; guint uint_slideshow_timeout; gboolean bool_hide_thumbnails_fullscreen; @@ -258,6 +265,7 @@ rstto_preferences_dialog_init ( RsttoPre g_object_get ( G_OBJECT (dialog->priv->settings), "invert-zoom-direction", &bool_invert_zoom_direction, + "delete-confirmation", &bool_delete_confirmation, "bgcolor-override", &bool_bgcolor_override, "bgcolor", &bgcolor, "slideshow-timeout", &uint_slideshow_timeout, @@ -414,7 +422,17 @@ rstto_preferences_dialog_init ( RsttoPre (GCallback)cb_invert_zoom_direction_check_button_toggled, dialog); - /* + dialog->priv->control_tab.delete_confirmation_check_button = gtk_check_button_new_with_label (_("Delete Confirmation")); + gtk_container_add (GTK_CONTAINER (dialog->priv->control_tab.scroll_vbox), dialog->priv->control_tab.delete_confirmation_check_button); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->control_tab.delete_confirmation_check_button), bool_delete_confirmation); + + g_signal_connect ( + G_OBJECT (dialog->priv->control_tab.delete_confirmation_check_button), + "toggled", + (GCallback)cb_delete_confirmation_check_button_toggled, + dialog); + + /* * Behaviour tab */ behaviour_main_vbox = gtk_vbox_new(FALSE, 0); @@ -724,6 +742,52 @@ cb_invert_zoom_direction_check_button_to } /** + * cb_delete_confirmation_check_button_toggled: + * @button: The check-button the user clicked. + * @user_data: The user-data provided when connecting the + * callback-function, the preferences-dialog. + * + * + * This function is called when a user toggles the + * 'delete_confirmation' check-button. This function then + * sets the right property in the ristretto settings container. + * + * When this property is set, the delete confirmation dialog is + * displayed when files are deleted. + * + * + * active = toggle_button_get_active () + * + * if ( active == TRUE ) then + * + * set_property ( "delete-confirmation", TRUE ); + * + * else + * + * set_property ( "delete-confirmation", FALSE ); + * + * endif + */ +static void +cb_delete_confirmation_check_button_toggled ( + GtkToggleButton *button, + gpointer user_data ) +{ + /* Variable Section */ + + RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data); + gboolean delete_confirmation = gtk_toggle_button_get_active ( button ); + + + /* Code Section */ + + rstto_settings_set_boolean_property ( + dialog->priv->settings, + "delete-confirmation", + delete_confirmation ); +} + +/** * cb_slideshow_timeout_value_changed: * @range: The slider the user moved. * @user_data: The user-data provided when connecting the --- ristretto-0.6.3.orig/po/en_GB.po +++ ristretto-0.6.3/po/en_GB.po @@ -746,6 +746,10 @@ msgstr "Scroll wheel" msgid "Invert zoom direction" msgstr "Invert zoom direction" +#: ../src/preferences_dialog.c:407 +msgid "Delete Confirmation" +msgstr "Delete Confirmation" + #: ../src/preferences_dialog.c:421 msgid "Behaviour" msgstr "Behaviour" --- ristretto-0.6.3.orig/src/main_window.c +++ ristretto-0.6.3/src/main_window.c @@ -3304,87 +3304,69 @@ cb_rstto_main_window_delete ( const gchar *file_basename = rstto_file_get_display_name(file); GtkWidget *dialog; GdkModifierType state; - gboolean delete_file = FALSE; + gboolean delete_file = TRUE; GError *error = NULL; + const char *delete_confirm_msg = _("Are you sure you want to delete image '%s' from disk?"); + const char *delete_error_msg = _("An error occurred when deleting image '%s' from disk.\n\n%s"); + const char *trash_confirm_msg = _("Are you sure you want to send image '%s' to trash?"); + const char *trash_error_msg = _("An error occurred when sending image '%s' to trash.\n\n%s"); + const char *confirm_msg= trash_confirm_msg; + const char *error_msg = trash_error_msg; + /* Set this to either g_file_delete or g_file_trash */ + gboolean (*do_remove_file) (GFile*, GCancellable*, GError**) = g_file_trash; + g_return_if_fail (rstto_image_list_get_n_images (window->priv->image_list) > 0); if (gtk_get_current_event_state (&state)) { if (state & GDK_SHIFT_MASK) { - delete_file = TRUE; + confirm_msg= delete_confirm_msg; + error_msg = delete_error_msg; + do_remove_file = g_file_delete; } } - if (delete_file) + if (rstto_settings_get_boolean_property (RSTTO_SETTINGS (window->priv->settings_manager), "delete-confirmation")) { 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?"), + confirm_msg, file_basename); g_object_ref (file); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) { - if (g_file_delete (rstto_file_get_file(file), NULL, &error) == TRUE) - { - rstto_image_list_remove_file (window->priv->image_list, file); - } - else - { - gtk_widget_destroy (dialog); - dialog = gtk_message_dialog_new ( - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("An error occurred when deleting image '%s' from disk.\n\n%s"), - file_basename, - error->message); - gtk_dialog_run (GTK_DIALOG (dialog)); - } + delete_file = FALSE; } - 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 (delete_file) + { + if (do_remove_file (rstto_file_get_file(file), NULL, &error) == TRUE) + { + rstto_image_list_remove_file (window->priv->image_list, file); + } + else { - if (g_file_trash (rstto_file_get_file(file), NULL, &error) == TRUE) - { - rstto_image_list_remove_file (window->priv->image_list, file); - } - else - { - gtk_widget_destroy (dialog); - dialog = gtk_message_dialog_new ( - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("An error occurred when sending image '%s' to trash.\n\n%s"), - file_basename, - error->message); - gtk_dialog_run (GTK_DIALOG (dialog)); - } + gtk_widget_destroy (dialog); + dialog = gtk_message_dialog_new ( + GTK_WINDOW (window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + error_msg, + file_basename, + error->message); + gtk_dialog_run (GTK_DIALOG (dialog)); } - gtk_widget_destroy (dialog); - g_object_unref (file); } + gtk_widget_destroy (dialog); + g_object_unref (file); } /** --- ristretto-0.6.3.orig/src/settings.c +++ ristretto-0.6.3/src/settings.c @@ -73,6 +73,7 @@ enum PROP_WRAP_IMAGES, PROP_DESKTOP_TYPE, PROP_INVERT_ZOOM_DIRECTION, + PROP_DELETE_CONFIRMATION, PROP_USE_THUNAR_PROPERTIES, PROP_MAXIMIZE_ON_STARTUP, PROP_ERROR_MISSING_THUMBNAILER, @@ -118,6 +119,7 @@ struct _RsttoSettingsPriv gboolean hide_thumbnails_fullscreen; gchar *navigationbar_position; gboolean invert_zoom_direction; + gboolean delete_confirmation; guint window_width; guint window_height; gchar *last_file_path; @@ -184,6 +184,7 @@ rstto_settings_init (GObject *object) settings->priv->window_width = 600; settings->priv->window_height = 440; settings->priv->wrap_images = TRUE; + settings->priv->delete_confirmation = TRUE; settings->priv->show_thumbnailbar = TRUE; settings->priv->show_statusbar = TRUE; settings->priv->use_thunar_properties = TRUE; @@ -293,6 +295,13 @@ rstto_settings_init (GObject *object) xfconf_g_property_bind ( settings->priv->channel, + "/window/delete-confirmation", + G_TYPE_BOOLEAN, + settings, + "delete-confirmation"); + + xfconf_g_property_bind ( + settings->priv->channel, "/window/show-clock", G_TYPE_BOOLEAN, settings, @@ -472,6 +481,17 @@ rstto_settings_class_init (GObjectClass PROP_INVERT_ZOOM_DIRECTION, pspec); + pspec = g_param_spec_boolean ( + "delete-confirmation", + "", + "", + TRUE, + G_PARAM_READWRITE); + g_object_class_install_property ( + object_class, + PROP_DELETE_CONFIRMATION, + pspec); + pspec = g_param_spec_string ( "current-uri", "", @@ -725,6 +745,9 @@ rstto_settings_set_property (GObject case PROP_INVERT_ZOOM_DIRECTION: settings->priv->invert_zoom_direction = g_value_get_boolean (value); break; + case PROP_DELETE_CONFIRMATION: + settings->priv->delete_confirmation = g_value_get_boolean (value); + break; case PROP_WINDOW_WIDTH: settings->priv->window_width = g_value_get_uint (value); break; @@ -817,6 +840,9 @@ rstto_settings_get_property (GObject case PROP_INVERT_ZOOM_DIRECTION: g_value_set_boolean (value, settings->priv->invert_zoom_direction); break; + case PROP_DELETE_CONFIRMATION: + g_value_set_boolean (value, settings->priv->delete_confirmation); + break; case PROP_WINDOW_WIDTH: g_value_set_uint (value, settings->priv->window_width); break;