You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libreoffice/0001-setting-has-default-tr...

106 lines
4.1 KiB

From b1c1b0d4336f0acfa3696d0b83349acbce613b18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Thu, 31 Oct 2019 10:57:31 +0000
Subject: [PATCH] setting has-default true on an element in a GtkPopover is
fatal
in gtk 3.24.12 at least.
in ColorWindow explicitly track which button is the 'default' one for the two
modes instead of using get/use-default and then just grab_focus instead of
setting has-default for these popover cases
Change-Id: Ia226f847f666d2356c6ea4e8c47f5db8e2535410
---
include/svx/colorwindow.hxx | 1 +
svtools/source/control/ctrlbox.cxx | 4 ++--
svx/source/tbxctrls/tbcontrl.cxx | 14 ++++++++------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index 45a5a8b30343..c3863f80ee80 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -149,6 +149,7 @@ private:
std::unique_ptr<weld::Widget> mxAutomaticSeparator;
std::unique_ptr<weld::CustomWeld> mxColorSetWin;
std::unique_ptr<weld::CustomWeld> mxRecentColorSetWin;
+ weld::Button* mpDefaultButton;
DECL_LINK(SelectHdl, SvtValueSet*, void);
DECL_LINK(SelectPaletteHdl, weld::ComboBox&, void);
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index d67c69dce9e3..61d1d9e729ac 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1597,12 +1597,12 @@ void SvtLineListBox::SelectEntry(SvxBorderLineStyle nStyle)
if (nStyle == SvxBorderLineStyle::NONE)
{
m_xLineSet->SetNoSelection();
- m_xNoneButton->set_has_default(true);
+ m_xNoneButton->grab_focus();
}
else
{
m_xLineSet->SelectItem(static_cast<sal_Int16>(nStyle) + 1);
- m_xNoneButton->set_has_default(false);
+ m_xLineSet->GrabFocus();
}
UpdatePreview();
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 2c2603fb4c8d..1b8d6fe09092 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1791,6 +1791,7 @@ ColorWindow::ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager
, mxAutomaticSeparator(m_xBuilder->weld_widget("separator4"))
, mxColorSetWin(new weld::CustomWeld(*m_xBuilder, "colorset", *mxColorSet))
, mxRecentColorSetWin(new weld::CustomWeld(*m_xBuilder, "recent_colorset", *mxRecentColorSet))
+ , mpDefaultButton(nullptr)
{
mxColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_TABSTOP) );
mxRecentColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_TABSTOP) );
@@ -1988,7 +1989,7 @@ NamedColor ColorWindow::GetSelectEntryColor() const
return GetSelectEntryColor(mxColorSet.get());
if (!mxRecentColorSet->IsNoSelection())
return GetSelectEntryColor(mxRecentColorSet.get());
- if (mxButtonNoneColor->get_has_default())
+ if (mxButtonNoneColor.get() == mpDefaultButton)
return GetNoneColor();
return GetAutoColor();
}
@@ -2130,8 +2131,7 @@ void ColorWindow::SetNoSelection()
{
mxColorSet->SetNoSelection();
mxRecentColorSet->SetNoSelection();
- mxButtonAutoColor->set_has_default(false);
- mxButtonNoneColor->set_has_default(false);
+ mpDefaultButton = nullptr;
}
bool SvxColorWindow::IsNoSelection() const
@@ -2259,15 +2259,17 @@ void ColorWindow::SelectEntry(const NamedColor& rNamedColor)
const Color &rColor = rNamedColor.first;
- if (mxButtonNoneColor->get_visible() && (rColor == COL_TRANSPARENT || rColor == COL_AUTO))
+ if (mxButtonAutoColor->get_visible() && (rColor == COL_TRANSPARENT || rColor == COL_AUTO))
{
- mxButtonAutoColor->set_has_default(true);
+ mpDefaultButton = mxButtonAutoColor.get();
+ mxButtonAutoColor->grab_focus();
return;
}
if (mxButtonNoneColor->get_visible() && rColor == COL_NONE_COLOR)
{
- mxButtonNoneColor->set_has_default(true);
+ mpDefaultButton = mxButtonNoneColor.get();
+ mxButtonNoneColor->grab_focus();
return;
}
--
2.20.1