support changing subalbum image in context menu
authorgc <gc>
Thu, 7 Apr 2005 18:20:26 +0000 (18:20 +0000)
committergc <gc>
Thu, 7 Apr 2005 18:20:26 +0000 (18:20 +0000)
bin/booh-gui
data/booh/images/stock-images-16.png [new file with mode: 0644]

index c8f4f8645ccd0ad223b5a3f7e667501280754c97..9ac9013b7ae7044e10b58a2b2b2fc046568c763e 100755 (executable)
@@ -572,6 +572,39 @@ def change_dir
         $subalbums.attach(hbox,
                           0, 1, 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,
+                                            Gtk::FileChooser::ACTION_OPEN,
+                                            nil,
+                                            [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
+            fc.set_current_folder(xmldir.attributes['path'])
+            fc.transient_for = $main_window
+            fc.preview_widget = preview = Gtk::Alignment.new(0.5, 0.5, 0, 0).add(f = Gtk::Frame.new.set_shadow_type(Gtk::SHADOW_ETCHED_OUT))
+            f.add(preview_img = Gtk::Image.new)
+            preview.show_all
+            fc.signal_connect('update-preview') { |w|
+                begin
+                    if fc.preview_filename
+                        preview_img.pixbuf = rotate_pixbuf(Gdk::Pixbuf.new(fc.preview_filename, 240, 180), guess_rotate(fc.preview_filename))
+                        fc.preview_widget_active = true
+                    end
+                rescue Gdk::PixbufError
+                    fc.preview_widget_active = false
+                end
+            }
+            if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
+                msg 3, "new captionfile is: #{fc.filename}"
+                $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
+        }
+
         rotate_and_cleanup = Proc.new { |angle|
             rotate(angle, thumbnail_file, img, xmldir, find_infotype.call(xmldir) + '-',
                    $default_albums_thumbnails[:x], $default_albums_thumbnails[:y])
@@ -599,8 +632,12 @@ def change_dir
             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"))))
+                menu.append(changeimg = Gtk::ImageMenuItem.new(utf8(_("Change image"))))
+                menu.append(            Gtk::SeparatorMenuItem.new)
+                menu.append(      r90 = Gtk::ImageMenuItem.new(utf8(_("Rotate clockwise"))))
+                menu.append(     r270 = Gtk::ImageMenuItem.new(utf8(_("Rotate counter-clockwise"))))
+                changeimg.image = Gtk::Image.new("#{$FPATH}/images/stock-images-16.png")
+                changeimg.signal_connect('activate') { change_image.call }
                 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")
@@ -618,36 +655,7 @@ def change_dir
                 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,
-                                                Gtk::FileChooser::ACTION_OPEN,
-                                                nil,
-                                                [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
-                fc.set_current_folder(xmldir.attributes['path'])
-                fc.transient_for = $main_window
-                fc.preview_widget = preview = Gtk::Alignment.new(0.5, 0.5, 0, 0).add(f = Gtk::Frame.new.set_shadow_type(Gtk::SHADOW_ETCHED_OUT))
-                f.add(preview_img = Gtk::Image.new)
-                preview.show_all
-                fc.signal_connect('update-preview') { |w|
-                    begin
-                        if fc.preview_filename
-                            preview_img.pixbuf = rotate_pixbuf(Gdk::Pixbuf.new(fc.preview_filename, 240, 180), guess_rotate(fc.preview_filename))
-                            fc.preview_widget_active = true
-                        end
-                    rescue Gdk::PixbufError
-                        fc.preview_widget_active = false
-                    end
-                }
-                if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
-                    msg 3, "new captionfile is: #{fc.filename}"
-                    $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
+                change_image.call
                 true   #- handled
             end
         }
diff --git a/data/booh/images/stock-images-16.png b/data/booh/images/stock-images-16.png
new file mode 100644 (file)
index 0000000..3456e2c
Binary files /dev/null and b/data/booh/images/stock-images-16.png differ