move check for gimp and firefox to when needed, to allow soft require
[booh] / lib / booh / booh-lib.rb
index 0235647fd8fe09f2070da626129dcd60ee4ed0a4..13e63c4ac6acf22654691c28f01c9ee5c7ff4710 100644 (file)
@@ -529,10 +529,25 @@ module Booh
         ios.close
     end
 
+    def check_browser
+        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 })
+            return false
+        else
+            return true
+        end
+    end
+
     def open_url(url)
-        cmd = $config['browser'].gsub('%f', "'#{url}'") + ' &'
-        msg 2, cmd
-        system(cmd)
+        if check_browser
+            cmd = $config['browser'].gsub('%f', "'#{url}'") + ' &'
+            msg 2, cmd
+            system(cmd)
+        end
     end
 
     def get_license