+/* GtkWidget::map handler */
+static void
+gtk_file_chooser_dialog_map (GtkWidget *widget)
+{
+ GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
+ GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+
+ if (!GTK_WIDGET_MAPPED (priv->widget))
+ gtk_widget_map (priv->widget);
+
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
+
+ _gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget));
+}
+
+/* GtkWidget::unmap handler */
+static void
+gtk_file_chooser_dialog_unmap (GtkWidget *widget)
+{
+ GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
+ GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+
+ GTK_WIDGET_CLASS (parent_class)->unmap (widget);
+
+ /* See bug #145470. We unmap the GtkFileChooserWidget so that if the dialog
+ * is remapped, the widget will be remapped as well. Implementations should
+ * refresh their contents when this happens, as some applications keep a
+ * single file chooser alive and map/unmap it as needed, rather than creating
+ * a new file chooser every time they need one.
+ */
+ gtk_widget_unmap (priv->widget);
+}
+