+// ----------------------------------------------------------------------------
+// max text length support
+// ----------------------------------------------------------------------------
+
+void wxTextCtrl::IgnoreNextTextUpdate()
+{
+    m_ignoreNextUpdate = TRUE;
+}
+
+bool wxTextCtrl::IgnoreTextUpdate()
+{
+    if ( m_ignoreNextUpdate )
+    {
+        m_ignoreNextUpdate = FALSE;
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+void wxTextCtrl::SetMaxLength(unsigned long len)
+{
+    if ( !HasFlag(wxTE_MULTILINE) )
+    {
+        gtk_entry_set_max_length(GTK_ENTRY(m_text), len);
+
+        // there is a bug in GTK+ 1.2.x: "changed" signal is emitted even if
+        // we had tried to enter more text than allowed by max text length and
+        // the text wasn't really changed
+        //
+        // to detect this and generate TEXT_MAXLEN event instead of
+        // TEXT_CHANGED one in this case we also catch "insert_text" signal
+        //
+        // when max len is set to 0 we disconnect our handler as it means that
+        // we shouldn't check anything any more
+        if ( len )
+        {
+            gtk_signal_connect( GTK_OBJECT(m_text),
+                                "insert_text",
+                                GTK_SIGNAL_FUNC(gtk_insert_text_callback),
+                                (gpointer)this);
+        }
+        else // no checking
+        {
+            gtk_signal_disconnect_by_func
+            (
+                GTK_OBJECT(m_text),
+                GTK_SIGNAL_FUNC(gtk_insert_text_callback),
+                (gpointer)this
+            );
+        }
+    }
+}
+