@@ -268,17 +268,17 @@ entry_key_event(GtkEntry *entry, GdkEventKey *key, GtkEntryCompletion *completio
268
268
269
269
if (key -> keyval == GDK_KEY_Tab )
270
270
{
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,
272
272
* like in shells, and in GtkFileChoose. If there's a suggestion, it will
273
273
* be selected, and we may simply move the cursor to accept it. */
274
274
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry ), NULL , & end_pos ))
275
- {
276
275
gtk_editable_set_position (GTK_EDITABLE (entry ), end_pos );
277
276
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" );
282
282
283
283
/* The 2nd purpose of the Tab key is to trigger the procedure that
284
284
* calculates and suggests an inline completion. FYI doing this here
@@ -361,17 +361,16 @@ create_dialog(GtkWidget **dialog)
361
361
gtk_entry_completion_set_text_column (completion , 0 );
362
362
gtk_entry_completion_set_minimum_key_length (completion , 0 );
363
363
364
+ /* Initialize a model for the completion, to avoid errors in code that
365
+ * might attempt to utilize it, before any 'changed' events are fired. */
366
+ directory_check (GTK_ENTRY (entry ), completion );
367
+
364
368
/* Signals */
365
369
g_signal_connect_after (entry , "changed" ,
366
370
G_CALLBACK (directory_check ), completion );
367
371
g_signal_connect (completion , "insert-prefix" ,
368
372
G_CALLBACK (entry_inline_completion_event ), entry );
369
373
370
- /* Manual trigger to invoke directory_check to put together
371
- * a completion model (for the reference dirrectory), and to
372
- * show the completion options as soon as the dialog opens. */
373
- g_signal_emit_by_name (entry , "changed" );
374
-
375
374
gtk_widget_show_all (* dialog );
376
375
377
376
return entry ;
0 commit comments