From caf04a54eb750e8ab6fe7d7ec0716dcdad6ae145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 26 Jun 2008 19:04:28 +0200 Subject: [PATCH] Add new options to store columns width --- share/tryton/tryton.glade | 10 +++++++++- tryton/config.py | 1 + tryton/gui/main.py | 2 ++ tryton/gui/window/view_form/view/list.py | 20 +++++++++++++++++++ .../window/view_form/view/list_gtk/parser.py | 4 +++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/share/tryton/tryton.glade b/share/tryton/tryton.glade index fbdf511d5d..a131407877 100644 --- a/share/tryton/tryton.glade +++ b/share/tryton/tryton.glade @@ -915,11 +915,19 @@ True - Right Toolbar + Toolbar True + + + True + Save columns width + True + + + True diff --git a/tryton/config.py b/tryton/config.py index 1a8ee86c61..ca82ce60c1 100644 --- a/tryton/config.py +++ b/tryton/config.py @@ -72,6 +72,7 @@ class ConfigManager(object): 'form.toolbar': True, 'client.form_tab': 'left', 'client.form_tab_orientation': 90, + 'client.tree_width': True, 'client.lang': 'en_US', 'client.actions': { 'odt': {0: find_path(['ooffice', 'ooffice2'], '%s'), diff --git a/tryton/gui/main.py b/tryton/gui/main.py index f7746192c7..b8d6681662 100644 --- a/tryton/gui/main.py +++ b/tryton/gui/main.py @@ -574,6 +574,8 @@ class Main(object): signals = { 'on_opt_form_toolbar_activate': (fnc_menuitem, 'form.toolbar', 'opt_form_toolbar'), + 'on_opt_tree_width_activate': (fnc_menuitem, 'client.tree_width', + 'opt_tree_width'), } self.glade.get_widget('menubar_'+(CONFIG['client.toolbar'] or \ 'both')).set_active(True) diff --git a/tryton/gui/window/view_form/view/list.py b/tryton/gui/window/view_form/view/list.py index 1691ab92bc..deb31bb127 100644 --- a/tryton/gui/window/view_form/view/list.py +++ b/tryton/gui/window/view_form/view/list.py @@ -9,6 +9,7 @@ from tryton.action import Action from tryton.common import message import gettext import tryton.common as common +from tryton.config import CONFIG _ = gettext.gettext @@ -363,6 +364,25 @@ class ViewList(ParserView): return None def destroy(self): + if CONFIG['client.tree_width']: + fields = {} + last_col = None + for col in self.widget_tree.get_columns(): + if col.get_width() != col.width and col.get_visible(): + fields[col.name] = col.get_width() + if col.get_visible(): + last_col = col + #Don't set width for last visible columns + #as it depends of the screen size + if last_col and last_col.name in fields: + del fields[last_col.name] + + if fields: + try: + rpc.execute('object', 'execute', 'ir.ui.view_tree_width', + 'set_width', self.screen.name, fields, rpc.CONTEXT) + except: + pass self.widget_tree.destroy() del self.screen del self.widget_tree diff --git a/tryton/gui/window/view_form/view/list_gtk/parser.py b/tryton/gui/window/view_form/view/list_gtk/parser.py index fce66e9531..676dda5302 100644 --- a/tryton/gui/window/view_form/view/list_gtk/parser.py +++ b/tryton/gui/window/view_form/view/list_gtk/parser.py @@ -153,7 +153,9 @@ class ParserTree(ParserInterface): width = int(fields[fname]['width']) else: width = twidth.get(fields[fname]['type'], 100) - col.set_min_width(width) + col.width = width + if width > 0: + col.set_fixed_width(width) #XXX doesn't work well when resize columns #col.set_expand(True) if not treeview.sequence: