@@ -266,17 +266,17 @@ entry_key_event(GtkEntry *entry, GdkEventKey *key, GtkEntryCompletion *completio
266
266
267
267
if (key -> keyval == GDK_KEY_Tab )
268
268
{
269
- /* The user may 'accept' the autocomplete's suggestion with the Tab key ,
269
+ /* The user can use the Tab key to 'accept' the autocomplete's suggestion,
270
270
* like in shells, and in GtkFileChoose. If there's a suggestion, it will
271
271
* be selected, and we may simply move the cursor to accept it. */
272
272
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry ), NULL , & end_pos ))
273
- {
274
273
gtk_editable_set_position (GTK_EDITABLE (entry ), end_pos );
275
274
276
- /* Moving the cursor does not trigger the "changed" event. Do it
277
- * manually, to caclulate & show completions for the new path. */
278
- g_signal_emit_by_name (entry , "changed" );
279
- }
275
+ /* The Tab key may also be used to trigger the autocomplete list
276
+ * to show up. And this trigger right here after 'accepting' an
277
+ * autocomplete suggestion is also useful in order to calculate
278
+ * and show completions for the new path. */
279
+ g_signal_emit_by_name (entry , "changed" );
280
280
281
281
/* The 2nd purpose of the Tab key is to trigger the procedure that
282
282
* calculates and suggests an inline completion. FYI doing this here
@@ -359,17 +359,16 @@ create_dialog(GtkWidget **dialog)
359
359
gtk_entry_completion_set_text_column (completion , 0 );
360
360
gtk_entry_completion_set_minimum_key_length (completion , 0 );
361
361
362
+ /* Initialize a model for the completion, to avoid errors in code that
363
+ * might attempt to utilize it, before any 'changed' events are fired. */
364
+ directory_check (GTK_ENTRY (entry ), completion );
365
+
362
366
/* Signals */
363
367
g_signal_connect_after (entry , "changed" ,
364
368
G_CALLBACK (directory_check ), completion );
365
369
g_signal_connect (completion , "insert-prefix" ,
366
370
G_CALLBACK (entry_inline_completion_event ), entry );
367
371
368
- /* Manual trigger to invoke directory_check to put together
369
- * a completion model (for the reference dirrectory), and to
370
- * show the completion options as soon as the dialog opens. */
371
- g_signal_emit_by_name (entry , "changed" );
372
-
373
372
gtk_widget_show_all (* dialog );
374
373
375
374
return entry ;
0 commit comments