check config at bootup; checked for the video viewer, more to come
authorgc <gc>
Sun, 18 Sep 2005 19:56:16 +0000 (19:56 +0000)
committergc <gc>
Sun, 18 Sep 2005 19:56:16 +0000 (19:56 +0000)
bin/booh

index e25ecc0dea2a923f440f12b3730147ce0e56eb56..325205a14ae69eeff37c600df1f664d6087a3db1 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -82,12 +82,14 @@ def read_config
         $xmldoc = REXML::Document.new(File.new($config_file))
         $xmldoc.root.elements.each { |element|
             txt = element.get_text
         $xmldoc = REXML::Document.new(File.new($config_file))
         $xmldoc.root.elements.each { |element|
             txt = element.get_text
-            if txt 
+            if txt
                 if txt.value =~ /~~~/ || element.name == 'last-opens'
                     $config[element.name] = txt.value.split(/~~~/)
                 else
                     $config[element.name] = txt.value
                 end
                 if txt.value =~ /~~~/ || element.name == 'last-opens'
                     $config[element.name] = txt.value.split(/~~~/)
                 else
                     $config[element.name] = txt.value
                 end
+            elsif element.elements.size == 0
+                $config[element.name] = ''
             else
                 $config[element.name] = {}
                 element.each { |chld|
             else
                 $config[element.name] = {}
                 element.each { |chld|
@@ -97,7 +99,7 @@ def read_config
             end
         }
     end
             end
         }
     end
-    $config['video-viewer'] ||= 'mplayer %f'
+    $config['video-viewer'] ||= '/usr/bin/mplayer %f'
     if !FileTest.directory?(File.expand_path('~/.booh'))
         system("mkdir ~/.booh")
     end
     if !FileTest.directory?(File.expand_path('~/.booh'))
         system("mkdir ~/.booh")
     end
@@ -106,6 +108,16 @@ def read_config
     $todelete = []
 end
 
     $todelete = []
 end
 
+def check_config
+    viewer_binary = $config['video-viewer'].split.first
+    if viewer_binary && !File.executable?(viewer_binary)
+        show_popup($main_window, utf8(_("The configured video viewer seems to be unavailable.
+You should fix this in Edit/Preferences so that you can view videos.
+
+Problem was: '%s' is not an executable file.") % viewer_binary), { :pos_centered => true, :not_transient => true })
+    end
+end
+
 def write_config
     if $config['last-opens'] && $config['last-opens'].size > 5
         $config['last-opens'] = $config['last-opens'][-5, 5]
 def write_config
     if $config['last-opens'] && $config['last-opens'].size > 5
         $config['last-opens'] = $config['last-opens'][-5, 5]
@@ -2655,7 +2667,8 @@ def preferences
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(video_viewer_entry = Gtk::Entry.new.set_text($config['video-viewer'])),
                1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips = Gtk::Tooltips.new
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(video_viewer_entry = Gtk::Entry.new.set_text($config['video-viewer'])),
                1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips = Gtk::Tooltips.new
-    tooltips.set_tip(video_viewer_entry, utf8(_("Use %f to specify the filename; for example: mplayer %f")), nil)
+    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(smp_check = Gtk::CheckButton.new(utf8(_("Use symmetric multi-processing")))),
                0, 1, 1, 2, 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)),
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(smp_check = Gtk::CheckButton.new(utf8(_("Use symmetric multi-processing")))),
                0, 1, 1, 2, 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)),
@@ -3142,6 +3155,8 @@ read_config
 
 Gtk.init
 create_main_window
 
 Gtk.init
 create_main_window
+check_config
+
 if ARGV[0]
     open_file_user(ARGV[0])
 end
 if ARGV[0]
     open_file_user(ARGV[0])
 end