Skip to content

Convert the view buttons in the toolbar into radio buttons (Issue #925)

Manuel Grießmayr requested to merge (removed):pushed_buttons into master

Hi @alexxcons, I am happy to present my latest work to you 😄

Fixes #925 (closed)

Some notes regarding the implementation:

In #925 (closed) @lastonestanding wrote:

The "Search for Files..." button already has the described behavior, so looking up its code may help to implement this enhancement.

I thought that myself and then wondered why this is so difficult to implement. After a while I recognized I have to use another button type called GtkRadioToolButton. Maybe it's possible to implement the buttons as GtkToggleToolButton by disabling the signals temporarily but I have done it the official way without any workarounds now.

In function thunar_window_location_toolbar_create() I have to determine which radio view button is active on thunar startup. I tried to get this info by window->view_type and also by calling thunar_window_view_type_for_directory(). But that didn't work because I assume the values aren't initialised that early. Because of that I compare directly the string stored in xfconf like for example !g_strcmp0 (type_name, "ThunarIconView").

The function thunar_window_create_toolbar_radio_item_from_action() is a bit bigger regarding lines of code than the similar function thunar_window_create_toolbar_toggle_item_from_action(). That is because the is no helper function in libxfce4ui like xfce_gtk_toggle_tool_button_new_from_action_entry().

The radio buttons also behave correctly when the view changes with different tabs and also when the focus changes in the split view.

Merge request reports