Skip to content

Use a toggle button for the MIME chooser dropdown buttons

The current code uses a regular GtkButton, and connects to the long-deprecated "pressed" signal to pop up the dropdown menu while the button is still in the "pressed in" state.

There was a dodgy use of a manual button-release-event emission that was causing an invalid memory read, though in practice it was likely mostly harmless. When fixing this, the dropdowns more or less broke as well.

I noticed that it was also using a recursive main loop in the pressed signal handler to delay the button-release event until after the menu had been dismissed, another hack.

Instead, we can more or less equivalently use GtkToggleButton, and pop up the menu when the button is toggled to the active state, and then reset the button to the inactive state when the menu is dismissed. It doesn't quite look exactly the same (depending on theme), but it's close enough, and ultimately the purpose of this custom widget is to behave like a GtkMenuButton (which is a GtkToggleButton subclass), except allowing the code to lazy-load the dropdown menu's contents, which isn't possible with GtkMenuButton.

Closes #548 (closed)

Merge request reports