@@ -268,17 +268,17 @@ entry_key_event(GtkEntry *entry, GdkEventKey *key, GtkEntryCompletion *completio
268268
269269 if (key -> keyval == GDK_KEY_Tab )
270270 {
271- /* The user may 'accept' the autocomplete's suggestion with the Tab key ,
271+ /* The user can use the Tab key to 'accept' the autocomplete's suggestion,
272272 * like in shells, and in GtkFileChoose. If there's a suggestion, it will
273273 * be selected, and we may simply move the cursor to accept it. */
274274 if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry ), NULL , & end_pos ))
275- {
276275 gtk_editable_set_position (GTK_EDITABLE (entry ), end_pos );
277276
278- /* Moving the cursor does not trigger the "changed" event. Do it
279- * manually, to caclulate & show completions for the new path. */
280- g_signal_emit_by_name (entry , "changed" );
281- }
277+ /* The Tab key may also be used to trigger the autocomplete list
278+ * to show up. And this trigger right here after 'accepting' an
279+ * autocomplete suggestion is also useful in order to calculate
280+ * and show completions for the new path. */
281+ g_signal_emit_by_name (entry , "changed" );
282282
283283 /* The 2nd purpose of the Tab key is to trigger the procedure that
284284 * calculates and suggests an inline completion. FYI doing this here
@@ -360,6 +360,10 @@ create_dialog(GtkWidget **dialog)
360360 gtk_entry_completion_set_text_column (completion , 0 );
361361 gtk_entry_completion_set_minimum_key_length (completion , 0 );
362362
363+ /* Initialize a model for the completion, to avoid errors in code that
364+ * might attempt to utilize it, before any 'changed' events are fired. */
365+ directory_check (GTK_ENTRY (entry ), completion );
366+
363367 /* Signals */
364368 g_signal_connect_after (entry , "changed" ,
365369 G_CALLBACK (directory_check ), completion );
@@ -370,11 +374,6 @@ create_dialog(GtkWidget **dialog)
370374 * reference, and it will be deallocated when the entry is destroyed. */
371375 g_object_unref (completion );
372376
373- /* Manual trigger to invoke directory_check to put together
374- * a completion model (for the reference dirrectory), and to
375- * show the completion options as soon as the dialog opens. */
376- g_signal_emit_by_name (entry , "changed" );
377-
378377 gtk_widget_show_all (* dialog );
379378
380379 return entry ;
0 commit comments