end
if options[:okcancel]
cancel = dialog.add_button(Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL)
+ dialog.add_button(Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK)
+ elsif options[:yestoall]
+ cancel = dialog.add_button(Gtk::Stock::NO, Gtk::Dialog::RESPONSE_NO)
if ! options[:bottomwidget]
cancel.grab_focus
end
- dialog.add_button(Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK)
+ dialog.add_button(Gtk::Stock::YES, Gtk::Dialog::RESPONSE_YES)
+ dialog.add_button(utf8(_("Yes to all")), Gtk::Dialog::RESPONSE_ACCEPT)
else
ok = dialog.add_button(Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK).grab_focus
if ! options[:bottomwidget]
dialog.destroy
if options[:okcancel]
return response == Gtk::Dialog::RESPONSE_OK
+ elsif options[:yestoall]
+ return response == Gtk::Dialog::RESPONSE_YES ? 'yes' : response == Gtk::Dialog::RESPONSE_ACCEPT ? 'yestoall' : 'no'
end
}
else
begin
moved = 0
copied = 0
+ ignored_errors = []
stuff.keys.each { |key|
if key.is_a?(Label) && stuff[key][:combo] && stuff[key][:combo].active <= 1
destination = stuff[key][:pathlabel].text
label2entries[key].each { |entry|
if stuff[key][:combo].active == 0
- system("cp -dp '#{entry.path}' '#{destination}'") or raise "failed to copy '#{entry.path}'"
- copied += 1
+ result = `cp -dp '#{entry.path}' '#{destination}' 2>&1`
elsif stuff[key][:combo].active == 1
- system("mv '#{entry.path}' '#{destination}'") or raise "failed to move '#{entry.path}'"
- moved += 1
+ result = `mv '#{entry.path}' '#{destination}' 2>&1`
+ end
+ if $?.exitstatus > 0
+ simplified_error = result.sub(/#{Regexp.quote(destination + '/' + File.basename(entry.path))}/, ''). #'
+ sub(/#{Regexp.quote(entry.path)}/, '').
+ sub(/#{Regexp.quote(File.basename(entry.path))}/, '')
+ if ! ignored_errors.include?(simplified_error)
+ response = show_popup($main_window,
+ utf8(_("Failure:\n\n%s\nDo you wish to continue?" % result)),
+ { :yestoall => true })
+ if response == 'no'
+ raise "failure on '#{entry.path}'"
+ elsif response == 'yestoall'
+ ignored_errors << simplified_error
+ end
+ end
+ else
+ if stuff[key][:combo].active == 0
+ copied += 1
+ else
+ moved += 1
+ end
end
}
end
}
end
rescue
- msg 1, "woops: #{$!}"
- show_popup(dialog, utf8(_("Unexpected error: '%s'.") % $!))
+ msg 1, "woops: #{$!}\n" + $@.join("\n")
end
show_popup(dialog, utf8(_("Successfully moved %d files, copied %d file, and removed %d files.") % [ moved, copied, removed ]))
dialog.destroy