diff --git a/src/damaris/gui/DamarisGUI.py b/src/damaris/gui/DamarisGUI.py index b9716e7..279d83f 100644 --- a/src/damaris/gui/DamarisGUI.py +++ b/src/damaris/gui/DamarisGUI.py @@ -17,6 +17,7 @@ import tempfile import gi gi.require_version('Gtk', '3.0') gi.require_version('GtkSource', '3.0') +gi.require_version('GdkPixbuf', '2.0') # import 3rd party modules # gui graphics @@ -32,6 +33,7 @@ if gtk_version_missmatch: raise Exception( "insufficient gtk version: " + gtk_version_missmatch ) from gi.repository import Gdk as gdk +from gi.repository import GdkPixbuf from gi.repository import GtkSource as gtksourceview @@ -2976,6 +2978,39 @@ pygobject version %(pygobject)s configfile.write( "\n" ) +# crosshair icon for the display toolbar, drawn from inline XPM data +# so it does not depend on an installed icon theme +crosshair_xpm = ( + "24 24 2 1", + " c None", + ". c #cc0000", + " .. ", + " .. ", + " .. ", + " .. ", + " .. ", + " ", + " ", + " ...... ", + " . . ", + " . . ", + " . .... . ", + "..... . .... . .....", + "..... . .... . .....", + " . .... . ", + " . . ", + " . . ", + " ...... ", + " ", + " ", + " .. ", + " .. ", + " .. ", + " .. ", + " .. ", + ) + + class MonitorWidgets: """Manages the matplotlib-based data visualization panel. @@ -3082,13 +3117,10 @@ class MonitorWidgets: self.matplot_toolbar.remove(self.matplot_toolbar.get_nth_item(6)) # now let's add a button to the toolbar self.matplot_cursor_button = gtk.ToggleButton(label='') - try: - icon_theme = gtk.IconTheme.get_default() - icon = icon_theme.load_icon("crosshairs", 24, 0) - image = gtk.Image.new_from_pixbuf(icon) - self.matplot_cursor_button.set_image(image) - except: - pass + cursor_icon = GdkPixbuf.Pixbuf.new_from_xpm_data( crosshair_xpm ) + self.matplot_cursor_button.set_image( gtk.Image.new_from_pixbuf( cursor_icon ) ) + # gtk-button-images is False on many desktops, which would hide the icon + self.matplot_cursor_button.set_always_show_image( True ) self.matplot_cursor_button.set_tooltip_text('Enable Crosshairs') self.matplot_cursor_button.show() self.matplot_cursor_button.connect('toggled', self.toggle_cursor)