From 93c609c7373cc29da60a05926c6ba3a19e1cabb5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Nov 2012 00:15:26 +0000 Subject: [PATCH] Add wxApp::GTKIsUsingGlobalMenu() helper to wxGTK. This allows to check whether the global menu is being used and will be mostly useful for working around various bugs/problems uncovered by it. See #14302. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73008 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/app.h | 7 +++++++ src/gtk/app.cpp | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/wx/gtk/app.h b/include/wx/gtk/app.h index 57ff95fbf3..f4618d5a5a 100644 --- a/include/wx/gtk/app.h +++ b/include/wx/gtk/app.h @@ -56,6 +56,13 @@ public: // must return XVisualInfo pointer (it is not freed by caller) virtual void *GetXVisualInfo() { return NULL; } + // Check if we're using a global menu. Currently this is only true when + // running under Ubuntu Unity and global menu is not disabled. + // + // This is mostly used in the implementation in order to work around + // various bugs arising due to this. + static bool GTKIsUsingGlobalMenu(); + #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // Maemo-specific method: get the main program object HildonProgram *GetHildonProgram(); diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 63ed6f13b3..7e07406519 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -529,6 +529,25 @@ void wxGUIAppTraits::MutexGuiLeave() } #endif // wxUSE_THREADS +/* static */ +bool wxApp::GTKIsUsingGlobalMenu() +{ + static int s_isUsingGlobalMenu = -1; + if ( s_isUsingGlobalMenu == -1 ) + { + // Currently we just check for this environment variable because this + // is how support for the global menu is implemented under Ubuntu. + // + // If we ever get false positives, we could also check for + // XDG_CURRENT_DESKTOP env var being set to "Unity". + wxString proxy; + s_isUsingGlobalMenu = wxGetEnv("UBUNTU_MENUPROXY", &proxy) && + !proxy.empty(); + } + + return s_isUsingGlobalMenu == 1; +} + #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // Maemo-specific method: get the main program object HildonProgram *wxApp::GetHildonProgram() -- 2.47.2