Skip to content

Commit

Permalink
set the respective transient window for the dialog windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias47n9e committed Apr 30, 2015
1 parent 99c9938 commit 903aa5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
17 changes: 11 additions & 6 deletions innstereo/dialog_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AboutDialog(object):
that are declared in Glade.
"""

def __init__(self):
def __init__(self, main_window):
"""
Initializes the AboutDialog.
Expand All @@ -37,6 +37,7 @@ def __init__(self):
self.builder.add_objects_from_file(abs_path,
("aboutdialog", ""))
self.ab = self.builder.get_object("aboutdialog")
self.ab.set_transient_for(main_window)
self.builder.connect_signals(self)

def run(self):
Expand Down Expand Up @@ -146,7 +147,7 @@ class StereonetProperties(object):
connects all the signals defined in the that file.
"""

def __init__(self, settings, redraw_function):
def __init__(self, settings, redraw_function, main_window):
"""
Initializes the plot-properties dialog.
Expand All @@ -161,6 +162,7 @@ def __init__(self, settings, redraw_function):
self.builder.add_objects_from_file(abs_path,
("stereonet_properties_dialog", "adjustment_pixel_density"))
self.spd = self.builder.get_object("stereonet_properties_dialog")
self.spd.set_transient_for(main_window)
self.spinbutton_pixel_density = \
self.builder.get_object("spinbutton_pixel_density")
self.adjustment_pixel_density = \
Expand Down Expand Up @@ -352,14 +354,15 @@ class FileChooserParse(object):
files for text parsing.
"""

def __init__(self, run_file_parser):
def __init__(self, run_file_parser, main_window):
self.builder = Gtk.Builder()
script_dir = os.path.dirname(__file__)
rel_path = "gui_layout.glade"
abs_path = os.path.join(script_dir, rel_path)
self.builder.add_objects_from_file(abs_path,
("filechooserdialog_parse", "filefilter_parse"))
self.dialog = self.builder.get_object("filechooserdialog_parse")
self.dialog.set_transient_for(main_window)
self.filefilters = self.builder.get_object("filefilter_parse")
self.filefilters.set_name("Text Files")
self.dialog.add_filter(self.filefilters)
Expand Down Expand Up @@ -434,7 +437,7 @@ class FileChooserExport(object):
to export data.
"""

def __init__(self, export_data):
def __init__(self, export_data, main_window):
self.builder = Gtk.Builder()
self.export_data = export_data
script_dir = os.path.dirname(__file__)
Expand All @@ -443,6 +446,7 @@ def __init__(self, export_data):
self.builder.add_objects_from_file(abs_path,
("filechooserdialog_export", ""))
self.dialog = self.builder.get_object("filechooserdialog_export")
self.dialog.set_transient_for(main_window)
self.builder.connect_signals(self)

def run(self):
Expand Down Expand Up @@ -503,7 +507,7 @@ def on_button_export_data_clicked(self, button):
"""
self.filename = self.dialog.get_filename()
if os.path.exists(self.filename) == True:
overwrite = OverwriteDialog(self.call_overwrite)
overwrite = OverwriteDialog(self.call_overwrite, self.dialog)
overwrite.run()
else:
self.export_data(self.filename)
Expand All @@ -530,7 +534,7 @@ class OverwriteDialog(object):
overwritten. This class handles all the signals of the dialog.
"""

def __init__(self, call_overwrite):
def __init__(self, call_overwrite, export_dialog):
self.builder = Gtk.Builder()
self.call_overwrite = call_overwrite
script_dir = os.path.dirname(__file__)
Expand All @@ -539,6 +543,7 @@ def __init__(self, call_overwrite):
self.builder.add_objects_from_file(abs_path,
("dialog_overwrite", ""))
self.dialog = self.builder.get_object("dialog_overwrite")
self.dialog.set_transient_for(export_dialog)
self.builder.connect_signals(self)

def run(self):
Expand Down
3 changes: 2 additions & 1 deletion innstereo/layer_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LayerProperties(object):
applied.
"""

def __init__(self, layer, redraw_plot):
def __init__(self, layer, redraw_plot, main_window):
"""
Initializes the Gtk.Builder and loads the about dialog from glade file.
The builder creates and instance of the about dialog and connects
Expand All @@ -48,6 +48,7 @@ def __init__(self, layer, redraw_plot):
self.redraw = redraw_plot
self.changes = []
self.dialog = self.builder.get_object("dialog_layer_properties")
self.dialog.set_transient_for(main_window)
self.marker_style_dict = {".": 0, ",": 1, "o": 2, "v": 3, "^": 4, "<": 5,
">": 6, "s": 7, "8": 8, "p": 9, "*": 10, "h": 11,
"H": 12, "+": 13, "x": 14, "D": 15, "d": 16,
Expand Down
11 changes: 6 additions & 5 deletions innstereo/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ def on_toolbutton_plot_properties_clicked(self, widget):
Triggered when the toolbutton is pressed. Creates and instance of the
StereonetProperties class, which is a Gtk DialogWindow and runs it.
"""
plot_properties = StereonetProperties(self.settings, self.redraw_plot)
plot_properties = StereonetProperties(self.settings, self.redraw_plot,
self.main_window)
plot_properties.run()

def on_toolbutton_print_figure_clicked(self, widget):
Expand Down Expand Up @@ -553,7 +554,7 @@ def on_toolbutton_layer_properties_clicked(self, toolbutton):

row = row_list[0]
layer_obj = self.layer_store[row][3]
layer_prop = LayerProperties(layer_obj, self.redraw_plot)
layer_prop = LayerProperties(layer_obj, self.redraw_plot, self.main_window)
layer_prop.run()

def layer_selection_changed(self, selection):
Expand Down Expand Up @@ -1311,7 +1312,7 @@ def on_menuitem_about_activate(self, widget):
of the AboutDialog class and calls the function "run" within that class
to show the dialog.
"""
about = AboutDialog()
about = AboutDialog(self.main_window)
about.run()

def on_menuitem_quit_activate(self, widget):
Expand Down Expand Up @@ -1534,7 +1535,7 @@ def on_toolbutton_file_parse_clicked(self, toolbutton):
model, row_list = selection.get_selected_rows()

if len(row_list) == 1:
fc = FileChooserParse(self.run_file_parser)
fc = FileChooserParse(self.run_file_parser, self.main_window)
fc.run()

elif len(row_list) == 0:
Expand Down Expand Up @@ -1577,7 +1578,7 @@ def on_toolbutton_export_clicked(self, toolbutton):

if len(row_list) == 1:
self.redraw_plot()
exportdialog = FileChooserExport(self.export_data)
exportdialog = FileChooserExport(self.export_data, self.main_window)
exportdialog.run()

elif len(row_list) == 0:
Expand Down

0 comments on commit 903aa5d

Please sign in to comment.