Improve treeview headers

- Use same alignment as the widget
- Use grid lines vertical on non-editable
- Use grid lines both on editable

issue6681
review37601002
This commit is contained in:
Cédric Krier committed 2017-09-03 11:30:04 +02:00
1 parent f8df73da42
commit 95f877489d
4 files changed
+19 -17

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Improve treeview headers
* Update states of both toolbar and menu
* Improve toolbar order
* Make readonly, required and invalid widget themable
+2
View File
@@ -1041,6 +1041,8 @@ class Main(object):
lambda *a: gobject.idle_add(toggle_favorite, *a), treeview)
# Unset fixed height mode to add column
treeview.set_fixed_height_mode(False)
treeview.set_property(
'enable-grid-lines', gtk.TREE_VIEW_GRID_LINES_NONE)
treeview.append_column(column)
screen.search_filter()
+7 -3
View File
@@ -276,12 +276,15 @@ class ViewTree(View):
self.reload = False
if self.attributes.get('editable'):
self.treeview = EditableTreeView(self.attributes['editable'], self)
grid_lines = gtk.TREE_VIEW_GRID_LINES_BOTH
else:
self.treeview = TreeView(self)
grid_lines = gtk.TREE_VIEW_GRID_LINES_VERTICAL
self.parse(xml)
self.treeview.set_property('rules-hint', True)
self.treeview.set_property('enable-grid-lines', grid_lines)
self.treeview.set_fixed_height_mode(
all(c.get_sizing() == gtk.TREE_VIEW_COLUMN_FIXED
for c in self.treeview.get_columns()))
@@ -386,7 +389,7 @@ class ViewTree(View):
column.set_cell_data_func(suffix.renderer,
suffix.setter)
self.set_column_widget(column, field, node_attrs)
self.set_column_widget(column, field, node_attrs, align=widget.align)
self.set_column_width(column, field, node_attrs)
if (not self.attributes.get('sequence')
@@ -448,7 +451,8 @@ class ViewTree(View):
def get_widget(cls, name):
return cls.WIDGETS[name]
def set_column_widget(self, column, field, attributes, arrow=True):
def set_column_widget(self, column, field, attributes,
arrow=True, align=0.5):
hbox = gtk.HBox(False, 2)
label = gtk.Label(attributes['string'])
if field and self.editable:
@@ -478,7 +482,7 @@ class ViewTree(View):
column.set_clickable(True)
hbox.show()
column.set_widget(hbox)
column.set_alignment(0.5)
column.set_alignment(align)
def set_column_width(self, column, field, attributes):
default_width = {
@@ -172,6 +172,7 @@ class Affix(Cell):
class GenericText(Cell):
align = 0
def __init__(self, view, attrs, renderer=None):
super(GenericText, self).__init__()
@@ -211,13 +212,6 @@ class GenericText(Cell):
field = record[self.attrs['name']]
if self.attrs.get('type', field.attrs.get('type')) in \
('float', 'integer', 'biginteger', 'boolean',
'numeric', 'timedelta'):
align = 1
else:
align = 0
editable = getattr(self.view.treeview, 'editable', False)
states = ('invisible',)
if editable:
@@ -244,7 +238,7 @@ class GenericText(Cell):
if isinstance(cell, CellRendererToggle):
cell.set_property('activatable', False)
cell.set_property('xalign', align)
cell.set_property('xalign', self.align)
def open_remote(self, record, create, changed=False, text=None,
callback=None):
@@ -285,6 +279,7 @@ class Text(GenericText):
class Int(GenericText):
align = 1
def __init__(self, view, attrs, renderer=None):
if renderer is None:
@@ -306,6 +301,7 @@ class Int(GenericText):
class Boolean(GenericText):
align = 0.5
def __init__(self, view, attrs=None,
renderer=None):
@@ -395,7 +391,7 @@ class Time(Date):
class TimeDelta(GenericText):
pass
align = 1
class Float(Int):
@@ -415,6 +411,7 @@ class Float(Int):
class Binary(GenericText):
align = 0.5
def __init__(self, view, attrs, renderer=None):
self.filename = attrs.get('filename')
@@ -515,6 +512,7 @@ class Binary(GenericText):
class Image(GenericText):
align = 0.5
def __init__(self, view, attrs=None, renderer=None):
if renderer is None:
@@ -698,11 +696,7 @@ class O2O(M2O):
class O2M(GenericText):
@realized
def setter(self, column, cell, store, iter):
super(O2M, self).setter(column, cell, store, iter)
cell.set_property('xalign', 0.5)
align = 0.5
def get_textual_value(self, record):
return '( ' + str(len(record[self.attrs['name']]
@@ -836,6 +830,7 @@ class Reference(GenericText, SelectionMixin):
class ProgressBar(object):
align = 0.5
orientations = {
'left_to_right': gtk.PROGRESS_LEFT_TO_RIGHT,
'right_to_left': gtk.PROGRESS_RIGHT_TO_LEFT,