Limit the size of form inside dialog according to the parent/transiant window

This commit is contained in:
Cédric Krier committed 2011-05-10 15:23:36 +02:00
1 parent 8a8b18b6dd
commit 7d4b921606
2 files changed
+10 -4

No files matched your search

+6
View File
@@ -43,6 +43,12 @@ class ViewForm(ParserView):
viewport.add(scroll)
if isinstance(self.screen.window, gtk.Dialog):
width, height = self.widget.size_request()
if self.screen.window:
parent = self.screen.window.get_transient_for()
if parent:
parent_width, parent_height = parent.get_size()
width = min(parent_width - 40, width)
height = min(parent_height - 80, height)
vbox.set_size_request(width or -1, height or -1)
vbox.pack_start(viewport, expand=True, fill=True)
+4 -4
View File
@@ -103,10 +103,10 @@ class Dialog(object):
width, height = self.screen.screen_container.size_get()
parent_width, parent_height = parent.get_size()
dia_width, dia_height = self.dia.get_size()
self.widget_width = max(min(parent_width - 20,
max(dia_width, width + 20)), size[0])
self.widget_height = max(min(parent_height - 60,
height + dia_height + 20), size[1])
self.widget_width = min(parent_width - 20,
max(dia_width, width + 20, size[0]))
self.widget_height = min(parent_height - 60,
max(height + dia_height + 20, size[1]))
self.dia.set_default_size(self.widget_width,
self.widget_height)
self.screen.widget.show()