}
end
-def popup_thumbnail_menu(event, optionals, type, xmldir, attributes_prefix, closures)
+def popup_thumbnail_menu(event, optionals, type, xmldir, attributes_prefix, possible_moves, closures)
menu = Gtk::Menu.new
if optionals.include?('change_image')
menu.append(changeimg = Gtk::ImageMenuItem.new(utf8(_("Change image"))))
menu.append(r270 = Gtk::ImageMenuItem.new(utf8(_("Rotate counter-clockwise"))))
r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
r270.signal_connect('activate') { closures[:rotate].call(-90) }
- menu.append(whitebalance = Gtk::ImageMenuItem.new(utf8(_("Fix white-balance"))))
- whitebalance.image = Gtk::Image.new("#{$FPATH}/images/stock-tool-color-balance-16.png")
- whitebalance.signal_connect('activate') { closures[:whitebalance].call }
+ menu.append( Gtk::SeparatorMenuItem.new)
+ if !possible_moves[:forbid_left]
+ menu.append(moveleft = Gtk::ImageMenuItem.new(utf8(_("Move left"))))
+ moveleft.image = Gtk::Image.new("#{$FPATH}/images/stock-move-left.png")
+ moveleft.signal_connect('activate') { closures[:move].call('left') }
+ if !possible_moves[:can_left]
+ moveleft.sensitive = false
+ end
+ end
+ if !possible_moves[:forbid_right]
+ menu.append(moveright = Gtk::ImageMenuItem.new(utf8(_("Move right"))))
+ moveright.image = Gtk::Image.new("#{$FPATH}/images/stock-move-right.png")
+ moveright.signal_connect('activate') { closures[:move].call('right') }
+ if !possible_moves[:can_right]
+ moveright.sensitive = false
+ end
+ end
+ menu.append(moveup = Gtk::ImageMenuItem.new(utf8(_("Move up"))))
+ moveup.image = Gtk::Image.new("#{$FPATH}/images/stock-move-up.png")
+ moveup.signal_connect('activate') { closures[:move].call('up') }
+ if !possible_moves[:can_up]
+ moveup.sensitive = false
+ end
+ menu.append(movedown = Gtk::ImageMenuItem.new(utf8(_("Move down"))))
+ movedown.image = Gtk::Image.new("#{$FPATH}/images/stock-move-down.png")
+ movedown.signal_connect('activate') { closures[:move].call('down') }
+ if !possible_moves[:can_down]
+ movedown.sensitive = false
+ end
if type == 'video'
menu.append( Gtk::SeparatorMenuItem.new)
menu.append( color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
frame_offset.signal_connect('activate') { closures[:frame_offset].call }
end
menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(whitebalance = Gtk::ImageMenuItem.new(utf8(_("Fix white-balance"))))
+ whitebalance.image = Gtk::Image.new("#{$FPATH}/images/stock-tool-color-balance-16.png")
+ whitebalance.signal_connect('activate') { closures[:whitebalance].call }
menu.append(enhance = Gtk::ImageMenuItem.new(utf8(xmldir.attributes["#{attributes_prefix}enhance"] ? _("Original contrast") :
_("Enhance constrast"))))
enhance.image = Gtk::Image.new("#{$FPATH}/images/stock-channels-16.png")
cleanup_all_thumbnails.call
}
+ move = Proc.new { |direction|
+ do_method = "move_#{direction}"
+ undo_method = "move_" + case direction; when 'left'; 'right'; when 'right'; 'left'; when 'up'; 'down'; when 'down'; 'up' end
+ perform = Proc.new {
+ done = autotable.method(do_method).call(vbox)
+ textview.grab_focus #- because if moving, focus is stolen
+ done
+ }
+ if perform.call
+ save_undo(_("move %s") % direction,
+ Proc.new {
+ autotable.method(undo_method).call(vbox)
+ $notebook.set_page(1)
+ Proc.new {
+ autotable.method(do_method).call(vbox)
+ $notebook.set_page(1)
+ }
+ })
+ end
+ }
+
color_swap_and_cleanup = Proc.new {
perform_color_swap_and_cleanup = Proc.new {
color_swap($xmldir.elements["[@filename='#{filename}']"], '')
$vbox2textview[autotable.get_widget_at_pos(x, y - 1)].grab_focus
end
if shift_pressed
- autotable.move_up(vbox)
- textview.grab_focus #- because if moving, focus is stolen
+ move.call('up')
end
end
if event.keyval == Gdk::Keyval::GDK_Down && y < autotable.get_max_y
$vbox2textview[autotable.get_widget_at_pos(x, y + 1)].grab_focus
end
if shift_pressed
- autotable.move_down(vbox)
- textview.grab_focus #- because if moving, focus is stolen
+ move.call('down')
end
end
if event.keyval == Gdk::Keyval::GDK_Left
- previous = autotable.get_previous_widget(vbox)
- if previous && autotable.get_current_pos(previous)[0] < x
+ if x > 0
if control_pressed
$vbox2textview[previous].grab_focus
end
if shift_pressed
- autotable.move_left(vbox)
- textview.grab_focus #- because if moving, focus is stolen
+ move.call('left')
end
end
if alt_pressed
$vbox2textview[next_].grab_focus
end
if shift_pressed
- autotable.move_right(vbox)
- textview.grab_focus #- because if moving, focus is stolen
+ move.call('right')
end
end
if alt_pressed
end
end
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
+ x, y = autotable.get_current_pos(vbox)
+ next_ = autotable.get_next_widget(vbox)
popup_thumbnail_menu(event, ['delete'], type, $xmldir.elements["[@filename='#{filename}']"], '',
- { :rotate => rotate_and_cleanup, :color_swap => color_swap_and_cleanup, :enhance => enhance_and_cleanup,
+ { :can_left => x > 0, :can_right => next_ && autotable.get_current_pos(next_)[0] > x,
+ :can_up => y > 0, :can_down => y < autotable.get_max_y },
+ { :rotate => rotate_and_cleanup, :move => move, :color_swap => color_swap_and_cleanup, :enhance => enhance_and_cleanup,
:frame_offset => change_frame_offset_and_cleanup, :delete => delete, :whitebalance => whitebalance_and_cleanup })
end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
$xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
$subalbums_edits = {}
+ subalbums_counter = 0
+ subalbums_edits_bypos = {}
- add_subalbum = Proc.new { |xmldir|
+ add_subalbum = Proc.new { |xmldir, counter|
+ $subalbums_edits[xmldir.attributes['path']] = { :position => counter }
+ subalbums_edits_bypos[counter] = $subalbums_edits[xmldir.attributes['path']]
if xmldir == $xmldir
thumbnail_file = "#{current_dest_dir}/thumbnails-thumbnail.jpg"
caption = xmldir.attributes['thumbnails-caption']
$subalbums.attach(hbox,
0, 1, current_y_sub_albums, current_y_sub_albums + 1, Gtk::FILL, Gtk::FILL, 2, 2)
+ frame, textview = create_editzone($subalbums_sw, 0, img)
+ textview.buffer.text = caption
+ $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)
+
change_image = Proc.new {
fc = Gtk::FileChooserDialog.new(utf8(_("Select image for caption")),
nil,
system("rm -f '#{thumbnail_file}'")
}
+ move = Proc.new { |direction|
+ save_changes
+ if direction == 'up'
+ oldpos = $subalbums_edits[xmldir.attributes['path']][:position]
+ $subalbums_edits[xmldir.attributes['path']][:position] -= 1
+ subalbums_edits_bypos[oldpos - 1][:position] += 1
+ else
+ oldpos = $subalbums_edits[xmldir.attributes['path']][:position]
+ $subalbums_edits[xmldir.attributes['path']][:position] += 1
+ subalbums_edits_bypos[oldpos + 1][:position] -= 1
+ end
+
+ elems = []
+ $xmldir.elements.each('dir') { |element|
+ elems << [ element.attributes['path'], element.remove ]
+ }
+ elems.sort { |a,b| $subalbums_edits[a[0]][:position] <=> $subalbums_edits[b[0]][:position] }.
+ each { |e| $xmldir.add_element(e[1]) }
+ change_dir
+ }
+
color_swap_and_cleanup = Proc.new {
perform_color_swap_and_cleanup = Proc.new {
color_swap(xmldir, "#{infotype}-")
end
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
popup_thumbnail_menu(event, ['change_image'], entry2type(captionfile), xmldir, "#{infotype}-",
- { :change => change_image, :rotate => rotate_and_cleanup, :enhance => enhance_and_cleanup,
+ { :forbid_left => true, :forbid_right => true,
+ :can_up => counter > 1, :can_down => counter > 0 && counter < subalbums_counter },
+ { :change => change_image, :move => move, :rotate => rotate_and_cleanup, :enhance => enhance_and_cleanup,
:color_swap => color_swap_and_cleanup, :frame_offset => change_frame_offset_and_cleanup, :whitebalance => whitebalance_and_cleanup })
end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
end
$gesture_press = nil
}
-
- frame, textview = create_editzone($subalbums_sw, 0, img)
- textview.buffer.text = caption
- $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 }
+
+ $subalbums_edits[xmldir.attributes['path']][:editzone] = textview
+ $subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile
current_y_sub_albums += 1
}
$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)
+ add_subalbum.call($xmldir, 0)
end
end
$xmldir.elements.each { |element|
end
if element.name == 'dir'
#- sub-album image/caption
- add_subalbum.call(element)
+ add_subalbum.call(element, subalbums_counter += 1)
end
}
$subalbums_vb.add($subalbums)