summaryrefslogtreecommitdiff
path: root/gtk/gtkspinbutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-01-30 17:35:49 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-01-30 17:35:49 +0000
commit19f92e70d6f2020bf2ea6d7c5e029052e978e216 (patch)
tree39249329647bd0d4d6a2f8726db9e44707521115 /gtk/gtkspinbutton.c
parenta475d3fa2fddd4afb3349c3618890bcde2652f9c (diff)
downloadgtk+-19f92e70d6f2020bf2ea6d7c5e029052e978e216.tar.gz
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)
Diffstat (limited to 'gtk/gtkspinbutton.c')
-rw-r--r--gtk/gtkspinbutton.c33
1 files changed, 31 insertions, 2 deletions
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);
}