Commit 60c49c56 authored by Ell's avatar Ell
Browse files

Issue #2237 - export as, select file type (by extention) list problem

In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.

Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.

(cherry picked from commit e26a220a)
parent 7d0d7491
......@@ -808,26 +808,32 @@ gimp_file_dialog_proc_changed (GimpFileProcView *view,
GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
GtkFileFilter *filter;
gchar *name;
gchar *label;
dialog->file_proc = gimp_file_proc_view_get_proc (view, &name, &filter);
if (name)
{
gchar *label = g_strdup_printf (_("Select File _Type (%s)"), name);
label = g_strdup_printf (_("Select File _Type (%s)"), name);
else
label = g_strdup (_("Select File _Type"));
gtk_expander_set_label (GTK_EXPANDER (dialog->proc_expander), label);
gtk_expander_set_label (GTK_EXPANDER (dialog->proc_expander), label);
g_free (label);
g_free (name);
g_free (label);
g_free (name);
}
if (dialog->show_all_files)
g_clear_object (&filter);
if (! filter)
{
g_object_unref (filter);
filter = gtk_file_filter_new ();
filter = g_object_ref_sink (gtk_file_filter_new ());
gtk_file_filter_add_pattern (filter, "*");
g_object_ref_sink (filter);
}
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
g_object_unref (filter);
if (gtk_file_chooser_get_action (chooser) == GTK_FILE_CHOOSER_ACTION_SAVE)
......
......@@ -231,49 +231,61 @@ gimp_file_proc_view_get_proc (GimpFileProcView *view,
gchar **label,
GtkFileFilter **filter)
{
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreeSelection *selection;
GimpPlugInProcedure *proc;
GtkTreeIter iter;
gboolean has_selection;
g_return_val_if_fail (GIMP_IS_FILE_PROC_VIEW (view), NULL);
if (label) *label = NULL;
if (filter) *filter = NULL;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
has_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
/* if there's no selected item, we return the "automatic" procedure, which,
* if exists, is the first item.
*/
if (! has_selection)
{
GimpPlugInProcedure *proc;
if (label && filter)
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &proc,
COLUMN_LABEL, label,
COLUMN_FILTER, filter,
-1);
else if (label)
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &proc,
COLUMN_LABEL, label,
-1);
else if (filter)
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &proc,
COLUMN_FILTER, filter,
-1);
else
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &proc,
-1);
if (proc)
g_object_unref (proc);
return proc;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
if (! gtk_tree_model_get_iter_first (model, &iter))
return NULL;
}
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &proc,
-1);
if (proc)
{
g_object_unref (proc);
/* there's no selected item, and no "automatic" procedure. return NULL.
*/
if (! has_selection)
return NULL;
}
if (label)
*label = NULL;
{
gtk_tree_model_get (model, &iter,
COLUMN_LABEL, label,
-1);
}
return NULL;
if (filter)
{
gtk_tree_model_get (model, &iter,
COLUMN_FILTER, filter,
-1);
}
return proc;
}
gboolean
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment