[gimp/gimp-2-10] app, pdb: add gimp-register-file-handler-priority procedure
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app, pdb: add gimp-register-file-handler-priority procedure
- Date: Tue, 17 Jul 2018 07:04:48 +0000 (UTC)
commit c5c0f87310a7123a182c6395801020dafb5970b7
Author: Ell <ell_se yahoo com>
Date: Tue Jul 17 02:19:58 2018 -0400
app, pdb: add gimp-register-file-handler-priority procedure
Add a gimp-register-file-handler-priority procedure, which can be
used to set the priority of a file-handler procedure. When more
than one file-handler procedure matches a file, the procedure with
the lowest priority is used; if more than one procedure has the
lowest priority, it is unspecified which one of them is used. The
default priority of file-handler procedures is 0.
Add the necessary plumbing (plus some fixes) to the plug-in manager
to handle file-handler priorities. In particular, use two
different lists for each type of file-handler procedures: one meant
for searching, and is sorted according to priority, and one meant
for display, and is sorted alphabetically.
(cherry picked from commit b4ac956859bc2784bc67e7272a3ca01a3004f271)
app/dialogs/preferences-dialog.c | 2 +-
app/pdb/fileops-cmds.c | 59 ++++++++++++++++++
app/pdb/internal-procs.c | 2 +-
app/plug-in/gimppluginmanager-file.c | 32 +++++++++-
app/plug-in/gimppluginmanager-file.h | 5 ++
app/plug-in/gimppluginmanager-restore.c | 95 +++++++++++++++++++++++------
app/plug-in/gimppluginmanager.c | 21 ++++++-
app/plug-in/gimppluginmanager.h | 5 ++
app/plug-in/gimppluginprocedure.c | 9 +++
app/plug-in/gimppluginprocedure.h | 3 +
app/plug-in/plug-in-rc.c | 104 ++++++++++++++++++++++++--------
devel-docs/libgimp/libgimp-docs.sgml | 4 ++
devel-docs/libgimp/libgimp-sections.txt | 1 +
libgimp/gimp.def | 1 +
libgimp/gimpfileops_pdb.c | 38 ++++++++++++
libgimp/gimpfileops_pdb.h | 68 +++++++++++----------
pdb/groups/fileops.pdb | 37 +++++++++++-
17 files changed, 402 insertions(+), 84 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 05c64fc77b..ff0131d76a 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1529,7 +1529,7 @@ prefs_dialog_new (Gimp *gimp,
gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
- view = gimp_plug_in_view_new (gimp->plug_in_manager->raw_load_procs);
+ view = gimp_plug_in_view_new (gimp->plug_in_manager->display_raw_load_procs);
gimp_plug_in_view_set_plug_in (GIMP_PLUG_IN_VIEW (view),
core_config->import_raw_plug_in);
gtk_container_add (GTK_CONTAINER (scrolled_window), view);
diff --git a/app/pdb/fileops-cmds.c b/app/pdb/fileops-cmds.c
index ded6228c66..5af8d42f54 100644
--- a/app/pdb/fileops-cmds.c
+++ b/app/pdb/fileops-cmds.c
@@ -505,6 +505,35 @@ register_save_handler_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
+static GimpValueArray *
+register_file_handler_priority_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ const gchar *procedure_name;
+ gint32 priority;
+
+ procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
+ priority = g_value_get_int (gimp_value_array_index (args, 1));
+
+ if (success)
+ {
+ gchar *canonical = gimp_canonicalize_identifier (procedure_name);
+
+ success = gimp_plug_in_manager_register_priority (gimp->plug_in_manager,
+ canonical, priority);
+
+ g_free (canonical);
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
static GimpValueArray *
register_file_handler_mime_invoker (GimpProcedure *procedure,
Gimp *gimp,
@@ -1013,6 +1042,36 @@ register_fileops_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
+ /*
+ * gimp-register-file-handler-priority
+ */
+ procedure = gimp_procedure_new (register_file_handler_priority_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-register-file-handler-priority");
+ gimp_procedure_set_static_strings (procedure,
+ "gimp-register-file-handler-priority",
+ "Sets the priority of a file handler procedure.",
+ "Sets the priority of a file handler procedure. When more than one
procedure matches a given file, the procedure with the lowest priority is used; if more than one procedure
has the lowest priority, it is unspecified which one of them is used. The default priority for file handler
procedures is 0.",
+ "Ell",
+ "Ell",
+ "2018",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_string ("procedure-name",
+ "procedure name",
+ "The name of the procedure to set the priority of.",
+ FALSE, FALSE, TRUE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_int32 ("priority",
+ "priority",
+ "The procedure priority.",
+ G_MININT32, G_MAXINT32, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
/*
* gimp-register-file-handler-mime
*/
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 179a93cba4..c17b0ccd43 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 841 procedures registered total */
+/* 842 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/plug-in/gimppluginmanager-file.c b/app/plug-in/gimppluginmanager-file.c
index 53e503693b..4da5e55049 100644
--- a/app/plug-in/gimppluginmanager-file.c
+++ b/app/plug-in/gimppluginmanager-file.c
@@ -157,6 +157,32 @@ gimp_plug_in_manager_register_save_handler (GimpPlugInManager *manager,
return TRUE;
}
+gboolean
+gimp_plug_in_manager_register_priority (GimpPlugInManager *manager,
+ const gchar *name,
+ gint priority)
+{
+ GimpPlugInProcedure *file_proc;
+ GSList *list;
+
+ g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), FALSE);
+ g_return_val_if_fail (name != NULL, FALSE);
+
+ if (manager->current_plug_in && manager->current_plug_in->plug_in_def)
+ list = manager->current_plug_in->plug_in_def->procedures;
+ else
+ list = manager->plug_in_procedures;
+
+ file_proc = gimp_plug_in_procedure_find (list, name);
+
+ if (! file_proc)
+ return FALSE;
+
+ gimp_plug_in_procedure_set_priority (file_proc, priority);
+
+ return TRUE;
+}
+
gboolean
gimp_plug_in_manager_register_mime_types (GimpPlugInManager *manager,
const gchar *name,
@@ -273,13 +299,13 @@ gimp_plug_in_manager_get_file_procedures (GimpPlugInManager *manager,
return NULL;
case GIMP_FILE_PROCEDURE_GROUP_OPEN:
- return manager->load_procs;
+ return manager->display_load_procs;
case GIMP_FILE_PROCEDURE_GROUP_SAVE:
- return manager->save_procs;
+ return manager->display_save_procs;
case GIMP_FILE_PROCEDURE_GROUP_EXPORT:
- return manager->export_procs;
+ return manager->display_export_procs;
default:
g_return_val_if_reached (NULL);
diff --git a/app/plug-in/gimppluginmanager-file.h b/app/plug-in/gimppluginmanager-file.h
index 48cc26f4eb..8408218f0e 100644
--- a/app/plug-in/gimppluginmanager-file.h
+++ b/app/plug-in/gimppluginmanager-file.h
@@ -31,6 +31,11 @@ gboolean gimp_plug_in_manager_register_save_handler (GimpPlugInManager *manage
const gchar *extensions,
const gchar *prefixes);
+gboolean gimp_plug_in_manager_register_priority (GimpPlugInManager *manager,
+ const gchar *name,
+ gint priority);
+
+
gboolean gimp_plug_in_manager_register_mime_types (GimpPlugInManager *manager,
const gchar *name,
const gchar *mime_types);
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index 59eb67b5c0..e2108f1f07 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -869,14 +869,40 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
manager->load_procs =
g_slist_sort_with_data (manager->load_procs,
- gimp_plug_in_manager_file_proc_compare, manager);
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (FALSE));
manager->save_procs =
g_slist_sort_with_data (manager->save_procs,
- gimp_plug_in_manager_file_proc_compare, manager);
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (FALSE));
manager->export_procs =
g_slist_sort_with_data (manager->export_procs,
- gimp_plug_in_manager_file_proc_compare, manager);
-
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (FALSE));
+
+ g_clear_pointer (&manager->display_load_procs, g_slist_free);
+ g_clear_pointer (&manager->display_save_procs, g_slist_free);
+ g_clear_pointer (&manager->display_export_procs, g_slist_free);
+
+ manager->display_load_procs = g_slist_copy (manager->load_procs);
+ manager->display_save_procs = g_slist_copy (manager->save_procs);
+ manager->display_export_procs = g_slist_copy (manager->export_procs);
+
+ manager->display_load_procs =
+ g_slist_sort_with_data (manager->display_load_procs,
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (TRUE));
+ manager->display_save_procs =
+ g_slist_sort_with_data (manager->display_save_procs,
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (TRUE));
+ manager->display_export_procs =
+ g_slist_sort_with_data (manager->display_export_procs,
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (TRUE));
+
+ g_clear_pointer (&manager->raw_load_procs, g_slist_free);
+ g_clear_pointer (&manager->display_raw_load_procs, g_slist_free);
if (config->import_raw_plug_in)
{
@@ -898,8 +924,8 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
{
GFile *file;
- manager->raw_load_procs = g_slist_append (manager->raw_load_procs,
- file_proc);
+ manager->raw_load_procs = g_slist_prepend (manager->raw_load_procs,
+ file_proc);
file = gimp_plug_in_procedure_get_file (file_proc);
@@ -912,6 +938,13 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
}
}
+ manager->raw_load_procs = g_slist_reverse (manager->raw_load_procs);
+ manager->display_raw_load_procs = g_slist_copy (manager->raw_load_procs);
+ manager->display_raw_load_procs =
+ g_slist_sort_with_data (manager->display_raw_load_procs,
+ gimp_plug_in_manager_file_proc_compare,
+ GINT_TO_POINTER (TRUE));
+
if (config_plug_in)
g_object_unref (config_plug_in);
@@ -969,8 +1002,10 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
! g_file_equal (gimp_plug_in_procedure_get_file (file_proc),
raw_plug_in))
{
- manager->load_procs = g_slist_remove (manager->load_procs,
- file_proc);
+ manager->load_procs =
+ g_slist_remove (manager->load_procs, file_proc);
+ manager->display_load_procs =
+ g_slist_remove (manager->display_load_procs, file_proc);
}
}
}
@@ -980,23 +1015,49 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
- GimpPlugInProcedure *proc_a = GIMP_PLUG_IN_PROCEDURE (a);
- GimpPlugInProcedure *proc_b = GIMP_PLUG_IN_PROCEDURE (b);
+ GimpPlugInProcedure *proc_a = GIMP_PLUG_IN_PROCEDURE (a);
+ GimpPlugInProcedure *proc_b = GIMP_PLUG_IN_PROCEDURE (b);
+ gboolean display = GPOINTER_TO_INT (data);
const gchar *label_a;
const gchar *label_b;
- gint retval = 0;
+ gint retval = 0;
- if (g_str_has_prefix (gimp_file_get_utf8_name (proc_a->file), "gimp-xcf"))
- return -1;
+ if (g_str_has_prefix (gimp_file_get_utf8_name (proc_a->file),
+ "gimp-xcf"))
+ {
+ if (! g_str_has_prefix (gimp_file_get_utf8_name (proc_b->file),
+ "gimp-xcf"))
+ {
+ return -1;
+ }
+ }
+ else if (g_str_has_prefix (gimp_file_get_utf8_name (proc_b->file),
+ "gimp-xcf"))
+ {
+ return 1;
+ }
- if (g_str_has_prefix (gimp_file_get_utf8_name (proc_b->file), "gimp-xcf"))
- return 1;
+ if (! display && proc_a->priority != proc_b->priority)
+ return proc_a->priority - proc_b->priority;
label_a = gimp_procedure_get_label (GIMP_PROCEDURE (proc_a));
label_b = gimp_procedure_get_label (GIMP_PROCEDURE (proc_b));
- if (label_a && label_b)
- retval = g_utf8_collate (label_a, label_b);
+ if (label_a)
+ {
+ if (label_b)
+ retval = g_utf8_collate (label_a, label_b);
+ else
+ return -1;
+ }
+ else if (label_b)
+ {
+ return 1;
+ }
+ else
+ {
+ retval = (proc_b < proc_a) - (proc_a < proc_b);
+ }
return retval;
}
diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c
index 2260a16d91..d8952a289f 100644
--- a/app/plug-in/gimppluginmanager.c
+++ b/app/plug-in/gimppluginmanager.c
@@ -137,6 +137,11 @@ gimp_plug_in_manager_finalize (GObject *object)
g_clear_pointer (&manager->export_procs, g_slist_free);
g_clear_pointer (&manager->raw_load_procs, g_slist_free);
+ g_clear_pointer (&manager->display_load_procs, g_slist_free);
+ g_clear_pointer (&manager->display_save_procs, g_slist_free);
+ g_clear_pointer (&manager->display_export_procs, g_slist_free);
+ g_clear_pointer (&manager->display_raw_load_procs, g_slist_free);
+
if (manager->plug_in_procedures)
{
g_slist_free_full (manager->plug_in_procedures,
@@ -180,6 +185,11 @@ gimp_plug_in_manager_get_memsize (GimpObject *object,
memsize += gimp_g_slist_get_memsize (manager->load_procs, 0);
memsize += gimp_g_slist_get_memsize (manager->save_procs, 0);
memsize += gimp_g_slist_get_memsize (manager->export_procs, 0);
+ memsize += gimp_g_slist_get_memsize (manager->raw_load_procs, 0);
+ memsize += gimp_g_slist_get_memsize (manager->display_load_procs, 0);
+ memsize += gimp_g_slist_get_memsize (manager->display_save_procs, 0);
+ memsize += gimp_g_slist_get_memsize (manager->display_export_procs, 0);
+ memsize += gimp_g_slist_get_memsize (manager->display_raw_load_procs, 0);
memsize += gimp_g_slist_get_memsize (manager->menu_branches, 0 /* FIXME */);
memsize += gimp_g_slist_get_memsize (manager->locale_domains, 0 /* FIXME */);
@@ -304,9 +314,14 @@ gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager,
}
/* also remove it from the lists of load, save and export procs */
- manager->load_procs = g_slist_remove (manager->load_procs, tmp_proc);
- manager->save_procs = g_slist_remove (manager->save_procs, tmp_proc);
- manager->export_procs = g_slist_remove (manager->export_procs, tmp_proc);
+ manager->load_procs = g_slist_remove (manager->load_procs, tmp_proc);
+ manager->save_procs = g_slist_remove (manager->save_procs, tmp_proc);
+ manager->export_procs = g_slist_remove (manager->export_procs, tmp_proc);
+ manager->raw_load_procs = g_slist_remove (manager->raw_load_procs, tmp_proc);
+ manager->display_load_procs = g_slist_remove (manager->display_load_procs, tmp_proc);
+ manager->display_save_procs = g_slist_remove (manager->display_save_procs, tmp_proc);
+ manager->display_export_procs = g_slist_remove (manager->display_export_procs, tmp_proc);
+ manager->display_raw_load_procs = g_slist_remove (manager->display_raw_load_procs, tmp_proc);
/* and from the history */
gimp_filter_history_remove (manager->gimp, GIMP_PROCEDURE (tmp_proc));
diff --git a/app/plug-in/gimppluginmanager.h b/app/plug-in/gimppluginmanager.h
index de48b298cb..11f80b120f 100644
--- a/app/plug-in/gimppluginmanager.h
+++ b/app/plug-in/gimppluginmanager.h
@@ -49,6 +49,11 @@ struct _GimpPlugInManager
GSList *export_procs;
GSList *raw_load_procs;
+ GSList *display_load_procs;
+ GSList *display_save_procs;
+ GSList *display_export_procs;
+ GSList *display_raw_load_procs;
+
GSList *menu_branches;
GSList *locale_domains;
GSList *help_domains;
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index b010b33790..db7d240fab 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -1188,6 +1188,15 @@ gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *proc,
proc->magics_list = extensions_parse (proc->magics);
}
+void
+gimp_plug_in_procedure_set_priority (GimpPlugInProcedure *proc,
+ gint priority)
+{
+ g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
+
+ proc->priority = priority;
+}
+
void
gimp_plug_in_procedure_set_mime_types (GimpPlugInProcedure *proc,
const gchar *mime_types)
diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h
index 88396725b8..e462040830 100644
--- a/app/plug-in/gimppluginprocedure.h
+++ b/app/plug-in/gimppluginprocedure.h
@@ -60,6 +60,7 @@ struct _GimpPlugInProcedure
gchar *extensions;
gchar *prefixes;
gchar *magics;
+ gint priority;
gchar *mime_types;
gboolean handles_uri;
gboolean handles_raw;
@@ -120,6 +121,8 @@ void gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *pro
const gchar *extensions,
const gchar *prefixes,
const gchar *magics);
+void gimp_plug_in_procedure_set_priority (GimpPlugInProcedure *proc,
+ gint priority);
void gimp_plug_in_procedure_set_mime_types (GimpPlugInProcedure *proc,
const gchar *mime_ypes);
void gimp_plug_in_procedure_set_handles_uri (GimpPlugInProcedure *proc);
diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c
index da8c47dce5..87bd8e7292 100644
--- a/app/plug-in/plug-in-rc.c
+++ b/app/plug-in/plug-in-rc.c
@@ -91,6 +91,7 @@ enum
EXTENSIONS,
PREFIXES,
MAGICS,
+ PRIORITY,
MIME_TYPES,
HANDLES_URI,
HANDLES_RAW,
@@ -155,6 +156,8 @@ plug_in_rc_parse (Gimp *gimp,
"prefixes", GINT_TO_POINTER (PREFIXES));
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
"magics", GINT_TO_POINTER (MAGICS));
+ g_scanner_scope_add_symbol (scanner, LOAD_PROC,
+ "priority", GINT_TO_POINTER (PRIORITY));
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
"mime-types", GINT_TO_POINTER (MIME_TYPES));
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
@@ -168,6 +171,8 @@ plug_in_rc_parse (Gimp *gimp,
"extensions", GINT_TO_POINTER (EXTENSIONS));
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
"prefixes", GINT_TO_POINTER (PREFIXES));
+ g_scanner_scope_add_symbol (scanner, SAVE_PROC,
+ "priority", GINT_TO_POINTER (PRIORITY));
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
"mime-types", GINT_TO_POINTER (MIME_TYPES));
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
@@ -603,9 +608,8 @@ static GTokenType
plug_in_file_proc_deserialize (GScanner *scanner,
GimpPlugInProcedure *proc)
{
- GTokenType token;
- gint symbol;
- gchar *value;
+ GTokenType token;
+ gint symbol;
if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
return G_TOKEN_LEFT_PAREN;
@@ -633,38 +637,66 @@ plug_in_file_proc_deserialize (GScanner *scanner,
symbol = GPOINTER_TO_INT (scanner->value.v_symbol);
- if (symbol == MAGICS)
- {
- if (! gimp_scanner_parse_string_no_validate (scanner, &value))
- return G_TOKEN_STRING;
- }
- else if (symbol != HANDLES_URI &&
- symbol != HANDLES_RAW)
- {
- if (! gimp_scanner_parse_string (scanner, &value))
- return G_TOKEN_STRING;
- }
-
switch (symbol)
{
case EXTENSIONS:
- g_free (proc->extensions);
- proc->extensions = value;
+ {
+ gchar *extensions;
+
+ if (! gimp_scanner_parse_string (scanner, &extensions))
+ return G_TOKEN_STRING;
+
+ g_free (proc->extensions);
+ proc->extensions = extensions;
+ }
break;
case PREFIXES:
- g_free (proc->prefixes);
- proc->prefixes = value;
+ {
+ gchar *prefixes;
+
+ if (! gimp_scanner_parse_string (scanner, &prefixes))
+ return G_TOKEN_STRING;
+
+ g_free (proc->prefixes);
+ proc->extensions = prefixes;
+ }
break;
case MAGICS:
- g_free (proc->magics);
- proc->magics = value;
+ {
+ gchar *magics;
+
+ if (! gimp_scanner_parse_string_no_validate (scanner, &magics))
+ return G_TOKEN_STRING;
+
+ g_free (proc->magics);
+ proc->magics = magics;
+ }
+ break;
+
+ case PRIORITY:
+ {
+ gint priority;
+
+ if (! gimp_scanner_parse_int (scanner, &priority))
+ return G_TOKEN_INT;
+
+ gimp_plug_in_procedure_set_priority (proc, priority);
+ }
break;
case MIME_TYPES:
- gimp_plug_in_procedure_set_mime_types (proc, value);
- g_free (value);
+ {
+ gchar *mime_types;
+
+ if (! gimp_scanner_parse_string (scanner, &mime_types))
+ return G_TOKEN_STRING;
+
+ gimp_plug_in_procedure_set_mime_types (proc, mime_types);
+
+ g_free (mime_types);
+ }
break;
case HANDLES_URI:
@@ -676,8 +708,16 @@ plug_in_file_proc_deserialize (GScanner *scanner,
break;
case THUMB_LOADER:
- gimp_plug_in_procedure_set_thumb_loader (proc, value);
- g_free (value);
+ {
+ gchar *thumb_loader;
+
+ if (! gimp_scanner_parse_string (scanner, &thumb_loader))
+ return G_TOKEN_STRING;
+
+ gimp_plug_in_procedure_set_thumb_loader (proc, thumb_loader);
+
+ g_free (thumb_loader);
+ }
break;
default:
@@ -961,6 +1001,13 @@ plug_in_rc_write (GSList *plug_in_defs,
gimp_config_writer_close (writer);
}
+ if (proc->priority)
+ {
+ gimp_config_writer_open (writer, "priority");
+ gimp_config_writer_printf (writer, "%d", proc->priority);
+ gimp_config_writer_close (writer);
+ }
+
if (proc->mime_types && *proc->mime_types)
{
gimp_config_writer_open (writer, "mime-types");
@@ -968,6 +1015,13 @@ plug_in_rc_write (GSList *plug_in_defs,
gimp_config_writer_close (writer);
}
+ if (proc->priority)
+ {
+ gimp_config_writer_open (writer, "priority");
+ gimp_config_writer_printf (writer, "%d", proc->priority);
+ gimp_config_writer_close (writer);
+ }
+
if (proc->handles_uri)
{
gimp_config_writer_open (writer, "handles-uri");
diff --git a/devel-docs/libgimp/libgimp-docs.sgml b/devel-docs/libgimp/libgimp-docs.sgml
index 940144bcfd..f2b276f8f7 100644
--- a/devel-docs/libgimp/libgimp-docs.sgml
+++ b/devel-docs/libgimp/libgimp-docs.sgml
@@ -166,6 +166,10 @@
<title>Index of new symbols in GIMP 2.10.4</title>
<xi:include href="xml/api-index-2.10.4.xml"><xi:fallback /></xi:include>
</index>
+ <index role="2.10.6" id="api-index-2-10-6">
+ <title>Index of new symbols in GIMP 2.10.6</title>
+ <xi:include href="xml/api-index-2.10.6.xml"><xi:fallback /></xi:include>
+ </index>
<index role="deprecated" id="api-index-deprecated">
<title>Index of deprecated symbols</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
diff --git a/devel-docs/libgimp/libgimp-sections.txt b/devel-docs/libgimp/libgimp-sections.txt
index e09b241ce6..ff17ea00f4 100644
--- a/devel-docs/libgimp/libgimp-sections.txt
+++ b/devel-docs/libgimp/libgimp-sections.txt
@@ -507,6 +507,7 @@ gimp_file_save_thumbnail
gimp_register_magic_load_handler
gimp_register_load_handler
gimp_register_save_handler
+gimp_register_file_handler_priority
gimp_register_file_handler_mime
gimp_register_file_handler_uri
gimp_register_file_handler_raw
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 79bb8b9b38..a37171c1ca 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -797,6 +797,7 @@ EXPORTS
gimp_read_expect_msg
gimp_rect_select
gimp_register_file_handler_mime
+ gimp_register_file_handler_priority
gimp_register_file_handler_raw
gimp_register_file_handler_uri
gimp_register_load_handler
diff --git a/libgimp/gimpfileops_pdb.c b/libgimp/gimpfileops_pdb.c
index d045f3c85d..6f14eae610 100644
--- a/libgimp/gimpfileops_pdb.c
+++ b/libgimp/gimpfileops_pdb.c
@@ -365,6 +365,44 @@ gimp_register_save_handler (const gchar *procedure_name,
return success;
}
+/**
+ * gimp_register_file_handler_priority:
+ * @procedure_name: The name of the procedure to set the priority of.
+ * @priority: The procedure priority.
+ *
+ * Sets the priority of a file handler procedure.
+ *
+ * Sets the priority of a file handler procedure. When more than one
+ * procedure matches a given file, the procedure with the lowest
+ * priority is used; if more than one procedure has the lowest
+ * priority, it is unspecified which one of them is used. The default
+ * priority for file handler procedures is 0.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.10.6
+ **/
+gboolean
+gimp_register_file_handler_priority (const gchar *procedure_name,
+ gint priority)
+{
+ GimpParam *return_vals;
+ gint nreturn_vals;
+ gboolean success = TRUE;
+
+ return_vals = gimp_run_procedure ("gimp-register-file-handler-priority",
+ &nreturn_vals,
+ GIMP_PDB_STRING, procedure_name,
+ GIMP_PDB_INT32, priority,
+ GIMP_PDB_END);
+
+ success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+ gimp_destroy_params (return_vals, nreturn_vals);
+
+ return success;
+}
+
/**
* gimp_register_file_handler_mime:
* @procedure_name: The name of the procedure to associate a MIME type with.
diff --git a/libgimp/gimpfileops_pdb.h b/libgimp/gimpfileops_pdb.h
index f972c99bc4..80d2589631 100644
--- a/libgimp/gimpfileops_pdb.h
+++ b/libgimp/gimpfileops_pdb.h
@@ -32,39 +32,41 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-gint32 gimp_file_load (GimpRunMode run_mode,
- const gchar *filename,
- const gchar *raw_filename);
-gint32 gimp_file_load_layer (GimpRunMode run_mode,
- gint32 image_ID,
- const gchar *filename);
-gint* gimp_file_load_layers (GimpRunMode run_mode,
- gint32 image_ID,
- const gchar *filename,
- gint *num_layers);
-gboolean gimp_file_save (GimpRunMode run_mode,
- gint32 image_ID,
- gint32 drawable_ID,
- const gchar *filename,
- const gchar *raw_filename);
-gboolean gimp_file_save_thumbnail (gint32 image_ID,
- const gchar *filename);
-gboolean gimp_register_magic_load_handler (const gchar *procedure_name,
- const gchar *extensions,
- const gchar *prefixes,
- const gchar *magics);
-gboolean gimp_register_load_handler (const gchar *procedure_name,
- const gchar *extensions,
- const gchar *prefixes);
-gboolean gimp_register_save_handler (const gchar *procedure_name,
- const gchar *extensions,
- const gchar *prefixes);
-gboolean gimp_register_file_handler_mime (const gchar *procedure_name,
- const gchar *mime_types);
-gboolean gimp_register_file_handler_uri (const gchar *procedure_name);
-gboolean gimp_register_file_handler_raw (const gchar *procedure_name);
-gboolean gimp_register_thumbnail_loader (const gchar *load_proc,
- const gchar *thumb_proc);
+gint32 gimp_file_load (GimpRunMode run_mode,
+ const gchar *filename,
+ const gchar *raw_filename);
+gint32 gimp_file_load_layer (GimpRunMode run_mode,
+ gint32 image_ID,
+ const gchar *filename);
+gint* gimp_file_load_layers (GimpRunMode run_mode,
+ gint32 image_ID,
+ const gchar *filename,
+ gint *num_layers);
+gboolean gimp_file_save (GimpRunMode run_mode,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ const gchar *filename,
+ const gchar *raw_filename);
+gboolean gimp_file_save_thumbnail (gint32 image_ID,
+ const gchar *filename);
+gboolean gimp_register_magic_load_handler (const gchar *procedure_name,
+ const gchar *extensions,
+ const gchar *prefixes,
+ const gchar *magics);
+gboolean gimp_register_load_handler (const gchar *procedure_name,
+ const gchar *extensions,
+ const gchar *prefixes);
+gboolean gimp_register_save_handler (const gchar *procedure_name,
+ const gchar *extensions,
+ const gchar *prefixes);
+gboolean gimp_register_file_handler_priority (const gchar *procedure_name,
+ gint priority);
+gboolean gimp_register_file_handler_mime (const gchar *procedure_name,
+ const gchar *mime_types);
+gboolean gimp_register_file_handler_uri (const gchar *procedure_name);
+gboolean gimp_register_file_handler_raw (const gchar *procedure_name);
+gboolean gimp_register_thumbnail_loader (const gchar *load_proc,
+ const gchar *thumb_proc);
G_END_DECLS
diff --git a/pdb/groups/fileops.pdb b/pdb/groups/fileops.pdb
index 6501920699..ff5ded8fa5 100644
--- a/pdb/groups/fileops.pdb
+++ b/pdb/groups/fileops.pdb
@@ -555,6 +555,40 @@ CODE
);
}
+sub register_file_handler_priority {
+ $blurb = 'Sets the priority of a file handler procedure.';
+
+ $help = <<'HELP';
+Sets the priority of a file handler procedure. When more than one
+procedure matches a given file, the procedure with the lowest priority
+is used; if more than one procedure has the lowest priority, it is
+unspecified which one of them is used. The default priority for file
+handler procedures is 0.
+HELP
+
+ &ell_pdb_misc('2018', '2.10.6');
+
+ @inargs = (
+ { name => 'procedure_name', type => 'string', non_empty => 1,
+ desc => "The name of the procedure to set the priority of." },
+ { name => 'priority', type => 'int32',
+ desc => "The procedure priority." }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ gchar *canonical = gimp_canonicalize_identifier (procedure_name);
+
+ success = gimp_plug_in_manager_register_priority (gimp->plug_in_manager,
+ canonical, priority);
+
+ g_free (canonical);
+}
+CODE
+ );
+}
+
sub register_file_handler_uri {
$blurb = 'Registers a file handler procedure as capable of handling URIs.';
@@ -706,12 +740,13 @@ CODE
register_magic_load_handler
register_load_handler
register_save_handler
+ register_file_handler_priority
register_file_handler_mime
register_file_handler_uri
register_file_handler_raw
register_thumbnail_loader);
-%exports = (app => [@procs], lib => [@procs[0..3,5..12]]);
+%exports = (app => [@procs], lib => [@procs[0..3,5..13]]);
$desc = 'File Operations';
$doc_title = 'gimpfileops';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]