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.
This commit is contained in:
Jehan 2021-04-02 01:57:10 +02:00
parent 353c73457a
commit 3f9c736592
2 changed files with 15 additions and 0 deletions

View file

@ -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
{

View file

@ -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,