Piggy 0.5.0.0 → 0.5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGES.txt +31 -0
  2. data/README.txt +3 -5
  3. data/lib/icons/gallery.jpg +0 -0
  4. data/lib/piggy-core/album.rb +8 -0
  5. data/lib/piggy-core/exifr_adapter.rb +10 -2
  6. data/lib/piggy-core/file_info.rb +6 -1
  7. data/lib/piggy-core/options.rb +21 -3
  8. data/lib/piggy-core/rmagick_thumbnail_page_generator.rb +8 -7
  9. data/lib/piggy-core/thumbnail_generator.rb +1 -1
  10. data/lib/piggy-core/thumbnail_page_generator.rb +12 -4
  11. data/lib/piggy-core/version.rb +2 -2
  12. data/lib/piggy-gui/directory_diff_widget.rb +12 -8
  13. data/lib/piggy-gui/filtered_file_list.rb +6 -1
  14. data/lib/piggy-gui/ftp_browser_widget.rb +4 -3
  15. data/lib/piggy-gui/html_generation_dialog.rb +2 -0
  16. data/lib/piggy-gui/html_options_widget.rb +27 -4
  17. data/lib/piggy-gui/image_processor.rb +3 -2
  18. data/lib/piggy-gui/options_dialog.rb +52 -13
  19. data/lib/piggy-gui/piggy_image_browser.rb +134 -15
  20. data/lib/templates/PiggyFX.jar +0 -0
  21. data/lib/templates/PiggyFX.jnlp +2 -2
  22. data/lib/templates/PiggyFX_browser.jnlp +2 -2
  23. data/lib/templates/javafx.htm +2 -2
  24. data/lib/templates/slideshow.htm +12 -3
  25. data/lib/templates/slideshow.js +5 -0
  26. data/lib/templates/styles/candle/kerze-160x213.png +0 -0
  27. data/lib/templates/styles/candle/style.css +73 -0
  28. data/lib/templates/styles/cappuccinoheart/cappuccino-300x225.png +0 -0
  29. data/lib/templates/styles/cappuccinoheart/cappuccinoheart-80x81.png +0 -0
  30. data/lib/templates/styles/cappuccinoheart/style.css +81 -0
  31. data/lib/templates/styles/feuerzangenbowle/feuerzangenbowle.jpg +0 -0
  32. data/lib/templates/styles/feuerzangenbowle/sh.png +0 -0
  33. data/lib/templates/styles/feuerzangenbowle/style.css +79 -0
  34. data/lib/templates/styles/glitterballs/christbaum-detail.png +0 -0
  35. data/lib/templates/styles/glitterballs/christbaumkugel-120x155-multi.png +0 -0
  36. data/lib/templates/styles/glitterballs/christbaumkugel-120x155.png +0 -0
  37. data/lib/templates/styles/glitterballs/style.css +86 -0
  38. data/lib/templates/styles/qualle/qualle.jpg +0 -0
  39. data/lib/templates/styles/qualle/style.css +73 -0
  40. data/lib/templates/styles/snow/sitzgruppe-im-schnee-300x225.png +0 -0
  41. data/lib/templates/styles/snow/style.css +76 -0
  42. data/lib/templates/styles/snowman/snowman.png +0 -0
  43. data/lib/templates/styles/snowman/style.css +73 -0
  44. data/lib/templates/styles/snowwoman/snowwomen.png +0 -0
  45. data/lib/templates/styles/snowwoman/style.css +73 -0
  46. data/lib/templates/styles/sylvester/fireworks.png +0 -0
  47. data/lib/templates/styles/sylvester/gluecksklee-375x500.png +0 -0
  48. data/lib/templates/styles/sylvester/style.css +7 -9
  49. data/lib/templates/styles/sylvester/wunderkerze.gif +0 -0
  50. metadata +64 -33
  51. data/lib/templates/styles/sylvester/wunderkerze.jpg +0 -0
@@ -59,10 +59,10 @@ class HtmlOptionsWidget < Fox::FXMatrix
59
59
  @options.addSlideshow = ptr
60
60
  }
61
61
  add_label_to(self, ""); # TODO empty cell in matrix layout
