changeset 91b30931cd49 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset&node=91b30931cd49
description:
        Remove TreeViewControl

        It is better to use the standard behavior of TreeView selection.

        issue11180
        review374801002
diffstat:

 CHANGELOG                                                   |   1 +
 tryton/common/treeviewcontrol.py                            |  36 -------------
 tryton/gui/window/email_.py                                 |   3 +-
 tryton/gui/window/view_form/view/form_gtk/dictionary.py     |   3 +-
 tryton/gui/window/view_form/view/form_gtk/multiselection.py |   3 +-
 tryton/gui/window/view_form/view/screen_container.py        |   3 +-
 6 files changed, 5 insertions(+), 44 deletions(-)

diffs (128 lines):

diff -r 9a5bf563940b -r 91b30931cd49 CHANGELOG
--- a/CHANGELOG Sun Mar 06 18:02:00 2022 +0100
+++ b/CHANGELOG Wed Mar 09 00:19:52 2022 +0100
@@ -1,3 +1,4 @@
+* Remove TreeViewControl
 * Manage optional column
 * Default CSV encoding to UTF8 with BOM
 * Display the number of selected records
diff -r 9a5bf563940b -r 91b30931cd49 tryton/common/treeviewcontrol.py
--- a/tryton/common/treeviewcontrol.py  Sun Mar 06 18:02:00 2022 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-# This file is part of Tryton.  The COPYRIGHT file at the top level of this
-# repository contains the full copyright notices and license terms.
-from gi.repository import Gdk, GObject, Gtk
-
-MOVEMENT_KEYS = {
-    Gdk.KEY_Up,
-    Gdk.KEY_Down,
-    Gdk.KEY_space,
-    Gdk.KEY_Left,
-    Gdk.KEY_KP_Left,
-    Gdk.KEY_Right,
-    Gdk.KEY_KP_Right,
-    Gdk.KEY_Home,
-    Gdk.KEY_KP_Home,
-    Gdk.KEY_End,
-    Gdk.KEY_KP_End,
-    }
-
-__all__ = ['TreeViewControl']
-
-
-class TreeViewControl(Gtk.TreeView):
-
-    def do_button_press_event(self, event):
-        self.grab_focus()  # grab focus because it doesn't whith CONTROL MASK
-        if event.button == 1:
-            event.state ^= Gdk.ModifierType.CONTROL_MASK
-        return Gtk.TreeView.do_button_press_event(self, event)
-
-    def do_key_press_event(self, event):
-        if event.keyval in MOVEMENT_KEYS:
-            event.state ^= Gdk.ModifierType.CONTROL_MASK
-        return Gtk.TreeView.do_key_press_event(self, event)
-
-
-GObject.type_register(TreeViewControl)
diff -r 9a5bf563940b -r 91b30931cd49 tryton/gui/window/email_.py
--- a/tryton/gui/window/email_.py       Sun Mar 06 18:02:00 2022 +0100
+++ b/tryton/gui/window/email_.py       Wed Mar 09 00:19:52 2022 +0100
@@ -14,7 +14,6 @@
 from tryton.common import IconFactory, RPCException, RPCExecute, Tooltips
 from tryton.common.richtext import (
     add_toolbar, get_content, register_format, set_content)
-from tryton.common.treeviewcontrol import TreeViewControl
 from tryton.common.underline import set_underline
 from tryton.common.widget_style import widget_class
 from tryton.config import CONFIG, TRYTON_ICON
@@ -213,7 +212,7 @@
         attachment_frame.add(scrolledwindow)
         scrolledwindow.set_policy(
             Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
-        self.attachments = TreeViewControl()
+        self.attachments = Gtk.TreeView()
         self.attachments.set_headers_visible(False)
         scrolledwindow.add(self.attachments)
         self.attachments.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
diff -r 9a5bf563940b -r 91b30931cd49 
tryton/gui/window/view_form/view/form_gtk/dictionary.py
--- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py   Sun Mar 06 
18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py   Wed Mar 09 
00:19:52 2022 +0100
@@ -18,7 +18,6 @@
 from tryton.common.entry_position import reset_position
 from tryton.common.number_entry import NumberEntry
 from tryton.common.selection import selection_shortcuts
-from tryton.common.treeviewcontrol import TreeViewControl
 from tryton.common.underline import set_underline
 from tryton.common.widget_style import widget_class
 from tryton.gui.window.win_search import WinSearch
@@ -187,7 +186,7 @@
         widget.set_size_request(100, 100)
 
         model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
-        self.tree = TreeViewControl()
+        self.tree = Gtk.TreeView()
         self.tree.set_model(model)
         self.tree.set_search_column(1)
         self.tree.connect(
diff -r 9a5bf563940b -r 91b30931cd49 
tryton/gui/window/view_form/view/form_gtk/multiselection.py
--- a/tryton/gui/window/view_form/view/form_gtk/multiselection.py       Sun Mar 
06 18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/multiselection.py       Wed Mar 
09 00:19:52 2022 +0100
@@ -3,7 +3,6 @@
 from gi.repository import GLib, GObject, Gtk
 
 from tryton.common.selection import SelectionMixin
-from tryton.common.treeviewcontrol import TreeViewControl
 
 from .widget import Widget
 
@@ -25,7 +24,7 @@
         self.widget.get_accessible().set_name(attrs.get('string', ''))
 
         self.model = Gtk.ListStore(GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
-        self.tree = self.mnemonic_widget = TreeViewControl()
+        self.tree = self.mnemonic_widget = Gtk.TreeView()
         self.tree.set_model(self.model)
         self.tree.set_search_column(1)
         self.tree.connect('focus-out-event', lambda *a: self._focus_out())
diff -r 9a5bf563940b -r 91b30931cd49 
tryton/gui/window/view_form/view/screen_container.py
--- a/tryton/gui/window/view_form/view/screen_container.py      Sun Mar 06 
18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/screen_container.py      Wed Mar 09 
00:19:52 2022 +0100
@@ -9,7 +9,6 @@
 from tryton.common.datetime_ import Date, DateTime, Time, add_operators
 from tryton.common.domain_parser import quote
 from tryton.common.number_entry import NumberEntry
-from tryton.common.treeviewcontrol import TreeViewControl
 from tryton.pyson import PYSONDecoder
 
 _ = gettext.gettext
@@ -153,7 +152,7 @@
 
     def __init__(self, selections):
         super(Selection, self).__init__()
-        self.treeview = TreeViewControl()
+        self.treeview = Gtk.TreeView()
         model = Gtk.ListStore(GObject.TYPE_STRING)
         for selection in selections:
             model.append((selection,))

Reply via email to