6871: workaround the gtk RTL bug in MultiTreeView

Best of both worlds brought to you by Nick and Vassilii :-)

svn: r22886
This commit is contained in:
Vassilii Khachaturov 2013-08-20 21:39:47 +00:00
parent 22d4c1dd2c
commit ee8bc7aaad
2 changed files with 16 additions and 6 deletions

View File

@ -507,11 +507,7 @@ class SimpleTable(object):
#treeview.enable_model_drag_dest(DdTargets.all_targets(), #treeview.enable_model_drag_dest(DdTargets.all_targets(),
# gtk.gdk.ACTION_DEFAULT) # gtk.gdk.ACTION_DEFAULT)
treeview.connect('drag_data_get', self.object_drag_data_get) treeview.connect('drag_data_get', self.object_drag_data_get)
if treeview.get_direction() == gtk.TEXT_DIR_RTL: treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
# Don't show vertical grid lines with RTL (bug #6871)
treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_HORIZONTAL)
else:
treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
#treeview.connect('row-activated', on_table_doubleclick, self) #treeview.connect('row-activated', on_table_doubleclick, self)
#treeview.connect('cursor-changed', on_table_click, self) #treeview.connect('cursor-changed', on_table_click, self)
treeview.connect('button-press-event', self.button_press_event) treeview.connect('button-press-event', self.button_press_event)

View File

@ -42,6 +42,20 @@ class MultiTreeView(gtk.TreeView):
self.connect('key_press_event', self.key_press_event) self.connect('key_press_event', self.key_press_event)
self.defer_select = False self.defer_select = False
__grid_lines_remove_vertical = {
gtk.TREE_VIEW_GRID_LINES_NONE : gtk.TREE_VIEW_GRID_LINES_NONE,
gtk.TREE_VIEW_GRID_LINES_HORIZONTAL : gtk.TREE_VIEW_GRID_LINES_HORIZONTAL,
gtk.TREE_VIEW_GRID_LINES_VERTICAL : gtk.TREE_VIEW_GRID_LINES_NONE,
gtk.TREE_VIEW_GRID_LINES_BOTH : gtk.TREE_VIEW_GRID_LINES_HORIZONTAL
}
def set_grid_lines(self, grid_lines):
if self.get_direction() == gtk.TEXT_DIR_RTL:
# Work around a gtk RTL bug, see #6871
# On post-gramps34 branches should also check for gtk version <(3,8),
# but this is always true here on gramps34!
grid_lines = MultiTreeView.__grid_lines_remove_vertical[grid_lines]
super(MultiTreeView, self).set_grid_lines(grid_lines)
def key_press_event(self, widget, event): def key_press_event(self, widget, event):
if event.type == gtk.gdk.KEY_PRESS: if event.type == gtk.gdk.KEY_PRESS:
if event.keyval == gtk.keysyms.Delete: if event.keyval == gtk.keysyms.Delete:
@ -73,7 +87,7 @@ class MultiTreeView(gtk.TreeView):
# re-enable selection # re-enable selection
self.get_selection().set_select_function(lambda *ignore: True) self.get_selection().set_select_function(lambda *ignore: True)
target = self.get_path_at_pos(int(event.x), int(event.y)) target = self.get_path_at_pos(int(event.x), int(event.y))
if (self.defer_select and target if (self.defer_select and target
and self.defer_select == target[0] and self.defer_select == target[0]
and not (event.x==0 and event.y==0)): # certain drag and drop and not (event.x==0 and event.y==0)): # certain drag and drop