app/core: Use G_DECLARE_INTERFACE()

This cuts aways a little of the GObject boilerplate.
This commit is contained in:
Niels De Graef 2019-07-18 19:19:01 +02:00 committed by Jehan
parent a0ba37649d
commit d3e9e5617d
12 changed files with 51 additions and 88 deletions

View File

@ -22,14 +22,10 @@
#define __GIMP_CANCELABLE_H__
#define GIMP_TYPE_CANCELABLE (gimp_cancelable_get_type ())
#define GIMP_IS_CANCELABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANCELABLE))
#define GIMP_CANCELABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANCELABLE, GimpCancelable))
#define GIMP_CANCELABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CANCELABLE, GimpCancelableInterface))
#define GIMP_TYPE_CANCELABLE (gimp_cancelable_get_type ())
G_DECLARE_INTERFACE (GimpCancelable, gimp_cancelable, GIMP, CANCELABLE, GObject)
typedef struct _GimpCancelableInterface GimpCancelableInterface;
struct _GimpCancelableInterface
{
GTypeInterface base_iface;
@ -39,8 +35,6 @@ struct _GimpCancelableInterface
};
GType gimp_cancelable_get_type (void) G_GNUC_CONST;
void gimp_cancelable_cancel (GimpCancelable *cancelable);

View File

