mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
entrycompletion: Don't reconnect signals all the time
We block signal handlers areound GtkEntry signal emission and if those signals get used to call functions on the completion that cause a reconnection of the signals, then the reconnected signals will not be blocked anymore (so they might get emitted?) and unblocking the old signal id will later cause warnings. Fixes spurious warnings in gtk/tests/filechooser tests.
This commit is contained in:
parent
173317e9ce
commit
dc331ccb17
@ -1929,12 +1929,6 @@ gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion,
|
||||
{
|
||||
completion->priv->inline_completion = inline_completion;
|
||||
|
||||
if (completion->priv->entry)
|
||||
{
|
||||
disconnect_completion_signals (completion);
|
||||
connect_completion_signals (completion);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (completion), "inline-completion");
|
||||
}
|
||||
}
|
||||
@ -1979,12 +1973,6 @@ gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion,
|
||||
{
|
||||
completion->priv->popup_completion = popup_completion;
|
||||
|
||||
if (completion->priv->entry)
|
||||
{
|
||||
disconnect_completion_signals (completion);
|
||||
connect_completion_signals (completion);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (completion), "popup-completion");
|
||||
}
|
||||
}
|
||||
@ -2218,6 +2206,9 @@ gtk_entry_completion_key_press (GtkWidget *widget,
|
||||
gint matches, actions = 0;
|
||||
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
||||
|
||||
if (!completion->priv->popup_completion)
|
||||
return FALSE;
|
||||
|
||||
if (event->keyval == GDK_KEY_Return ||
|
||||
event->keyval == GDK_KEY_KP_Enter ||
|
||||
event->keyval == GDK_KEY_ISO_Enter ||
|
||||
@ -2500,6 +2491,9 @@ gtk_entry_completion_changed (GtkWidget *widget,
|
||||
GtkEntry *entry = GTK_ENTRY (widget);
|
||||
GdkDevice *device;
|
||||
|
||||
if (!completion->priv->popup_completion)
|
||||
return;
|
||||
|
||||
/* (re)install completion timeout */
|
||||
if (completion->priv->completion_timeout)
|
||||
g_source_remove (completion->priv->completion_timeout);
|
||||
@ -2545,13 +2539,14 @@ static void
|
||||
clear_completion_callback (GtkEntry *entry,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkEntryCompletion *completion = gtk_entry_get_completion (entry);
|
||||
|
||||
if (!completion->priv->inline_completion)
|
||||
return;
|
||||
|
||||
if (pspec->name == I_("cursor-position") ||
|
||||
pspec->name == I_("selection-bound"))
|
||||
{
|
||||
GtkEntryCompletion *completion = gtk_entry_get_completion (entry);
|
||||
|
||||
completion->priv->has_completion = FALSE;
|
||||
}
|
||||
completion->priv->has_completion = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2559,6 +2554,9 @@ accept_completion_callback (GtkEntry *entry)
|
||||
{
|
||||
GtkEntryCompletion *completion = gtk_entry_get_completion (entry);
|
||||
|
||||
if (!completion->priv->inline_completion)
|
||||
return FALSE;
|
||||
|
||||
if (completion->priv->has_completion)
|
||||
gtk_editable_set_position (GTK_EDITABLE (entry),
|
||||
gtk_entry_buffer_get_length (gtk_entry_get_buffer (entry)));
|
||||
@ -2573,6 +2571,9 @@ completion_insert_text_callback (GtkEntry *entry,
|
||||
gint position,
|
||||
GtkEntryCompletion *completion)
|
||||
{
|
||||
if (!completion->priv->inline_completion)
|
||||
return;
|
||||
|
||||
/* idle to update the selection based on the file list */
|
||||
if (completion->priv->check_completion_idle == NULL)
|
||||
{
|
||||
@ -2588,27 +2589,21 @@ completion_insert_text_callback (GtkEntry *entry,
|
||||
static void
|
||||
connect_completion_signals (GtkEntryCompletion *completion)
|
||||
{
|
||||
if (completion->priv->popup_completion)
|
||||
{
|
||||
completion->priv->changed_id =
|
||||
g_signal_connect (completion->priv->entry, "changed",
|
||||
G_CALLBACK (gtk_entry_completion_changed), completion);
|
||||
g_signal_connect (completion->priv->entry, "key-press-event",
|
||||
G_CALLBACK (gtk_entry_completion_key_press), completion);
|
||||
}
|
||||
completion->priv->changed_id =
|
||||
g_signal_connect (completion->priv->entry, "changed",
|
||||
G_CALLBACK (gtk_entry_completion_changed), completion);
|
||||
g_signal_connect (completion->priv->entry, "key-press-event",
|
||||
G_CALLBACK (gtk_entry_completion_key_press), completion);
|
||||
|
||||
if (completion->priv->inline_completion)
|
||||
{
|
||||
completion->priv->insert_text_id =
|
||||
g_signal_connect (completion->priv->entry, "insert-text",
|
||||
G_CALLBACK (completion_insert_text_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "notify",
|
||||
G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "activate",
|
||||
G_CALLBACK (accept_completion_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "focus-out-event",
|
||||
G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
completion->priv->insert_text_id =
|
||||
g_signal_connect (completion->priv->entry, "insert-text",
|
||||
G_CALLBACK (completion_insert_text_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "notify",
|
||||
G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "activate",
|
||||
G_CALLBACK (accept_completion_callback), completion);
|
||||
g_signal_connect (completion->priv->entry, "focus-out-event",
|
||||
G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user