tdf#145296 use a 'clickable' widget for custom spacing

Change-Id: I7c0b609a074a68dcc7ca4f6a775743e836a6caa7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124165
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index a5c812c..a007164 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -470,17 +470,17 @@ public:
    virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
private:
    rtl::Reference<svt::PopupWindowController> mxControl;
    std::unique_ptr<weld::RadioButton> mxVeryTight;
    std::unique_ptr<weld::RadioButton> mxTight;
    std::unique_ptr<weld::RadioButton> mxNormal;
    std::unique_ptr<weld::RadioButton> mxLoose;
    std::unique_ptr<weld::RadioButton> mxVeryLoose;
    std::unique_ptr<weld::RadioButton> mxCustom;
    std::unique_ptr<weld::ToggleButton> mxVeryTight;
    std::unique_ptr<weld::ToggleButton> mxTight;
    std::unique_ptr<weld::ToggleButton> mxNormal;
    std::unique_ptr<weld::ToggleButton> mxLoose;
    std::unique_ptr<weld::ToggleButton> mxVeryLoose;
    std::unique_ptr<weld::ToggleButton> mxCustom;
    std::unique_ptr<weld::CheckButton> mxKernPairs;
    bool mbSettingValue;

    DECL_LINK( KernSelectHdl, weld::Toggleable&, void );
    DECL_LINK( SelectHdl, weld::Toggleable&, void );
    DECL_LINK( SelectHdl, weld::Button&, void );

    void    implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
    void    implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled);
@@ -494,21 +494,21 @@ constexpr OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharac
FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
    : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkcharacterspacingcontrol.ui", "FontworkCharacterSpacingControl")
    , mxControl(pControl)
    , mxVeryTight(m_xBuilder->weld_radio_button("verytight"))
    , mxTight(m_xBuilder->weld_radio_button("tight"))
    , mxNormal(m_xBuilder->weld_radio_button("normal"))
    , mxLoose(m_xBuilder->weld_radio_button("loose"))
    , mxVeryLoose(m_xBuilder->weld_radio_button("veryloose"))
    , mxCustom(m_xBuilder->weld_radio_button("custom"))
    , mxVeryTight(m_xBuilder->weld_toggle_button("verytight"))
    , mxTight(m_xBuilder->weld_toggle_button("tight"))
    , mxNormal(m_xBuilder->weld_toggle_button("normal"))
    , mxLoose(m_xBuilder->weld_toggle_button("loose"))
    , mxVeryLoose(m_xBuilder->weld_toggle_button("veryloose"))
    , mxCustom(m_xBuilder->weld_toggle_button("custom"))
    , mxKernPairs(m_xBuilder->weld_check_button("kernpairs"))
    , mbSettingValue(false)
{
    mxVeryTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxNormal->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxVeryLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxCustom->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxVeryTight->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxTight->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxNormal->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxLoose->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxVeryLoose->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
    mxCustom->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));

    mxKernPairs->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, KernSelectHdl));

@@ -542,7 +542,6 @@ void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharact
    mxNormal->set_active(false);
    mxLoose->set_active(false);
    mxVeryLoose->set_active(false);
    mxCustom->set_active(true);

    switch(nCharacterSpacing)
    {
@@ -563,6 +562,12 @@ void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharact
            break;
    }

    mxCustom->set_active(!mxVeryTight->get_active() &&
                         !mxTight->get_active() &&
                         !mxNormal->get_active() &&
                         !mxLoose->get_active() &&
                         !mxVeryLoose->get_active());

    mbSettingValue = bSettingValue;
}

@@ -619,10 +624,14 @@ IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, KernSelectHdl, weld::Toggleable&
    mxControl->EndPopupMode();
}

IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Toggleable&, rButton, void)
IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Button&, rButton, void)
{
    if (!rButton.get_active())
        return;
    mxVeryTight->set_active(&rButton == mxVeryTight.get());
    mxTight->set_active(&rButton == mxTight.get());
    mxNormal->set_active(&rButton == mxNormal.get());
    mxLoose->set_active(&rButton == mxLoose.get());
    mxVeryLoose->set_active(&rButton == mxVeryLoose.get());
    mxCustom->set_active(&rButton == mxCustom.get());

    if (mbSettingValue)
        return;
diff --git a/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui b/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui
index aee1943..df7f5e1 100644
--- a/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui
+++ b/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui
@@ -1,121 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.38.2 -->
<interface domain="svx">
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkPopover" id="FontworkCharacterSpacingControl">
    <property name="can_focus">False</property>
    <property name="no_show_all">True</property>
    <property name="border_width">4</property>
    <property name="can-focus">False</property>
    <property name="no-show-all">True</property>
    <property name="border-width">4</property>
    <child>
      <!-- n-columns=1 n-rows=1 -->
      <!-- n-columns=1 n-rows=7 -->
      <object class="GtkGrid" id="container">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="can-focus">False</property>
        <property name="hexpand">True</property>
        <property name="vexpand">True</property>
        <property name="row_spacing">6</property>
        <property name="row-spacing">6</property>
        <child>
          <object class="GtkRadioButton" id="verytight">
          <object class="GtkToggleButton" id="verytight">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_VERY_TIGHT">_Very Tight</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="group">normal</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
            <property name="left-attach">0</property>
            <property name="top-attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkRadioButton" id="tight">
          <object class="GtkToggleButton" id="tight">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_TIGHT">_Tight</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="group">normal</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
            <property name="left-attach">0</property>
            <property name="top-attach">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkRadioButton" id="normal">
          <object class="GtkToggleButton" id="normal">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_NORMAL">_Normal</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
            <property name="active">True</property>
            <property name="draw_indicator">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">2</property>
            <property name="left-attach">0</property>
            <property name="top-attach">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkRadioButton" id="loose">
          <object class="GtkToggleButton" id="loose">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_LOOSE">_Loose</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="group">normal</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">3</property>
            <property name="left-attach">0</property>
            <property name="top-attach">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkRadioButton" id="veryloose">
          <object class="GtkToggleButton" id="veryloose">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_VERY_LOOSE">Very _Loose</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="group">normal</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">4</property>
            <property name="left-attach">0</property>
            <property name="top-attach">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkRadioButton" id="custom">
          <object class="GtkToggleButton" id="custom">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_CUSTOM">_Custom...</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="group">normal</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">5</property>
            <property name="left-attach">0</property>
            <property name="top-attach">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkCheckButton" id="kernpairs">
            <property name="label" translatable="yes" context="fontworkcharacterspacingcontrol|RID_SVXSTR_CHARS_SPACING_KERN_PAIRS">_Kern Character Pairs</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">False</property>
            <property name="use_underline">True</property>
            <property name="draw_indicator">True</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="use-underline">True</property>
            <property name="draw-indicator">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">6</property>
            <property name="left-attach">0</property>
            <property name="top-attach">6</property>
          </packing>
        </child>
      </object>