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



commit 3f9c7365925310f79cadd33545cb8f4275172b85
Author: Jehan <jehan girinstud io>
Date:   Fri Apr 2 01:57:10 2021 +0200

    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.

 libgimp/gimpplugin.c | 11 +++++++++++
 libgimp/gimpplugin.h |  4 ++++
 2 files changed, 15 insertions(+)
---
diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c
index d85c626d10..86fd4975f4 100644
--- a/libgimp/gimpplugin.c
+++ b/libgimp/gimpplugin.c
@@ -106,6 +106,17 @@
 
 #define WRITE_BUFFER_SIZE 1024
 
+/**
+ * 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)
 
 enum
 {
diff --git a/libgimp/gimpplugin.h b/libgimp/gimpplugin.h
index ef6cc5b848..9cc9c521a0 100644
--- a/libgimp/gimpplugin.h
+++ b/libgimp/gimpplugin.h
@@ -31,6 +31,8 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
+#define GIMP_PLUG_IN_ERROR           (gimp_plug_in_error_quark ())
+
 #define GIMP_TYPE_PLUG_IN            (gimp_plug_in_get_type ())
 #define GIMP_PLUG_IN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PLUG_IN, GimpPlugIn))
 #define GIMP_PLUG_IN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PLUG_IN, GimpPlugInClass))
@@ -141,6 +143,8 @@ struct _GimpPlugInClass
 };
 
 
+GQuark          gimp_plug_in_error_quark            (void);
+
 GType           gimp_plug_in_get_type               (void) G_GNUC_CONST;
 
 void            gimp_plug_in_set_translation_domain (GimpPlugIn    *plug_in,


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