From 3e27a53e958867252ad8a77258cd0ef824fc7f7d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Jul 2018 19:53:13 +0200 Subject: [PATCH 1/2] Make wxInfoBar actually appear when using GTK+ 3 Due to https://bugzilla.gnome.org/show_bug.cgi?id=710888 GtkInfoBar wasn't shown if it had been hidden before -- which is exactly what wxInfoBar did. Fix this using the workaround proposed in the bug report, which makes the info bar appear immediately, without any transition, which might be not ideal, but markedly better than failing to show it at all. --- docs/changes.txt | 1 + src/gtk/infobar.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index d64d16eeca..7936144c7b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -106,6 +106,7 @@ All (GUI): wxGTK: - Implement wxTextCtrl::HitTest() for single line controls. +- Fix not showing wxInfoBar with GTK+ 3 < 3.22.29. - Fix the build with glib < 2.32 (e.g. CentOS 6). wxMSW: diff --git a/src/gtk/infobar.cpp b/src/gtk/infobar.cpp index f918415505..ea7be9274b 100644 --- a/src/gtk/infobar.cpp +++ b/src/gtk/infobar.cpp @@ -145,6 +145,31 @@ bool wxInfoBar::Create(wxWindow *parent, wxWindowID winid) GTKConnectWidget("response", G_CALLBACK(wxgtk_infobar_response)); GTKConnectWidget("close", G_CALLBACK(wxgtk_infobar_close)); + // Work around GTK+ bug https://bugzilla.gnome.org/show_bug.cgi?id=710888 + // by disabling the transition when showing it: without this, it's not + // shown at all. + // + // Compile-time check is needed because GtkRevealer is new in 3.10. +#if GTK_CHECK_VERSION(3, 10, 0) + // Run-time check is needed because the bug was introduced in 3.10 and + // fixed in 3.22.29 (see 6b4d95e86dabfcdaa805fbf068a99e19736a39a4 and a + // couple of previous commits in GTK+ repository). + if ( gtk_check_version(3, 10, 0) == NULL && + gtk_check_version(3, 22, 29) != NULL ) + { + GObject* const + revealer = gtk_widget_get_template_child(GTK_WIDGET(m_widget), + GTK_TYPE_INFO_BAR, + "revealer"); + if ( revealer ) + { + gtk_revealer_set_transition_type(GTK_REVEALER (revealer), + GTK_REVEALER_TRANSITION_TYPE_NONE); + gtk_revealer_set_transition_duration(GTK_REVEALER (revealer), 0); + } + } +#endif // GTK+ >= 3.10 + return true; } From c482c2cb6486b256d0c415e158b2fafbd81c2655 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Jul 2018 20:08:53 +0200 Subject: [PATCH 2/2] Make wxInfoBar in the dialogs sample more readable As usual, when changing the background colour, we need to change the foreground as well, otherwise the text risks becoming unreadable with some default text colour values -- as was the case under GTK+ 3 with its default theme. --- samples/dialogs/dialogs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 9de1fa2ab5..3fbfd99aeb 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -686,6 +686,7 @@ MyFrame::MyFrame(const wxString& title) // ... changing the colours and/or fonts m_infoBarAdvanced->SetOwnBackgroundColour(0xc8ffff); + m_infoBarAdvanced->SetForegroundColour(0x123312); m_infoBarAdvanced->SetFont(GetFont().Bold().Larger()); // ... and changing the effect (only does anything under MSW currently)