From ec044782002f4d6aee2de621dc01531c5fca4f78 Mon Sep 17 00:00:00 2001 From: Toshi Nagata Date: Mon, 19 Sep 2022 00:24:37 +0900 Subject: [PATCH] API of open_auxiliary_window is changed, so that they do not have 'default' buttons --- Scripts/commands.rb | 8 ++++---- Scripts/crystal.rb | 8 ++++---- Scripts/molecule.rb | 12 ++++++------ Scripts/uff.rb | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Scripts/commands.rb b/Scripts/commands.rb index 8048316..832acd2 100755 --- a/Scripts/commands.rb +++ b/Scripts/commands.rb @@ -233,7 +233,7 @@ class Molecule sprintf("%.8f", mol.get_property(col - 1, row)) rescue "" end } - mol.open_auxiliary_window("Extra Props", nil, nil, :resizable=>true, :has_close_box=>true) { + mol.open_auxiliary_window("Extra Props", :resizable=>true, :has_close_box=>true) { names = nil @on_document_modified = lambda { |m| if (n = m.property_names) != names @@ -252,7 +252,7 @@ class Molecule set_min_size(320, 200) # listen(mol, "documentModified", on_document_modified) # listen(mol, "documentWillClose", lambda { |m| close } ) - on_document_modified.call(mol) + @on_document_modified.call(mol) show } end @@ -261,7 +261,7 @@ class Molecule wave = [0.0, 0.0] cur = 0 mol = self - d = open_auxiliary_window("Energy", nil, nil, :resizable=>true, :has_close_box=>true) { + d = open_auxiliary_window("Energy", :resizable=>true, :has_close_box=>true) { graph_item = nil # Forward declaration target_mol = nil draw_graph = lambda { |it| @@ -329,7 +329,7 @@ class Molecule end surface_dialog_attr = @surface_dialog_attr mol = self - mol.open_auxiliary_window("MO Surface", nil, nil, :resizable=>true, :has_close_box=>true) { + mol.open_auxiliary_window("MO Surface", :resizable=>true, :has_close_box=>true) { tags = ["mo_ao", "mo", "color", "opacity", "threshold", "expand", "grid"] motype = mol.get_mo_info(:type) alpha = mol.get_mo_info(:alpha) diff --git a/Scripts/crystal.rb b/Scripts/crystal.rb index 555f944..45a46f7 100755 --- a/Scripts/crystal.rb +++ b/Scripts/crystal.rb @@ -679,7 +679,7 @@ end def cmd_plane plane_settings = @plane_settings || Hash.new mol = self - mol.open_auxiliary_window("Best-Fit Planes", "Close", nil) { + mol.open_auxiliary_window("Best-Fit Planes", :has_close_box=>true) { refresh_proc = lambda { |it| n = it[:tag][/\d/].to_i g = plane_settings["group#{n}"] @@ -1044,7 +1044,7 @@ end def cmd_bond_angle_with_sigma mol = self - mol.open_auxiliary_window("Bond & Angle with Sigma", nil, nil) { + mol.open_auxiliary_window("Bond & Angle with Sigma", :has_close_box=>true) { values = [] clicked = [] sel = mol.selection @@ -1105,7 +1105,7 @@ def cmd_bond_angle_with_sigma layout(1, item(:table, :width=>500, :height=>300, :tag=>"table", :columns=>[["atom1", 60], ["atom2", 60], ["atom3", 60], - "value(sigma)", "symop1", "symop2", "symop3"], + ["value(sigma)", 80], ["symop1", 80], ["symop2", 80], ["symop3", 80]], :on_count=> lambda { |it| values.count }, :on_get_value=>on_get_value, :on_selection_changed=>on_selection_changed), @@ -1451,7 +1451,7 @@ def cmd_show_ortep ["H", "all", "Open", "black"] ] } - mol.open_auxiliary_window("Show ORTEP", nil, nil, :resizable=>true, :has_close_box=>true) { + mol.open_auxiliary_window("Show ORTEP", :resizable=>true, :has_close_box=>true) { tepview = nil # Forward declaration tab = "Atoms" columns = { diff --git a/Scripts/molecule.rb b/Scripts/molecule.rb index be738a6..fd3edd2 100755 --- a/Scripts/molecule.rb +++ b/Scripts/molecule.rb @@ -727,14 +727,14 @@ class Molecule end # Open a Ruby Dialog that is a "child" window of the molecule - def open_auxiliary_window(*args, &block) - title = args[0] || "(untitled)" + def open_auxiliary_window(title, options, &block) + title = title || "(untitled)" mol = self if (win = (@aux_windows ||= Hash.new)[title]) win.show else - args[0] = self.name + ": " + title - d = Dialog.new(*args) + title = self.name + ": " + title + d = Dialog.new(title, nil, nil, options) if block d.instance_eval(&block) d.instance_eval { |_d| @@ -742,9 +742,9 @@ class Molecule # listen(mol, "documentWillClose", lambda { |m| m.close_auxiliary_window(_d) } ) if @on_close != nil save_on_close = @on_close - @on_close = lambda { save_on_close.call; mol.close_auxiliary_window(_d, true); true} + @on_close = lambda { save_on_close.call; _d.hide; mol.close_auxiliary_window(_d, true); true} else - @on_close = lambda { mol.close_auxiliary_window(_d, true); true } + @on_close = lambda { _d.hide; mol.close_auxiliary_window(_d, true); true } end } end diff --git a/Scripts/uff.rb b/Scripts/uff.rb index 0287761..45525d4 100644 --- a/Scripts/uff.rb +++ b/Scripts/uff.rb @@ -281,7 +281,7 @@ def guess_uff_parameters arena.prepare(true) xatoms = IntGroup[] xbonds = xangles = xdihedrals = xfragments = [] - mol.open_auxiliary_window("Guess UFF Parameters", nil, nil, :resizable=>true) { + mol.open_auxiliary_window("Guess UFF Parameters", :resizable=>true) { update_xatoms = lambda { xatoms = mol.atom_group { |ap| !exclude.member?(ap.atomic_number) } xfragments = mol.fragments(xatoms) -- 2.11.0