From ee709d2722a75f11b5f6c9d7cd9b4a925107e54f Mon Sep 17 00:00:00 2001 From: Neui Date: Wed, 21 Apr 2021 01:58:40 +0200 Subject: [PATCH] Remove Gdk.Cursor.new depredation warnings Gdk.Cursor.new has been replaced by Gdk.Cursor.new_for_display, which needs an additional display. It was only used to set the cursor on windows, which has an display associated with it, so now it is created when needed rather than being cached. --- GTG/gtk/editor/taskview.py | 12 ++++++------ GTG/plugins/unmaintained/tomboy/tomboy.py | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/GTG/gtk/editor/taskview.py b/GTG/gtk/editor/taskview.py index 7f73fbb3..4b510499 100644 --- a/GTG/gtk/editor/taskview.py +++ b/GTG/gtk/editor/taskview.py @@ -74,10 +74,6 @@ class TaskView(Gtk.TextView): # Timeout in milliseconds PROCESSING_DELAY = 250 - # Mouse cursors - CURSOR_HAND = Gdk.Cursor.new(Gdk.CursorType.HAND2) - CURSOR_NORMAL = Gdk.Cursor.new(Gdk.CursorType.XTERM) - def __init__(self, req: Requester, clipboard) -> None: super().__init__() @@ -601,7 +597,9 @@ class TaskView(Gtk.TextView): tags = view.get_iter_at_location(x, y)[1].get_tags() # Reset cursor and hover states - window.set_cursor(self.CURSOR_NORMAL) + cursor = Gdk.Cursor.new_for_display(window.get_display(), + Gdk.CursorType.XTERM) + window.set_cursor(cursor) if self.hovered_tag: try: @@ -615,7 +613,9 @@ class TaskView(Gtk.TextView): try: tag = tags[0] tag.set_hover() - window.set_cursor(self.CURSOR_HAND) + cursor = Gdk.Cursor.new_for_display(window.get_display(), + Gdk.CursorType.HAND2) + window.set_cursor(cursor) self.hovered_tag = tag except (AttributeError, IndexError): diff --git a/GTG/plugins/unmaintained/tomboy/tomboy.py b/GTG/plugins/unmaintained/tomboy/tomboy.py index 33ec9264..28c4226a 100644 --- a/GTG/plugins/unmaintained/tomboy/tomboy.py +++ b/GTG/plugins/unmaintained/tomboy/tomboy.py @@ -337,6 +337,8 @@ class TomboyPlugin(): # cursor changes to a hand def realize_callback(widget): - eventbox.window.set_cursor(Gdk.Cursor.new(Gdk.HAND2)) + cursor = Gdk.Cursor.new_for_display(eventbox.window.get_display(), + Gdk.CursorType.HAND2) + eventbox.window.set_cursor(cursor) eventbox.connect("realize", realize_callback) return eventbox -- 2.30.0