[gimp/gimp-2-10] libgimp: new gimp_plug_in_error_quark() / GIMP_PLUG_IN_ERROR.



commit ab582b0e5634572a690a73b34913c42cc75fccb8
Author: Jehan <jehan girinstud io>
Date:   Wed Jan 19 14:52:06 2022 +0100

    libgimp: new gimp_plug_in_error_quark() / GIMP_PLUG_IN_ERROR.
    
    We heavily rely on GError in libgimp to retrieve plug-in error messages.
    In a lot of our code, we just use domain=0 for g_set_error*() functions
    and alike, but this is actually forbidden and results in GLib warnings.
    
    Some plug-ins instead create their own domain, other use G_FILE_ERROR
    nearly everywhere, even in some cases where the choice is really
    questionable. Since anyway this is mostly useful for passing the error
    message through, it is much nicer to provide a generic domain
    GIMP_PLUG_IN_ERROR, which can be used by all plug-ins when they don't
    want to bother with the error domain.
    
    Note: basically a copy-paste from commit 3f9c7365925 which could not be
    cherry-picked as surrounding code is completely different.

 libgimp/gimpplugin.c | 14 ++++++++++++++
 libgimp/gimpplugin.h |  4 ++++
 2 files changed, 18 insertions(+)
---
diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c
index 6b938c4562..64611f9fd4 100644
--- a/libgimp/gimpplugin.c
+++ b/libgimp/gimpplugin.c
@@ -24,6 +24,20 @@
 
 #include "gimp.h"
 
+
+/**
+ * gimp_plug_in_error_quark:
+ *
+ * Generic #GQuark error domain for plug-ins. Plug-ins are welcome to
+ * create their own domain when they want to handle advanced error
+ * handling. Often, you just want to pass an error message to the core.
+ * This domain can be used for such simple usage.
+ *
+ * See #GError for information on error domains.
+ */
+G_DEFINE_QUARK (gimp-plug-in-error-quark, gimp_plug_in_error)
+
+
 gboolean
 gimp_plugin_icon_register (const gchar  *procedure_name,
                            GimpIconType  icon_type,
diff --git a/libgimp/gimpplugin.h b/libgimp/gimpplugin.h
index 32b9936471..434f947205 100644
--- a/libgimp/gimpplugin.h
+++ b/libgimp/gimpplugin.h
@@ -29,6 +29,10 @@ G_BEGIN_DECLS
 
 /* For information look into the C source or the html documentation */
 
+#define GIMP_PLUG_IN_ERROR         (gimp_plug_in_error_quark ())
+
+
+GQuark   gimp_plug_in_error_quark  (void);
 
 gboolean gimp_plugin_icon_register (const gchar  *procedure_name,
                                     GimpIconType  icon_type,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]