libgimpwidgets: Make GimpButton a derivable type

This commit is contained in:
Alx Sa 2024-07-30 19:04:53 +00:00
parent f73bf7fb07
commit 9b6e6effeb
2 changed files with 8 additions and 26 deletions

View File

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

View File

@ -32,22 +32,7 @@ G_BEGIN_DECLS
#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;
};
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,