62
- add_slideshow_check = FXCheckButton.new(self, 'Add JavaFX slideshow')
63
- add_slideshow_check.setCheck(@options.addJavaFxSlideshow?)
64
- add_slideshow_check.connect(SEL_COMMAND) { |sender, sel, ptr|
65
- @options.addJavaFxSlideshow = ptr
62
+ add_slideshow_check = FXCheckButton.new(self, 'Add JavaFX slideshow')
63
+ add_slideshow_check.setCheck(@options.addJavaFxSlideshow?)
64
+ add_slideshow_check.connect(SEL_COMMAND) { |sender, sel, ptr|
65
+ @options.addJavaFxSlideshow = ptr
66
66
  }
67
67
  add_label_to(self, "Style:")
68
68
  style_text_field = new_combobox(self, 32,
@@ -78,6 +78,19 @@ class HtmlOptionsWidget < Fox::FXMatrix
78
78
  style_text_field.connect(SEL_COMMAND) { |sender, sel, ptr|
79
79
  @options.style = ptr
80
80
  }
81
+ add_label_to(self, "Sort order")
82
+ sort_order_text_field = new_combobox(self, 32,
83
+ 2,
84
+ nil, 0, COMBOBOX_INSERT_LAST)
85
+ sort_order_text_field.setFrameStyle(FRAME_SUNKEN|FRAME_THICK)
86
+ sort_order_text_field.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
87
+ sort_order_text_field.clearItems
88
+ sort_order_text_field.appendItem(PiggyOptions::SortByName)
89
+ sort_order_text_field.appendItem(PiggyOptions::SortByTime)
90
+ sort_order_text_field.setText(@options.sortOrder)
91
+ sort_order_text_field.connect(SEL_COMMAND) { |sender, sel, ptr|
92
+ @options.sortOrder = ptr
93
+ }
81
94
  add_label_to(self, "Image size:")
82
95
  size_frame = FXHorizontalFrame.new(self, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0)
83
96
  image_width_field = FXTextField.new(size_frame, 4)
@@ -99,5 +112,15 @@ class HtmlOptionsWidget < Fox::FXMatrix
99
112
  image_height_field.setText(ruby_2_fox(@options.imageHeight.to_s))
100
113
  end
101
114
  }
115
+ add_label_to(self, "Widescreen image width:")
116
+ w_image_width_field = FXTextField.new(self, 4)
117
+ w_image_width_field.setText(ruby_2_fox(@options.widescreenWidth.to_s))
118
+ w_image_width_field.connect(SEL_COMMAND) { |sender, sel, ptr|
119
+ begin
120
+ @options.widescreenWidth = fox_2_ruby(w_image_width_field.getText).to_i
121
+ rescue StandardError => ex
122
+ w_image_width_field.setText(ruby_2_fox(@options.widescreenWidth.to_s))
123
+ end
124
+ }
102
125
  end
103
126
  end
@@ -63,11 +63,12 @@ class ImageProcessor
63
63
  GC.start
64
64
  end
65
65
 
66
- def fit_image(img, maxW, maxH, quality = 1)
66
+ def fit_image(img, maxW, maxH, quality = 1, widescreen_w = -1)
67
67
  w = img.getWidth
68
68
  h = img.getHeight
69
+ used_width = (widescreen_w > 0 and h.to_f > 0 and w.to_f/h.to_f > 1.6) ? widescreen_w : maxW
69
70
  ratios = Array.new(2)
70
- ratios[0] = maxW.to_f / w.to_f
71
+ ratios[0] = used_width.to_f / w.to_f
71
72
  ratios[1] = maxH.to_f / h.to_f
72
73
  ratio = ratios.min
73
74
  new_w = (w * ratio).to_i
@@ -118,34 +118,34 @@ class OptionsDialog < ModalDialog
118
118
 
119
119
  def add_tab_ftp_to(tabs)
120
120
  tab = add_tab(tabs, "Upload")
121
- frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS)
122
- add_label_to(frame, "FTP server:")
123
- server_field = FXTextField.new(frame, 32)
121
+ expert_settings_frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS)
122
+ add_label_to(expert_settings_frame, "FTP server:")
123
+ server_field = FXTextField.new(expert_settings_frame, 32)
124
124
  server_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
125
125
  server_field.setText(ruby_2_fox(@options.ftpHost))
126
126
  server_field.connect(SEL_COMMAND) {
127
127
  @options.ftpHost = fox_2_ruby(server_field.getText)
128
128
  }
129
- add_label_to(frame, "User:")
130
- user_field = FXTextField.new(frame, 32)
129
+ add_label_to(expert_settings_frame, "User:")
130
+ user_field = FXTextField.new(expert_settings_frame, 32)
131
131
  user_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
132
132
  user_field.setText(@options.ftpUser)
