Thread.kill(src_nb_thread)
src_nb_thread = nil
end
- if File.directory?(from_utf8_safe(src_nb_calculated_for)) && src_nb_calculated_for != '/'
- if File.readable?(from_utf8_safe(src_nb_calculated_for))
- src_nb_thread = Thread.new {
- gtk_thread_protect { src_nb.set_markup(utf8(_("<span size='small'><i>processing...</i></span>"))) }
- total = { 'image' => 0, 'video' => 0, nil => 0 }
- `find '#{from_utf8_safe(src_nb_calculated_for)}' -type d -follow`.each { |dir|
- if File.basename(dir) =~ /^\./
- next
- else
- begin
- Dir.entries(dir.chomp).each { |file|
- total[entry2type(file)] += 1
- }
- rescue Errno::EACCES, Errno::ENOENT
+ if src_nb_calculated_for != '' && from_utf8_safe(src_nb_calculated_for) == ''
+ src_nb.set_markup(utf8(_("<span size='small'><i>invalid source directory</i></span>")))
+ else
+ if File.directory?(from_utf8_safe(src_nb_calculated_for)) && src_nb_calculated_for != '/'
+ if File.readable?(from_utf8_safe(src_nb_calculated_for))
+ src_nb_thread = Thread.new {
+ gtk_thread_protect { src_nb.set_markup(utf8(_("<span size='small'><i>processing...</i></span>"))) }
+ total = { 'image' => 0, 'video' => 0, nil => 0 }
+ `find '#{from_utf8_safe(src_nb_calculated_for)}' -type d -follow`.each { |dir|
+ if File.basename(dir) =~ /^\./
+ next
+ else
+ begin
+ Dir.entries(dir.chomp).each { |file|
+ total[entry2type(file)] += 1
+ }
+ rescue Errno::EACCES, Errno::ENOENT
+ end
end
- end
+ }
+ gtk_thread_protect { src_nb.set_markup(utf8(_("<span size='small'><i>%s images and %s videos</i></span>") % [ total['image'], total['video'] ])) }
+ src_nb_thread = nil
}
- gtk_thread_protect { src_nb.set_markup(utf8(_("<span size='small'><i>%s images and %s videos</i></span>") % [ total['image'], total['video'] ])) }
- src_nb_thread = nil
- }
+ else
+ src_nb.set_markup(utf8(_("<span size='small'><i>permission denied</i></span>")))
+ end
else
- src_nb.set_markup(utf8(_("<span size='small'><i>permission denied</i></span>")))
+ src_nb.set_markup(utf8(_("<span size='small'><i>N/A</i></span>")))
end
- else
- src_nb.set_markup(utf8(_("<span size='small'><i>N/A</i></span>")))
end
end
true
while keepon
dialog.run { |response|
if response == Gtk::Dialog::RESPONSE_OK
- srcdir = from_utf8(src.text)
- destdir = from_utf8(dest.text)
- if !File.directory?(srcdir)
+ srcdir = from_utf8_safe(src.text)
+ destdir = from_utf8_safe(dest.text)
+ confpath = from_utf8_safe(conf.text)
+ if src.text != '' && srcdir == ''
+ show_popup(dialog, utf8(_("The directory of images/videos is invalid. Please check your input.")))
+ src.grab_focus
+ elsif !File.directory?(srcdir)
show_popup(dialog, utf8(_("The directory of images/videos doesn't exist. Please check your input.")))
src.grab_focus
- elsif conf.text == ''
- show_popup(dialog, utf8(_("Please specify a filename to store the album's properties.")))
- conf.grab_focus
- elsif File.directory?(from_utf8(conf.text))
- show_popup(dialog, utf8(_("Sorry, the filename specified to store the album's properties is an existing directory. Please choose another one.")))
- conf.grab_focus
+ elsif dest.text != '' && destdir == ''
+ show_popup(dialog, utf8(_("The destination directory is invalid. Please check your input.")))
+ dest.grab_focus
elsif destdir != make_dest_filename(destdir)
show_popup(dialog, utf8(_("Sorry, destination directory can't contain non simple alphanumeric characters.")))
dest.grab_focus
elsif File.exists?(destdir) && !File.directory?(destdir)
show_popup(dialog, utf8(_("There is already a file by the name of the destination directory. Please choose another one.")))
dest.grab_focus
+ elsif conf.text == ''
+ show_popup(dialog, utf8(_("Please specify a filename to store the album's properties.")))
+ conf.grab_focus
+ elsif conf.text != '' && confpath == ''
+ show_popup(dialog, utf8(_("The filename to store the album's properties is invalid. Please check your input.")))
+ conf.grab_focus
+ elsif File.directory?(confpath)
+ show_popup(dialog, utf8(_("Sorry, the filename specified to store the album's properties is an existing directory. Please choose another one.")))
+ conf.grab_focus
elsif !theme_sizes.detect { |e| e[:value] != 'original' && e[:widget].active? }
show_popup(dialog, utf8(_("You need to select at least one size (not counting original).")))
else
end
}
end
- srcdir = from_utf8(src.text)
- destdir = from_utf8(dest.text)
- configskel = File.expand_path(from_utf8(conf.text))
- theme = theme_button.label
- sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }.join(',')
- nperrow = nperrows.find { |e| e[:widget].active? }[:value]
- opt432 = optimize432.active?
- madewith = madewithentry.text
+ if ok
+ srcdir = from_utf8(src.text)
+ destdir = from_utf8(dest.text)
+ configskel = File.expand_path(from_utf8(conf.text))
+ theme = theme_button.label
+ sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }.join(',')
+ nperrow = nperrows.find { |e| e[:widget].active? }[:value]
+ opt432 = optimize432.active?
+ madewith = madewithentry.text
+ end
if src_nb_thread
Thread.kill(src_nb_thread)
gtk_thread_flush #- needed because we're about to destroy widgets in dialog, for which they may be some pending gtk calls