GtkScaleButton: Move public members to private structure

This commit is contained in:
Javier Jardón 2010-07-08 03:13:10 +02:00
parent bcc8494899
commit 9ddda9c844
2 changed files with 21 additions and 22 deletions

View File

@ -94,10 +94,10 @@ enum
PROP_ICONS PROP_ICONS
}; };
#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SCALE_BUTTON, GtkScaleButtonPrivate))
struct _GtkScaleButtonPrivate struct _GtkScaleButtonPrivate
{ {
GtkWidget *plus_button;
GtkWidget *minus_button;
GtkWidget *dock; GtkWidget *dock;
GtkWidget *box; GtkWidget *box;
GtkWidget *scale; GtkWidget *scale;
@ -354,7 +354,9 @@ gtk_scale_button_init (GtkScaleButton *button)
GtkScaleButtonPrivate *priv; GtkScaleButtonPrivate *priv;
GtkWidget *frame; GtkWidget *frame;
button->priv = priv = GET_PRIVATE (button); button->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
GTK_TYPE_SCALE_BUTTON,
GtkScaleButtonPrivate);
priv->timeout = FALSE; priv->timeout = FALSE;
priv->click_id = 0; priv->click_id = 0;
@ -392,22 +394,22 @@ gtk_scale_button_init (GtkScaleButton *button)
gtk_container_add (GTK_CONTAINER (frame), priv->box); gtk_container_add (GTK_CONTAINER (frame), priv->box);
/* + */ /* + */
button->plus_button = gtk_button_new_with_label ("+"); priv->plus_button = gtk_button_new_with_label ("+");
gtk_button_set_relief (GTK_BUTTON (button->plus_button), GTK_RELIEF_NONE); gtk_button_set_relief (GTK_BUTTON (priv->plus_button), GTK_RELIEF_NONE);
g_signal_connect (button->plus_button, "button-press-event", g_signal_connect (priv->plus_button, "button-press-event",
G_CALLBACK (cb_button_press), button); G_CALLBACK (cb_button_press), button);
g_signal_connect (button->plus_button, "button-release-event", g_signal_connect (priv->plus_button, "button-release-event",
G_CALLBACK (cb_button_release), button); G_CALLBACK (cb_button_release), button);
gtk_box_pack_start (GTK_BOX (priv->box), button->plus_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->box), priv->plus_button, FALSE, FALSE, 0);
/* - */ /* - */
button->minus_button = gtk_button_new_with_label ("-"); priv->minus_button = gtk_button_new_with_label ("-");
gtk_button_set_relief (GTK_BUTTON (button->minus_button), GTK_RELIEF_NONE); gtk_button_set_relief (GTK_BUTTON (priv->minus_button), GTK_RELIEF_NONE);
g_signal_connect (button->minus_button, "button-press-event", g_signal_connect (priv->minus_button, "button-press-event",
G_CALLBACK (cb_button_press), button); G_CALLBACK (cb_button_press), button);
g_signal_connect (button->minus_button, "button-release-event", g_signal_connect (priv->minus_button, "button-release-event",
G_CALLBACK (cb_button_release), button); G_CALLBACK (cb_button_release), button);
gtk_box_pack_end (GTK_BOX (priv->box), button->minus_button, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (priv->box), priv->minus_button, FALSE, FALSE, 0);
priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 2, 20, 0)); priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 2, 20, 0));
g_object_ref_sink (priv->adjustment); g_object_ref_sink (priv->adjustment);
@ -735,7 +737,7 @@ gtk_scale_button_get_plus_button (GtkScaleButton *button)
{ {
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL); g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
return button->plus_button; return button->priv->plus_button;
} }
/** /**
@ -753,7 +755,7 @@ gtk_scale_button_get_minus_button (GtkScaleButton *button)
{ {
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL); g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
return button->minus_button; return button->priv->minus_button;
} }
/** /**
@ -787,13 +789,13 @@ gtk_scale_button_set_orientation_private (GtkScaleButton *button,
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box),
orientation); orientation);
gtk_container_child_set (GTK_CONTAINER (priv->box), gtk_container_child_set (GTK_CONTAINER (priv->box),
button->plus_button, priv->plus_button,
"pack-type", "pack-type",
orientation == GTK_ORIENTATION_VERTICAL ? orientation == GTK_ORIENTATION_VERTICAL ?
GTK_PACK_START : GTK_PACK_END, GTK_PACK_START : GTK_PACK_END,
NULL); NULL);
gtk_container_child_set (GTK_CONTAINER (priv->box), gtk_container_child_set (GTK_CONTAINER (priv->box),
button->minus_button, priv->minus_button,
"pack-type", "pack-type",
orientation == GTK_ORIENTATION_VERTICAL ? orientation == GTK_ORIENTATION_VERTICAL ?
GTK_PACK_END : GTK_PACK_START, GTK_PACK_END : GTK_PACK_START,
@ -1234,7 +1236,7 @@ cb_button_press (GtkWidget *widget,
if (priv->click_id != 0) if (priv->click_id != 0)
g_source_remove (priv->click_id); g_source_remove (priv->click_id);
if (widget == button->plus_button) if (widget == priv->plus_button)
priv->direction = fabs (adj->page_increment); priv->direction = fabs (adj->page_increment);
else else
priv->direction = - fabs (adj->page_increment); priv->direction = - fabs (adj->page_increment);

View File

@ -59,11 +59,8 @@ struct _GtkScaleButton
{ {
GtkButton parent; GtkButton parent;
GtkWidget *GSEAL (plus_button);
GtkWidget *GSEAL (minus_button);
/*< private >*/ /*< private >*/
GtkScaleButtonPrivate *GSEAL (priv); GtkScaleButtonPrivate *priv;
}; };
struct _GtkScaleButtonClass struct _GtkScaleButtonClass