@ -122,7 +122,7 @@ gimp_pickable_flush (GimpPickable *pickable)
g_return_if_fail (GIMP_IS_PICKABLE (pickable));
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->flush)
pickable_iface->flush (pickable);
@ -135,7 +135,7 @@ gimp_pickable_get_image (GimpPickable *pickable)
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_image)
return pickable_iface->get_image (pickable);
@ -150,7 +150,7 @@ gimp_pickable_get_format (GimpPickable *pickable)
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_format)
return pickable_iface->get_format (pickable);
@ -165,7 +165,7 @@ gimp_pickable_get_format_with_alpha (GimpPickable *pickable)
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_format_with_alpha)
return pickable_iface->get_format_with_alpha (pickable);
@ -180,7 +180,7 @@ gimp_pickable_get_buffer (GimpPickable *pickable)
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_buffer)
return pickable_iface->get_buffer (pickable);
@ -203,7 +203,7 @@ gimp_pickable_get_pixel_at (GimpPickable *pickable,
if (! format)
format = gimp_pickable_get_format (pickable);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_pixel_at)
return pickable_iface->get_pixel_at (pickable, x, y, format, pixel);
@ -226,7 +226,7 @@ gimp_pickable_get_pixel_average (GimpPickable *pickable,
if (! format)
format = gimp_pickable_get_format (pickable);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_pixel_average)
pickable_iface->get_pixel_average (pickable, rect, format, pixel);
@ -262,7 +262,7 @@ gimp_pickable_get_opacity_at (GimpPickable *pickable,
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), GIMP_OPACITY_TRANSPARENT);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->get_opacity_at)
return pickable_iface->get_opacity_at (pickable, x, y);
@ -285,7 +285,7 @@ gimp_pickable_pixel_to_srgb (GimpPickable *pickable,
if (! format)
format = gimp_pickable_get_format (pickable);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->pixel_to_srgb)
{
@ -312,7 +312,7 @@ gimp_pickable_srgb_to_pixel (GimpPickable *pickable,
if (! format)
format = gimp_pickable_get_format (pickable);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
pickable_iface = GIMP_PICKABLE_GET_IFACE (pickable);
if (pickable_iface->srgb_to_pixel)
{

View File

@ -22,13 +22,8 @@
#define __GIMP_PICKABLE_H__
#define GIMP_TYPE_PICKABLE (gimp_pickable_get_type ())
#define GIMP_IS_PICKABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PICKABLE))
#define GIMP_PICKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PICKABLE, GimpPickable))
#define GIMP_PICKABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_PICKABLE, GimpPickableInterface))
typedef struct _GimpPickableInterface GimpPickableInterface;
#define GIMP_TYPE_PICKABLE (gimp_pickable_get_type ())
G_DECLARE_INTERFACE (GimpPickable, gimp_pickable, GIMP, PICKABLE, GObject)
struct _GimpPickableInterface
{
@ -63,8 +58,6 @@ struct _GimpPickableInterface
};
GType gimp_pickable_get_type (void) G_GNUC_CONST;
void gimp_pickable_flush (GimpPickable *pickable);
GimpImage * gimp_pickable_get_image (GimpPickable *pickable);
const Babl * gimp_pickable_get_format (GimpPickable *pickable);

View File

@ -78,7 +78,7 @@ gimp_progress_start (GimpProgress *progress,
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (format != NULL, NULL);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->start)
{
@ -107,7 +107,7 @@ gimp_progress_end (GimpProgress *progress)
g_return_if_fail (GIMP_IS_PROGRESS (progress));
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->end)
progress_iface->end (progress);
@ -120,7 +120,7 @@ gimp_progress_is_active (GimpProgress *progress)
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), FALSE);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->is_active)
return progress_iface->is_active (progress);
@ -157,7 +157,7 @@ gimp_progress_set_text_literal (GimpProgress *progress,
g_return_if_fail (GIMP_IS_PROGRESS (progress));
g_return_if_fail (message != NULL);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->set_text)
progress_iface->set_text (progress, message);
@ -173,7 +173,7 @@ gimp_progress_set_value (GimpProgress *progress,
percentage = CLAMP (percentage, 0.0, 1.0);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->set_value)
progress_iface->set_value (progress, percentage);
@ -186,7 +186,7 @@ gimp_progress_get_value (GimpProgress *progress)
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), 0.0);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->get_value)
return progress_iface->get_value (progress);
@ -201,7 +201,7 @@ gimp_progress_pulse (GimpProgress *progress)
g_return_if_fail (GIMP_IS_PROGRESS (progress));
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->pulse)
progress_iface->pulse (progress);
@ -214,7 +214,7 @@ gimp_progress_get_window_id (GimpProgress *progress)
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), 0);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->get_window_id)
return progress_iface->get_window_id (progress);
@ -236,7 +236,7 @@ gimp_progress_message (GimpProgress *progress,
g_return_val_if_fail (domain != NULL, FALSE);
g_return_val_if_fail (message != NULL, FALSE);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
progress_iface = GIMP_PROGRESS_GET_IFACE (progress);
if (progress_iface->message)
return progress_iface->message (progress, gimp, severity, domain, message);

View File

@ -22,14 +22,10 @@
#define __GIMP_PROGRESS_H__
#define GIMP_TYPE_PROGRESS (gimp_progress_get_type ())
#define GIMP_IS_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROGRESS))
#define GIMP_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROGRESS, GimpProgress))
#define GIMP_PROGRESS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_PROGRESS, GimpProgressInterface))
#define GIMP_TYPE_PROGRESS (gimp_progress_get_type ())
G_DECLARE_INTERFACE (GimpProgress, gimp_progress, GIMP, PROGRESS, GObject)
typedef struct _GimpProgressInterface GimpProgressInterface;
struct _GimpProgressInterface
{
GTypeInterface base_iface;
@ -61,8 +57,6 @@ struct _GimpProgressInterface
};
GType gimp_progress_get_type (void) G_GNUC_CONST;
GimpProgress * gimp_progress_start (GimpProgress *progress,
gboolean cancellable,
const gchar *format,

View File

@ -148,7 +148,7 @@ gimp_projectable_get_image (GimpProjectable *projectable)
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->get_image)
return iface->get_image (projectable);
@ -163,7 +163,7 @@ gimp_projectable_get_format (GimpProjectable *projectable)
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->get_format)
return iface->get_format (projectable);
@ -182,7 +182,7 @@ gimp_projectable_get_offset (GimpProjectable *projectable,
g_return_if_fail (x != NULL);
g_return_if_fail (y != NULL);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
*x = 0;
*y = 0;
@ -199,7 +199,7 @@ gimp_projectable_get_bounding_box (GimpProjectable *projectable)
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), result);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->get_bounding_box)
result = iface->get_bounding_box (projectable);
@ -214,7 +214,7 @@ gimp_projectable_get_graph (GimpProjectable *projectable)
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->get_graph)
return iface->get_graph (projectable);
@ -229,7 +229,7 @@ gimp_projectable_begin_render (GimpProjectable *projectable)
g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->begin_render)
iface->begin_render (projectable);
@ -242,7 +242,7 @@ gimp_projectable_end_render (GimpProjectable *projectable)
g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->end_render)
iface->end_render (projectable);
@ -255,7 +255,7 @@ gimp_projectable_invalidate_preview (GimpProjectable *projectable)
g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
iface = GIMP_PROJECTABLE_GET_IFACE (projectable);
if (iface->invalidate_preview)
iface->invalidate_preview (projectable);

