Skip to content

Use symbolic icons for buttons in GTK toolbar. #17539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# auto-backend selection logic correctly skips.
raise ImportError from e

from gi.repository import GLib, GObject, Gtk, Gdk
from gi.repository import Gio, GLib, GObject, Gtk, Gdk


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


class ToolbarGTK3(ToolContainerBase, Gtk.Box):
_icon_extension = '.png'
_icon_extension = '-symbolic.svg'

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

if image_file is not None:
image = Gtk.Image()
image.set_from_file(image_file)
image = Gtk.Image.new_from_gicon(
Gio.Icon.new_for_string(image_file),
Gtk.IconSize.LARGE_TOOLBAR)
tbutton.set_icon_widget(image)

if position is None:
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/back-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/filesave-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/forward-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/help-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/home-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/move-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/subplots-symbolic.svg
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg