Simplify GTK+ 2 version checks with a helper function

Use wx_is_at_least_gtk2(minor) instead of gtk_check_version(2, minor)
because it is more clear and also works as expected (i.e. returns true)
when using GTK+ 3 instead of creating difficult to notice bugs in the
code by failing the version check in this case.

See #18004.
This commit is contained in:
Vadim Zeitlin
2017-11-22 23:59:21 +01:00
parent a8671869e5
commit d6af0236c5
31 changed files with 101 additions and 148 deletions

View File

@@ -408,7 +408,7 @@ bool wxToolBar::Create( wxWindow *parent,
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
#ifndef __WXGTK3__
if (gtk_check_version(2, 12, 0))
if (!wx_is_at_least_gtk2(12))
{
m_tooltips = gtk_tooltips_new();
g_object_ref(m_tooltips);
@@ -580,7 +580,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty())
{
#if GTK_CHECK_VERSION(2, 12, 0)
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
if (wx_is_at_least_gtk2(12))
{
gtk_tool_item_set_tooltip_text(tool->m_item,
wxGTK_CONV(tool->GetShortHelp()));
@@ -754,7 +754,7 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
if (tool->m_item)
{
#if GTK_CHECK_VERSION(2, 12, 0)
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
if (wx_is_at_least_gtk2(12))
{
gtk_tool_item_set_tooltip_text(tool->m_item,
wxGTK_CONV(helpString));