Fix deprecation warnings for Gtk.Widget.render_icon

[Gtk.Widget.render_icon](https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Widget.html#Gtk.Widget.render_icon)
has been deprecated since 3.0.

The replacement solution is to use Gtk.IconTheme.load_icon.

Most of `Gtk.STOCK_*` value are deprecated:
* `Gtk.STOCK_NEW` is now "document-new"
* `Gtk.STOCK_GO_FORWARD` is now "go-next"
* `Gtk.STOCK_GO_BACK` is now "go-previous"
This commit is contained in:
Romain Failliot 2020-03-28 18:10:42 -04:00
parent c1b88634e5
commit ff18e4a342
1 changed files with 6 additions and 3 deletions

View File

@ -7450,9 +7450,12 @@ class Diffuse(Gtk.Window):
DIFFUSE_STOCK_LEFT_RIGHT = 'diffuse-left-right'
DIFFUSE_STOCK_RIGHT_LEFT = 'diffuse-right-left'
default_theme = Gtk.IconTheme.get_default()
icon_size = Gtk.IconSize.lookup(Gtk.IconSize.LARGE_TOOLBAR).height
factory = Gtk.IconFactory()
# render the base item used to indicate a new document
p0 = self.render_icon(Gtk.STOCK_NEW, Gtk.IconSize.LARGE_TOOLBAR)
p0 = default_theme.load_icon("document-new", icon_size, 0)
w, h = p0.get_width(), p0.get_height()
# render new 2-way merge icon
@ -7478,8 +7481,8 @@ class Diffuse(Gtk.Window):
factory.add(DIFFUSE_STOCK_NEW_3WAY_MERGE, Gtk.IconSet.new_from_pixbuf(p))
# render the left and right arrow we will use in our custom icons
p0 = self.render_icon(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.LARGE_TOOLBAR)
p1 = self.render_icon(Gtk.STOCK_GO_BACK, Gtk.IconSize.LARGE_TOOLBAR)
p0 = default_theme.load_icon("go-next", icon_size, 0)
p1 = default_theme.load_icon("go-previous", icon_size, 0)
w, h, s = p0.get_width(), p0.get_height(), 0.65
sw, sh = int(s * w), int(s * h)
w1, h1 = w - sw, h - sh