From 430f215c31df5446e4019371831195c0422cfb11 Mon Sep 17 00:00:00 2001 From: gc Date: Mon, 26 Dec 2005 16:24:13 +0000 Subject: [PATCH 1/1] add ability to restore deleted images/videos/subalbums (suggested by JC) --- bin/booh | 35 +++++++++++++++++++++++++++++++---- data/booh/images/restore.png | Bin 0 -> 575 bytes 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 data/booh/images/restore.png diff --git a/bin/booh b/bin/booh index 38ca520..fbb4caf 100755 --- a/bin/booh +++ b/bin/booh @@ -864,6 +864,8 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr end def delete_current_subalbum + $modified = true + sel = $albums_tv.selection.selected_rows $xmldir.elements.each { |e| if e.name == 'image' || e.name == 'video' e.add_attribute('deleted', 'true') @@ -884,9 +886,29 @@ def delete_current_subalbum break end end + sel[0].up! end save_changes('forced') - populate_subalbums_treeview + populate_subalbums_treeview(false) + $albums_tv.selection.select_path(sel[0]) +end + +def restore_deleted + $modified = true + save_changes + $current_path = nil #- prevent save_changes from being rerun again + sel = $albums_tv.selection.selected_rows + restore_one = proc { |xmldir| + xmldir.elements.each { |e| + if e.name == 'dir' && e.attributes['deleted'] + restore_one.call(e) + end + e.delete_attribute('deleted') + } + } + restore_one.call($xmldir) + populate_subalbums_treeview(false) + $albums_tv.selection.select_path(sel[0]) end def add_thumbnail(autotable, filename, type, thumbnail_img, caption) @@ -2294,7 +2316,7 @@ def show_password_protections examine_dir_elem.call(nil, $xmldoc.elements['//dir'], false) end -def populate_subalbums_treeview +def populate_subalbums_treeview(select_first) $albums_ts.clear $autotable.clear $albums_iters = {} @@ -2327,7 +2349,9 @@ def populate_subalbums_treeview show_password_protections $albums_tv.expand_all - $albums_tv.selection.select_iter($albums_ts.iter_first) + if select_first + $albums_tv.selection.select_iter($albums_ts.iter_first) + end end def open_file(filename) @@ -2418,7 +2442,7 @@ def open_file(filename) $albums_thumbnail_size =~ /(.*)x(.*)/ $default_albums_thumbnails = { :x => $1.to_i, :y => $2.to_i } - populate_subalbums_treeview + populate_subalbums_treeview(true) $save.sensitive = $save_as.sensitive = $merge_current.sensitive = $merge_newsubs.sensitive = $merge.sensitive = $generate.sensitive = $view_wa.sensitive = $properties.sensitive = $remove_all_captions.sensitive = true return nil @@ -3824,6 +3848,9 @@ def create_main_window menu.append(passprotect = Gtk::ImageMenuItem.new(utf8(_("Password protect")))) passprotect.image = Gtk::Image.new("#{$FPATH}/images/galeon-secure.png") passprotect.signal_connect('activate') { ask_password_protect } + menu.append(restore = Gtk::ImageMenuItem.new(utf8(_("Restore deleted images/videos/subalbums")))) + restore.image = Gtk::Image.new("#{$FPATH}/images/restore.png") + restore.signal_connect('activate') { restore_deleted } menu.append(Gtk::SeparatorMenuItem.new) menu.append(delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE)) delete.signal_connect('activate') { diff --git a/data/booh/images/restore.png b/data/booh/images/restore.png new file mode 100644 index 0000000000000000000000000000000000000000..cfaea21dd4e3cf048433a021bc0f3ce66bf0cf86 GIT binary patch literal 575 zcmV-F0>J%=P)R;#ma~il_x4rZrnC% z3l*0Tu>>x#g%c}ItXOg4#86foWeFujgtAmcloA3JC$2Dsh!GJRh?qhsBSKiw!VYLaIJyhI#Y7;fF{C0r06TuM9}y`QC>;EbbP#MF+;1NBQ&m79te@fSc+M zAX35cG-pv14C1WCXp*t6YX-@3Un$iXlvf4-z_KhECK>gGZgFw9pqwAEuIpyMAC22} zL@Fpg=G0m z1}g*6Xs&Wqe|7D??b)!00FesDB5KzNJ<7Rk>iL1K;cdG-{&GwJ{0FfM&X6}LrFQ@T N002ovPDHLkV1o6e^Z)<= literal 0 HcmV?d00001 -- 2.30.4