[pygobject] Do not override Treeview.enable_model_drag_xx for GTK4
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Do not override Treeview.enable_model_drag_xx for GTK4
- Date: Sun, 27 Mar 2022 13:51:35 +0000 (UTC)
commit 8ea38cd186f5e33d8e328a8b66180f7ca83abedc
Author: Arjan Molenaar <gaphor gmail com>
Date: Wed May 19 15:36:42 2021 +0200
Do not override Treeview.enable_model_drag_xx for GTK4
Those methods require a Gdk.ContentFormats object.
gi/overrides/Gtk.py | 22 ++++++++++++----------
tests/test_overrides_gtk.py | 15 ++++++++++++++-
2 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index f53ec6bd..d9ec6fbe 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1359,16 +1359,18 @@ class TreeView(Gtk.TreeView, Container):
get_visible_range = strip_boolean_result(Gtk.TreeView.get_visible_range)
get_dest_row_at_pos = strip_boolean_result(Gtk.TreeView.get_dest_row_at_pos)
- def enable_model_drag_source(self, start_button_mask, targets, actions):
- target_entries = _construct_target_list(targets)
- super(TreeView, self).enable_model_drag_source(start_button_mask,
- target_entries,
- actions)
-
- def enable_model_drag_dest(self, targets, actions):
- target_entries = _construct_target_list(targets)
- super(TreeView, self).enable_model_drag_dest(target_entries,
- actions)
+ if GTK2 or GTK3:
+ def enable_model_drag_source(self, start_button_mask, targets, actions):
+ target_entries = _construct_target_list(targets)
+ super(TreeView, self).enable_model_drag_source(start_button_mask,
+ target_entries,
+ actions)
+
+ if GTK2 or GTK3:
+ def enable_model_drag_dest(self, targets, actions):
+ target_entries = _construct_target_list(targets)
+ super(TreeView, self).enable_model_drag_dest(target_entries,
+ actions)
def scroll_to_cell(self, path, column=None, use_align=False, row_align=0.0, col_align=0.0):
if not isinstance(path, Gtk.TreePath):
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 6bd2345a..50c1ad8b 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -786,7 +786,7 @@ class TestGtk(unittest.TestCase):
@unittest.skipIf(sys.platform == "darwin", "crashes")
@unittest.skipIf(GTK4, "uses lots of gtk3 only api")
- def test_drag_target_list_gtk3(self):
+ def test_tree_view_drag_target_list_gtk3(self):
mixed_target_list = [Gtk.TargetEntry.new('test0', 0, 0),
('test1', 1, 1),
Gtk.TargetEntry.new('test2', 2, 2),
@@ -818,6 +818,19 @@ class TestGtk(unittest.TestCase):
treeview.enable_model_drag_dest(mixed_target_list,
Gdk.DragAction.DEFAULT | Gdk.DragAction.MOVE)
+ @unittest.skipUnless(GTK4, "gtk4 only")
+ def test_tree_view_drag_content_formats_gtk4(self):
+ content_formats = Gdk.ContentFormats.new(
+ ["application/json", "GTK_TREE_MODEL_ROW"]
+ )
+ treeview = Gtk.TreeView()
+ treeview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
+ content_formats,
+ Gdk.DragAction.MOVE)
+
+ treeview.enable_model_drag_dest(content_formats,
+ Gdk.DragAction.MOVE)
+
@unittest.skipIf(Gtk_version == "4.0", "not in gtk4")
def test_scrollbar(self):
adjustment = Gtk.Adjustment()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]