[cheese] allow multiple items to be deleted at once
- From: Daniel G. Siegel <dgsiegel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] allow multiple items to be deleted at once
- Date: Sun, 5 Dec 2010 17:27:05 +0000 (UTC)
commit 579c5406821d34b3a9812432a276f1a28e68fbc9
Author: daniel g. siegel <dgsiegel gnome org>
Date: Sun Dec 5 18:26:40 2010 +0100
allow multiple items to be deleted at once
src/cheese-window.vala | 60 ++++++++++++++++++++++++++++++++----------------
1 files changed, 40 insertions(+), 20 deletions(-)
---
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index a970ffd..41f4c68 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -186,29 +186,49 @@ public class Cheese.MainWindow : Gtk.Window
[CCode (instance_pos = -1)]
public void on_file_delete (Gtk.Action action)
{
- string filename, basename;
+ File file;
+ int response;
MessageDialog confirmation_dialog;
- int response;
- filename = thumb_view.get_selected_image ();
- if (filename == null)
- return; /* Nothing selected. */
+ GLib.List<GLib.File> files = thumb_view.get_selected_images_list ();
- basename = GLib.Filename.display_basename (filename);
- confirmation_dialog = new MessageDialog.with_markup (this,
- Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.MessageType.WARNING,
- Gtk.ButtonsType.NONE,
- "Are you sure you want to permanently delete the file \"%s\"?",
- basename);
- confirmation_dialog.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
- confirmation_dialog.add_button (Gtk.STOCK_DELETE, Gtk.ResponseType.ACCEPT);
- confirmation_dialog.format_secondary_text ("%s", "If you delete an item, it will be permanently lost");
- response = confirmation_dialog.run ();
- confirmation_dialog.destroy ();
- if (response == Gtk.ResponseType.ACCEPT)
+ for (int i = 0; i < files.length (); i++)
{
- GLib.FileUtils.remove (filename);
+ file = files<GLib.File>.nth (i).data;
+ if (file == null)
+ return;
+
+ confirmation_dialog = new MessageDialog.with_markup (this,
+ Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ Gtk.MessageType.WARNING,
+ Gtk.ButtonsType.NONE,
+ "Are you sure you want to permanently delete the file \"%s\"?",
+ file.get_basename ());
+ confirmation_dialog.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
+ confirmation_dialog.add_button (Gtk.STOCK_DELETE, Gtk.ResponseType.ACCEPT);
+ confirmation_dialog.format_secondary_text ("%s", "If you delete an item, it will be permanently lost");
+ response = confirmation_dialog.run ();
+ confirmation_dialog.destroy ();
+ if (response == Gtk.ResponseType.ACCEPT)
+ {
+ try
+ {
+ file.delete (null);
+ }
+ catch (Error err)
+ {
+ MessageDialog error_dialog = new MessageDialog (this,
+ Gtk.DialogFlags.MODAL |
+ Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.OK,
+ "Could not delete %s",
+ file.get_path());
+
+ error_dialog.run ();
+ error_dialog.destroy ();
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]