From: Robert Roebling Date: Tue, 10 Jul 2007 11:58:03 +0000 (+0000) Subject: Block all events in wxSpinButton::SetValue etc. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a596eeb93f525c64d374f49e5986c57d1ea124a7 Block all events in wxSpinButton::SetValue etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47292 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/spinbutt.h b/include/wx/gtk/spinbutt.h index 4daf12bb37..cb7e59778e 100644 --- a/include/wx/gtk/spinbutt.h +++ b/include/wx/gtk/spinbutt.h @@ -51,6 +51,9 @@ public: int m_pos; protected: + void GtkDisableEvents() const; + void GtkEnableEvents() const; + virtual wxSize DoGetBestSize() const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index 46bdce9690..6be5c3a209 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -150,18 +150,18 @@ void wxSpinButton::SetValue( int value ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - BlockScrollEvent(); + GtkDisableEvents(); gtk_spin_button_set_value((GtkSpinButton*)m_widget, value); - UnblockScrollEvent(); + GtkEnableEvents(); } void wxSpinButton::SetRange(int minVal, int maxVal) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - BlockScrollEvent(); + GtkDisableEvents(); gtk_spin_button_set_range((GtkSpinButton*)m_widget, minVal, maxVal); - UnblockScrollEvent(); + GtkEnableEvents(); } void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) @@ -172,6 +172,18 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) gtk_widget_set_size_request( m_widget, m_width, m_height ); } +void wxSpinButton::GtkDisableEvents() const +{ + g_signal_handlers_block_by_func(m_widget, + (gpointer)gtk_value_changed, (void*) this); +} + +void wxSpinButton::GtkEnableEvents() const +{ + g_signal_handlers_unblock_by_func(m_widget, + (gpointer)gtk_value_changed, (void*) this); +} + GdkWindow *wxSpinButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const { return GTK_SPIN_BUTTON(m_widget)->panel;