@@ -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
@@ -360,6 +360,13 @@ create_dialog(GtkWidget **dialog)
360
360
gtk_entry_completion_set_text_column (completion , 0 );
361
361
gtk_entry_completion_set_minimum_key_length (completion , 0 );
362
362
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
+
367
+ /* Manual trigger to show the completion list as soon as the dialog opens */
368
+ g_signal_emit_by_name (entry , "changed" );
369
+
363
370
/* Signals */
364
371
g_signal_connect_after (entry , "changed" ,
365
372
G_CALLBACK (directory_check ), completion );
@@ -370,11 +377,6 @@ create_dialog(GtkWidget **dialog)
370
377
* reference, and it will be deallocated when the entry is destroyed. */
371
378
g_object_unref (completion );
372
379
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
-
378
380
gtk_widget_show_all (* dialog );
379
381
380
382
return entry ;
0 commit comments