filechooser: Fix gtk_file_chooser_set_choice again
authorrobxnano <91250-robxnano@users.noreply.gitlab.gnome.org>
Wed, 16 Nov 2022 18:07:20 +0000 (18:07 +0000)
committerrobxnano <91250-robxnano@users.noreply.gitlab.gnome.org>
Wed, 16 Nov 2022 18:07:20 +0000 (18:07 +0000)
If the choice was in the form of a GtkDropDown, the code failed to
find the widget and so the choice never got set. Fixes #5346.

gtk/gtkfilechooserwidget.c

index 20a8f4abb2c267dae32d67c37fe155088e532358..c2b29a203493f4e5a52ea2c42ad5f9585e43f3d6 100644 (file)
@@ -7360,20 +7360,17 @@ gtk_file_chooser_widget_set_choice (GtkFileChooser  *chooser,
 
   widget = (GtkWidget *)g_hash_table_lookup (impl->choices, id);
 
-  if (GTK_IS_BOX (widget))
+  if (GTK_IS_DROP_DOWN (widget))
     {
       guint i;
       const char **options;
-      GtkWidget *dropdown;
-
-      dropdown = gtk_widget_get_last_child (widget);
 
-      options = (const char **) g_object_get_data (G_OBJECT (dropdown), "options");
+      options = (const char **) g_object_get_data (G_OBJECT (widget), "options");
       for (i = 0; options[i]; i++)
         {
           if (strcmp (option, options[i]) == 0)
             {
-              gtk_drop_down_set_selected (GTK_DROP_DOWN (dropdown), i);
+              gtk_drop_down_set_selected (GTK_DROP_DOWN (widget), i);
               break;
             }
         }