X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae6a64b6af83a95769363424e09d117a96a15a4c..d6f582e704041c4b133893183270d4853ea34bac:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 182d64038a..48dbbd95a2 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -16,7 +16,6 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" - #include "wx/panel.h" #include "wx/settings.h" #include "wx/math.h" #endif @@ -29,7 +28,6 @@ #include #include "wx/gtk/private.h" -#include // ---------------------------------------------------------------------------- // helpers @@ -926,7 +924,7 @@ wxFontEncoding wxTextCtrl::GetTextEncoding() const bool wxTextCtrl::IsEmpty() const { if ( IsMultiLine() ) - return gtk_text_buffer_get_char_count(m_buffer) != 0; + return gtk_text_buffer_get_char_count(m_buffer) == 0; return wxTextCtrlBase::IsEmpty(); } @@ -969,6 +967,12 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) gtk_entry_set_text( GTK_ENTRY(m_text), buffer ); } + // if, for whatever reason, the callback wasn't called the expected number + // of times, still reset the flags to the default values + m_dontMarkDirty = false; + m_countUpdatesToIgnore = 0; + + // GRG, Jun/2000: Changed this after a lot of discussion in // the lists. wxWidgets 2.2 will have a set of flags to // customize this behaviour. @@ -1149,31 +1153,7 @@ int wxTextCtrl::GetNumberOfLines() const { if ( IsMultiLine() ) { - GtkTextIter iter; - gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, 0 ); - - // move forward by one display line until the end is reached - int lineCount = 1; - while ( gtk_text_view_forward_display_line(GTK_TEXT_VIEW(m_text), &iter) ) - { - lineCount++; - } - - // If the last character in the text buffer is a newline, - // gtk_text_view_forward_display_line() will return false without that - // line being counted. Must add one manually in that case. - GtkTextIter lastCharIter; - gtk_text_buffer_get_iter_at_offset - ( - m_buffer, - &lastCharIter, - gtk_text_buffer_get_char_count(m_buffer) - 1 - ); - gchar lastChar = gtk_text_iter_get_char( &lastCharIter ); - if ( lastChar == wxT('\n') ) - lineCount++; - - return lineCount; + return gtk_text_buffer_get_line_count( m_buffer ); } else // single line { @@ -1846,7 +1826,10 @@ void wxTextCtrl::Freeze() G_CALLBACK (gtk_text_exposed_callback), this); gtk_widget_set_sensitive(m_widget, false); g_object_ref(m_buffer); - gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), gtk_text_buffer_new(NULL)); + GtkTextBuffer* buf_new = gtk_text_buffer_new(NULL); + gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), buf_new); + // FIXME: this leaks the new buffer, since gtk_text_view_set_buffer + // adds its own reference, but unrefing it here can cause a crash later } } }