[gimp/gtk3-port: 152/227] libgimpwidgets: move all GimpButton members to a private struct
- From: Clayton Walker <claytonw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 152/227] libgimpwidgets: move all GimpButton members to a private struct
- Date: Mon, 21 Oct 2013 21:31:11 +0000 (UTC)
commit 75fe86e0a2269bb0fbcb0fa35f3bdf130fd020a8
Author: Michael Natterer <mitch gimp org>
Date: Fri Dec 31 17:24:54 2010 +0100
libgimpwidgets: move all GimpButton members to a private struct
libgimpwidgets/gimpbutton.c | 32 +++++++++++++++++++++++++-------
libgimpwidgets/gimpbutton.h | 5 +----
2 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/libgimpwidgets/gimpbutton.c b/libgimpwidgets/gimpbutton.c
index e5dfa74..04a9e39 100644
--- a/libgimpwidgets/gimpbutton.c
+++ b/libgimpwidgets/gimpbutton.c
@@ -47,6 +47,18 @@ enum
};
+typedef struct _GimpButtonPrivate GimpButtonPrivate;
+
+struct _GimpButtonPrivate
+{
+ GdkModifierType press_state;
+};
+
+#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+ GIMP_TYPE_BUTTON, \
+ GimpButtonPrivate)
+
+
static gboolean gimp_button_button_press (GtkWidget *widget,
GdkEventButton *event);
static void gimp_button_clicked (GtkButton *button);
@@ -62,6 +74,7 @@ static guint button_signals[LAST_SIGNAL] = { 0 };
static void
gimp_button_class_init (GimpButtonClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
@@ -86,12 +99,16 @@ gimp_button_class_init (GimpButtonClass *klass)
widget_class->button_press_event = gimp_button_button_press;
button_class->clicked = gimp_button_clicked;
+
+ g_type_class_add_private (object_class, sizeof (GimpButtonPrivate));
}
static void
gimp_button_init (GimpButton *button)
{
- button->press_state = 0;
+ GimpButtonPrivate *private = GET_PRIVATE (button);
+
+ private->press_state = 0;
}
/**
@@ -127,15 +144,15 @@ static gboolean
gimp_button_button_press (GtkWidget *widget,
GdkEventButton *bevent)
{
- GimpButton *button = GIMP_BUTTON (widget);
+ GimpButtonPrivate *private = GET_PRIVATE (widget);
if (bevent->button == 1)
{
- button->press_state = bevent->state;
+ private->press_state = bevent->state;
}
else
{
- button->press_state = 0;
+ private->press_state = 0;
}
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
@@ -144,7 +161,9 @@ gimp_button_button_press (GtkWidget *widget,
static void
gimp_button_clicked (GtkButton *button)
{
- if (GIMP_BUTTON (button)->press_state &
+ GimpButtonPrivate *private = GET_PRIVATE (button);
+
+ if (private->press_state &
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK |
gtk_widget_get_modifier_mask (GTK_WIDGET (button),
GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR) |
@@ -155,8 +174,7 @@ gimp_button_clicked (GtkButton *button)
{
g_signal_stop_emission_by_name (button, "clicked");
- gimp_button_extended_clicked (GIMP_BUTTON (button),
- GIMP_BUTTON (button)->press_state);
+ gimp_button_extended_clicked (GIMP_BUTTON (button), private->press_state);
}
else if (GTK_BUTTON_CLASS (parent_class)->clicked)
{
diff --git a/libgimpwidgets/gimpbutton.h b/libgimpwidgets/gimpbutton.h
index 933eeba..7476ae4 100644
--- a/libgimpwidgets/gimpbutton.h
+++ b/libgimpwidgets/gimpbutton.h
@@ -43,10 +43,7 @@ typedef struct _GimpButtonClass GimpButtonClass;
struct _GimpButton
{
- GtkButton parent_instance;
-
- /*< private >*/
- GdkModifierType press_state;
+ GtkButton parent_instance;
};
struct _GimpButtonClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]