From 0d013e46a0ac91251f1c2a1495f85d1086f80ffe Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Oct 2009 22:56:12 +0000 Subject: [PATCH] No real changes, just inline wxSuspendStyleEvents. wxSuspendStyleEvents helper class was used in one place only and the code is more clear if its ctor and dtor are inlined directly into DoApplyWidgetStyle() itself instead of being located far away from it. Also, we only need to suppress the events for top level windows so don't bother doing anything at all when changing styles for m_widget and not m_wxwindow. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62285 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 3a4ec1a..8d8154f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1925,30 +1925,6 @@ void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget), } // extern "C" -// Helper to suspend colour change event event processing while we change a widget's style -class wxSuspendStyleEvents -{ -public: - wxSuspendStyleEvents(wxWindow* win) - { - m_win = NULL; - if (win->m_wxwindow && win->IsTopLevel()) - { - m_win = win; - g_signal_handlers_block_by_func( - m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win); - } - } - ~wxSuspendStyleEvents() - { - if (m_win) - g_signal_handlers_unblock_by_func( - m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win); - } - - wxWindow* m_win; -}; - // ---------------------------------------------------------------------------- // this wxWindowBase function is implemented here (in platform-specific file) // because it is static and so couldn't be made virtual @@ -3907,12 +3883,30 @@ void wxWindowGTK::GTKApplyWidgetStyle(bool forceStyle) void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style) { - wxSuspendStyleEvents s(static_cast(this)); + if ( m_wxwindow ) + { + // block the signal temporarily to avoid sending + // wxSysColourChangedEvents when we change the colours ourselves + bool unblock = false; + if ( IsTopLevel() ) + { + unblock = true; + g_signal_handlers_block_by_func( + m_wxwindow, (void *)gtk_window_style_set_callback, this); + } - if (m_wxwindow) gtk_widget_modify_style(m_wxwindow, style); + + if ( unblock ) + { + g_signal_handlers_unblock_by_func( + m_wxwindow, (void *)gtk_window_style_set_callback, this); + } + } else + { gtk_widget_modify_style(m_widget, style); + } } bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) -- 2.7.4