printunixdialog: Set selection after list view item created

Commit b807b84e16 ("print dialog: Fix initial selection") made a
change where we connect to items-changed before the list item manager.
That leads to us attempting to set a selection for a tile that does
not yet exist.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/7109
This commit is contained in:
Corey Berla
2024-10-28 22:25:37 -07:00
parent 6722e3307e
commit 9e1016a581

View File

@@ -892,8 +892,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
selection = G_LIST_MODEL (gtk_single_selection_new (NULL));
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
gtk_single_selection_set_model (GTK_SINGLE_SELECTION (selection), filtered);
@@ -901,6 +899,9 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
gtk_column_view_set_model (GTK_COLUMN_VIEW (dialog->printer_list), GTK_SELECTION_MODEL (selection));
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
g_object_unref (selection);
gtk_print_load_custom_papers (dialog->custom_paper_list);