133
133
  user_field.connect(SEL_COMMAND) {
134
134
  @options.ftpUser = fox_2_ruby(user_field.getText)
135
135
  }
136
- add_label_to(frame, "Remote path:")
137
- remote_path_field = FXTextField.new(frame, 32)
136
+ add_label_to(expert_settings_frame, "Remote path:")
137
+ remote_path_field = FXTextField.new(expert_settings_frame, 32)
138
138
  remote_path_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
139
139
  remote_path_field.setText(@options.remoteDestinationPath)
140
140
  remote_path_field.connect(SEL_COMMAND) {
141
141
  @options.remoteDestinationPath = fox_2_ruby(remote_path_field.getText)
142
142
  }
143
143
 
144
- frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS)
145
- add_txt_to(frame, "Expert settings")
146
- add_txt_to(frame, "")
147
- add_label_to(frame, "Exclude filters:")
148
- filters_field = FXTextField.new(frame, 32)
144
+ expert_settings_frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS)
145
+ add_txt_to(expert_settings_frame, "Expert settings")
146
+ add_txt_to(expert_settings_frame, "")
147
+ add_label_to(expert_settings_frame, "Exclude filters:")
148
+ filters_field = FXTextField.new(expert_settings_frame, 32)
149
149
  filters_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
150
150
  filters_field.setText(@options.excludeFilters.join(','))
151
151
  filters_field.connect(SEL_COMMAND) {
@@ -154,6 +154,28 @@ class OptionsDialog < ModalDialog
154
154
  collect { |s| s.strip }.
155
155
  reject { |s| s.length == 0 }
156
156
  }
157
+ add_label_to(expert_settings_frame, "Timeouts:")
158
+ timeouts_frame = FXHorizontalFrame.new(expert_settings_frame, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0)
159
+ add_label_to(timeouts_frame, "Connection:")
160
+ connection_timeout_field = FXTextField.new(timeouts_frame, 5)
161
+ connection_timeout_field.setText(ruby_2_fox(@options.ftpConnectionTimeout.to_s))
162
+ connection_timeout_field.connect(SEL_COMMAND) { |sender, sel, ptr|
163
+ begin
164
+ @options.ftpConnectionTimeout = fox_2_ruby(connection_timeout_field.getText).to_i
165
+ rescue StandardError => ex
166
+ connection_timeout_field.setText(ruby_2_fox(@options.ftpConnectionTimeout.to_s))
167
+ end
168
+ }
169
+ add_label_to(timeouts_frame, "Transfer:")
170
+ transfer_timeout_field = FXTextField.new(timeouts_frame, 5)
171
+ transfer_timeout_field.setText(ruby_2_fox(@options.ftpTransferTimeout.to_s))
172
+ transfer_timeout_field.connect(SEL_COMMAND) { |sender, sel, ptr|
173
+ begin
174
+ @options.ftpTransferTimeout = fox_2_ruby(transfer_timeout_field.getText).to_i
175
+ rescue StandardError => ex
176
+ transfer_timeout_field.setText(ruby_2_fox(@options.ftpTransferTimeout.to_s))
177
+ end
178
+ }
157
179
  end
158
180
 
159
181
  def add_tab_experimental_to(tabs)
@@ -182,6 +204,13 @@ class OptionsDialog < ModalDialog
182
204
  cb.connect(SEL_COMMAND) { |sender, sel, ptr|
183
205
  @options.useTable = ptr
184
206
  }
207
+ cb = FXCheckButton.new(tab,
208
+ 'Use Exif comments',
209
+ nil, 0, cb_flags)
210
+ cb.setCheck(@options.useExifComments)
211
+ cb.connect(SEL_COMMAND) { |sender, sel, ptr|
212
+ @options.useExifComments = ptr
213
+ }
185
214
  cb = FXCheckButton.new(tab,
186
215
  'Styles sample',
187
216
  nil, 0, cb_flags)
@@ -211,6 +240,16 @@ class OptionsDialog < ModalDialog
211
240
  thumb_height_field.setText(ruby_2_fox(@options.thumbHeight.to_s))
212
241
  end
213
242
  }
243
+ add_label_to(tab, "Cameras naming patterns:")
244
+ naming_field = FXTextField.new(tab, 32)
245
+ naming_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
246
+ naming_field.setText(@options.namingPatterns.join(','))
247
+ naming_field.connect(SEL_COMMAND) {
248
+ naming_txt = fox_2_ruby(naming_field.getText)
249
+ @options.namingPatterns = naming_txt.split(',').
250
+ collect { |s| s.strip }.
251
+ reject { |s| s.length == 0 }
252
+ }
214
253
  end
215
254
 
216
255
  def browser_changed
@@ -225,7 +264,7 @@ class OptionsDialog < ModalDialog
225
264
 
226
265
  def validate
227
266
  if @options.browser?
228
- return warn("Browser not found", "Warning") unless File.exists?(@options.browser)
267
+ return warn("Warning", "Browser not found") unless File.exists?(@options.browser)
229
268
  end
230
269
  true
231
270
  end
@@ -4,10 +4,12 @@
4
4
  # piggy.rb allows you to view image files, choose some and generate a new
5
5
  # page for an internet picture album.
6
6
 
7
+ require 'yaml'
7
8
  require 'piggy-core/version'
8
9
  require 'piggy-core/environment'
9
10
  require 'piggy-core/debug'
10
11
  require 'piggy-core/options_persistence'
12
+ require 'piggy-core/album'
11
13
  require 'piggy-core/winshell'
12
14
  require 'piggy-core/exifr_adapter'
13
15
  require 'piggy-core/nconvert_thumbsgen'
@@ -138,10 +140,16 @@ class PiggyImageBrowser < Fox::FXMainWindow
138
140
 
139
141
  # File menu entries
140
142
  tmp = FXMenuCommand.new(menus['file'],
141
- "&Open...\tCtl-O\tOpen image file.")
143
+ "Open &album...\tCtl-a\tOpen album list file.")
144
+ tmp.connect(SEL_COMMAND, method(:on_cmd_open_album))
145
+ tmp = FXMenuCommand.new(menus['file'],
146
+ "Sa&ve album...\tCtl-v\tSave album list file.")
147
+ tmp.connect(SEL_COMMAND, method(:on_cmd_save_album))
148
+ tmp = FXMenuCommand.new(menus['file'],
149
+ "&Open image...\tCtl-o\tOpen image file.")
142
150
  tmp.connect(SEL_COMMAND, method(:on_cmd_open))
143
151
  tmp = FXMenuCommand.new(menus['file'],
144
- "B&ack\t\tBack in history",
152
+ "&Back\t\tBack in history",
145
153
  @backIcon)
146
154
  tmp.connect(SEL_COMMAND, method(:on_cmd_back))
