[gimp] Issue #2237 - export as, select file type (by extention) list problem
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #2237 - export as, select file type (by extention) list problem
- Date: Tue, 16 Oct 2018 11:51:19 +0000 (UTC)
commit e26a220a6fb78358fe3078f23a25e539e6a165e8
Author: Ell <ell_se yahoo com>
Date: Tue Oct 16 04:28:28 2018 -0400
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.
app/widgets/gimpfiledialog.c | 24 ++++++++-----
app/widgets/gimpfileprocview.c | 78 ++++++++++++++++++++++++------------------
2 files changed, 60 insertions(+), 42 deletions(-)
---
diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c
index c326272d35..ae403cb240 100644
--- a/app/widgets/gimpfiledialog.c
+++ b/app/widgets/gimpfiledialog.c
@@ -797,26 +797,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)
diff --git a/app/widgets/gimpfileprocview.c b/app/widgets/gimpfileprocview.c
index 554c1553e0..ce50f84fda 100644
--- a/app/widgets/gimpfileprocview.c
+++ b/app/widgets/gimpfileprocview.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]