colorscale: Remove priv pointer

This commit is contained in:
Timm Bäder 2018-06-18 14:28:19 +02:00
parent a7d8127d59
commit 501efeb6b9
2 changed files with 14 additions and 14 deletions

View File

@ -32,11 +32,11 @@
#include <math.h> #include <math.h>
struct _GtkColorScalePrivate typedef struct
{ {
GdkRGBA color; GdkRGBA color;
GtkColorScaleType type; GtkColorScaleType type;
}; } GtkColorScalePrivate;
enum enum
{ {
@ -59,12 +59,13 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
int width, int width,
int height) int height)
{ {
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
GtkWidget *widget = GTK_WIDGET (scale); GtkWidget *widget = GTK_WIDGET (scale);
if (width <= 1 || height <= 1) if (width <= 1 || height <= 1)
return; return;
if (scale->priv->type == GTK_COLOR_SCALE_HUE) if (priv->type == GTK_COLOR_SCALE_HUE)
{ {
GdkTexture *texture; GdkTexture *texture;
gint stride; gint stride;
@ -104,7 +105,7 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
&GRAPHENE_RECT_INIT(x, y, width, height)); &GRAPHENE_RECT_INIT(x, y, width, height));
g_object_unref (texture); g_object_unref (texture);
} }
else if (scale->priv->type == GTK_COLOR_SCALE_ALPHA) else if (priv->type == GTK_COLOR_SCALE_ALPHA)
{ {
cairo_t *cr; cairo_t *cr;
graphene_point_t start, end; graphene_point_t start, end;
@ -143,7 +144,7 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
cairo_destroy (cr); cairo_destroy (cr);
color = &scale->priv->color; color = &priv->color;
gtk_snapshot_append_linear_gradient (snapshot, gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT(x, y, width, height), &GRAPHENE_RECT_INIT(x, y, width, height),
@ -163,8 +164,6 @@ gtk_color_scale_init (GtkColorScale *scale)
GtkStyleContext *context; GtkStyleContext *context;
GtkGesture *gesture; GtkGesture *gesture;
scale->priv = gtk_color_scale_get_instance_private (scale);
gesture = gtk_gesture_long_press_new (); gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed", g_signal_connect (gesture, "pressed",
G_CALLBACK (hold_action), scale); G_CALLBACK (hold_action), scale);
@ -183,11 +182,12 @@ scale_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkColorScale *scale = GTK_COLOR_SCALE (object); GtkColorScale *scale = GTK_COLOR_SCALE (object);
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
switch (prop_id) switch (prop_id)
{ {
case PROP_SCALE_TYPE: case PROP_SCALE_TYPE:
g_value_set_int (value, scale->priv->type); g_value_set_int (value, priv->type);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -199,9 +199,10 @@ static void
scale_set_type (GtkColorScale *scale, scale_set_type (GtkColorScale *scale,
GtkColorScaleType type) GtkColorScaleType type)
{ {
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
AtkObject *atk_obj; AtkObject *atk_obj;
scale->priv->type = type; priv->type = type;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (scale)); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (scale));
if (GTK_IS_ACCESSIBLE (atk_obj)) if (GTK_IS_ACCESSIBLE (atk_obj))
@ -262,7 +263,9 @@ void
gtk_color_scale_set_rgba (GtkColorScale *scale, gtk_color_scale_set_rgba (GtkColorScale *scale,
const GdkRGBA *color) const GdkRGBA *color)
{ {
scale->priv->color = *color; GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
priv->color = *color;
gtk_widget_queue_draw (GTK_WIDGET (scale)); gtk_widget_queue_draw (GTK_WIDGET (scale));
} }

View File

@ -32,13 +32,10 @@ G_BEGIN_DECLS
typedef struct _GtkColorScale GtkColorScale; typedef struct _GtkColorScale GtkColorScale;
typedef struct _GtkColorScaleClass GtkColorScaleClass; typedef struct _GtkColorScaleClass GtkColorScaleClass;
typedef struct _GtkColorScalePrivate GtkColorScalePrivate;
struct _GtkColorScale struct _GtkColorScale
{ {
GtkScale parent_instance; GtkScale parent_instance;
GtkColorScalePrivate *priv;
}; };
struct _GtkColorScaleClass struct _GtkColorScaleClass