From fe6507398889fe49a8a4f8b61859259ce7e4c361 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Sun, 18 Oct 2026 17:47:59 +0200 Subject: [PATCH] draw the crosshair toolbar icon from inline XPM data The crosshair toggle button loaded the "crosshairs" icon from the icon theme inside a bare try/except, so on systems without that icon the button was empty and invisible. Replace it with a self-contained red reticle (circle, center dot, cross arms) drawn from inline XPM data, and set always-show-image so the desktop default gtk-button-images=False cannot hide it. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- src/damaris/gui/DamarisGUI.py | 46 +++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) 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)