Add communication between boards

The communication (refresh) is simply activated by using "_active_%s" in the
domain of the act_window (where %s is the id of the other act_window).  When
the selection of one board is changed, every other board domain are evaluated
and if they change the corresponding board is reloaded.
This commit is contained in:
Cédric Krier committed 2011-01-30 22:58:44 +01:00
1 parent fbb9a9fa6b
commit 344d4342e6
4 files changed
+58 -9

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add communication between boards
* Added domain inversion feature
* Handle loading attribute on fields
* Use default format for value in wizard form
+34 -5
View File
@@ -13,12 +13,14 @@ import tryton.common as common
from tryton.pyson import PYSONDecoder
import gettext
from tryton.config import CONFIG
from tryton.signal_event import SignalEvent
_ = gettext.gettext
class Action(object):
class Action(SignalEvent):
def __init__(self, window, attrs=None):
super(Action, self).__init__()
self.act_id = int(attrs['name'])
self._window = window
self.screen = None
@@ -51,10 +53,8 @@ class Action(object):
self.context.update(PYSONDecoder(eval_ctx).decode(
self.action.get('pyson_context', '{}')))
domain_ctx = self.context.copy()
self.domain = PYSONDecoder(domain_ctx).decode(
self.action['pyson_domain'])
self.domain = []
self.update_domain([])
self.widget = gtk.Frame()
self.widget.set_border_width(0)
@@ -151,6 +151,8 @@ class Action(object):
alignment.add(self.screen.screen_container.alternate_viewport)
name = self.screen.current_view.title
self.screen.signal_connect(self, 'record-message', self._sig_label)
self.screen.signal_connect(self, 'record-message',
self._active_changed)
elif self.action['view_type'] == 'tree':
ctx = {}
ctx.update(rpc.CONTEXT)
@@ -172,6 +174,8 @@ class Action(object):
alignment.add(self.tree.widget_get())
name = self.tree.name
self.tree.view.connect('key_press_event', self.sig_key_press)
self.tree.signal_connect(self, 'select-changed',
self._active_changed)
if attrs.get('string'):
self.title.set_text(attrs['string'])
@@ -251,3 +255,28 @@ class Action(object):
.get_selected_rows()
for path in paths:
self.tree.view.expand_row(path, False)
def _active_changed(self, *args):
self.signal('active-changed')
def _get_active(self):
if self.screen:
return common.EvalEnvironment(self.screen.current_record, False)
elif self.tree:
return {'id': self.tree.sel_id_get()}
active = property(_get_active)
def update_domain(self, actions):
domain_ctx = self.context.copy()
for action in actions:
if action.active:
domain_ctx['_active_%s' % action.act_id] = action.active
new_domain = PYSONDecoder(domain_ctx).decode(
self.action['pyson_domain'])
if self.domain == new_domain:
return
del self.domain[:]
self.domain.extend(new_domain)
if self.screen:
self.screen.search_filter()
+13 -1
View File
@@ -2,8 +2,9 @@
#this repository contains the full copyright notices and license terms.
'View board'
from parser import ParserBoard
import xml.dom.minidom
from parser import ParserBoard
from tryton.gui.window.view_board.action import Action
class ViewBoard(object):
'View board'
@@ -18,7 +19,12 @@ class ViewBoard(object):
continue
self.widget, self.widgets = parser.parse(node)
break
self.actions = [x for x in self.widgets if isinstance(x, Action)]
for action in self.actions:
action.signal_connect(self, 'active-changed',
self._active_changed)
self.widget.show_all()
self._active_changed(None)
def widget_get(self):
return self.widget
@@ -26,3 +32,9 @@ class ViewBoard(object):
def reload(self):
for widget in self.widgets:
widget.display()
def _active_changed(self, event_action, *args):
for action in self.actions:
if action == event_action:
continue
action.update_domain(self.actions)
+10 -3
View File
@@ -13,6 +13,7 @@ from tryton.common import HM_FORMAT
import tryton.common as common
from tryton.translate import date_format
from tryton.pyson import PYSONDecoder
from tryton.signal_event import SignalEvent
FIELDS_LIST_TYPE = {
'boolean': gobject.TYPE_BOOLEAN,
@@ -323,11 +324,12 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
except Exception:
return None
class ViewTree(object):
class ViewTree(SignalEvent):
"View tree"
def __init__(self, view_info, ids, window, sel_multi=False,
context=None):
super(ViewTree, self).__init__()
self.window = window
self.view = gtk.TreeView()
self.view.set_headers_visible(not CONFIG['client.modepda'])
@@ -342,10 +344,12 @@ class ViewTree(object):
self.name = parse.title
self.sel_multi = sel_multi
selection = self.view.get_selection()
if sel_multi:
self.view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
selection.set_mode(gtk.SELECTION_MULTIPLE)
else:
self.view.get_selection().set_mode(gtk.SELECTION_SINGLE)
selection.self.view.get_selection().set_mode(gtk.SELECTION_SINGLE)
selection.connect('changed', self.__select_changed)
self.view.set_expander_column(self.view.get_column(1))
self.view.set_enable_search(False)
self.view.get_column(0).set_visible(False)
@@ -413,3 +417,6 @@ class ViewTree(object):
if not i:
return None
return model.get_value(i, col)
def __select_changed(self, tree_sel):
self.signal('select-changed')