end
end
end
- i = Gtk::Image.new(dest_img)
- f = Gtk::Frame.new
- f.add(i)
- f.set_shadow_type(Gtk::SHADOW_ETCHED_OUT)
- hb = Gtk::HBox.new
- hb.pack_start(Gtk::Label.new, true, true)
- hb.pack_start(f, false, false)
- hb.pack_end(Gtk::Label.new, true, true)
- evt = Gtk::EventBox.new
- evt.add(hb)
+ evt = Gtk::EventBox.new.add(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(Gtk::Frame.new.add(Gtk::Image.new(dest_img)).set_shadow_type(Gtk::SHADOW_ETCHED_OUT)))
tooltips = Gtk::Tooltips.new
tooltips.set_tip(evt, utf8(File.basename(filename).gsub(/\.jpg/, '')), nil)
-
- hb2 = Gtk::HBox.new
- hb2.pack_start(Gtk::Label.new, true, true)
- hb2.pack_start(b = Gtk::Button.new(Gtk::Stock::CLOSE), false, false)
+
+ bottom = Gtk::Alignment.new(0.5, 0.5, 0, 0).add(b = Gtk::Button.new(Gtk::Stock::CLOSE))
b.signal_connect('clicked') { w.destroy }
- hb2.pack_end(Gtk::Label.new, true, true)
vb = Gtk::VBox.new
vb.pack_start(evt, false, false)
- vb.pack_end(hb2, false, false)
+ vb.pack_end(bottom, false, false)
w.add(vb)
w.signal_connect('delete-event') { w.destroy }
def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
- frame1 = Gtk::Frame.new
- #- generate the thumbnail if missing (if image was rotated but booh was not relaunched)
- if !$rotated_pixbufs[thumbnail_img] && !File.exists?(thumbnail_img)
- frame1.add(img = Gtk::Image.new)
+ img = nil
+ gen_real_thumbnail = Proc.new {
Thread.new {
gen_thumbnails_element(from_utf8("#{$current_path}/#{filename}"), $xmldir, false, [ { 'filename' => thumbnail_img, 'size' => $default_size['thumbnails'] } ])
img.set(thumbnail_img)
+ $rotated_pixbufs[thumbnail_img] = { :orig => img.pixbuf, :angle_to_orig => 0 }
+ if type == 'video'
+ #- cleanup temp for videos
+ system("rm -f #{current_dest_dir}/screenshot.jpg00000*")
+ end
}
+ }
+
+ frame1 = Gtk::Frame.new
+ #- generate the thumbnail if missing (if image was rotated but booh was not relaunched)
+ if !$rotated_pixbufs[thumbnail_img] && !File.exists?(thumbnail_img)
+ frame1.add(img = Gtk::Image.new)
+ gen_real_thumbnail.call
else
frame1.add(img = Gtk::Image.new($rotated_pixbufs[thumbnail_img] ? $rotated_pixbufs[thumbnail_img][:pixbuf] : thumbnail_img))
end
- frame1.set_shadow_type(Gtk::SHADOW_ETCHED_OUT)
- hbox1 = Gtk::HBox.new
- hbox1.pack_start(Gtk::Label.new, true, true)
- hbox1.pack_start(frame1, false, false)
- hbox1.pack_end(Gtk::Label.new, true, true)
- evtbox = Gtk::EventBox.new
- evtbox.add(hbox1)
+ evtbox = Gtk::EventBox.new.add(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(frame1.set_shadow_type(Gtk::SHADOW_ETCHED_OUT)))
tooltips = Gtk::Tooltips.new
tipname = File.basename(thumbnail_img).gsub(/-\d+x\d+\.jpg/, '')
end
}
+ color_swap_and_cleanup = Proc.new {
+ xmlelem = $xmldir.elements["[@filename='#{filename}']"]
+ if xmlelem.attributes['color-swap']
+ xmlelem.delete_attribute('color-swap')
+ else
+ xmlelem.add_attribute('color-swap', '1')
+ end
+ system("rm -f '#{thumbnail_img}'")
+
+ #- remove out of sync images
+ dest_img_base = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '')
+ for sizeobj in $images_size
+ system("rm -f #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
+ end
+
+ gen_real_thumbnail.call
+ }
+
delete = Proc.new {
after = autotable.get_next_widget(vbox)
if !after
textview.grab_focus
end
end
+ if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
+ menu = Gtk::Menu.new
+ menu.append( r90 = Gtk::ImageMenuItem.new(utf8(_("Rotate clockwise"))))
+ menu.append( r270 = Gtk::ImageMenuItem.new(utf8(_("Rotate counter-clockwise"))))
+ r90.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-90-16.png")
+ r90.signal_connect('activate') { rotate_and_cleanup.call(90) }
+ r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
+ r270.signal_connect('activate') { rotate_and_cleanup.call(270) }
+ if type == 'video'
+ menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
+ menu.append( flip = Gtk::ImageMenuItem.new(utf8(_("Flip upside-down"))))
+ color_swap.image = Gtk::Image.new("#{$FPATH}/images/stock-color-triangle-16.png")
+ color_swap.signal_connect('activate') { color_swap_and_cleanup.call }
+ flip.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-180-16.png")
+ flip.signal_connect('activate') { rotate_and_cleanup.call(180) }
+ end
+ menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
+ delete.signal_connect('activate') { delete.call }
+ menu.show_all
+ menu.popup(nil, nil, event.button, event.time)
+ end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
view_element(filename)
else
$xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
$subalbums_edits = {}
+
+ find_infotype = Proc.new { |xmldir|
+ xmldir == $xmldir ? 'thumbnails' : find_subalbum_info_type(xmldir)
+ }
+
add_subalbum = Proc.new { |xmldir|
if xmldir == $xmldir
thumbnail_file = "#{current_dest_dir}/thumbnails-thumbnail.jpg"
end
msg 3, "add subdir: #{xmldir.attributes['path']} with file: #{thumbnail_file}"
hbox = Gtk::HBox.new
- hbox.pack_start(Gtk::Label.new, true, true)
- hbox.pack_start(Gtk::Label.new.set_markup('<i>' + File.basename(xmldir.attributes['path']) + ':</i>'), false, false)
+ hbox.pack_start(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup('<i>' + File.basename(xmldir.attributes['path']) + ':</i>')))
f = Gtk::Frame.new
f.set_shadow_type(Gtk::SHADOW_ETCHED_OUT)
- if !$rotated_pixbufs[thumbnail_file] && !File.exists?(thumbnail_file)
- f.add(img = Gtk::Image.new)
+ img = nil
+ gen_real_thumbnail = Proc.new {
Thread.new {
- infotype = xmldir == $xmldir ? 'thumbnails' : find_subalbum_info_type(xmldir)
+ system("rm -f '#{thumbnail_file}'")
gen_thumbnails_subdir(from_utf8(captionfile), xmldir, false,
- [ { 'filename' => thumbnail_file, 'size' => $albums_thumbnail_size } ], infotype)
+ [ { 'filename' => thumbnail_file, 'size' => $albums_thumbnail_size } ], find_infotype.call(xmldir))
img.set(thumbnail_file)
+ $rotated_pixbufs[thumbnail_file] = { :orig => img.pixbuf, :angle_to_orig => 0 }
+ if entry2type(captionfile) == 'video'
+ system("rm -f #{current_dest_dir}/screenshot.jpg00000*")
+ end
}
+ }
+
+ if !$rotated_pixbufs[thumbnail_file] && !File.exists?(thumbnail_file)
+ f.add(img = Gtk::Image.new)
+ gen_real_thumbnail.call
else
f.add(img = Gtk::Image.new($rotated_pixbufs[thumbnail_file] ? $rotated_pixbufs[thumbnail_file][:pixbuf] : thumbnail_file))
end
0, 1, current_y_sub_albums, current_y_sub_albums + 1, Gtk::FILL, Gtk::FILL, 2, 2)
rotate_and_cleanup = Proc.new { |angle|
- rotate(angle, thumbnail_file, img, xmldir, ( xmldir == $xmldir ? 'thumbnails' : find_subalbum_info_type(xmldir) ) + '-',
+ rotate(angle, thumbnail_file, img, xmldir, find_infotype.call(xmldir) + '-',
$default_albums_thumbnails[:x], $default_albums_thumbnails[:y])
system("rm -f '#{thumbnail_file}'")
}
+ color_swap_and_cleanup = Proc.new {
+ infotype = find_infotype.call(xmldir)
+ if xmldir.attributes["#{infotype}-color-swap"]
+ xmldir.delete_attribute("#{infotype}-color-swap")
+ else
+ xmldir.add_attribute("#{infotype}-color-swap", '1')
+ end
+ gen_real_thumbnail.call
+ }
+
evtbox.signal_connect('button-press-event') { |w, event|
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 1
if $r90.active?
rotate_and_cleanup.call(270)
end
end
+ if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
+ menu = Gtk::Menu.new
+ menu.append( r90 = Gtk::ImageMenuItem.new(utf8(_("Rotate clockwise"))))
+ menu.append( r270 = Gtk::ImageMenuItem.new(utf8(_("Rotate counter-clockwise"))))
+ r90.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-90-16.png")
+ r90.signal_connect('activate') { rotate_and_cleanup.call(90) }
+ r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
+ r270.signal_connect('activate') { rotate_and_cleanup.call(270) }
+ if entry2type(captionfile) == 'video'
+ menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
+ menu.append( flip = Gtk::ImageMenuItem.new(utf8(_("Flip upside-down"))))
+ color_swap.image = Gtk::Image.new("#{$FPATH}/images/stock-color-triangle-16.png")
+ color_swap.signal_connect('activate') { color_swap_and_cleanup.call }
+ flip.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-180-16.png")
+ flip.signal_connect('activate') { rotate_and_cleanup.call(180) }
+ end
+ menu.show_all
+ menu.popup(nil, nil, event.button, event.time)
+ end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
fc = Gtk::FileChooserDialog.new(utf8(_("Select image for caption")),
nil,
}
if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
msg 3, "new captionfile is: #{fc.filename}"
- $subalbums_edits[xmldir.attributes['path']][:captionfile] = utf8(fc.filename)
- Thread.new(fc.filename) { |filename|
- system("rm -f '#{thumbnail_file}'")
- $rotated_pixbufs.delete(thumbnail_file)
- infotype = xmldir == $xmldir ? 'thumbnails' : find_subalbum_info_type(xmldir)
- xmldir.delete_attribute("#{infotype}-rotate")
- gen_thumbnails_subdir(filename, xmldir, false,
- [ { 'filename' => thumbnail_file, 'size' => $albums_thumbnail_size } ], infotype)
- img.set(thumbnail_file)
- }
+ $subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile = utf8(fc.filename)
+ $rotated_pixbufs.delete(thumbnail_file)
+ infotype = find_infotype.call(xmldir)
+ xmldir.delete_attribute("#{infotype}-rotate")
+ xmldir.delete_attribute("#{infotype}-color-swap")
+ gen_real_thumbnail.call
end
fc.destroy
true #- handled
$gesture_press = nil
}
- vbox = Gtk::VBox.new
- vbox.pack_start(Gtk::Label.new, true, true)
frame, textview = create_editzone($subalbums_sw)
textview.buffer.text = caption
- vbox.pack_start(frame, false, false)
- vbox.pack_end(Gtk::Label.new, true, true)
- $subalbums.attach(vbox,
+ $subalbums.attach(Gtk::Alignment.new(0, 0.5, 0.5, 0).add(frame),
1, 2, current_y_sub_albums, current_y_sub_albums + 1, Gtk::FILL, Gtk::FILL, 2, 2)
$subalbums_edits[xmldir.attributes['path']] = { :editzone => textview, :captionfile => captionfile }
frame, $subalbums_title = create_editzone($subalbums_sw)
$subalbums_title.buffer.text = $xmldir.attributes['subdirs-caption']
$subalbums_title.set_justification(Gtk::Justification::CENTER)
- hbox = Gtk::HBox.new
- hbox.add(Gtk::Label.new)
- hbox.add(frame)
- hbox.add(Gtk::Label.new)
- $subalbums_vb.pack_start(hbox, false, false)
+ $subalbums_vb.pack_start(Gtk::Alignment.new(0.5, 0.5, 0.5, 0).add(frame), false, false)
#- this album image/caption
if $xmldir.attributes['thumbnails-caption']
add_subalbum.call($xmldir)