allow to move subalbums directly to the top or bottom
authorgc <gc>
Mon, 26 Dec 2005 21:44:38 +0000 (21:44 +0000)
committergc <gc>
Mon, 26 Dec 2005 21:44:38 +0000 (21:44 +0000)
bin/booh
data/booh/images/move-bottom.png [new file with mode: 0644]
data/booh/images/move-top.png [new file with mode: 0644]

index 969b3ca..a91dbac 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -774,6 +774,14 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr
                 moveright.sensitive = false
             end
         end
+        if optionals.include?('move_top')
+            menu.append(movetop = Gtk::ImageMenuItem.new(utf8(_("Move top"))))
+            movetop.image = Gtk::Image.new("#{$FPATH}/images/move-top.png")
+            movetop.signal_connect('activate') { closures[:move].call('top') }
+            if !possible_actions[:can_top]
+                movetop.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') }
@@ -786,6 +794,14 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr
         if !possible_actions[:can_down]
             movedown.sensitive = false
         end
+        if optionals.include?('move_bottom')
+            menu.append(movebottom = Gtk::ImageMenuItem.new(utf8(_("Move bottom"))))
+            movebottom.image = Gtk::Image.new("#{$FPATH}/images/move-bottom.png")
+            movebottom.signal_connect('activate') { closures[:move].call('bottom') }
+            if !possible_actions[:can_bottom]
+                movebottom.sensitive = false
+            end
+        end
     end
     if type == 'video'
         if !possible_actions[:can_multiple] || $selected_elements.length == 0 || $selected_elements.reject { |k,v| $name2widgets[k][:type] == 'video' }.empty?
@@ -2116,15 +2132,27 @@ def change_dir
             $modified = true
 
             save_changes('forced')
+            oldpos = $subalbums_edits[xmldir.attributes['path']][:position]
             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]
+            end
+            if direction == 'down'
                 $subalbums_edits[xmldir.attributes['path']][:position] += 1
                 subalbums_edits_bypos[oldpos + 1][:position] -= 1
             end
+            if direction == 'top'
+                for i in 1 .. oldpos - 1
+                    subalbums_edits_bypos[i][:position] += 1
+                end
+                $subalbums_edits[xmldir.attributes['path']][:position] = 1
+            end
+            if direction == 'bottom'
+                for i in oldpos + 1 .. subalbums_counter
+                    subalbums_edits_bypos[i][:position] -= 1
+                end
+                $subalbums_edits[xmldir.attributes['path']][:position] = subalbums_counter
+            end
 
             elems = []
             $xmldir.elements.each('dir') { |element|
@@ -2138,7 +2166,11 @@ def change_dir
             $xmldir.elements.each('descendant::dir') { |elem|
                 elem.delete_attribute('already-generated')
             }
+
+            sel = $albums_tv.selection.selected_rows
             change_dir
+            populate_subalbums_treeview(false)
+            $albums_tv.selection.select_path(sel[0])
         }
 
         color_swap_and_cleanup = Proc.new {
@@ -2232,9 +2264,10 @@ def change_dir
                 end
             end
             if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
-                popup_thumbnail_menu(event, ['change_image'], captionfile, entry2type(captionfile), xmldir, "#{infotype}-",
+                popup_thumbnail_menu(event, ['change_image', 'move_top', 'move_bottom'], captionfile, entry2type(captionfile), xmldir, "#{infotype}-",
                                      { :forbid_left => true, :forbid_right => true,
-                                       :can_up => counter > 1, :can_down => counter > 0 && counter < subalbums_counter },
+                                       :can_up => counter > 1, :can_down => counter > 0 && counter < subalbums_counter,
+                                       :can_top => counter > 1, :can_bottom => 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
diff --git a/data/booh/images/move-bottom.png b/data/booh/images/move-bottom.png
new file mode 100644 (file)
index 0000000..b53d677
Binary files /dev/null and b/data/booh/images/move-bottom.png differ
diff --git a/data/booh/images/move-top.png b/data/booh/images/move-top.png
new file mode 100644 (file)
index 0000000..369e0e0
Binary files /dev/null and b/data/booh/images/move-top.png differ