[gtk+/font-selection-new: 27/73] GtkFontSelection: Improvements on the spin/slider interaction
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/font-selection-new: 27/73] GtkFontSelection: Improvements on the spin/slider interaction
- Date: Sat, 7 May 2011 18:14:29 +0000 (UTC)
commit 5b2eeb48dcc649fd998cbf9ac0b802204d0b9410
Author: Alberto Ruiz <aruiz gnome org>
Date: Sat Apr 16 17:21:07 2011 +0100
GtkFontSelection: Improvements on the spin/slider interaction
gtk/gtkfontsel.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index 6349de2..f2d704a 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -98,6 +98,8 @@ struct _GtkFontSelectionPrivate
gint size;
PangoFontFace *face;
PangoFontFamily *family;
+
+ gboolean ignore_slider;
};
@@ -312,6 +314,13 @@ slider_change_cb (GtkAdjustment *adjustment, gpointer data)
{
GtkFontSelectionPrivate *priv = (GtkFontSelectionPrivate*)data;
+ /* If we set the silder value manually, we ignore this callback */
+ if (priv->ignore_slider)
+ {
+ priv->ignore_slider = FALSE;
+ return;
+ }
+
gtk_adjustment_set_value (gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON(priv->size_spin)),
gtk_adjustment_get_value (adjustment));
}
@@ -325,10 +334,16 @@ spin_change_cb (GtkAdjustment *adjustment, gpointer data)
GtkAdjustment *slider_adj = gtk_range_get_adjustment (GTK_RANGE (priv->size_slider));
- if (size >= gtk_adjustment_get_lower (slider_adj) ||
- size <= gtk_adjustment_get_upper (slider_adj))
+ /* We ignore the slider value change callback for both of this set_value call */
+ if (size < gtk_adjustment_get_lower (slider_adj))
+ {
+ priv->ignore_slider = TRUE;
+ gtk_adjustment_set_value (slider_adj, gtk_adjustment_get_lower (slider_adj));
+ }
+ else if (size > gtk_adjustment_get_upper (slider_adj))
{
- gtk_adjustment_set_value (slider_adj, size);
+ priv->ignore_slider = TRUE;
+ gtk_adjustment_set_value (slider_adj, gtk_adjustment_get_upper (slider_adj));
}
priv->size = ((gint)gtk_adjustment_get_value (adjustment)) * PANGO_SCALE;
@@ -436,6 +451,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
"value-changed", G_CALLBACK (slider_change_cb), (gpointer)priv);
g_signal_connect (G_OBJECT (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->size_spin))),
"value-changed", G_CALLBACK (spin_change_cb), (gpointer)priv);
+ priv->ignore_slider = FALSE;
gtk_widget_pop_composite_child();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]