View File

@ -22,14 +22,10 @@
#define __GIMP_PROJECTABLE_H__
#define GIMP_TYPE_PROJECTABLE (gimp_projectable_get_type ())
#define GIMP_IS_PROJECTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROJECTABLE))
#define GIMP_PROJECTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROJECTABLE, GimpProjectable))
#define GIMP_PROJECTABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_PROJECTABLE, GimpProjectableInterface))
#define GIMP_TYPE_PROJECTABLE (gimp_projectable_get_type ())
G_DECLARE_INTERFACE (GimpProjectable, gimp_projectable, GIMP, PROJECTABLE, GObject)
typedef struct _GimpProjectableInterface GimpProjectableInterface;
struct _GimpProjectableInterface
{
GTypeInterface base_iface;
@ -61,8 +57,6 @@ struct _GimpProjectableInterface
};
GType gimp_projectable_get_type (void) G_GNUC_CONST;
void gimp_projectable_invalidate (GimpProjectable *projectable,
gint x,
gint y,

View File

@ -90,7 +90,7 @@ gimp_tagged_add_tag (GimpTagged *tagged,
g_return_if_fail (GIMP_IS_TAGGED (tagged));
g_return_if_fail (GIMP_IS_TAG (tag));
if (GIMP_TAGGED_GET_INTERFACE (tagged)->add_tag (tagged, tag))
if (GIMP_TAGGED_GET_IFACE (tagged)->add_tag (tagged, tag))
{
g_signal_emit (tagged, gimp_tagged_signals[TAG_ADDED], 0, tag);
}
@ -124,7 +124,7 @@ gimp_tagged_remove_tag (GimpTagged *tagged,
{
g_object_ref (tag_ref);
if (GIMP_TAGGED_GET_INTERFACE (tagged)->remove_tag (tagged, tag_ref))
if (GIMP_TAGGED_GET_IFACE (tagged)->remove_tag (tagged, tag_ref))
{
g_signal_emit (tagged, gimp_tagged_signals[TAG_REMOVED], 0,
tag_ref);
@ -185,7 +185,7 @@ gimp_tagged_get_tags (GimpTagged *tagged)
{
g_return_val_if_fail (GIMP_IS_TAGGED (tagged), NULL);
return GIMP_TAGGED_GET_INTERFACE (tagged)->get_tags (tagged);
return GIMP_TAGGED_GET_IFACE (tagged)->get_tags (tagged);
}
/**
@ -207,7 +207,7 @@ gimp_tagged_get_identifier (GimpTagged *tagged)
{
g_return_val_if_fail (GIMP_IS_TAGGED (tagged), NULL);
return GIMP_TAGGED_GET_INTERFACE (tagged)->get_identifier (tagged);
return GIMP_TAGGED_GET_IFACE (tagged)->get_identifier (tagged);
}
/**
@ -229,7 +229,7 @@ gimp_tagged_get_checksum (GimpTagged *tagged)
{
g_return_val_if_fail (GIMP_IS_TAGGED (tagged), FALSE);
return GIMP_TAGGED_GET_INTERFACE (tagged)->get_checksum (tagged);
return GIMP_TAGGED_GET_IFACE (tagged)->get_checksum (tagged);
}
/**

View File

@ -22,14 +22,10 @@
#define __GIMP_TAGGED_H__
#define GIMP_TYPE_TAGGED (gimp_tagged_get_type ())
#define GIMP_IS_TAGGED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TAGGED))
#define GIMP_TAGGED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TAGGED, GimpTagged))
#define GIMP_TAGGED_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_TAGGED, GimpTaggedInterface))
#define GIMP_TYPE_TAGGED (gimp_tagged_get_type ())
G_DECLARE_INTERFACE (GimpTagged, gimp_tagged, GIMP, TAGGED, GObject)
typedef struct _GimpTaggedInterface GimpTaggedInterface;
struct _GimpTaggedInterface
{
GTypeInterface base_iface;
@ -51,8 +47,6 @@ struct _GimpTaggedInterface
};
GType gimp_tagged_get_type (void) G_GNUC_CONST;
void gimp_tagged_add_tag (GimpTagged *tagged,
GimpTag *tag);
void gimp_tagged_remove_tag (GimpTagged *tagged,

View File

@ -51,7 +51,7 @@ gimp_waitable_wait (GimpWaitable *waitable)
g_return_if_fail (GIMP_IS_WAITABLE (waitable));
iface = GIMP_WAITABLE_GET_INTERFACE (waitable);
iface = GIMP_WAITABLE_GET_IFACE (waitable);
if (iface->wait)
iface->wait (waitable);
@ -64,7 +64,7 @@ gimp_waitable_try_wait (GimpWaitable *waitable)
g_return_val_if_fail (GIMP_IS_WAITABLE (waitable), FALSE);
iface = GIMP_WAITABLE_GET_INTERFACE (waitable);
iface = GIMP_WAITABLE_GET_IFACE (waitable);
if (iface->try_wait)
{
@ -86,7 +86,7 @@ gimp_waitable_wait_until (GimpWaitable *waitable,
g_return_val_if_fail (GIMP_IS_WAITABLE (waitable), FALSE);
iface = GIMP_WAITABLE_GET_INTERFACE (waitable);
iface = GIMP_WAITABLE_GET_IFACE (waitable);
if (iface->wait_until)
{

View File

@ -22,14 +22,10 @@
#define __GIMP_WAITABLE_H__
#define GIMP_TYPE_WAITABLE (gimp_waitable_get_type ())
#define GIMP_IS_WAITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_WAITABLE))
#define GIMP_WAITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_WAITABLE, GimpWaitable))
#define GIMP_WAITABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_WAITABLE, GimpWaitableInterface))
#define GIMP_TYPE_WAITABLE (gimp_waitable_get_type ())
G_DECLARE_INTERFACE (GimpWaitable, gimp_waitable, GIMP, WAITABLE, GObject)
typedef struct _GimpWaitableInterface GimpWaitableInterface;
struct _GimpWaitableInterface
{
GTypeInterface base_iface;
@ -42,8 +38,6 @@ struct _GimpWaitableInterface
};
GType gimp_waitable_get_type (void) G_GNUC_CONST;
void gimp_waitable_wait (GimpWaitable *waitable);
gboolean gimp_waitable_try_wait (GimpWaitable *waitable);
gboolean gimp_waitable_wait_until (GimpWaitable *waitable,

View File

@ -2939,7 +2939,7 @@ GIMP_PROGRESS
GIMP_IS_PROGRESS
GIMP_TYPE_PROGRESS
gimp_progress_interface_get_type
GIMP_PROGRESS_GET_INTERFACE
GIMP_PROGRESS_GET_IFACE
</SECTION>
<SECTION>
@ -3098,7 +3098,7 @@ GIMP_TAGGED
GIMP_IS_TAGGED
GIMP_TYPE_TAGGED
gimp_tagged_interface_get_type
GIMP_TAGGED_GET_INTERFACE
GIMP_TAGGED_GET_IFACE
</SECTION>
<SECTION>
@ -11468,7 +11468,7 @@ GIMP_PICKABLE
GIMP_IS_PICKABLE
GIMP_TYPE_PICKABLE
gimp_pickable_interface_get_type
GIMP_PICKABLE_GET_INTERFACE
GIMP_PICKABLE_GET_IFACE
</SECTION>
<SECTION>
@ -11484,7 +11484,7 @@ gimp_preview_cache_get_memsize
<SECTION>
<FILE>gimpprojectable</FILE>
<TITLE>GimpProjectable</TITLE>
GIMP_PROJECTABLE_GET_INTERFACE
GIMP_PROJECTABLE_GET_IFACE
GimpProjectable
gimp_projectable_invalidate
gimp_projectable_flush