]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
corrected off by 1 error in cMB2WC() call (thanks valgrind)
[wxWidgets.git] / src / gtk / textctrl.cpp
index 26e65214afff677e047b6ca62c72d8b063d94d5e..1b08ecc0a8d49d2e91fb2e9f88a429ce433dcde9 100644 (file)
@@ -10,6 +10,8 @@
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#if wxUSE_TEXTCTRL
+
 #include "wx/textctrl.h"
 
 #ifndef WX_PRECOMP
 #include "wx/textctrl.h"
 
 #ifndef WX_PRECOMP
@@ -1016,11 +1018,11 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
         return;
     }
 
         return;
     }
 
+    void* blockWidget = IsMultiLine() ? (void*)m_buffer : (void*)m_text;
+    g_signal_handlers_block_by_func(blockWidget,
+        (gpointer)gtk_text_changed_callback, this);
     if ( IsMultiLine() )
     {
     if ( IsMultiLine() )
     {
-        g_signal_handlers_disconnect_by_func (m_buffer,
-                    (gpointer) gtk_text_changed_callback, this);
-                    
         gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
                     
         if ( !m_defaultStyle.IsDefault() )
         gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
                     
         if ( !m_defaultStyle.IsDefault() )
@@ -1030,20 +1032,13 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
             wxGtkTextApplyTagsFromAttr(m_widget, m_buffer, m_defaultStyle,
                                        &start, &end);
         }
             wxGtkTextApplyTagsFromAttr(m_widget, m_buffer, m_defaultStyle,
                                        &start, &end);
         }
-        
-        g_signal_connect (m_buffer, "changed",
-                          G_CALLBACK (gtk_text_changed_callback), this);
     }
     else
     {
     }
     else
     {
-        g_signal_handlers_disconnect_by_func (m_text,
-                          (gpointer) gtk_text_changed_callback, this);
-                          
         gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
         gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
-        
-        g_signal_connect (m_text, "changed",
-                          G_CALLBACK (gtk_text_changed_callback), this);
     }
     }
+    g_signal_handlers_unblock_by_func(blockWidget,
+        (gpointer)gtk_text_changed_callback, this);
                     
     // This was added after discussion on the list
     SetInsertionPoint(0);
                     
     // This was added after discussion on the list
     SetInsertionPoint(0);
@@ -1996,3 +1991,5 @@ wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
 {
     return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
 }
 {
     return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
 }
+
+#endif // wxUSE_TEXTCTRL