Skip to content

Conversation

@Uks2
Copy link
Contributor

@Uks2 Uks2 commented Jan 18, 2025

The update_toolbar_buttons function, which is called whenever a codebox is reconfigured or when codebox toolbars are en-/disabled, works by removing all the toolbar buttons and readding them as necessary. It was using the _toolbar.append() function which sets up the buttons' callback at the same time. Because the ToolbarButton objects are persistent, an extra copy of the callback was being connected each time the button was removed and readded, so Gtk thought we wanted to run it multiple times.

Now, the buttons' callbacks are setup once using
signal_clicked().connect() in the codebox constructor and the update_toolbar_buttons function uses _toolbar.insert() which doesn't affect the callbacks at all.

Fixes #2628

The `update_toolbar_buttons` function, which is called whenever a
codebox is reconfigured or when codebox toolbars are en-/disabled, works
by removing all the toolbar buttons and readding them as necessary.  It
was using the `_toolbar.append()` function which sets up the buttons'
callback at the same time.  Because the ToolbarButton objects are
persistent, an extra copy of the callback was being connected each time
the button was removed and readded, so Gtk thought we wanted to run it
multiple times.

Now, the buttons' callbacks are setup once using
`signal_clicked().connect()` in the codebox constructor and the
`update_toolbar_buttons` function uses `_toolbar.insert()` which doesn't
affect the callbacks at all.

Fixes giuspen#2628
@giuspen giuspen merged commit 895faaa into giuspen:master Jan 18, 2025
@giuspen
Copy link
Owner

giuspen commented Jan 18, 2025

Nice one thanks @Uks2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing the syntax of a codebox

2 participants