Include a Other Software section in Help file
[geeqie.git] / src / trash.c
index 2665df5..b3aecfc 100644 (file)
@@ -118,18 +118,6 @@ static gchar *file_util_safe_dest(const gchar *path)
        return dest;
 }
 
-static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data)
-{
-       options->file_ops.safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-}
-
-static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data)
-{
-       GenericDialog **gd = data;
-
-       *gd = NULL;
-}
-
 gboolean file_util_safe_unlink(const gchar *path)
 {
        static GenericDialog *gd = NULL;
@@ -138,55 +126,64 @@ gboolean file_util_safe_unlink(const gchar *path)
 
        if (!isfile(path)) return FALSE;
 
-       if (!isdir(options->file_ops.safe_delete_path))
+       if (options->file_ops.no_trash)
                {
-               DEBUG_1("creating trash: %s", options->file_ops.safe_delete_path);
-               if (!options->file_ops.safe_delete_path || !mkdir_utf8(options->file_ops.safe_delete_path, 0755))
+               if (!unlink_file(path))
                        {
-                       result = _("Could not create folder");
+                       file_util_warning_dialog(_("Delete failed"),
+                                                _("Unable to remove file"),
+                                                GTK_STOCK_DIALOG_WARNING, NULL);
                        success = FALSE;
                        }
                }
-
-       if (success)
+       else if (!options->file_ops.use_system_trash)
                {
-               gchar *dest;
-
-               dest = file_util_safe_dest(path);
-               if (dest)
+               if (!isdir(options->file_ops.safe_delete_path))
                        {
-                       DEBUG_1("safe deleting %s to %s", path, dest);
-                       success = move_file(path, dest);
+                       DEBUG_1("creating trash: %s", options->file_ops.safe_delete_path);
+                       if (!options->file_ops.safe_delete_path || !mkdir_utf8(options->file_ops.safe_delete_path, 0755))
+                               {
+                               result = _("Could not create folder");
+                               success = FALSE;
+                               }
                        }
-               else
+
+               if (success)
                        {
-                       success = FALSE;
+                       gchar *dest;
+
+                       dest = file_util_safe_dest(path);
+                       if (dest)
+                               {
+                               DEBUG_1("safe deleting %s to %s", path, dest);
+                               success = move_file(path, dest);
+                               }
+                       else
+                               {
+                               success = FALSE;
+                               }
+
+                       if (!success && !access_file(path, W_OK))
+                               {
+                               result = _("Permission denied");
+                               }
+                       g_free(dest);
                        }
 
-               if (!success && !access_file(path, W_OK))
+               if (result && !gd)
                        {
-                       result = _("Permission denied");
+                       gchar *buf;
+
+                       buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->file_ops.safe_delete_path);
+                       gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL);
+                       g_free(buf);
                        }
-               g_free(dest);
                }
-
-       if (result && !gd)
+       else
                {
-               GtkWidget *button;
-               gchar *buf;
-
-               buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->file_ops.safe_delete_path);
-               gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL);
-               g_free(buf);
-
-               button = gtk_check_button_new_with_label(_("Turn off safe delete"));
-               g_signal_connect(G_OBJECT(button), "toggled",
-                                G_CALLBACK(file_util_safe_del_toggle_cb), NULL);
-               gtk_box_pack_start(GTK_BOX(gd->vbox), button, FALSE, FALSE, 0);
-               gtk_widget_show(button);
-
-               g_signal_connect(G_OBJECT(gd->dialog), "destroy",
-                                G_CALLBACK(file_util_safe_del_close_cb), &gd);
+               GFile *tmp = g_file_new_for_path (path);
+               g_file_trash(tmp, FALSE, NULL);
+               g_object_unref(tmp);
                }
 
        return success;
@@ -194,28 +191,32 @@ gboolean file_util_safe_unlink(const gchar *path)
 
 gchar *file_util_safe_delete_status(void)
 {
-       gchar *buf;
+       gchar *buf = NULL;
 
        if (is_valid_editor_command(CMD_DELETE))
                {
                buf = g_strdup(_("Deletion by external command"));
                }
-       else
+       else if (options->file_ops.no_trash)
+               {
+               buf = g_strdup(_("Deleting without trash"));
+               }
+       else if (options->file_ops.safe_delete_enable)
                {
-               if (options->file_ops.safe_delete_enable)
+               if (!options->file_ops.use_system_trash)
                        {
                        gchar *buf2;
                        if (options->file_ops.safe_delete_folder_maxsize > 0)
-                               buf2 = g_strdup_printf(_(" (max. %d MB)"), options->file_ops.safe_delete_folder_maxsize);
+                               buf2 = g_strdup_printf(_(" (max. %d MiB)"), options->file_ops.safe_delete_folder_maxsize);
                        else
                                buf2 = g_strdup("");
 
-                       buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, options->file_ops.safe_delete_path);
+                       buf = g_strdup_printf(_("Using Geeqie Trash bin\n%s"), buf2);
                        g_free(buf2);
                        }
                else
                        {
-                       buf = g_strdup_printf(_("Safe delete: %s"), _("off"));
+                       buf = g_strdup(_("Using system Trash bin"));
                        }
                }