From 8ebcfebc5c20ca576b6bc7d7b1b256449c5c7412 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Jul 2018 00:00:27 +0200 Subject: [PATCH 1/3] Fix wxGTK 1 build after gtk/gtk.h wrapper header addition Changes of c0b0562533609e453b2b0dae25c0780e477b768b to common code broke wxGTK1 build, as wx/gtk/private/wrapgtk.h is for wxGTK 2+ only. Fix this by handling wxGTK 1 separately and including gtk/gtk.h directly for it. Hopefully this code will be removed, together with the rest of wxGTK1 support, in some not so distant future. --- include/wx/gtk1/private/addremovectrl.h | 80 +++++++++++++++++++++++++ include/wx/private/addremovectrl.h | 4 +- src/aui/dockart.cpp | 7 ++- src/common/popupcmn.cpp | 5 +- src/common/utilscmn.cpp | 14 +++-- src/generic/graphicc.cpp | 4 ++ src/unix/taskbarx11.cpp | 6 +- src/unix/utilsx11.cpp | 5 ++ 8 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 include/wx/gtk1/private/addremovectrl.h diff --git a/include/wx/gtk1/private/addremovectrl.h b/include/wx/gtk1/private/addremovectrl.h new file mode 100644 index 0000000000..bce4061df5 --- /dev/null +++ b/include/wx/gtk1/private/addremovectrl.h @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/gtk/private/addremovectrl.h +// Purpose: GTK specific wxAddRemoveImpl implementation +// Author: Vadim Zeitlin +// Created: 2015-02-05 +// Copyright: (c) 2015 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GTK_PRIVATE_ADDREMOVECTRL_H_ +#define _WX_GTK_PRIVATE_ADDREMOVECTRL_H_ + +#include "wx/artprov.h" +#include "wx/bmpbuttn.h" +#include "wx/toolbar.h" + +#include + +// ---------------------------------------------------------------------------- +// wxAddRemoveImpl +// ---------------------------------------------------------------------------- + +class wxAddRemoveImpl : public wxAddRemoveImplBase +{ +public: + wxAddRemoveImpl(wxAddRemoveAdaptor* adaptor, + wxAddRemoveCtrl* parent, + wxWindow* ctrlItems) + : wxAddRemoveImplBase(adaptor, parent, ctrlItems), + m_tbar(new wxToolBar(parent, wxID_ANY)) + { + m_tbar->AddTool(wxID_ADD, wxString(), GetNamedBitmap("list-add")); + m_tbar->AddTool(wxID_REMOVE, wxString(), GetNamedBitmap("list-remove")); + +#if defined(__WXGTK3__) && !defined(__WXUNIVERSAL__) + // Tweak the toolbar appearance to correspond to how the toolbars used + // in other GNOME applications for similar purposes look. + GtkToolbar* const toolbar = m_tbar->GTKGetToolbar(); + GtkStyleContext* context = gtk_widget_get_style_context(GTK_WIDGET(toolbar)); + gtk_style_context_add_class(context, GTK_STYLE_CLASS_INLINE_TOOLBAR); + gtk_style_context_set_junction_sides(context, GTK_JUNCTION_TOP); +#endif // GTK+3 + + wxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL); + sizerTop->Add(ctrlItems, wxSizerFlags(1).Expand()); + sizerTop->Add(m_tbar, wxSizerFlags().Expand()); + parent->SetSizer(sizerTop); + + m_tbar->Bind(wxEVT_UPDATE_UI, + &wxAddRemoveImplBase::OnUpdateUIAdd, this, wxID_ADD); + m_tbar->Bind(wxEVT_UPDATE_UI, + &wxAddRemoveImplBase::OnUpdateUIRemove, this, wxID_REMOVE); + + m_tbar->Bind(wxEVT_TOOL, &wxAddRemoveImplBase::OnAdd, this, wxID_ADD); + m_tbar->Bind(wxEVT_TOOL, &wxAddRemoveImplBase::OnRemove, this, wxID_REMOVE); + } + + virtual void SetButtonsToolTips(const wxString& addtip, + const wxString& removetip) wxOVERRIDE + { + m_tbar->SetToolShortHelp(wxID_ADD, addtip); + m_tbar->SetToolShortHelp(wxID_REMOVE, removetip); + } + +private: + static wxBitmap GetNamedBitmap(const wxString& name) + { + // GTK UI guidelines recommend using "symbolic" versions of the icons + // for these buttons, so try them first but fall back to the normal + // ones if symbolic theme is not installed. + wxBitmap bmp = wxArtProvider::GetBitmap(name + "-symbolic", wxART_MENU); + if ( !bmp.IsOk() ) + bmp = wxArtProvider::GetBitmap(name, wxART_MENU); + return bmp; + } + + wxToolBar* const m_tbar; +}; + +#endif // _WX_GTK_PRIVATE_ADDREMOVECTRL_H_ diff --git a/include/wx/private/addremovectrl.h b/include/wx/private/addremovectrl.h index 19540e8df1..13a10ade02 100644 --- a/include/wx/private/addremovectrl.h +++ b/include/wx/private/addremovectrl.h @@ -145,8 +145,10 @@ protected: #ifdef __WXOSX__ #include "wx/osx/private/addremovectrl.h" -#elif defined(__WXGTK__) +#elif defined(__WXGTK20__) #include "wx/gtk/private/addremovectrl.h" +#elif defined(__WXGTK__) + #include "wx/gtk1/private/addremovectrl.h" #else #include "wx/generic/private/addremovectrl.h" #endif diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index 391d322efe..9cf66e43c7 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -43,7 +43,12 @@ #ifdef __WXGTK__ #include "wx/renderer.h" -#include "wx/gtk/private/wrapgtk.h" +#ifdef __WXGTK20__ + #include "wx/gtk/private/wrapgtk.h" +#else + #include + #define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE +#endif #ifdef __WXGTK3__ #include "wx/graphics.h" #include "wx/gtk/private.h" diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index f05fc5e97c..e69ad0d2ad 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -41,8 +41,11 @@ #include "wx/scrolbar.h" #endif // __WXUNIVERSAL__ -#ifdef __WXGTK__ +#ifdef __WXGTK20__ #include "wx/gtk/private/wrapgtk.h" +#elif defined(__WXGTK__) + #include + #define gtk_widget_get_window(x) x->window #elif defined(__WXMSW__) #include "wx/msw/private.h" #elif defined(__WXX11__) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 729c51da67..bae186b759 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -103,13 +103,17 @@ #include "wx/msw/private.h" #endif -#if wxUSE_GUI && defined(__WXGTK__) - #include "wx/gtk/private/wrapgtk.h" // for GTK_XXX_VERSION constants +#if wxUSE_GUI + // Include the definitions of GTK_XXX_VERSION constants. + #ifdef __WXGTK20__ + #include "wx/gtk/private/wrapgtk.h" + #elif defined(__WXGTK__) + #include + #elif defined(__WXQT__) + #include // for QT_VERSION_STR constants + #endif #endif -#if wxUSE_GUI && defined(__WXQT__) - #include // for QT_VERSION_STR constants -#endif #if wxUSE_BASE // ============================================================================ diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index a1ad0dca9f..ddf2f94c52 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -83,7 +83,11 @@ using namespace std; #endif #ifdef __WXGTK__ +#ifdef __WXGTK20__ #include "wx/gtk/private/wrapgtk.h" +#else // GTK+ 1.x +#include +#endif #include "wx/fontutil.h" #ifndef __WXGTK3__ #include "wx/gtk/dc.h" diff --git a/src/unix/taskbarx11.cpp b/src/unix/taskbarx11.cpp index 0e608e89eb..f58590d519 100644 --- a/src/unix/taskbarx11.cpp +++ b/src/unix/taskbarx11.cpp @@ -64,7 +64,11 @@ // ---------------------------------------------------------------------------- #if defined(__WXGTK__) - #include "wx/gtk/private/wrapgtk.h" + #ifdef __WXGTK20__ + #include "wx/gtk/private/wrapgtk.h" + #else // GTK+ 1.x + #include + #endif #include #define GetDisplay() GDK_DISPLAY() #define GetXWindow(wxwin) GDK_WINDOW_XWINDOW((wxwin)->m_widget->window) diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index 8b9f37b831..d4f659df7c 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -37,7 +37,12 @@ #endif #ifdef __WXGTK__ +#ifdef __WXGTK20__ #include "wx/gtk/private/wrapgtk.h" +#else // GTK+ 1.x +#include +#define GDK_WINDOWING_X11 +#endif #ifdef GDK_WINDOWING_X11 #include #endif From a74058a958e864aaa2f9f902ae5dbbf0d3d0cc25 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Jul 2018 00:09:05 +0200 Subject: [PATCH 2/3] Fix wxGetKeyState() compilation with wxGTK 1 This was broken back in a73251a80d95efa37bf1fc7879b21a6aec57910d which added check for GDK_WINDOWING_X11 which is not defined by GTK+ 1. See #14469. --- src/unix/utilsx11.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index d4f659df7c..97c8fa5560 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -50,8 +50,9 @@ GdkWindow* wxGetTopLevelGDK(); GtkWidget* wxGetTopLevelGTK(); #endif -// Only X11 backend is supported for wxGTK here -#if !defined(__WXGTK__) || defined(GDK_WINDOWING_X11) +// Only X11 backend is supported for wxGTK here (GTK < 2 has no others) +#if !defined(__WXGTK__) || \ + (!defined(__WXGTK20__) || defined(GDK_WINDOWING_X11)) // Various X11 Atoms used in this file: static Atom _NET_WM_STATE = 0; From 2034f6683b753f4a912477683972ab93d175c34c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Jul 2018 00:24:35 +0200 Subject: [PATCH 3/3] Disable use of wxSecretStore with wxGTK1 libsecret is for GTK+ 2+ only and can't be used with GTK+ 1. --- configure | 20 ++++++-------------- configure.in | 5 ++++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/configure b/configure index 1b11ac5dc3..779605646c 100755 --- a/configure +++ b/configure @@ -1040,7 +1040,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -1461,7 +1460,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1714,15 +1712,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1860,7 +1849,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -2013,7 +2002,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -34150,7 +34138,11 @@ fi if test "$wxUSE_SECRETSTORE" = "yes"; then - if test "$wxUSE_MSW" != "1" -a "$wxUSE_OSX_COCOA" != 1; then + if test "$WXGTK1" = "1"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libsecret is incompatible with GTK+ 1, disabled" >&5 +$as_echo "$as_me: WARNING: libsecret is incompatible with GTK+ 1, disabled" >&2;} + wxUSE_SECRETSTORE=no + elif test "$wxUSE_MSW" != "1" -a "$wxUSE_OSX_COCOA" != 1; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBSECRET" >&5 diff --git a/configure.in b/configure.in index cbd7392216..7720f2f5d9 100644 --- a/configure.in +++ b/configure.in @@ -5419,7 +5419,10 @@ dnl --------------------------------------------------------------------------- if test "$wxUSE_SECRETSTORE" = "yes"; then dnl The required APIs are always available under MSW and OS X but we must dnl have GNOME libsecret under Unix to be able to compile this class. - if test "$wxUSE_MSW" != "1" -a "$wxUSE_OSX_COCOA" != 1; then + if test "$WXGTK1" = "1"; then + AC_MSG_WARN([libsecret is incompatible with GTK+ 1, disabled]) + wxUSE_SECRETSTORE=no + elif test "$wxUSE_MSW" != "1" -a "$wxUSE_OSX_COCOA" != 1; then PKG_CHECK_MODULES(LIBSECRET, [libsecret-1], [ CXXFLAGS="$LIBSECRET_CFLAGS $CXXFLAGS"