GtkHSV: unseal private pointer

This commit is contained in:
Javier Jardón 2010-06-22 16:26:09 +02:00
parent 997c7b96a8
commit c0228f609c
2 changed files with 68 additions and 108 deletions

View File

@ -56,7 +56,8 @@ typedef enum {
} DragMode;
/* Private part of the GtkHSV structure */
typedef struct {
struct _GtkHSVPriv
{
/* Color value */
double h;
double s;
@ -76,10 +77,8 @@ typedef struct {
DragMode mode;
guint focus_on_ring : 1;
};
} HSVPrivate;
/* Signal IDs */
@ -199,16 +198,16 @@ gtk_hsv_class_init (GtkHSVClass *class)
"move", 1,
G_TYPE_ENUM, GTK_DIR_LEFT);
g_type_class_add_private (gobject_class, sizeof (HSVPrivate));
g_type_class_add_private (gobject_class, sizeof (GtkHSVPriv));
}
/* Object initialization function for the HSV color selector */
static void
gtk_hsv_init (GtkHSV *hsv)
{
HSVPrivate *priv;
GtkHSVPriv *priv;
priv = G_TYPE_INSTANCE_GET_PRIVATE (hsv, GTK_TYPE_HSV, HSVPrivate);
priv = G_TYPE_INSTANCE_GET_PRIVATE (hsv, GTK_TYPE_HSV, GtkHSVPriv);
hsv->priv = priv;
@ -238,11 +237,8 @@ gtk_hsv_destroy (GtkObject *object)
static void
gtk_hsv_map (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
GTK_WIDGET_CLASS (gtk_hsv_parent_class)->map (widget);
@ -254,11 +250,8 @@ gtk_hsv_map (GtkWidget *widget)
static void
gtk_hsv_unmap (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
gdk_window_hide (priv->window);
@ -269,14 +262,11 @@ gtk_hsv_unmap (GtkWidget *widget)
static void
gtk_hsv_realize (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
GdkWindow *parent_window;
GdkWindowAttr attr;
int attr_mask;
GdkWindow *parent_window;
hsv = GTK_HSV (widget);
priv = hsv->priv;
gtk_widget_set_realized (widget, TRUE);
@ -317,11 +307,8 @@ gtk_hsv_realize (GtkWidget *widget)
static void
gtk_hsv_unrealize (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
gdk_window_set_user_data (priv->window, NULL);
gdk_window_destroy (priv->window);
@ -339,7 +326,7 @@ gtk_hsv_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkHSV *hsv = GTK_HSV (widget);
HSVPrivate *priv = hsv->priv;
GtkHSVPriv *priv = hsv->priv;
gint focus_width;
gint focus_pad;
@ -357,11 +344,8 @@ static void
gtk_hsv_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
widget->allocation = *allocation;
@ -536,14 +520,12 @@ compute_triangle (GtkHSV *hsv,
gint *vx,
gint *vy)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
gdouble center_x;
gdouble center_y;
gdouble inner, outer;
gdouble angle;
priv = hsv->priv;
center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
outer = priv->size / 2.0;
@ -564,14 +546,12 @@ is_in_ring (GtkHSV *hsv,
gdouble x,
gdouble y)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
gdouble dx, dy, dist;
gdouble center_x;
gdouble center_y;
gdouble inner, outer;
priv = hsv->priv;
center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
outer = priv->size / 2.0;
@ -718,11 +698,9 @@ static void
set_cross_grab (GtkHSV *hsv,
guint32 time)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
GdkCursor *cursor;
priv = hsv->priv;
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (hsv)),
GDK_CROSSHAIR);
gdk_pointer_grab (priv->window, FALSE,
@ -740,9 +718,7 @@ gtk_hsv_grab_broken (GtkWidget *widget,
GdkEventGrabBroken *event)
{
GtkHSV *hsv = GTK_HSV (widget);
HSVPrivate *priv;
priv = hsv->priv;
GtkHSVPriv *priv = hsv->priv;
priv->mode = DRAG_NONE;
@ -754,13 +730,10 @@ static gint
gtk_hsv_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkHSV *hsv;
HSVPrivate *priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
double x, y;
hsv = GTK_HSV (widget);
priv = hsv->priv;
if (priv->mode != DRAG_NONE || event->button != 1)
return FALSE;
@ -807,14 +780,11 @@ static gint
gtk_hsv_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GtkHSV *hsv;
HSVPrivate *priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
DragMode mode;
gdouble x, y;
hsv = GTK_HSV (widget);
priv = hsv->priv;
if (priv->mode == DRAG_NONE || event->button != 1)
return FALSE;
@ -848,13 +818,10 @@ static gint
gtk_hsv_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GtkHSV *hsv;
HSVPrivate *priv;
double x, y;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
GdkModifierType mods;
hsv = GTK_HSV (widget);
priv = hsv->priv;
double x, y;
if (priv->mode == DRAG_NONE)
return FALSE;
@ -894,8 +861,8 @@ paint_ring (GtkHSV *hsv,
gint width,
gint height)
{
GtkHSVPriv *priv = hsv->priv;
GtkWidget *widget = GTK_WIDGET (hsv);
HSVPrivate *priv;
int xx, yy;
gdouble dx, dy, dist;
gdouble center_x;
@ -1045,8 +1012,8 @@ paint_triangle (GtkHSV *hsv,
gint width,
gint height)
{
GtkHSVPriv *priv = hsv->priv;
GtkWidget *widget = GTK_WIDGET (hsv);
HSVPrivate *priv;
gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
gint x2, y2, r2, g2, b2; /* Second vertex */
@ -1262,14 +1229,11 @@ static gint
gtk_hsv_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkHSV *hsv;
HSVPrivate *priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
GdkRectangle rect, dest;
cairo_t *cr;
hsv = GTK_HSV (widget);
priv = hsv->priv;
if (!(event->window == widget->window && gtk_widget_is_drawable (widget)))
return FALSE;
@ -1306,11 +1270,8 @@ static gboolean
gtk_hsv_focus (GtkWidget *widget,
GtkDirectionType dir)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
if (!gtk_widget_has_focus (widget))
{
@ -1394,7 +1355,7 @@ gtk_hsv_set_color (GtkHSV *hsv,
gdouble s,
gdouble v)
{
HSVPrivate *priv;
GtkHSVPriv *priv;
g_return_if_fail (GTK_IS_HSV (hsv));
g_return_if_fail (h >= 0.0 && h <= 1.0);
@ -1430,7 +1391,7 @@ gtk_hsv_get_color (GtkHSV *hsv,
double *s,
double *v)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
g_return_if_fail (GTK_IS_HSV (hsv));
@ -1461,7 +1422,7 @@ gtk_hsv_set_metrics (GtkHSV *hsv,
gint size,
gint ring_width)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
int same_size;
g_return_if_fail (GTK_IS_HSV (hsv));
@ -1497,7 +1458,7 @@ gtk_hsv_get_metrics (GtkHSV *hsv,
gint *size,
gint *ring_width)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
g_return_if_fail (GTK_IS_HSV (hsv));
@ -1528,7 +1489,7 @@ gtk_hsv_get_metrics (GtkHSV *hsv,
gboolean
gtk_hsv_is_adjusting (GtkHSV *hsv)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
g_return_val_if_fail (GTK_IS_HSV (hsv), FALSE);
@ -1619,13 +1580,11 @@ static void
gtk_hsv_move (GtkHSV *hsv,
GtkDirectionType dir)
{
HSVPrivate *priv;
GtkHSVPriv *priv = hsv->priv;
gdouble hue, sat, val;
gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
gint x, y; /* position in triangle */
priv = hsv->priv;
hue = priv->h;
sat = priv->s;
val = priv->v;

View File

@ -49,14 +49,15 @@ G_BEGIN_DECLS
typedef struct _GtkHSV GtkHSV;
typedef struct _GtkHSVPriv GtkHSVPriv;
typedef struct _GtkHSVClass GtkHSVClass;
struct _GtkHSV
{
GtkWidget parent_instance;
/* Private data */
gpointer GSEAL (priv);
/* <private> */
GtkHSVPriv *priv;
};
struct _GtkHSVClass