handle preferences and put mproc in it
authorgc <gc>
Sun, 17 Apr 2005 01:38:00 +0000 (01:38 +0000)
committergc <gc>
Sun, 17 Apr 2005 01:38:00 +0000 (01:38 +0000)
bin/booh-gui

index 4ea48a32699044e377e3f25b2e16d57134ac1de8..354473e2ee5285d2910223aa1197b06e7421f701 100755 (executable)
@@ -1313,6 +1313,9 @@ def new_album
         button, w8 = wait_message($main_window, utf8(_("Please wait while scanning source directory...")))
         backend = Thread.new {
             cmd = "booh --source #{srcdir} --destination #{destdir} --config-skel #{configskel} --for-gui --verbose-level #{$verbose_level}"
         button, w8 = wait_message($main_window, utf8(_("Please wait while scanning source directory...")))
         backend = Thread.new {
             cmd = "booh --source #{srcdir} --destination #{destdir} --config-skel #{configskel} --for-gui --verbose-level #{$verbose_level}"
+            if $config['mproc']
+                cmd += " --mproc #{$config['mproc'].to_i}"
+            end
             msg 2, cmd
             system(cmd)
             w8.destroy
             msg 2, cmd
             system(cmd)
             w8.destroy
@@ -1341,6 +1344,47 @@ def save_as_do
     fc.destroy
 end
 
     fc.destroy
 end
 
+def preferences
+    w = Gtk::Window.new
+    w.set_transient_for($main_window)
+    w.add(vb = Gtk::VBox.new)
+
+    vb.add(tbl = Gtk::Table.new(0, 0, false))
+    tbl.attach(smp_check = Gtk::CheckButton.new(utf8(_("Use symmetric multi-processing"))),
+               0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 2, 2)
+    tbl.attach(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, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 2, 2)
+    smp_check.signal_connect('toggled') {
+        if smp_check.active?
+            smp_hbox.sensitive = true
+        else
+            smp_hbox.sensitive = false
+        end
+    }
+    if $config['mproc']
+        smp_check.active = true
+        smp_spin.value = $config['mproc'].to_i
+    end
+
+    vb.add(Gtk::HSeparator.new)
+    vb.add(bottom = Gtk::HButtonBox.new)
+
+    bottom.add(cancel = Gtk::Button.new(Gtk::Stock::CANCEL))
+    bottom.add(ok     = Gtk::Button.new(Gtk::Stock::OK))
+
+    ok.signal_connect('clicked') {
+        if smp_check.active?
+            $config['mproc'] = smp_spin.value.to_i
+        else
+            $config.delete('mproc')
+        end
+        w.destroy
+    }
+    cancel.signal_connect_after('clicked') { w.destroy }
+    w.signal_connect('delete-event') { w.destroy }
+    w.show_all
+end
+
 def create_menu_and_toolbar
 
     #- menu
 def create_menu_and_toolbar
 
     #- menu
@@ -1373,6 +1417,8 @@ def create_menu_and_toolbar
     editmenu.set_submenu(editsubmenu)
     mb.append(editmenu)
 
     editmenu.set_submenu(editsubmenu)
     mb.append(editmenu)
 
+    prefs.signal_connect('activate') { preferences }
+
     helpmenu = Gtk::MenuItem.new(utf8(_("_Help")))
     helpsubmenu = Gtk::Menu.new
     helpsubmenu.append(about = Gtk::ImageMenuItem.new(Gtk::Stock::ABOUT))
     helpmenu = Gtk::MenuItem.new(utf8(_("_Help")))
     helpsubmenu = Gtk::Menu.new
     helpsubmenu.append(about = Gtk::ImageMenuItem.new(Gtk::Stock::ABOUT))