Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5445d77

Browse files
authored
Merge pull request #17539 from QuLogic/gtk-symbolic-icons
Use symbolic icons for buttons in GTK toolbar.
2 parents da3baa1 + 82877b7 commit 5445d77

9 files changed

+18
-7
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# auto-backend selection logic correctly skips.
2828
raise ImportError from e
2929

30-
from gi.repository import GLib, GObject, Gtk, Gdk
30+
from gi.repository import Gio, GLib, GObject, Gtk, Gdk
3131

3232

3333
_log = logging.getLogger(__name__)
@@ -464,9 +464,11 @@ def __init__(self, canvas, window):
464464
if text is None:
465465
self.insert(Gtk.SeparatorToolItem(), -1)
466466
continue
467-
image = Gtk.Image()
468-
image.set_from_file(
469-
str(cbook._get_data_path('images', image_file + '.png')))
467+
image = Gtk.Image.new_from_gicon(
468+
Gio.Icon.new_for_string(
469+
str(cbook._get_data_path('images',
470+
f'{image_file}-symbolic.svg'))),
471+
Gtk.IconSize.LARGE_TOOLBAR)
470472
self._gtk_ids[text] = tbutton = (
471473
Gtk.ToggleToolButton() if callback in ['zoom', 'pan'] else
472474
Gtk.ToolButton())
@@ -623,7 +625,7 @@ def set_history_buttons(self):
623625

624626

625627
class ToolbarGTK3(ToolContainerBase, Gtk.Box):
626-
_icon_extension = '.png'
628+
_icon_extension = '-symbolic.svg'
627629

628630
def __init__(self, toolmanager):
629631
ToolContainerBase.__init__(self, toolmanager)
@@ -644,8 +646,9 @@ def add_toolitem(self, name, group, position, image_file, description,
644646
tbutton.set_label(name)
645647

646648
if image_file is not None:
647-
image = Gtk.Image()
648-
image.set_from_file(image_file)
649+
image = Gtk.Image.new_from_gicon(
650+
Gio.Icon.new_for_string(image_file),
651+
Gtk.IconSize.LARGE_TOOLBAR)
649652
tbutton.set_icon_widget(image)
650653

651654
if position is None:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
back.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
filesave.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
forward.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
help.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
home.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
move.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subplots.svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
zoom_to_rect.svg

0 commit comments

Comments
 (0)