X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/929bd94ee1ebf1d6d73c038954eef424a3ef8739..4c0d2cd3d0c59bf0114e0e10355bff86ddb116a0:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 4b2f349fb2..1b08ecc0a8 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -10,6 +10,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_TEXTCTRL + #include "wx/textctrl.h" #ifndef WX_PRECOMP @@ -757,6 +759,18 @@ bool wxTextCtrl::Create( wxWindow *parent, gtk_widget_show(m_text); } + // We want to be notified about text changes. + if (multi_line) + { + g_signal_connect (m_buffer, "changed", + G_CALLBACK (gtk_text_changed_callback), this); + } + else + { + g_signal_connect (m_text, "changed", + G_CALLBACK (gtk_text_changed_callback), this); + } + if (!value.empty()) { SetValue( value ); @@ -772,13 +786,9 @@ bool wxTextCtrl::Create( wxWindow *parent, if ( style & (wxTE_RIGHT | wxTE_CENTRE) ) GTKSetJustification(); - // We want to be notified about text changes. if (multi_line) { - g_signal_connect (m_buffer, "changed", - G_CALLBACK (gtk_text_changed_callback), this); - - // .. and handle URLs on multi-line controls with wxTE_AUTO_URL style + // Handle URLs on multi-line controls with wxTE_AUTO_URL style if (style & wxTE_AUTO_URL) { GtkTextIter start, end; @@ -814,12 +824,7 @@ bool wxTextCtrl::Create( wxWindow *parent, au_check_range(&start, &end); } } - else - { - g_signal_connect (m_text, "changed", - G_CALLBACK (gtk_text_changed_callback), this); - } - + g_signal_connect (m_text, "copy-clipboard", G_CALLBACK (gtk_copy_clipboard_callback), this); g_signal_connect (m_text, "cut-clipboard", @@ -1013,11 +1018,11 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) 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() ) { - 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() ) @@ -1027,20 +1032,13 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) wxGtkTextApplyTagsFromAttr(m_widget, m_buffer, m_defaultStyle, &start, &end); } - - g_signal_connect (m_buffer, "changed", - G_CALLBACK (gtk_text_changed_callback), this); } else { - g_signal_handlers_disconnect_by_func (m_text, - (gpointer) gtk_text_changed_callback, this); - 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); @@ -1993,3 +1991,5 @@ wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true); } + +#endif // wxUSE_TEXTCTRL