filechooserwidget: Return an id in get_choice()
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Sat, 18 Sep 2021 03:17:36 +0000 (00:17 -0300)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 31 Oct 2021 21:52:04 +0000 (17:52 -0400)
gtk_file_chooser_widget_get_choice() is supposed to return the option
id of the choice, but it currently is returning the option label.

Return the option id instead.

gtk/gtkfilechooserwidget.c

index 88e08c171b95eed5518ba719719d0a539fcf4bd4..a2310f35d856c5e0ba5d1087ca5332a1646f341c 100644 (file)
@@ -8060,10 +8060,13 @@ gtk_file_chooser_widget_get_choice (GtkFileChooser  *chooser,
   widget = (GtkWidget *)g_hash_table_lookup (impl->choices, id);
   if (GTK_IS_DROP_DOWN (widget))
     {
-      gpointer selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (widget));
-      if (GTK_IS_STRING_OBJECT (selected))
-        return gtk_string_object_get_string (GTK_STRING_OBJECT (selected));
-      return NULL;
+      const char **options;
+      guint selected;
+
+      options = (const char **) g_object_get_data (G_OBJECT (widget), "options");
+      selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (widget));
+
+      return options[selected];
     }
   else if (GTK_IS_CHECK_BUTTON (widget))
     {