use a gtkdialog for preferences, to have a more consistent look and feel
authorgc <gc>
Sun, 17 Apr 2005 01:53:55 +0000 (01:53 +0000)
committergc <gc>
Sun, 17 Apr 2005 01:53:55 +0000 (01:53 +0000)
bin/booh-gui

index 354473e2ee5285d2910223aa1197b06e7421f701..6bcef47d31bdf12f5a3dc6606d82c8df94abd64a 100755 (executable)
@@ -1345,11 +1345,13 @@ def save_as_do
 end
 
 def preferences
-    w = Gtk::Window.new
-    w.set_transient_for($main_window)
-    w.add(vb = Gtk::VBox.new)
+    dialog = Gtk::Dialog.new(utf8(_("Edit preferences")),
+                             $main_window,
+                             Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
+                             [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
+                             [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
 
-    vb.add(tbl = Gtk::Table.new(0, 0, false))
+    dialog.vbox.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),
@@ -1366,23 +1368,17 @@ def preferences
         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')
+    dialog.vbox.show_all
+    dialog.run { |response|
+        if response == Gtk::Dialog::RESPONSE_OK
+            if smp_check.active?
+                $config['mproc'] = smp_spin.value.to_i
+            else
+                $config.delete('mproc')
+            end
         end
-        w.destroy
     }
-    cancel.signal_connect_after('clicked') { w.destroy }
-    w.signal_connect('delete-event') { w.destroy }
-    w.show_all
+    dialog.destroy
 end
 
 def create_menu_and_toolbar