diff --git a/tryton/tryton/gui/main.py b/tryton/tryton/gui/main.py index ace2cd3739..ea12afd045 100644 --- a/tryton/tryton/gui/main.py +++ b/tryton/tryton/gui/main.py @@ -772,6 +772,9 @@ class Main(Gtk.Application): expand=True, fill=True, padding=0) treeview = screen.current_view.treeview treeview.set_headers_visible(False) + for col in treeview.get_columns(): + if col._type in {'selection', 'optional', 'drag'}: + col.set_visible(False) # Favorite column column = Gtk.TreeViewColumn() diff --git a/tryton/tryton/gui/window/view_form/view/list.py b/tryton/tryton/gui/window/view_form/view/list.py index 01e51b0dbf..24d3b5400b 100644 --- a/tryton/tryton/gui/window/view_form/view/list.py +++ b/tryton/tryton/gui/window/view_form/view/list.py @@ -451,6 +451,8 @@ class ViewTree(View): grid_lines = Gtk.TreeViewGridLines.VERTICAL super().__init__(view_id, screen, xml) + + self.set_selection_column() self.set_drag_and_drop() self.mnemonic_widget = self.treeview @@ -616,6 +618,21 @@ class ViewTree(View): else: arrow.clear() + def set_selection_column(self): + def select_data_func(column, cell, model, iter_, selection): + cell.set_property('active', selection.iter_is_selected(iter_)) + + selection = self.treeview.get_selection() + column = Gtk.TreeViewColumn() + column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) + column.name = None + column._type = 'selection' + cell = Gtk.CellRendererToggle() + cell.set_sensitive(False) + column.pack_start(cell, expand=False) + column.set_cell_data_func(cell, select_data_func, selection) + self.treeview.insert_column(column, 0) + def set_drag_and_drop(self): dnd = False if self.children_field: @@ -1153,7 +1170,7 @@ class ViewTree(View): column.set_visible(not unique or bool(self.children_field)) if self.children_field: for i, column in enumerate(self.treeview.get_columns()): - if (self.draggable or self.optionals) and not i: + if column._type in {'selection', 'optional', 'drag'}: continue if column.get_visible(): self.treeview.set_expander_column(column)