allow to edit images externally with gimp
authorgc <gc>
Sun, 29 Jan 2006 19:15:18 +0000 (19:15 +0000)
committergc <gc>
Sun, 29 Jan 2006 19:15:18 +0000 (19:15 +0000)
bin/booh
data/booh/images/stock-tool-ink-16.png [new file with mode: 0644]

index 42f23a9..962fd97 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -108,6 +108,7 @@ def read_config
         }
     end
     $config['video-viewer'] ||= '/usr/bin/mplayer %f'
+    $config['image-editor'] ||= '/usr/bin/gimp-remote %f'
     $config['browser'] ||= "/usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f"
     $config['comments-format'] ||= '%t'
     if !FileTest.directory?(File.expand_path('~/.booh'))
@@ -141,6 +142,15 @@ You should fix this in Edit/Preferences so that you can view videos.
 Problem was: '%s' is not an executable file.
 Hint: don't forget to specify the full path to the executable,
 e.g. '/usr/bin/mplayer' is correct but 'mplayer' only is not.") % viewer_binary), { :pos_centered => true, :not_transient => true })
+    end
+    image_editor_binary = $config['image-editor'].split.first
+    if image_editor_binary && !File.executable?(image_editor_binary)
+        show_popup($main_window, utf8(_("The configured image editor seems to be unavailable.
+You should fix this in Edit/Preferences so that you can edit images externally.
+
+Problem was: '%s' is not an executable file.
+Hint: don't forget to specify the full path to the executable,
+e.g. '/usr/bin/gimp-remote' is correct but 'gimp-remote' only is not.") % image_editor_binary), { :pos_centered => true, :not_transient => true })
     end
     browser_binary = $config['browser'].split.first
     if browser_binary && !File.executable?(browser_binary)
@@ -857,8 +867,8 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr
             end
        }
     end
+    menu.append(               Gtk::SeparatorMenuItem.new)
     if optionals.include?('delete')
-        menu.append(               Gtk::SeparatorMenuItem.new)
         menu.append(cut_item     = Gtk::ImageMenuItem.new(Gtk::Stock::CUT))
         cut_item.signal_connect('activate') { distribute_multiple_call.call(:cut) }
         if !possible_actions[:can_multiple] || $selected_elements.length == 0
@@ -871,14 +881,21 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr
             end
         end
         menu.append(               Gtk::SeparatorMenuItem.new)
-        menu.append(refresh_item = Gtk::ImageMenuItem.new(Gtk::Stock::REFRESH))
-        refresh_item.signal_connect('activate') { distribute_multiple_call.call(:refresh) }
+    end
+    if type == 'image' && (! possible_actions[:can_multiple] || $selected_elements.length == 0)
+        menu.append(editexternally = Gtk::ImageMenuItem.new(utf8(_("Edit image"))))
+        editexternally.image = Gtk::Image.new("#{$FPATH}/images/stock-tool-ink-16.png")
+        editexternally.signal_connect('activate') {
+            cmd = from_utf8($config['image-editor']).gsub('%f', "'#{fullpath}'")
+            msg 2, cmd
+            system(cmd)
+        }
+    end
+    menu.append(refresh_item = Gtk::ImageMenuItem.new(Gtk::Stock::REFRESH))
+    refresh_item.signal_connect('activate') { distribute_multiple_call.call(:refresh) }
+    if optionals.include?('delete')
         menu.append(delete_item  = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
         delete_item.signal_connect('activate') { distribute_multiple_call.call(:delete) }
-    else
-        menu.append(               Gtk::SeparatorMenuItem.new)
-        menu.append(refresh_item = Gtk::ImageMenuItem.new(Gtk::Stock::REFRESH))
-        refresh_item.signal_connect('activate') { distribute_multiple_call.call(:refresh) }
     end
     menu.show_all
     menu.popup(nil, nil, event.button, event.time)
@@ -3195,22 +3212,28 @@ def preferences
     tooltips = Gtk::Tooltips.new
     tooltips.set_tip(video_viewer_entry, utf8(_("Use %f to specify the filename;
 for example: /usr/bin/mplayer %f")), nil)
-    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Browser's command: ")))),
+    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Command for editing images: ")))),
                0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 2)
-    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(browser_entry = Gtk::Entry.new.set_text($config['browser'])),
+    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(image_editor_entry = Gtk::Entry.new.set_text($config['image-editor'])),
                1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 2)
+    tooltips.set_tip(image_editor_entry, utf8(_("Use %f to specify the filename;
+for example: /usr/bin/gimp-remote %f")), nil)
+    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Browser's command: ")))),
+               0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
+    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(browser_entry = Gtk::Entry.new.set_text($config['browser'])),
+               1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(browser_entry, utf8(_("Use %f to specify the filename;
 for example: /usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f")), nil)
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(smp_check = Gtk::CheckButton.new(utf8(_("Use symmetric multi-processing")))),
-               0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(smp_hbox = Gtk::HBox.new.add(smp_spin = Gtk::SpinButton.new(2, 16, 1)).add(Gtk::Label.new(utf8(_("processors")))).set_sensitive(false)),
-               1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(smp_check, utf8(_("When activated, this option allows the thumbnails creation to run faster. However, if you don't have a multi-processor machine, this will only slow down processing!")), nil)
     tbl.attach(nogestures_check = Gtk::CheckButton.new(utf8(_("Disable mouse gestures"))),
-               0, 2, 3, 4, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 2, 4, 5, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(nogestures_check, utf8(_("Mouse gestures are 'unusual' mouse movements triggering special actions, and are great for speeding up your editions. Get details on available mouse gestures from the Help menu.")), nil)
     tbl.attach(deleteondisk_check = Gtk::CheckButton.new(utf8(_("Delete original images/videos as well"))),
-               0, 2, 5, 6, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 2, 6, 7, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(deleteondisk_check, utf8(_("Normally, deleting an image or video in booh only removes it from the web-album. If you check this option, the original file in source directory will be removed as well. Undo is possible, since actual deletion is performed only when web-album is saved.")), nil)
 
     smp_check.signal_connect('toggled') {
@@ -3385,8 +3408,9 @@ Where tag can be one of the following:
     dialog.vbox.show_all
     dialog.run { |response|
         if response == Gtk::Dialog::RESPONSE_OK
-            $config['video-viewer'] = video_viewer_entry.text
-            $config['browser'] = browser_entry.text
+            $config['video-viewer'] = from_utf8(video_viewer_entry.text)
+            $config['image-editor'] = from_utf8(image_editor_entry.text)
+            $config['browser'] = from_utf8(browser_entry.text)
             if smp_check.active?
                 $config['mproc'] = smp_spin.value.to_i
             else
@@ -3395,8 +3419,8 @@ Where tag can be one of the following:
             $config['nogestures'] = nogestures_check.active?
             $config['deleteondisk'] = deleteondisk_check.active?
 
-            $config['convert-enhance'] = enhance_entry.text
-            $config['comments-format'] = commentsformat_entry.text.gsub(/'/, '')
+            $config['convert-enhance'] = from_utf8(enhance_entry.text)
+            $config['comments-format'] = from_utf8(commentsformat_entry.text.gsub(/'/, ''))
         end
     }
     dialog.destroy
diff --git a/data/booh/images/stock-tool-ink-16.png b/data/booh/images/stock-tool-ink-16.png
new file mode 100644 (file)
index 0000000..73dfb1e
Binary files /dev/null and b/data/booh/images/stock-tool-ink-16.png differ