Refactory toolbox - Improve handling of "clicked" signal to reduce resource usage
Version
Commit 0997887d
Description
The toolbox is located to the left in the main windows. It provide the buttons to create diagram objects and tools.
On button activation, mouse click, the signal “clicked” is emitted by GTK. The callback connected to this signal is toolbox::tool_select_update. This function unpack arguments and calls the function tool::tool_select. The tool_select function select the tool or object to be created given the type of button selected by the user. A very neat 3 step process, callback, select and create.
Issue
The signal “clicked” is called twice by GTK. The first signal is on the button being deselected and the second on the button being selected. Assume the modify tool is active, the default, and the user selects uml class, then the modify tool button emits the first signal and uml class button the second.
The current code make no difference between those two signals. As a result a new modify tool is created on the first signal and then destroyed on the second signal. This could be improved.
The GTK provide the function gtk_toggle_button_get_active that can be used to detect status of button. It return false on the first signal since the button is deactivated. For the second signal from the active button it return true.
Effects
Improves resource usage, no behavior change to the UI.
Setup
Some additional log lines to the effected functions.
Test case
Manually.
This effect all tools since it is a change to the event handling. It is not clear if this have side effect.