From: Guillaume Cottenceau Date: Thu, 26 Mar 2009 14:33:45 +0000 (+0100) Subject: support gimp 2.6 doesn't have gimp-remote anymore, and a few related improvements... X-Git-Tag: 0.9.2~15 X-Git-Url: http://git.zarb.org/?p=booh;a=commitdiff_plain;h=48ad7e54039b6b9cfdcf928cc4eb185aa2896524 support gimp 2.6 doesn't have gimp-remote anymore, and a few related improvements, thanks Lucas Nussbaum --- diff --git a/bin/booh b/bin/booh old mode 100755 new mode 100644 index 9f654e8..9f8e073 --- a/bin/booh +++ b/bin/booh @@ -117,8 +117,8 @@ 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['image-editor'] ||= '/usr/bin/gimp-remote %f || /usr/bin/gimp %f' + $config['browser'] ||= "/usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f || /usr/bin/firefox %f" $config['comments-format'] ||= '%t' if !FileTest.directory?(File.expand_path('~/.booh')) system("mkdir ~/.booh") @@ -167,14 +167,13 @@ e.g. '/usr/bin/mplayer' is correct but 'mplayer' only is not.") % viewer_binary) end def check_image_editor - image_editor_binary = $config['image-editor'].split.first - if image_editor_binary && !File.executable?(image_editor_binary) + if last_failed_binary = check_multi_binaries($config['image-editor']) 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 photos 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 }) +e.g. '/usr/bin/gimp-remote' is correct but 'gimp-remote' only is not.") % last_failed_binary), { :pos_centered => true, :not_transient => true }) return false else return true @@ -4845,7 +4844,7 @@ if binding_version == [ 0, 15, 0 ] exit end if binding_version == [ 0, 17, 0 ] - puts "It seems that we're running ruby-gtk2 0.17.0; this version is known to has a serious memory leak; please upgrade or downgrade." + puts "It seems that we're running ruby-gtk2 0.17.0; this version is known to have a serious memory leak; please upgrade or downgrade." exit end if binding_version == [ 0, 18, 0 ] diff --git a/bin/booh-classifier b/bin/booh-classifier index b6d4421..64ed74f 100755 --- a/bin/booh-classifier +++ b/bin/booh-classifier @@ -161,13 +161,7 @@ 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 - browser_binary = $config['browser'].split.first - if browser_binary && ! File.executable?(browser_binary) - show_popup($main_window, utf8(_("The configured browser seems to be unavailable. -You should fix this in Edit/Preferences so that you can open URLs. - -Problem was: '%s' is not an executable file.") % browser_binary), { :pos_centered => true, :not_transient => true }) - end + check_browser end def write_config diff --git a/lib/booh/booh-lib.rb b/lib/booh/booh-lib.rb index 6b55ce4..9c4a41d 100644 --- a/lib/booh/booh-lib.rb +++ b/lib/booh/booh-lib.rb @@ -540,13 +540,24 @@ module Booh } end + def check_multi_binaries(input) + #- e.g. check at least one binary from '/usr/bin/gimp-remote %f || /usr/bin/gimp %f' is available + for attempts in input.split('||') + binary = attempts.split.first + if binary && File.executable?(binary) + return nil + end + end + #- return last tried binary for error message + return binary + end + def check_browser - browser_binary = $config['browser'].split.first - if browser_binary && !File.executable?(browser_binary) + if last_failed_binary = check_multi_binaries($config['browser']) show_popup($main_window, utf8(_("The configured browser seems to be unavailable. You should fix this in Edit/Preferences so that you can open URLs. -Problem was: '%s' is not an executable file.") % browser_binary), { :pos_centered => true, :not_transient => true }) +Problem was: '%s' is not an executable file.") % last_failed_binary), { :pos_centered => true, :not_transient => true }) return false else return true