211
* Delete the requested image in the thumbview from storage.
231
* Delete the requested image or images in the thumbview from storage.
213
* A confirmation dialog is shown to the user before deleting the file.
233
* A confirmation dialog is shown to the user before deleting any files.
215
235
* @param action the action that emitted the signal
217
237
[CCode (instance_pos = -1)]
218
238
public void on_file_delete (Gtk.Action action)
222
MessageDialog confirmation_dialog;
224
GLib.List<GLib.File> files = thumb_view.get_selected_images_list ();
226
for (int i = 0; i < files.length (); i++)
242
bool skip_all_errors = false;
244
var files = thumb_view.get_selected_images_list ();
245
var files_length = files.length ();
247
var confirmation_dialog = new MessageDialog.with_markup (this,
248
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
249
Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
250
GLib.ngettext("Are you sure you want to permanently delete the file?",
251
"Are you sure you want to permanently delete %d files?",
252
files_length), files_length);
253
confirmation_dialog.add_button (Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL);
254
confirmation_dialog.add_button (Gtk.Stock.DELETE, Gtk.ResponseType.ACCEPT);
255
confirmation_dialog.format_secondary_text ("%s",
256
GLib.ngettext("If you delete an item, it will be permanently lost",
257
"If you delete the items, they will be permanently lost",
260
response = confirmation_dialog.run ();
261
if (response == Gtk.ResponseType.ACCEPT)
228
file = files<GLib.File>.nth (i).data;
232
confirmation_dialog = new MessageDialog.with_markup (this,
233
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
234
Gtk.MessageType.WARNING,
235
Gtk.ButtonsType.NONE,
236
"Are you sure you want to permanently delete the file \"%s\"?",
237
file.get_basename ());
238
confirmation_dialog.add_button (Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL);
239
confirmation_dialog.add_button (Gtk.Stock.DELETE, Gtk.ResponseType.ACCEPT);
240
confirmation_dialog.format_secondary_text ("%s", "If you delete an item, it will be permanently lost");
241
response = confirmation_dialog.run ();
242
confirmation_dialog.destroy ();
243
if (response == Gtk.ResponseType.ACCEPT)
263
foreach (var file in files)
247
270
file.delete (null);
249
272
catch (Error err)
251
MessageDialog error_dialog = new MessageDialog (this,
252
Gtk.DialogFlags.MODAL |
253
Gtk.DialogFlags.DESTROY_WITH_PARENT,
254
Gtk.MessageType.ERROR,
256
"Could not delete %s",
260
error_dialog.destroy ();
274
warning ("Unable to delete file: %s", err.message);
276
if (!skip_all_errors) {
277
var error_dialog = new MessageDialog (this,
278
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
279
Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE,
280
"Could not delete %s", file.get_path ());
282
error_dialog.add_button (Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL);
283
error_dialog.add_button ("Skip", DeleteResponse.SKIP);
284
error_dialog.add_button ("Skip all", DeleteResponse.SKIP_ALL);
286
error_response = error_dialog.run ();
287
if (error_response == DeleteResponse.SKIP_ALL) {
288
skip_all_errors = true;
289
} else if (error_response == Gtk.ResponseType.CANCEL) {
293
error_dialog.destroy ();
298
confirmation_dialog.destroy ();
379
* Share the selected file(s) in the thumbview.
381
* A dialog is shown to the user, where the technology for sharing the
382
* image or video can be selected.
384
* @param action the action that emitted the signal
386
[CCode (instance_pos = -1)]
387
public void on_share_files (Gtk.Action action)
389
bool nautilus_sendto_installed = Environment.find_program_in_path (SENDTO_EXEC) != null;
391
if (!nautilus_sendto_installed)
392
install_packages ((obj, res) => {
393
install_packages.end (res);
394
get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.LEFT_PTR));
397
shareable_media.share_files (thumb_view.get_selected_images_list ());
401
* Install nautilus-sendto runtime dependency.
404
private async void install_packages ()
406
get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
409
PkProxy pk_proxy = yield GLib.Bus.get_proxy (BusType.SESSION,
410
"org.freedesktop.PackageKit",
411
"/org/freedesktop/PackageKit");
413
string[] packages = { "nautilus-sendto" };
415
yield pk_proxy.install_package_names ((uint) Gdk.X11Window.get_xid (this.get_window ()),
417
""); // Use interaction defaults.
418
} catch (IOError error) {
419
critical ("D-Bus error: %s\n", error.message);
344
424
* Save the selected file in the thumbview to an alternate storage location.
346
426
* A file chooser dialog is shown to the user, asking where the file should
1545
* Decide which actions will be sensitive or insensitive.
1547
* @param action the action that emitted the signal.
1549
public void on_action_pre_activated (Gtk.Action action)
1551
if (strcmp (action.get_name(), "edit_action") == 0)
1553
if (thumb_view.get_selected_images_list () == null)
1554
share_action.set_sensitive (false);
1556
share_action.set_sensitive (true);
1460
1561
* Setup the camera listed in GSettings.
1462
1563
* @param uri the uri of the device node to setup, or null