Resolves: tdf#137786 allow 'toggling' GtkToolButtons

even if they are not GtkToggleToolButtons

We already allow this for GtkMenuToolButton, we shouldn't need to allow
it for a GtkToolButton because a GtkToggleToolButton should be used. But
we have inconsistency where some of these 'align' features are
considered toggleable by some apps or modes within an app and not by
others.

So when this inconsistency arises reuse the pseudo-toggle support
for GtkMenuToolButton for GtkToolButton.

Change-Id: I78b625b206bf6187e36fc39f876d4828ada10a7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105476
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit e1e662065c911e55aeb85a67664dea9d5ed12313)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105463
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 828549eb..643ec0c 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8018,8 +8018,9 @@ public:

        GtkToolItem* pToolButton = m_aMap.find(rIdent)->second;

        assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || GTK_IS_MENU_TOOL_BUTTON(pToolButton) || !bActive);
        if (GTK_IS_MENU_TOOL_BUTTON(pToolButton))
        if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
            gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive);
        else
        {
            GtkButton* pButton = nullptr;
            // there is no GtkMenuToggleToolButton so abuse the CHECKED state of the GtkMenuToolButton button
@@ -8033,8 +8034,6 @@ public:
                gtk_widget_set_state_flags(GTK_WIDGET(pButton), static_cast<GtkStateFlags>(eState), true);
            }
        }
        else if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
            gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive);

        enable_item_notify_events();
    }
@@ -8043,8 +8042,9 @@ public:
    {
        GtkToolItem* pToolButton = m_aMap.find(rIdent)->second;

        assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || GTK_IS_MENU_TOOL_BUTTON(pToolButton));
        if (GTK_IS_MENU_TOOL_BUTTON(pToolButton))
        if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
            return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton));
        else
        {
            GtkButton* pButton = nullptr;
            // there is no GtkMenuToggleToolButton so abuse the CHECKED state of the GtkMenuToolButton button
@@ -8055,8 +8055,6 @@ public:
                return gtk_widget_get_state_flags(GTK_WIDGET(pButton)) & GTK_STATE_FLAG_CHECKED;
            }
        }
        else if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
            return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton));

        return false;
    }