From 9b6e6effeb1a8d771f1df4cb98485040f896671f Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 30 Jul 2024 19:04:53 +0000 Subject: [PATCH] libgimpwidgets: Make GimpButton a derivable type --- libgimpwidgets/gimpbutton.c | 13 ++++++------- libgimpwidgets/gimpbutton.h | 21 ++------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/libgimpwidgets/gimpbutton.c b/libgimpwidgets/gimpbutton.c index bff0d8c467..69675a9974 100644 --- a/libgimpwidgets/gimpbutton.c +++ b/libgimpwidgets/gimpbutton.c @@ -46,12 +46,10 @@ enum }; -struct _GimpButtonPrivate +typedef struct _GimpButtonPrivate { GdkModifierType press_state; -}; - -#define GET_PRIVATE(obj) (((GimpButton *) (obj))->priv) +} GimpButtonPrivate; static gboolean gimp_button_button_press (GtkWidget *widget, @@ -97,7 +95,6 @@ gimp_button_class_init (GimpButtonClass *klass) static void gimp_button_init (GimpButton *button) { - button->priv = gimp_button_get_instance_private (button); } /** @@ -134,7 +131,8 @@ static gboolean gimp_button_button_press (GtkWidget *widget, GdkEventButton *bevent) { - GimpButtonPrivate *private = GET_PRIVATE (widget); + GimpButton *button = GIMP_BUTTON (widget); + GimpButtonPrivate *private = gimp_button_get_instance_private (button); if (bevent->button == 1) { @@ -151,7 +149,8 @@ gimp_button_button_press (GtkWidget *widget, static void gimp_button_clicked (GtkButton *button) { - GimpButtonPrivate *private = GET_PRIVATE (button); + GimpButton *gimp_button = GIMP_BUTTON (button); + GimpButtonPrivate *private = gimp_button_get_instance_private (gimp_button); if (private->press_state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | diff --git a/libgimpwidgets/gimpbutton.h b/libgimpwidgets/gimpbutton.h index 8af62d28f7..fbd8f5324f 100644 --- a/libgimpwidgets/gimpbutton.h +++ b/libgimpwidgets/gimpbutton.h @@ -31,23 +31,8 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -#define GIMP_TYPE_BUTTON (gimp_button_get_type ()) -#define GIMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BUTTON, GimpButton)) -#define GIMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BUTTON, GimpButtonClass)) -#define GIMP_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BUTTON)) -#define GIMP_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BUTTON)) -#define GIMP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BUTTON, GimpButtonClass)) - - -typedef struct _GimpButtonPrivate GimpButtonPrivate; -typedef struct _GimpButtonClass GimpButtonClass; - -struct _GimpButton -{ - GtkButton parent_instance; - - GimpButtonPrivate *priv; -}; +#define GIMP_TYPE_BUTTON (gimp_button_get_type ()) +G_DECLARE_DERIVABLE_TYPE (GimpButton, gimp_button, GIMP, BUTTON, GtkButton) struct _GimpButtonClass { @@ -68,8 +53,6 @@ struct _GimpButtonClass }; -GType gimp_button_get_type (void) G_GNUC_CONST; - GtkWidget * gimp_button_new (void); void gimp_button_extended_clicked (GimpButton *button,