Improve dialog size
Disable scrolled-windows to let the dialog compute the best size and reactivate decoration. issue7511 review70301002
This commit is contained in:
1 parent
c7002898fc
commit
e3c0213f4f
10 files changed
+40
-76
No files matched your search
@@ -265,21 +265,6 @@ def get_sensible_widget(window):
|
||||
return window
|
||||
|
||||
|
||||
def center_window(window, parent, sensible):
|
||||
sensible_allocation = sensible.get_allocation()
|
||||
if hasattr(sensible.get_window(), 'get_root_coords'):
|
||||
x, y = sensible.get_window().get_root_coords(
|
||||
sensible_allocation.x, sensible_allocation.y)
|
||||
else:
|
||||
x, y = sensible.get_window().get_origin()
|
||||
x += sensible_allocation.x
|
||||
y += sensible_allocation.y
|
||||
window_allocation = window.get_allocation()
|
||||
x = x + int((sensible_allocation.width - window_allocation.width) / 2)
|
||||
y = y + int((sensible_allocation.height - window_allocation.height) / 2)
|
||||
window.move(x, y)
|
||||
|
||||
|
||||
def selection(title, values, alwaysask=False):
|
||||
if not values or len(values) == 0:
|
||||
return None
|
||||
|
||||
@@ -11,6 +11,7 @@ class View(object):
|
||||
modified = None
|
||||
editable = None
|
||||
children_field = None
|
||||
scroll = None
|
||||
|
||||
def __init__(self, screen, xml):
|
||||
self.screen = screen
|
||||
|
||||
@@ -59,7 +59,7 @@ class ViewCalendar(View):
|
||||
goocalendar.connect('day-pressed', self.on_day_pressed)
|
||||
goocalendar.connect('day-activated', self.on_day_activated)
|
||||
self.widgets['goocalendar'] = goocalendar
|
||||
scrolledWindow = gtk.ScrolledWindow()
|
||||
self.scroll = scrolledWindow = gtk.ScrolledWindow()
|
||||
scrolledWindow.add_with_viewport(goocalendar)
|
||||
vbox.pack_start(toolbar, False, False)
|
||||
vbox.pack_start(scrolledWindow, True, True)
|
||||
|
||||
@@ -179,7 +179,7 @@ class ViewForm(View):
|
||||
vp = gtk.Viewport()
|
||||
vp.set_shadow_type(gtk.SHADOW_NONE)
|
||||
vp.add(container.table)
|
||||
scroll = gtk.ScrolledWindow()
|
||||
self.scroll = scroll = gtk.ScrolledWindow()
|
||||
scroll.add(vp)
|
||||
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scroll.set_placement(gtk.CORNER_TOP_LEFT)
|
||||
|
||||
@@ -137,8 +137,9 @@ class TranslateDialog(NoModal):
|
||||
Main().add_window(self.win)
|
||||
self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.win.set_icon(TRYTON_ICON)
|
||||
self.win.set_decorated(False)
|
||||
self.win.connect('response', self.response)
|
||||
parent_allocation = self.parent.get_allocation()
|
||||
self.win.set_default_size(-1, min(400, parent_allocation.height))
|
||||
|
||||
self.accel_group = gtk.AccelGroup()
|
||||
self.win.add_accel_group(self.accel_group)
|
||||
@@ -215,7 +216,7 @@ class TranslateDialog(NoModal):
|
||||
viewport.set_shadow_type(gtk.SHADOW_NONE)
|
||||
viewport.add(vbox)
|
||||
scrolledwindow = gtk.ScrolledWindow()
|
||||
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
|
||||
scrolledwindow.set_shadow_type(gtk.SHADOW_NONE)
|
||||
scrolledwindow.add(viewport)
|
||||
self.win.vbox.pack_start(scrolledwindow, True, True)
|
||||
@@ -255,12 +256,7 @@ class TranslateDialog(NoModal):
|
||||
NoModal.destroy(self)
|
||||
|
||||
def show(self):
|
||||
sensible_allocation = self.sensible_widget.get_allocation()
|
||||
self.win.resize(
|
||||
sensible_allocation.width, sensible_allocation.height)
|
||||
self.win.show()
|
||||
gobject.idle_add(
|
||||
common.center_window, self.win, self.parent, self.sensible_widget)
|
||||
|
||||
def hide(self):
|
||||
self.win.hide()
|
||||
|
||||
@@ -302,7 +302,7 @@ class ViewTree(View):
|
||||
self.set_drag_and_drop()
|
||||
|
||||
self.widget = gtk.VBox()
|
||||
scroll = gtk.ScrolledWindow()
|
||||
self.scroll = scroll = gtk.ScrolledWindow()
|
||||
scroll.add(self.treeview)
|
||||
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scroll.set_placement(gtk.CORNER_TOP_LEFT)
|
||||
|
||||
@@ -8,7 +8,6 @@ import gtk
|
||||
import gobject
|
||||
import gettext
|
||||
|
||||
from tryton.common import center_window
|
||||
from tryton.config import TRYTON_ICON
|
||||
from tryton.gui import Main
|
||||
from tryton.gui.window.nomodal import NoModal
|
||||
@@ -41,7 +40,6 @@ class WinCSV(NoModal):
|
||||
Main().add_window(self.dialog)
|
||||
self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.dialog.set_icon(TRYTON_ICON)
|
||||
self.dialog.set_decorated(False)
|
||||
self.dialog.connect('response', self.response)
|
||||
|
||||
dialog_vbox = gtk.VBox()
|
||||
@@ -317,12 +315,7 @@ class WinCSV(NoModal):
|
||||
self.dialog.destroy()
|
||||
|
||||
def show(self):
|
||||
sensible_allocation = self.sensible_widget.get_allocation()
|
||||
self.dialog.resize(
|
||||
sensible_allocation.width, sensible_allocation.height)
|
||||
self.dialog.show()
|
||||
gobject.idle_add(
|
||||
center_window, self.dialog, self.parent, self.sensible_widget)
|
||||
|
||||
def hide(self):
|
||||
self.dialog.hide()
|
||||
@@ -3,7 +3,6 @@
|
||||
from tryton.common import TRYTON_ICON
|
||||
import tryton.common as common
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
import gettext
|
||||
|
||||
@@ -43,12 +42,18 @@ class WinForm(NoModal, InfoBar):
|
||||
Main().add_window(self.win)
|
||||
self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.win.set_icon(TRYTON_ICON)
|
||||
self.win.set_decorated(False)
|
||||
self.win.set_deletable(False)
|
||||
self.win.connect('delete-event', lambda *a: True)
|
||||
self.win.connect('close', self.close)
|
||||
self.win.connect('response', self.response)
|
||||
|
||||
allocation = self.parent.get_allocation()
|
||||
width, height, = allocation.width, allocation.height
|
||||
if self.parent != self.sensible_widget:
|
||||
width = max(width - 150, 0)
|
||||
height = max(height - 150, 0)
|
||||
self.win.set_default_size(width, height)
|
||||
|
||||
self.accel_group = gtk.AccelGroup()
|
||||
self.win.add_accel_group(self.accel_group)
|
||||
|
||||
@@ -449,12 +454,7 @@ class WinForm(NoModal, InfoBar):
|
||||
NoModal.destroy(self)
|
||||
|
||||
def show(self):
|
||||
sensible_allocation = self.sensible_widget.get_allocation()
|
||||
self.win.resize(
|
||||
sensible_allocation.width, sensible_allocation.height)
|
||||
self.win.show()
|
||||
gobject.idle_add(
|
||||
common.center_window, self.win, self.parent, self.sensible_widget)
|
||||
|
||||
def hide(self):
|
||||
self.win.hide()
|
||||
@@ -1,7 +1,6 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import gtk
|
||||
import gobject
|
||||
import gettext
|
||||
|
||||
import tryton.common as common
|
||||
@@ -37,10 +36,16 @@ class WinSearch(NoModal):
|
||||
gtk.DIALOG_DESTROY_WITH_PARENT)
|
||||
Main().add_window(self.win)
|
||||
self.win.set_icon(TRYTON_ICON)
|
||||
self.win.set_decorated(False)
|
||||
self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.win.set_default_response(gtk.RESPONSE_APPLY)
|
||||
self.win.connect('response', self.response)
|
||||
|
||||
parent_allocation = self.parent.get_allocation()
|
||||
width, height = parent_allocation.width, parent_allocation.height
|
||||
if self.parent != self.sensible_widget:
|
||||
width = max(width - 150, 0)
|
||||
self.win.set_default_size(min(600, width), min(400, height))
|
||||
|
||||
self.accel_group = gtk.AccelGroup()
|
||||
self.win.add_accel_group(self.accel_group)
|
||||
|
||||
@@ -64,9 +69,6 @@ class WinSearch(NoModal):
|
||||
hbox.show()
|
||||
self.win.vbox.pack_start(hbox, expand=False, fill=True)
|
||||
self.win.vbox.pack_start(gtk.HSeparator(), expand=False, fill=True)
|
||||
scrollwindow = gtk.ScrolledWindow()
|
||||
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.win.vbox.pack_start(scrollwindow, expand=True, fill=True)
|
||||
|
||||
self.screen = Screen(model, domain=domain, mode=['tree'], order=order,
|
||||
context=context, view_ids=view_ids, views_preload=views_preload,
|
||||
@@ -81,13 +83,8 @@ class WinSearch(NoModal):
|
||||
sel.set_mode(gtk.SELECTION_SINGLE)
|
||||
else:
|
||||
sel.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
viewport = gtk.Viewport()
|
||||
viewport.set_shadow_type(gtk.SHADOW_NONE)
|
||||
viewport.add(self.screen.widget)
|
||||
self.win.vbox.pack_start(self.screen.widget, expand=True, fill=True)
|
||||
self.screen.widget.show()
|
||||
viewport.show()
|
||||
scrollwindow.add(viewport)
|
||||
scrollwindow.show()
|
||||
|
||||
self.model_name = model
|
||||
|
||||
@@ -104,12 +101,7 @@ class WinSearch(NoModal):
|
||||
NoModal.destroy(self)
|
||||
|
||||
def show(self):
|
||||
sensible_allocation = self.sensible_widget.get_allocation()
|
||||
self.win.resize(
|
||||
sensible_allocation.width, sensible_allocation.height)
|
||||
self.win.show()
|
||||
gobject.idle_add(
|
||||
common.center_window, self.win, self.parent, self.sensible_widget)
|
||||
|
||||
def hide(self):
|
||||
self.win.hide()
|
||||
|
||||
+18
-21
@@ -4,7 +4,6 @@ import logging
|
||||
import gettext
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
|
||||
from gi.repository import Gtk
|
||||
@@ -107,8 +106,13 @@ class Wizard(InfoBar):
|
||||
if 'view' in result:
|
||||
self.clean()
|
||||
view = result['view']
|
||||
self.update(view['fields_view'], view['defaults'],
|
||||
view['buttons'])
|
||||
self.update(view['fields_view'], view['buttons'])
|
||||
|
||||
self.screen.new(default=False)
|
||||
self.screen.current_record.set_default(view['defaults'])
|
||||
self.update_buttons(self.screen.current_record)
|
||||
self.screen.set_cursor()
|
||||
|
||||
self.screen_state = view['state']
|
||||
self.__waiting_response = True
|
||||
else:
|
||||
@@ -185,7 +189,7 @@ class Wizard(InfoBar):
|
||||
for button in self.states.values():
|
||||
button.state_set(record)
|
||||
|
||||
def update(self, view, defaults, buttons):
|
||||
def update(self, view, buttons):
|
||||
tooltips = common.Tooltips()
|
||||
for button in buttons:
|
||||
self._get_button(button)
|
||||
@@ -244,11 +248,6 @@ class Wizard(InfoBar):
|
||||
self.create_info_bar()
|
||||
self.widget.pack_start(self.info_bar, False, True)
|
||||
|
||||
self.screen.new(default=False)
|
||||
self.screen.current_record.set_default(defaults)
|
||||
self.update_buttons(self.screen.current_record)
|
||||
self.screen.set_cursor()
|
||||
|
||||
|
||||
class WizardForm(Wizard, SignalEvent):
|
||||
"Wizard"
|
||||
@@ -279,8 +278,8 @@ class WizardForm(Wizard, SignalEvent):
|
||||
self.hbuttonbox.pack_start(button)
|
||||
return button
|
||||
|
||||
def update(self, view, defaults, buttons):
|
||||
super(WizardForm, self).update(view, defaults, buttons)
|
||||
def update(self, view, buttons):
|
||||
super(WizardForm, self).update(view, buttons)
|
||||
self.widget.pack_start(self.hbuttonbox, expand=False, fill=True)
|
||||
|
||||
def sig_close(self):
|
||||
@@ -315,7 +314,6 @@ class WizardDialog(Wizard, NoModal):
|
||||
Main().add_window(self.dia)
|
||||
self.dia.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.dia.set_icon(TRYTON_ICON)
|
||||
self.dia.set_decorated(False)
|
||||
self.dia.set_deletable(False)
|
||||
self.dia.connect('delete-event', lambda *a: True)
|
||||
self.dia.connect('close', self.close)
|
||||
@@ -349,11 +347,14 @@ class WizardDialog(Wizard, NoModal):
|
||||
self.dia.set_default_response(response)
|
||||
return button
|
||||
|
||||
def update(self, view, defaults, buttons):
|
||||
# Dialog must be shown before the screen is displayed
|
||||
# to get the treeview realized when displayed
|
||||
def update(self, view, buttons):
|
||||
super(WizardDialog, self).update(view, buttons)
|
||||
current_view = self.screen.current_view
|
||||
self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
|
||||
if current_view.scroll:
|
||||
current_view.scroll.set_policy(
|
||||
gtk.POLICY_NEVER, gtk.POLICY_NEVER)
|
||||
self.show()
|
||||
super(WizardDialog, self).update(view, defaults, buttons)
|
||||
|
||||
def destroy(self, action=None):
|
||||
super(WizardDialog, self).destroy()
|
||||
@@ -398,12 +399,8 @@ class WizardDialog(Wizard, NoModal):
|
||||
return True
|
||||
|
||||
def show(self):
|
||||
sensible_allocation = self.sensible_widget.get_allocation()
|
||||
self.dia.set_default_size(
|
||||
sensible_allocation.width, sensible_allocation.height)
|
||||
self.dia.set_default_size(200, -1)
|
||||
self.dia.show()
|
||||
gobject.idle_add(
|
||||
common.center_window, self.dia, self.parent, self.sensible_widget)
|
||||
|
||||
def hide(self):
|
||||
self.dia.hide()
|
||||
Reference in new issue
Block a user