From 55c99fe718d562e48a8ea996696462ea92220485 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 28 Jun 2016 16:24:21 -0500 Subject: [PATCH] Gdk.Cursor.new() deprecation fixes --- gramps/gui/dbman.py | 6 +++- gramps/gui/displaystate.py | 3 +- gramps/gui/plug/_windows.py | 8 ++++-- gramps/gui/plug/export/_exportassistant.py | 5 +++- gramps/gui/widgets/expandcollapsearrow.py | 3 +- gramps/gui/widgets/grabbers.py | 32 ++++++++++++++++------ gramps/gui/widgets/grampletpane.py | 8 ++++-- gramps/gui/widgets/labels.py | 3 +- gramps/plugins/tool/removeunused.py | 5 +++- gramps/plugins/tool/verify.py | 6 ++-- gramps/plugins/view/pedigreeview.py | 6 +++- 11 files changed, 64 insertions(+), 21 deletions(-) diff --git a/gramps/gui/dbman.py b/gramps/gui/dbman.py index 28b18f285..303ce9986 100644 --- a/gramps/gui/dbman.py +++ b/gramps/gui/dbman.py @@ -110,6 +110,7 @@ BACKEND_COL = 7 RCS_BUTTON = {True : _('_Extract'), False : _('_Archive')} class Information(ManagedWindow): + def __init__(self, uistate, data, parent): super().__init__(uistate, [], self) self.window = Gtk.Dialog() @@ -154,6 +155,9 @@ class DbManager(CLIDbManager): ERROR = ErrorDialog + BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.WATCH) + def __init__(self, uistate, dbstate, parent=None): """ Create the top level window from the glade description, and extracts @@ -936,7 +940,7 @@ class DbManager(CLIDbManager): message """ self.msg.set_label(msg) - self.top.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) + self.top.get_window().set_cursor(self.BUSY_CURSOR) while Gtk.events_pending(): Gtk.main_iteration() diff --git a/gramps/gui/displaystate.py b/gramps/gui/displaystate.py index 432061bb6..74a07c69b 100644 --- a/gramps/gui/displaystate.py +++ b/gramps/gui/displaystate.py @@ -386,7 +386,8 @@ class DisplayState(Callback): 'Note': _("No active note"), } - BUSY_CURSOR = Gdk.Cursor.new(Gdk.CursorType.WATCH) + BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.WATCH) def __init__(self, window, status, uimanager, viewmanager=None): diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index f1384a034..e717e4d6e 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -759,8 +759,12 @@ class ToolManagedWindowBase(ManagedWindow): self.results_text.connect('motion-notify-event', self.on_motion) self.tags = [] - self.link_cursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR) - self.standard_cursor = Gdk.Cursor.new(Gdk.CursorType.XTERM) + self.link_cursor = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.LEFT_PTR) + self.standard_cursor = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.XTERM) self.setup_other_frames() self.set_current_frame(self.initial_frame()) diff --git a/gramps/gui/plug/export/_exportassistant.py b/gramps/gui/plug/export/_exportassistant.py index 96109fb39..99982879a 100644 --- a/gramps/gui/plug/export/_exportassistant.py +++ b/gramps/gui/plug/export/_exportassistant.py @@ -625,8 +625,11 @@ class ExportAssistant(Gtk.Assistant, ManagedWindow) : a part of ManagedWindow """ + BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.WATCH) + if value: - self.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) + self.get_window().set_cursor(BUSY_CURSOR) #self.set_sensitive(0) else: self.get_window().set_cursor(None) diff --git a/gramps/gui/widgets/expandcollapsearrow.py b/gramps/gui/widgets/expandcollapsearrow.py index 088df7ada..361af09fa 100644 --- a/gramps/gui/widgets/expandcollapsearrow.py +++ b/gramps/gui/widgets/expandcollapsearrow.py @@ -46,7 +46,8 @@ from gramps.gen.constfunc import has_display # #------------------------------------------------------------------------- if has_display(): - HAND_CURSOR = Gdk.Cursor.new(Gdk.CursorType.HAND2) + HAND_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.HAND2) #------------------------------------------------------------------------- # diff --git a/gramps/gui/widgets/grabbers.py b/gramps/gui/widgets/grabbers.py index c1f579d62..98acd7c8c 100644 --- a/gramps/gui/widgets/grabbers.py +++ b/gramps/gui/widgets/grabbers.py @@ -197,14 +197,30 @@ GRABBERS_SWITCH = [ # cursors try: - CURSOR_UPPER = Gdk.Cursor.new(Gdk.CursorType.TOP_SIDE) - CURSOR_LOWER = Gdk.Cursor.new(Gdk.CursorType.BOTTOM_SIDE) - CURSOR_LEFT = Gdk.Cursor.new(Gdk.CursorType.LEFT_SIDE) - CURSOR_RIGHT = Gdk.Cursor.new(Gdk.CursorType.RIGHT_SIDE) - CURSOR_UPPER_LEFT = Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_CORNER) - CURSOR_UPPER_RIGHT = Gdk.Cursor.new(Gdk.CursorType.TOP_RIGHT_CORNER) - CURSOR_LOWER_LEFT = Gdk.Cursor.new(Gdk.CursorType.BOTTOM_LEFT_CORNER) - CURSOR_LOWER_RIGHT = Gdk.Cursor.new(Gdk.CursorType.BOTTOM_RIGHT_CORNER) + CURSOR_UPPER = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.TOP_SIDE) + CURSOR_LOWER = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.BOTTOM_SIDE) + CURSOR_LEFT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.LEFT_SIDE) + CURSOR_RIGHT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.RIGHT_SIDE) + CURSOR_UPPER_LEFT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.TOP_LEFT_CORNER) + CURSOR_UPPER_RIGHT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.TOP_RIGHT_CORNER) + CURSOR_LOWER_LEFT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.BOTTOM_LEFT_CORNER) + CURSOR_LOWER_RIGHT = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.BOTTOM_RIGHT_CORNER) except: CURSOR_UPPER = None CURSOR_LOWER = None diff --git a/gramps/gui/widgets/grampletpane.py b/gramps/gui/widgets/grampletpane.py index fa6089257..590201d7a 100644 --- a/gramps/gui/widgets/grampletpane.py +++ b/gramps/gui/widgets/grampletpane.py @@ -372,8 +372,12 @@ class GuiGramplet: self.pui = None # user code self.tooltips_text = None - self.link_cursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR) - self.standard_cursor = Gdk.Cursor.new(Gdk.CursorType.XTERM) + self.link_cursor = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.LEFT_PTR) + self.standard_cursor = \ + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.XTERM) self.scrolledwindow = None self.textview = None diff --git a/gramps/gui/widgets/labels.py b/gramps/gui/widgets/labels.py index 6ba673bc8..8890c7fed 100644 --- a/gramps/gui/widgets/labels.py +++ b/gramps/gui/widgets/labels.py @@ -56,7 +56,8 @@ from ..utils import rgb_to_hex # #------------------------------------------------------------------------- if has_display(): - HAND_CURSOR = Gdk.Cursor.new(Gdk.CursorType.HAND2) + HAND_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.HAND2) #------------------------------------------------------------------------- # diff --git a/gramps/plugins/tool/removeunused.py b/gramps/plugins/tool/removeunused.py index 81b4ef9ed..0f95bb3af 100644 --- a/gramps/plugins/tool/removeunused.py +++ b/gramps/plugins/tool/removeunused.py @@ -61,6 +61,9 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): OBJ_TYPE_COL = 3 OBJ_HANDLE_COL = 4 + BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.WATCH) + def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.title = _('Unused Objects') @@ -236,7 +239,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): self.uistate.set_busy_cursor(True) self.uistate.progress.show() - self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) + self.window.get_window().set_cursor(self.BUSY_CURSOR) self.real_model.clear() self.collect_unused() diff --git a/gramps/plugins/tool/verify.py b/gramps/plugins/tool/verify.py index 6de6ec98f..33142e955 100644 --- a/gramps/plugins/tool/verify.py +++ b/gramps/plugins/tool/verify.py @@ -349,9 +349,11 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback): self.uistate.set_busy_cursor(True) self.uistate.progress.show() - self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) + BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.WATCH) + self.window.get_window().set_cursor(BUSY_CURSOR) try: - self.vr.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) + self.vr.window.get_window().set_cursor(BUSY_CURSOR) except AttributeError: pass diff --git a/gramps/plugins/view/pedigreeview.py b/gramps/plugins/view/pedigreeview.py index 7df11f1fa..140f47cf7 100644 --- a/gramps/plugins/view/pedigreeview.py +++ b/gramps/plugins/view/pedigreeview.py @@ -508,6 +508,10 @@ class PedigreeView(NavigationView): ('interface.pedview-show-unknown-people', True), ) + FLEUR_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), + Gdk.CursorType.FLEUR) + + def __init__(self, pdata, dbstate, uistate, nav_group=0): NavigationView.__init__(self, _('Pedigree'), pdata, dbstate, uistate, PersonBookmarks, nav_group) @@ -1325,7 +1329,7 @@ class PedigreeView(NavigationView): or call option menu. """ if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS: - widget.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.FLEUR)) + widget.get_window().set_cursor(self.FLEUR_CURSOR) self._last_x = event.x self._last_y = event.y self._in_move = True