diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-12 11:32:53 +0000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-02-12 20:39:44 +0000 |
commit | 8856f425216f581b098ba84c125443c0856b7122 (patch) | |
tree | 6694d0b3b83ff3774aba9dfb58c13bee7d3dbb9d /vcl | |
parent | 77d2f04d802b2b94eb80206fbbc230719328ec4d (diff) |
Related: rhbz#1287593 subissue 6, get suitable hyperlink colors for dark theme
(cherry picked from commit 06e8c58acb6ba667f8fd8c5587a3b3037324971a)
Change-Id: Ieb5ed52fa8a9c26b3e839388a58cff295166eed9
Reviewed-on: https://gerrit.libreoffice.org/22313
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/fixedhyper.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 39 |
3 files changed, 22 insertions, 24 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 13ac19817b7a..2bb602982598 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -36,6 +36,7 @@ enum class GtkControlPart { Button, + LinkButton, CheckButton, CheckButtonCheck, RadioButton, @@ -100,6 +101,7 @@ public: private: GtkWidget *mpWindow; static GtkStyleContext *mpButtonStyle; + static GtkStyleContext *mpLinkButtonStyle; static GtkStyleContext *mpEntryStyle; static GtkStyleContext *mpTextViewStyle; static GtkStyleContext *mpVScrollbarStyle; diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx index a4ec5e784a82..34148687a117 100644 --- a/vcl/source/control/fixedhyper.cxx +++ b/vcl/source/control/fixedhyper.cxx @@ -18,6 +18,7 @@ */ #include <vcl/fixedhyper.hxx> +#include <vcl/svapp.hxx> FixedHyperlink::FixedHyperlink(vcl::Window* pParent, WinBits nWinStyle) : FixedText(pParent, nWinStyle) @@ -35,8 +36,8 @@ void FixedHyperlink::Initialize() // to underline aFont.SetUnderline( UNDERLINE_SINGLE ); SetControlFont( aFont ); - // changes the color to light blue - SetControlForeground( Color( COL_LIGHTBLUE ) ); + // changes the color to link color + SetControlForeground( Application::GetSettings().GetStyleSettings().GetLinkColor() ); // calculates text len m_nTextLen = GetCtrlTextWidth( GetText() ); } diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index d7d9a1d46681..d73a036f3b6e 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -22,6 +22,7 @@ #include <boost/optional.hpp> GtkStyleContext* GtkSalGraphics::mpButtonStyle = nullptr; +GtkStyleContext* GtkSalGraphics::mpLinkButtonStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpEntryStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpTextViewStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpVScrollbarStyle = nullptr; @@ -824,6 +825,15 @@ static GtkStyleContext* createStyleContext(GtkControlPart ePart, GtkStyleContext gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); #endif break; + case GtkControlPart::LinkButton: + gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); +#if GTK_CHECK_VERSION(3, 19, 2) + gtk_widget_path_iter_set_object_name(path, -1, "button"); +#else + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); +#endif + gtk_widget_path_iter_add_class(path, -1, "link"); + break; case GtkControlPart::CheckButton: gtk_widget_path_append_type(path, GTK_TYPE_CHECK_BUTTON); #if GTK_CHECK_VERSION(3, 19, 2) @@ -1743,11 +1753,6 @@ static inline ::Color getColor( const GdkRGBA& rCol ) return ::Color( (int)(rCol.red * 0xFFFF) >> 8, (int)(rCol.green * 0xFFFF) >> 8, (int)(rCol.blue * 0xFFFF) >> 8 ); } -static inline ::Color getColorFromColor( const GdkColor& rCol ) -{ - return ::Color( rCol.red >> 8, rCol.green >> 8, rCol.blue >> 8 ); -} - void GtkSalGraphics::updateSettings( AllSettings& rSettings ) { GtkStyleContext* pStyle = gtk_widget_get_style_context( mpWindow ); @@ -1998,23 +2003,12 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetMenuHighlightTextColor( aHighlightTextColor ); // hyperlink colors - GdkColor *link_color = nullptr; - gtk_style_context_get_style(pStyle, - "link-color", &link_color, - NULL); - if (link_color) { - aStyleSet.SetLinkColor(getColorFromColor(*link_color)); - gdk_color_free(link_color); - } - - link_color = nullptr; - gtk_style_context_get_style(pStyle, - "visited-link-color", &link_color, - NULL); - if (link_color) { - aStyleSet.SetVisitedLinkColor(getColorFromColor(*link_color)); - gdk_color_free(link_color); - } + gtk_style_context_set_state(mpLinkButtonStyle, GTK_STATE_FLAG_LINK); + gtk_style_context_get_color(mpLinkButtonStyle, gtk_style_context_get_state(mpLinkButtonStyle), &text_color); + aStyleSet.SetLinkColor(getColor(text_color)); + gtk_style_context_set_state(mpLinkButtonStyle, GTK_STATE_FLAG_VISITED); + gtk_style_context_get_color(mpLinkButtonStyle, gtk_style_context_get_state(mpLinkButtonStyle), &text_color); + aStyleSet.SetVisitedLinkColor(getColor(text_color)); #if GTK_CHECK_VERSION(3, 19, 2) { @@ -2353,6 +2347,7 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) getStyleContext(&mpTextViewStyle, gtk_text_view_new()); mpButtonStyle = createStyleContext(GtkControlPart::Button); + mpLinkButtonStyle = createStyleContext(GtkControlPart::LinkButton); GtkWidget* pToolbar = gtk_toolbar_new(); mpToolbarStyle = gtk_widget_get_style_context(pToolbar); |