summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-02 12:01:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-02 20:23:26 +0200
commit6c8e9d47f9a8e09349dc1dbd3155461cc96034ff (patch)
treef4b1595a311757502b93530d3d88edd1839070fe /vcl/unx
parent8d84d3800065b0c2d25479b84575da6906c035fc (diff)
support attempting to set a background color for widgets
but try to discourage use of random colors Change-Id: Iedd4dad7c039fbc4c5793f21e8ef3414ff0d4c96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101944 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx26
1 files changed, 15 insertions, 11 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 2ac4130e4392..18c3baa0341c 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2357,9 +2357,10 @@ private:
gtk_drag_source_set(m_pWidget, GDK_BUTTON1_MASK, rGtkTargets.data(), rGtkTargets.size(), eDragAction);
}
- void set_background(const OUString* pColor)
+ void do_set_background(const Color& rColor)
{
- if (!pColor && !m_pBgCssProvider)
+ const bool bRemoveColor = rColor == COL_AUTO;
+ if (bRemoveColor && !m_pBgCssProvider)
return;
GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(m_pWidget));
if (m_pBgCssProvider)
@@ -2367,10 +2368,11 @@ private:
gtk_style_context_remove_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pBgCssProvider));
m_pBgCssProvider = nullptr;
}
- if (!pColor)
+ if (bRemoveColor)
return;
+ OUString sColor = rColor.AsRGBHexString();
m_pBgCssProvider = gtk_css_provider_new();
- OUString aBuffer = "* { background-color: #" + *pColor + "; }";
+ OUString aBuffer = "* { background-color: #" + sColor + "; }";
OString aResult = OUStringToOString(aBuffer, RTL_TEXTENCODING_UTF8);
gtk_css_provider_load_from_data(m_pBgCssProvider, aResult.getStr(), aResult.getLength(), nullptr);
gtk_style_context_add_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pBgCssProvider),
@@ -2917,20 +2919,22 @@ public:
virtual void set_stack_background() override
{
- OUString sColor = Application::GetSettings().GetStyleSettings().GetWindowColor().AsRGBHexString();
- set_background(&sColor);
+ do_set_background(Application::GetSettings().GetStyleSettings().GetWindowColor());
}
virtual void set_title_background() override
{
- OUString sColor = Application::GetSettings().GetStyleSettings().GetShadowColor().AsRGBHexString();
- set_background(&sColor);
+ do_set_background(Application::GetSettings().GetStyleSettings().GetShadowColor());
}
virtual void set_highlight_background() override
{
- OUString sColor = Application::GetSettings().GetStyleSettings().GetHighlightColor().AsRGBHexString();
- set_background(&sColor);
+ do_set_background(Application::GetSettings().GetStyleSettings().GetHighlightColor());
+ }
+
+ virtual void set_background(const Color& rColor) override
+ {
+ do_set_background(rColor);
}
virtual void set_toolbar_background() override
@@ -2987,7 +2991,7 @@ public:
if (m_nSizeAllocateSignalId)
g_signal_handler_disconnect(m_pWidget, m_nSizeAllocateSignalId);
- set_background(nullptr);
+ do_set_background(COL_AUTO);
if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget)
{