From 19f92e70d6f2020bf2ea6d7c5e029052e978e216 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 30 Jan 2006 17:35:49 +0000 Subject: [PATCH] Add a wrapped signal. (#322933, Carlos Garnacho Parro) 2006-01-30 Matthias Clasen * gtk/gtkspinbutton.h: * gtk/gtkspinbutton.c: Add a wrapped signal. (#322933, Carlos Garnacho Parro) --- ChangeLog | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ gtk/gtkspinbutton.c | 33 +++++++++++++++++++++++++++++++-- gtk/gtkspinbutton.h | 3 ++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca82a56936..14f0c6c41a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-01-30 Matthias Clasen + * 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) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ca82a56936..14f0c6c41a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2006-01-30 Matthias Clasen + * 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) diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 45b4ca874a..cc2a7eaa8c 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -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); } diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h index 33668056e1..4bf3570c2b 100644 --- a/gtk/gtkspinbutton.h +++ b/gtk/gtkspinbutton.h @@ -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); };