+/* Calback for the "notify::popup-shown" signal on the combo box.
+ * When the combo is popped up, we don't want the ROW_TYPE_EMPTY_SELECTION to be visible
+ * at all; otherwise we would be showing a "(None)" item in the combo box's popup.
+ *
+ * However, when the combo box is *not* popped up, we want the empty-selection row
+ * to be visible depending on the selection.
+ *
+ * Since all that is done through the filter_model_visible_func(), this means
+ * that we need to refilter the model when the combo box pops up - hence the
+ * present signal handler.
+ */
+static void
+combo_box_notify_popup_shown_cb (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
+ GtkFileChooserButtonPrivate *priv = button->priv;
+ gboolean popup_shown;
+
+ g_object_get (priv->combo_box,
+ "popup-shown", &popup_shown,
+ NULL);
+
+ /* Indicate that the ROW_TYPE_EMPTY_SELECTION will change visibility... */
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
+
+ /* If the combo box popup got dismissed, go back to showing the ROW_TYPE_EMPTY_SELECTION if needed */
+ if (!popup_shown)
+ {
+ GFile *selected = get_selected_file (button);
+
+ if (!selected)
+ {
+ int pos;
+
+ pos = model_get_type_position (button, ROW_TYPE_EMPTY_SELECTION);
+ select_combo_box_row_no_notify (button, pos);
+ }
+ else
+ g_object_unref (selected);
+ }
+}
+