After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 584402 - _complete() does not work directly after _set_completion()
_complete() does not work directly after _set_completion()
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
2.16.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-05-31 23:46 UTC by Leon Winter
Modified: 2018-02-10 03:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Leon Winter 2009-05-31 23:46:35 UTC
Please describe the problem:
The problem occured when I tried to implement tab-completion for the GtkEntry widget, because if I assign a completion it will be invoked on every change, but my goal was to use <TAB> to invoke the completion and intercept the automatic completion. The attempt was to catch GDK_Tab on keypress and then gtk_entry_set_completion() and invoke gtk_entry_completion_complete() afterwards. Unfortunately nothing happened (this is the bug).

However if I enter a char or modify the text the completion will pop up.
Workaround: We could also simulate a change by gtk_editable_insert_text (GTK_EDITABLE (widget), "", 0, &p);

Steps to reproduce:
1. gtk_entry_set_completion((GtkEntry*)inputbox, completion);
2. gtk_entry_completion_complete(completion);


Actual results:
We set up completion and try to invoke it.

Expected results:
The completion should pop up.

Does this happen every time?
Actually nothing happens, and yes every time we setup the scenario.

Other information:
I traced back the calls a bit and noticed the following:

gtkentry.c:4148 g_signal_emit_by_name (editable, "insert-text", text, new_text_length, position);

:9358       g_source_set_closure (completion->priv->check_completion_idle,
                            g_cclosure_new_object (G_CALLBACK (check_completion_callback),
                                                   G_OBJECT (completion)));

:9311   completion->priv->check_completion_idle = NULL;

  gtk_entry_completion_complete (completion);
  gtk_entry_completion_insert_prefix (completion);

Hope this helps a bit :)
Comment 1 Salvatore De Paolis 2010-10-27 15:59:42 UTC
Hi,
I faced with the same issue today, I think the problem is related to the callback being called from the GtkEntry instead of the GtkEntryCompletion.

To replicate the bug you could do like that:

1. on a function disable the popup completion with:
   gtk_entry_completion_set_popup_completion(completion, FALSE);

2. bind the key-press-event signal to the entry

3. match for GDK_Tab and in the related if branch:

   gtk_entry_completion_set_popup_completion(completion, TRUE);
   gtk_entry_completion_complete(completion);
   gtk_entry_completion_set_popup_completion(completion, FALSE);
   return TRUE;

In this way the completion window will not be showed.

A workaround i found is to emit the "changed" signal on the GtkEntry
before to call the .._completion_complete in this way:

gboolean complete (GtkEntry *entry, GdkEventKey *ev, gpointer data) {

	GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION(data);
	if (ev->keyval ==  GDK_Tab) {
		gtk_entry_completion_set_popup_completion(completion, TRUE);
		GtkWidget *entry = gtk_entry_completion_get_entry(completion);
		g_signal_emit_by_name(entry, "changed", NULL);
		gtk_entry_completion_complete(completion);
		gtk_entry_completion_set_popup_completion(completion, FALSE);
		return TRUE;
	}
	return FALSE;
}

HTH

Salvatore
Comment 2 Matthias Clasen 2018-02-10 03:46:02 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.