Use the same "changed" GTK callback for wxComboBox and wxTextCtrl

And reuse EnableTextChangedEvents() between these classes as well.

No real changes so far, this is just a refactoring to centralize the
code in a single place before modifying it.
This commit is contained in:
Vadim Zeitlin
2019-07-08 16:04:24 +02:00
parent c024944d78
commit 5c766c0b8b
6 changed files with 53 additions and 68 deletions

View File

@@ -57,8 +57,16 @@ static int GetEntryTextLength(GtkEntry* entry)
// signal handlers implementation
// ============================================================================
// "insert_text" handler for GtkEntry
extern "C" {
// "changed" handler for GtkEntry
static void
wx_gtk_text_changed_callback(GtkWidget* WXUNUSED(widget), wxTextEntry* entry)
{
entry->GTKOnTextChanged();
}
// "insert_text" handler for GtkEntry
static void
wx_gtk_insert_text_callback(GtkEditable *editable,
const gchar * new_text,
@@ -869,6 +877,31 @@ int wxTextEntry::GTKIMFilterKeypress(GdkEventKey* event) const
return result;
}
// ----------------------------------------------------------------------------
// signals and events
// ----------------------------------------------------------------------------
void wxTextEntry::EnableTextChangedEvents(bool enable)
{
if ( enable )
{
g_signal_handlers_unblock_by_func(GetTextObject(),
(gpointer)wx_gtk_text_changed_callback, this);
}
else // disable events
{
g_signal_handlers_block_by_func(GetTextObject(),
(gpointer)wx_gtk_text_changed_callback, this);
}
}
void wxTextEntry::GTKConnectChangedSignal()
{
g_signal_connect(GetTextObject(), "changed",
G_CALLBACK(wx_gtk_text_changed_callback), this);
}
void wxTextEntry::GTKConnectInsertTextSignal(GtkEntry* entry)
{
g_signal_connect(entry, "insert_text",