Add a wrapped signal. (#322933, Carlos Garnacho Parro)

2006-01-30  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkspinbutton.h:
	* gtk/gtkspinbutton.c: Add a wrapped signal.  (#322933,
	Carlos Garnacho Parro)
This commit is contained in:
Matthias Clasen 2006-01-30 17:35:49 +00:00 committed by Matthias Clasen
parent a475d3fa2f
commit 19f92e70d6
4 changed files with 41 additions and 3 deletions

View File

@ -1,5 +1,9 @@
2006-01-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkspinbutton.h:
* gtk/gtkspinbutton.c: Add a wrapped signal. (#322933,
Carlos Garnacho Parro)
* gtk/gtkassistant.c: More generous spacing. (#328082,
Christian Persch, patch by Carlos Garnacho)

View File

@ -1,5 +1,9 @@
2006-01-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkspinbutton.h:
* gtk/gtkspinbutton.c: Add a wrapped signal. (#322933,
Carlos Garnacho Parro)
* gtk/gtkassistant.c: More generous spacing. (#328082,
Christian Persch, patch by Carlos Garnacho)

View File

@ -68,6 +68,7 @@ enum
OUTPUT,
VALUE_CHANGED,
CHANGE_VALUE,
WRAPPED,
LAST_SIGNAL
};
@ -342,6 +343,24 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkSpinButton::wrapped:
* @spinbutton: the object which received the signal
*
* The wrapped signal is emitted right after the spinbutton wraps
* from its maximum to minimum value or vice-versa.
*
* Since: 2.10
*/
spinbutton_signals[WRAPPED] =
g_signal_new (I_("wrapped"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkSpinButtonClass, wrapped),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/* Action signals */
spinbutton_signals[CHANGE_VALUE] =
g_signal_new (I_("change_value"),
@ -1480,6 +1499,7 @@ gtk_spin_button_real_spin (GtkSpinButton *spin_button,
{
GtkAdjustment *adj;
gdouble new_value = 0.0;
gboolean wrapped = FALSE;
adj = spin_button->adjustment;
@ -1490,7 +1510,10 @@ gtk_spin_button_real_spin (GtkSpinButton *spin_button,
if (spin_button->wrap)
{
if (fabs (adj->value - adj->upper) < EPSILON)
new_value = adj->lower;
{
new_value = adj->lower;
wrapped = TRUE;
}
else if (new_value > adj->upper)
new_value = adj->upper;
}
@ -1502,7 +1525,10 @@ gtk_spin_button_real_spin (GtkSpinButton *spin_button,
if (spin_button->wrap)
{
if (fabs (adj->value - adj->lower) < EPSILON)
new_value = adj->upper;
{
new_value = adj->upper;
wrapped = TRUE;
}
else if (new_value < adj->lower)
new_value = adj->lower;
}
@ -1513,6 +1539,9 @@ gtk_spin_button_real_spin (GtkSpinButton *spin_button,
if (fabs (new_value - adj->value) > EPSILON)
gtk_adjustment_set_value (adj, new_value);
if (wrapped)
g_signal_emit (spin_button, spinbutton_signals[WRAPPED], 0);
spin_button_redraw (spin_button);
}

View File

@ -108,11 +108,12 @@ struct _GtkSpinButtonClass
void (*change_value) (GtkSpinButton *spin_button,
GtkScrollType scroll);
void (*wrapped) (GtkSpinButton *spin_button);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};