priv->current_folder_while_inactive = g_object_ref (file);
+ update_combo_box (button);
+
g_signal_emit_by_name (button, "current-folder-changed");
return TRUE;
priv->selection_while_inactive = g_object_ref (file);
+ update_label_and_image (button);
+ update_combo_box (button);
+
return TRUE;
}
}
g_object_unref (priv->selection_while_inactive);
priv->selection_while_inactive = NULL;
}
+
+ update_label_and_image (button);
+ update_combo_box (button);
}
}
}
{
g_object_unref (priv->selection_while_inactive);
priv->selection_while_inactive = NULL;
+
+ update_label_and_image (button);
+ update_combo_box (button);
}
}
}
-static GSList *
-gtk_file_chooser_button_get_files (GtkFileChooser *chooser)
+static GFile *
+get_selected_file (GtkFileChooserButton *button)
{
- GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
GtkFileChooserButtonPrivate *priv = button->priv;
- GtkFileChooser *delegate;
-
- delegate = g_object_get_qdata (G_OBJECT (chooser),
- GTK_FILE_CHOOSER_DELEGATE_QUARK);
if (priv->active)
- return gtk_file_chooser_get_files (delegate);
+ return gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
else
{
- GSList *result;
-
- result = NULL;
-
if (priv->selection_while_inactive)
- result = g_slist_prepend (NULL, g_object_ref (priv->selection_while_inactive));
+ return g_object_ref (priv->selection_while_inactive);
else if (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (priv->dialog)) == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
/* If there is no "real" selection in SELECT_FOLDER mode, then we'll just return
* the current folder, since that is what GtkFileChooserDefault would do.
*/
if (priv->current_folder_while_inactive)
- result = g_slist_prepend (NULL, g_object_ref (priv->current_folder_while_inactive));
+ return g_object_ref (priv->current_folder_while_inactive);
}
-
- return result;
}
+
+ return NULL;
+}
+
+static GSList *
+gtk_file_chooser_button_get_files (GtkFileChooser *chooser)
+{
+ GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
+
+ return g_slist_prepend (NULL, get_selected_file (button));
}
static gboolean
GtkTreeIter iter;
gboolean row_found;
- gtk_tree_model_get_iter_first (priv->filter_model, &iter);
-
- file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
+ file = get_selected_file (button);
row_found = FALSE;
+ gtk_tree_model_get_iter_first (priv->filter_model, &iter);
+
do
{
gchar type;
gchar *label_text;
GFile *file;
- file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
+ file = get_selected_file (button);
+
label_text = NULL;
if (priv->update_button_cancellable)
_gtk_file_system_volume_unref (volume);
if (label_text)
- goto out;
+ goto out;
}
if (g_file_is_native (file))
if (pixbuf)
g_object_unref (pixbuf);
}
-
- g_object_unref (file);
}
out:
+ if (file)
+ g_object_unref (file);
+
if (label_text)
{
gtk_label_set_text (GTK_LABEL (priv->label), label_text);