From 9c76bdefcad85e631364c3e0bad9fd484cad78ee Mon Sep 17 00:00:00 2001 From: Teodor Petrov Date: Sat, 18 Apr 2020 14:15:24 +0300 Subject: [PATCH 1/2] Implement wxSYS_COLOUR_HOTLIGHT for GTK2 (requires GTK+ >= 2.10) --- src/gtk/settings.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index a3868eb217..aa8a30741e 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -87,6 +87,19 @@ static GtkWidget* ButtonWidget() return s_widget; } +static GtkWidget* LinkButtonWidget() +{ + static GtkWidget *s_widget; + if (s_widget == NULL) + { + s_widget = gtk_link_button_new("http://test.com"); + g_object_add_weak_pointer(G_OBJECT(s_widget), (void**)&s_widget); + gtk_container_add(ContainerWidget(), s_widget); + gtk_widget_ensure_style(s_widget); + } + return s_widget; +} + static GtkWidget* ListWidget() { static GtkWidget* s_widget; @@ -623,6 +636,16 @@ static const GtkStyle* ButtonStyle() return gtk_widget_get_style(ButtonWidget()); } +static const wxColor LinkButtonStyle() +{ + GdkColor *link_color = NULL; + gtk_widget_style_get(LinkButtonWidget(), "link-color", &link_color, NULL); + if (link_color) + return wxColor(*link_color); + else + return *wxBLUE; +} + static const GtkStyle* ListStyle() { return gtk_widget_get_style(ListWidget()); @@ -748,8 +771,7 @@ wxColour wxSystemSettingsNative::GetColour( wxSystemColour index ) break; case wxSYS_COLOUR_HOTLIGHT: - // TODO - color = *wxBLACK; + color = LinkButtonStyle(); break; case wxSYS_COLOUR_MAX: From 1b4a5ece642129ca872f8fa8404735e801262a94 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Apr 2020 17:55:50 +0200 Subject: [PATCH 2/2] Add GTK 2.10 version checks around code using GtkLinkButton Blindly repair compiling/running against GTK < 2.10 after the previous commit. --- src/gtk/settings.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index aa8a30741e..3063f4fcaf 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -87,10 +87,11 @@ static GtkWidget* ButtonWidget() return s_widget; } +#if GTK_CHECK_VERSION(2,10,0) static GtkWidget* LinkButtonWidget() { static GtkWidget *s_widget; - if (s_widget == NULL) + if (s_widget == NULL && wx_is_at_least_gtk2(10)) { s_widget = gtk_link_button_new("http://test.com"); g_object_add_weak_pointer(G_OBJECT(s_widget), (void**)&s_widget); @@ -99,6 +100,7 @@ static GtkWidget* LinkButtonWidget() } return s_widget; } +#endif // GTK 2.10+ static GtkWidget* ListWidget() { @@ -636,14 +638,16 @@ static const GtkStyle* ButtonStyle() return gtk_widget_get_style(ButtonWidget()); } -static const wxColor LinkButtonStyle() +static const wxColor LinkButtonColor() { +#if GTK_CHECK_VERSION(2,10,0) GdkColor *link_color = NULL; gtk_widget_style_get(LinkButtonWidget(), "link-color", &link_color, NULL); if (link_color) return wxColor(*link_color); - else - return *wxBLUE; +#endif // GTK 2.10+ + + return *wxBLUE; } static const GtkStyle* ListStyle() @@ -771,7 +775,7 @@ wxColour wxSystemSettingsNative::GetColour( wxSystemColour index ) break; case wxSYS_COLOUR_HOTLIGHT: - color = LinkButtonStyle(); + color = LinkButtonColor(); break; case wxSYS_COLOUR_MAX: