Fix PyGObject-3.11 DeprecationWarning
GObject.idle_add() ==> GLib.idle_add()
This commit is contained in:
parent
0af1c0bf41
commit
fc40578687
@ -285,7 +285,7 @@ class Gramplet(object):
|
||||
"""
|
||||
The main interface for running the :meth:`main` method.
|
||||
"""
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
if ((not self.active or
|
||||
self.gui.gstate in ["closed", "minimized"] or
|
||||
not self.dbstate.open) and
|
||||
@ -304,7 +304,7 @@ class Gramplet(object):
|
||||
self.interrupt()
|
||||
self._generator = self.main()
|
||||
self._pause = False
|
||||
self._idle_id = GObject.idle_add(self._updater,
|
||||
self._idle_id = GLib.idle_add(self._updater,
|
||||
priority=GObject.PRIORITY_LOW - 10)
|
||||
|
||||
def _updater(self):
|
||||
@ -361,9 +361,9 @@ class Gramplet(object):
|
||||
"""
|
||||
Resume the :meth:`main` method that has previously paused.
|
||||
"""
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, Glib
|
||||
self._pause = False
|
||||
self._idle_id = GObject.idle_add(self._updater,
|
||||
self._idle_id = GLib.idle_add(self._updater,
|
||||
priority=GObject.PRIORITY_LOW - 10)
|
||||
|
||||
def update_all(self, *args):
|
||||
|
@ -31,7 +31,7 @@ Address List display tab.
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -124,7 +124,7 @@ class AddrEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(name)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
"""
|
||||
|
@ -25,7 +25,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -74,7 +74,7 @@ class AltNameEmbedList(EmbeddedList):
|
||||
def add_callback(self, place_name):
|
||||
data = self.get_data()
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
place_name = self.get_selected()
|
||||
|
@ -27,7 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -108,7 +108,7 @@ class AttrEmbedList(EmbeddedList):
|
||||
data.append(name)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data)-1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data)-1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
attr = self.get_selected()
|
||||
|
@ -30,6 +30,7 @@ import sys
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib
|
||||
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
@ -57,9 +58,9 @@ class BackRefModel(Gtk.ListStore):
|
||||
self.sref_list = sref_list
|
||||
self.count = 0
|
||||
if sys.version_info[0] < 3:
|
||||
self.idle = GObject.idle_add(self.load_model().next)
|
||||
self.idle = GLib.idle_add(self.load_model().next)
|
||||
else:
|
||||
self.idle = GObject.idle_add(self.load_model().__next__)
|
||||
self.idle = GLib.idle_add(self.load_model().__next__)
|
||||
|
||||
def destroy(self):
|
||||
GObject.source_remove(self.idle)
|
||||
@ -68,7 +69,7 @@ class BackRefModel(Gtk.ListStore):
|
||||
"""
|
||||
Objects can have very large backreferences. To avoid blocking the
|
||||
interface up to the moment that the model is created, this method is
|
||||
called via GObject.idle_add.
|
||||
called via GLib.idle_add.
|
||||
WARNING: a consequence of above is that loading can still be happening
|
||||
while the GUI using this model is no longer used. Disconnect any
|
||||
methods before closing the GUI.
|
||||
|
@ -36,7 +36,7 @@ LOG = logging.getLogger(".citation")
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -152,7 +152,7 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
|
||||
self.callman.register_handles({'citation': [value]})
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def share_button_clicked(self, obj):
|
||||
SelectCitation = SelectorFactory('Citation')
|
||||
|
@ -40,6 +40,7 @@ else:
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
@ -346,7 +347,7 @@ class EmbeddedList(ButtonTab):
|
||||
self.tree.get_selection().select_path(path)
|
||||
# The height/location of Gtk.treecells is calculated in an idle handler
|
||||
# so use idle_add to scroll cell into view.
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
|
||||
def _move_down(self, row_from, obj, selmethod=None):
|
||||
"""
|
||||
@ -364,7 +365,7 @@ class EmbeddedList(ButtonTab):
|
||||
#select the row
|
||||
path = '%d' % (row_from+1)
|
||||
self.tree.get_selection().select_path(path)
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
|
||||
def get_icon_name(self):
|
||||
"""
|
||||
@ -599,7 +600,7 @@ class EmbeddedList(ButtonTab):
|
||||
self.dirty_selection = False
|
||||
self._selection_changed()
|
||||
if self.tree.get_realized():
|
||||
GObject.idle_add(self.tree.scroll_to_point, offset.x, offset.y)
|
||||
GLib.idle_add(self.tree.scroll_to_point, offset.x, offset.y)
|
||||
self.post_rebuild(selectedpath)
|
||||
|
||||
def post_rebuild(self, prebuildpath):
|
||||
|
@ -30,6 +30,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -290,7 +291,7 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
|
||||
self.callman.register_handles({'event': [primary.handle]})
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell,
|
||||
GLib.idle_add(self.tree.scroll_to_cell,
|
||||
(self._WORKGROUP, len(data) - 1))
|
||||
|
||||
def object_edited(self, ref, event):
|
||||
|
@ -51,6 +51,7 @@ from gi.repository import GdkPixbuf
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -311,7 +312,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
itr_last = model.iter_nth_child(None, len(data) - 1)
|
||||
if itr_last:
|
||||
path = model.get_path(itr_last)
|
||||
GObject.idle_add(self.iconlist.scroll_to_path, path, False,
|
||||
GLib.idle_add(self.iconlist.scroll_to_path, path, False,
|
||||
0.0, 0.0)
|
||||
|
||||
def __blocked_text(self):
|
||||
|
@ -41,6 +41,7 @@ from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS classes
|
||||
@ -320,7 +321,7 @@ class GroupEmbeddedList(EmbeddedList):
|
||||
#select the row
|
||||
path = (self._WORKGROUP, row_from[1]-1)
|
||||
self.tree.get_selection().select_path(path)
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
else:
|
||||
self._move_up_notwork(row_from, obj, selmethod)
|
||||
|
||||
@ -353,7 +354,7 @@ class GroupEmbeddedList(EmbeddedList):
|
||||
#select the row
|
||||
path = (self._WORKGROUP, row_from[1]+1)
|
||||
self.tree.get_selection().select_path(path)
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
else:
|
||||
self._move_down_notwork(row_from, obj, selmethod)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -97,7 +97,7 @@ class LdsEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(name)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
lds = self.get_selected()
|
||||
|
@ -27,7 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -86,7 +86,7 @@ class LocationEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(name)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
loc = self.get_selected()
|
||||
|
@ -28,6 +28,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -170,7 +171,7 @@ class NameEmbedList(GroupEmbeddedList):
|
||||
data = self.get_data()[self._WORKGROUP]
|
||||
data.append(name)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell,
|
||||
GLib.idle_add(self.tree.scroll_to_cell,
|
||||
(self._WORKGROUP, len(data) - 1))
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
|
@ -34,6 +34,7 @@ _ = glocale.translation.gettext
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -149,7 +150,7 @@ class NoteTab(EmbeddedList, DbGUIElement):
|
||||
self.callman.register_handles({'note': [name]})
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
"""
|
||||
|
@ -29,6 +29,7 @@
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -155,7 +156,7 @@ class PersonEventEmbedList(EventEmbedList):
|
||||
# New index is index-1 but for path, add another 1 for person events.
|
||||
path = (index,)
|
||||
self.tree.get_selection().select_path(path)
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
|
||||
def _move_down_group(self, groupindex):
|
||||
"""
|
||||
@ -183,4 +184,4 @@ class PersonEventEmbedList(EventEmbedList):
|
||||
# New index is index+1 but for path, add another 1 for person events.
|
||||
path = (index + 2,)
|
||||
self.tree.get_selection().select_path(path)
|
||||
GObject.idle_add(self.tree.scroll_to_cell, path)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, path)
|
||||
|
@ -28,6 +28,7 @@
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -98,7 +99,7 @@ class PersonRefEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(obj)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
from .. import EditPersonRef
|
||||
|
@ -28,6 +28,7 @@
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -86,7 +87,7 @@ class PlaceRefEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(name)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
placeref = self.get_selected()
|
||||
|
@ -27,7 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -153,7 +153,7 @@ class RepoEmbedList(EmbeddedList, DbGUIElement):
|
||||
self.callman.register_handles({'repository': [value[1].handle]})
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
ref = self.get_selected()
|
||||
|
@ -27,7 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -145,7 +145,7 @@ class SrcAttrEmbedList(EmbeddedList):
|
||||
data.append(name)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data)-1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data)-1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
attr = self.get_selected()
|
||||
|
@ -29,6 +29,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -96,7 +97,7 @@ class WebEmbedList(EmbeddedList):
|
||||
data = self.get_data()
|
||||
data.append(url)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
GLib.idle_add(self.tree.scroll_to_cell, len(data) - 1)
|
||||
|
||||
def edit_button_clicked(self, obj):
|
||||
from .. import EditUrl
|
||||
|
@ -60,6 +60,7 @@ from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Pango
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -204,7 +205,7 @@ class ChildEmbedList(EmbeddedList):
|
||||
ref.ref = person.get_handle()
|
||||
self.family.add_child_ref(ref)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell,
|
||||
GLib.idle_add(self.tree.scroll_to_cell,
|
||||
len(self.family.get_child_ref_list()) - 1)
|
||||
self.call_edit_childref(ref)
|
||||
|
||||
@ -226,7 +227,7 @@ class ChildEmbedList(EmbeddedList):
|
||||
ref.ref = person.get_handle()
|
||||
self.family.add_child_ref(ref)
|
||||
self.rebuild()
|
||||
GObject.idle_add(self.tree.scroll_to_cell,
|
||||
GLib.idle_add(self.tree.scroll_to_cell,
|
||||
len(self.family.get_child_ref_list()) - 1)
|
||||
self.call_edit_childref(ref)
|
||||
|
||||
|
@ -42,6 +42,7 @@ _LOG = logging.getLogger(".widgets.validatedmaskedentry")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GdkPixbuf
|
||||
@ -736,7 +737,7 @@ class MaskedEntry(UndoableEntry):
|
||||
if field is not False:
|
||||
pos = self.get_field_pos(field+1)
|
||||
if pos is not None:
|
||||
GObject.idle_add(self.set_position, pos)
|
||||
GLib.idle_add(self.set_position, pos)
|
||||
return pos
|
||||
|
||||
return None
|
||||
@ -795,11 +796,11 @@ class MaskedEntry(UndoableEntry):
|
||||
# text[pos+length:end]+
|
||||
# text[end:])
|
||||
new_pos = pos+1
|
||||
GObject.idle_add(self.set_position, new_pos)
|
||||
GLib.idle_add(self.set_position, new_pos)
|
||||
|
||||
# If the field is full, jump to the next field
|
||||
if len(self.get_field_text(field)) == self.get_field_length(field)-1:
|
||||
GObject.idle_add(self.set_field, field+1, True)
|
||||
GLib.idle_add(self.set_field, field+1, True)
|
||||
self.set_field(field+1)
|
||||
|
||||
return new_pos, new_text
|
||||
|
Loading…
Reference in New Issue
Block a user