Reviewers: ,


Please review this at http://codereview.tryton.org/304004/

Affected files:
  M tryton/common/cellrendererbutton.py
  M tryton/gui/window/view_form/view/list_gtk/parser.py


Index: tryton/common/cellrendererbutton.py
===================================================================
--- a/tryton/common/cellrendererbutton.py
+++ b/tryton/common/cellrendererbutton.py
@@ -12,6 +12,8 @@
                 "Displayed text", gobject.PARAM_READWRITE),
             'visible': (gobject.TYPE_INT, 'Visible',
                 'Visible', 0, 10, 0, gobject.PARAM_READWRITE),
+            'sensitive': (gobject.TYPE_INT, 'Sensitive',
+                'Sensitive', 0, 10, 0, gobject.PARAM_READWRITE),
     }

     __gsignals__ = {
@@ -25,6 +27,7 @@
         self.set_property('mode', gtk.CELL_RENDERER_MODE_EDITABLE)
         self.clicking = False
         self.visible = True
+        self.sensitive = True

     def do_set_property(self, pspec, value):
         setattr(self, pspec.name, value)
@@ -44,6 +47,8 @@
         if self.clicking and flags & gtk.CELL_RENDERER_SELECTED:
             state = gtk.STATE_ACTIVE
             shadow = gtk.SHADOW_IN
+        elif not self.sensitive:
+            state = gtk.STATE_INSENSITIVE
         widget.style.paint_box(window, state, shadow,
                 None, widget, "button",
                 cell_area.x, cell_area.y,
@@ -80,7 +85,7 @@

     def on_start_editing(self, event, widget, path, background_area,
             cell_area, flags):
-        if not self.visible:
+        if not self.visible or not self.sensitive:
             return
         if (event is None) or ((event.type == gtk.gdk.BUTTON_PRESS) \
                 or (event.type == gtk.gdk.KEY_PRESS \
Index: tryton/gui/window/view_form/view/list_gtk/parser.py
===================================================================
--- a/tryton/gui/window/view_form/view/list_gtk/parser.py
+++ b/tryton/gui/window/view_form/view/list_gtk/parser.py
@@ -970,7 +970,14 @@
             check_load=False)
         invisible = states.get('invisible', False)
         cell.set_property('visible', not invisible)
-        # TODO readonly
+        readonly = states.get('readonly', False)
+        cell.set_property('sensitive', not readonly)
+        parent = record.parent if record else None
+        while parent:
+            if parent.modified:
+                cell.set_property('sensitive', False)
+                break
+            parent = parent.parent
         # TODO icon

     def button_clicked(self, widget, path):


--
[email protected] mailing list

Reply via email to