147
155
  tmp = FXMenuCommand.new(menus['file'],
@@ -194,8 +202,8 @@ class PiggyImageBrowser < Fox::FXMainWindow
194
202
  msg += "- Ruby #{RUBY_VERSION} (released #{RUBY_RELEASE_DATE})\n"
195
203
  msg += "- FXRuby #{Fox.fxrubyversion}\n"
196
204
  msg += "- FOX Toolkit #{Fox.fxversion}\n"
197
- msg += "- Javascript slideshow no version information availiable\n"
198
- msg += "- JavaFX animation uses JavaFX Script Version 1.2 which runs on top of Java 6\n"
205
+ msg += "- BarelyFitz Javascript slideshow 1.16\n"
206
+ msg += "- JavaFX animation uses JavaFX Script 1.3 which runs on top of Java 6\n"
199
207
  msg += "- Piggy #{PiggyVersion.display_string}\n"
200
208
  about_title = "About Piggy"
201
209
  tmp = FXMenuCommand.new(menus['help'], "&About Piggy...")
@@ -295,6 +303,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
295
303
  @filelist.choosable = proc { |filename| supports(filename) }
296
304
  @filelist.setLayoutHints(fill_mode)
297
305
  @filelist.connect(SEL_COMMAND, method(:on_cmd_file_list_selection))
306
+ @filelist.connect(SEL_DOUBLECLICKED, method(:on_cmd_file_list_doubleclicked))
298
307
  @imageview = if UseImageView
299
308
  FXImageView.new(@imageviewframe)
300
309
  else
@@ -358,7 +367,10 @@ class PiggyImageBrowser < Fox::FXMainWindow
358
367
  end
359
368
 
360
369
  def log(msg)
361
- @pipeLog.appendText("#{msg}\n")
370
+ time = Time.new.strftime("%H:%M:%S")
371
+ log_msg = "#{time}> #{msg}\n"
372
+ puts(log_msg)
373
+ @pipeLog.appendText(log_msg)
362
374
  end
363
375
 
364
376
  def load_image(file)
@@ -442,7 +454,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
442
454
  return FoxThumbnailPageGenerator
443
455
  end
444
456
 
445
- def set_directory(dirname)
457
+ def set_directory(dirname, preselect = true)
446
458
  if @historyPos < @history.size
447
459
  @history.pop
448
460
  else
@@ -450,7 +462,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
450
462
  @historyPos = @history.size
451
463
  end
452
464
  @filelist.go_to_directory(dirname)
453
- if(@options.preselectDirectories?)
465
+ if(preselect and @options.preselectDirectories?)
454
466
  @filelist.choose_all_in_filelist
455
467
  next_image
456
468
  end
@@ -480,11 +492,14 @@ class PiggyImageBrowser < Fox::FXMainWindow
480
492
  path_string = @shell.ruby_path(osPathString)
481
493
  @exif = ExifrAdapter.new(path_string)
482
494
  info = CommentedFile.new(File.basename(path_string), File.dirname(path_string))
495
+ info.ctime = File.ctime(info.name_with_path)
496
+ info.mtime = File.mtime(info.name_with_path)
497
+ info.date_time = @exif.date_time
483
498
  if @fileInfos.has_key?(info)
484
499
  info = @fileInfos[info]
485
500
  else
486
501
  info.rotation = @exif.view_degrees
487
- info.comment = @exif.comment
502
+ info.comment = @exif.comment if @options.useExifComments?
488
503
  @fileInfos[info] = info
489
504
  end
490
505
  return info
@@ -544,7 +559,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
544
559
  if @currentRotation >= 360
545
560
  @currentRotation = @currentRotation - 360
546
561
  end
547
- @orientationStatus.setText(ruby_2_fox(@currentRotation.to_s + '�'))
562
+ @orientationStatus.setText(ruby_2_fox(@currentRotation.to_s + '�'))
548
563
  current_file_info.rotation = @currentRotation
549
564
  end
550
565
 
@@ -580,6 +595,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
580
595
  begin
581
596
  if(@options.browser?)
582
597
  cmd = @options.browser
598
+ cmd = "\"#{cmd}\"" if PLATFORM =~ /mswin/ and cmd.size > 0 and cmd[0] != "\""[0]
583
599
  @pipeLog.run_command(cmd + ' ' + url, working_dir, true)
584
600
  else
585
601
  if PLATFORM =~ /mswin/
@@ -632,22 +648,75 @@ class PiggyImageBrowser < Fox::FXMainWindow
632
648
 
633
649
  def open_system_file_chooser
634
650
  open_dialog = FXFileDialog.new(self, "Open Image")
635
- #openDialog.filename = @filename
636
- open_dialog.set_directory(@filelist.get_current_directory)
651
+ open_dialog.directory = @filelist.get_current_directory
637
652
  patterns = ["All Files (*)" ] + @supportedImageTypes.values
638
653
  open_dialog.patternList = patterns
639
654
  open_dialog.currentPattern = @preferredFileFilter
640
655
  if open_dialog.execute
641
656
  @preferredFileFilter = open_dialog.currentPattern
642
- filename = open_dialog.filename
643
- set_directory(open_dialog.getDirectory)
657
+ filename = fox_2_ruby(open_dialog.filename)
658
+ set_directory(fox_2_ruby(open_dialog.getDirectory))
644
659
  open_file_or_link(filename)
645
660
  end
646
661
  end
662
+
663
+ def on_cmd_open_album(sender, sel, ptr)
664
+ open_dialog = FXFileDialog.new(self, "Open album list file")
665
+ open_dialog.directory = @filelist.get_current_directory
666
+ patterns = ["All Files (*)" , "Yaml Files (*.yaml)"]
667
+ open_dialog.patternList = patterns
668
+ open_dialog.currentPattern = 1
669
+ if open_dialog.execute
670
+ filename = fox_2_ruby(open_dialog.filename)
671
+ return unless File.exists?(filename)
672
+ begin
673
+ album = File.open(filename) { |io| YAML.load(io) }
674
+ return unless album.class == Album
675
+ set_directory(album.path, false) unless (album.path.nil?)
676
+ unless(album.file_infos.nil?)
677
+ album.file_infos.each { |info|
678
+ @fileInfos[info] = info
679
+ @filelist.choose(info.name_with_path)
680
+ @filelist.update_file_list
681
+ }
682
+ next_image
683
+ end
684
+ rescue StandardError => ex
685
+ puts('Not an album file: ' + ex.message)
686
+ end
687
+ end
688
+ end
689
+
690
+ def on_cmd_save_album(sender, sel, ptr)
691
+ open_dialog = FXFileDialog.new(self, "Save album list file")
692
+ open_dialog.directory = @filelist.get_current_directory
693
+ patterns = ["All Files (*)" , "Yaml Files (*.yaml)"]
694
+ open_dialog.patternList = patterns
695
+ open_dialog.currentPattern = 1
696
+ if open_dialog.execute
697
+ filename = fox_2_ruby(open_dialog.filename)
698
+ filename = filename + ".yaml"unless(filename.split('.')[-1] == "yaml")
699
+ begin
700
+ album = Album.new
701
+ album.path = @filelist.get_current_directory
702
+ album.file_infos = chosen_sequence.collect { |f| info_for_file(f) }
703
+ File.open(filename, 'w') { |out|
704
+ YAML.dump(album, out)
705
+ }
706
+ puts "Album saved to #{filename}"
707
+ rescue StandardError => ex
708
+ puts "Album could not be saved to #{filename}: " + ex.message
709
+ end
710
+ end
711
+ end
647
712
 
648
713
  # Command message from the file list
649
714
 
650
715
  def on_cmd_file_list_selection(sender, dummy, index)
716
+ select_index(index) unless @filelist.isItemDirectory(index)
717
+ end
718
+
719
+ def on_cmd_file_list_doubleclicked(sender, dummy, index)
651
720
  select_index(index)
652
721
  end
653
722
 
@@ -778,7 +847,20 @@ class PiggyImageBrowser < Fox::FXMainWindow
778
847
  generator.set_title(title)
779
848
  generator.set_output_directory(output_dir)
780
849
  generator.client = @pipeLog
781
- generator.set_files(chosen_sequence.collect { |f| info_for_file(f) })
850
+ info_sequence = chosen_sequence.collect { |f| info_for_file(f) }
851
+ info_sequence.sort! { |x, y| x.name <=> y.name }
852
+ if(@options.sort_by_time?)
853
+ guess_missing_times(info_sequence)
854
+ info_sequence.sort! { |x, y|
855
+ begin
856
+ c1 = x.date_time <=> y.date_time
857
+ rescue Exception
858
+ c1 = 0
859
+ end
860
+ c1 == 0 ? x.name <=> y.name : c1
861
+ }
862
+ end
863
+ generator.set_files(info_sequence)
782
864
  getApp.beginWaitCursor
783
865
  progress = ProgressWithDialog.new(self)
784
866
  progress.set_task('Generating', @filelist.num_files_chosen)
@@ -787,6 +869,7 @@ class PiggyImageBrowser < Fox::FXMainWindow
787
869
  begin
788
870
  if(@options.stylesSample?)
789
871
  actual_options = @options.clone
872
+ success = true
790
873
  begin
791
874
  get_style_list.each { |style|
792
875
  @options.style = style
@@ -811,12 +894,48 @@ class PiggyImageBrowser < Fox::FXMainWindow
811
894
  end
812
895
  if(success)
813
896
  open_html_browser_on_result(generator)
897
+ log("Done!")
814
898
  else
815
- @pipeLog.appendText('Error')
899
+ log('Error')
816
900
  error("Error in html generation!")
817
901
  end
818
902
  return success
819
903
  end
904
+
905
+ # Call this if some files have an exif date_time and some don't.
906
+ # Assume that the given ordering for each naming pattern
907
+ # is correct and simply take the time from the predecessor in
908
+ # the subsequence corresponding to a naming pattern.
909
+ def guess_missing_times(info_sequence)
910
+ done = Set.new
911
+ (@options.namingPatterns + ['.*']).collect { |p| Regexp.new(p) }.each do
912
+ |pattern|
913
+ subsequence = info_sequence.select {
914
+ |info|
915
+ info.name =~ pattern and not done.include?(info.name_with_path)
916
+ }
917
+ subsequence.each { |info| done.add(info.name_with_path) }
918
+ guess_missing_times_for_subsequence(subsequence)
919
+ end
920
+ end
921
+
922
+ def guess_missing_times_for_subsequence(info_sequence)
923
+ first_with_time = info_sequence.detect{
924
+ |info|
925
+ puts "#{info.name} - #{info.date_time}"
926
+ not info.date_time.nil?
927
+ }
928
+ return if first_with_time.nil?
929
+ time = first_with_time.date_time
930
+ info_sequence.each do
931
+ |info|
932
+ if(info.date_time.nil?)
933
+ info.date_time = time
934
+ else
935
+ time = info.date_time
936
+ end
937
+ end
938
+ end
820
939
 
821
940
  def on_ftp_browser_dialog_closed(sender, sel, ptr)
822
941
  # get options?
Binary file