diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-01-18 00:57:20 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-01-18 00:58:38 -0500 |
commit | 345d865ac6b2f7760503ab144dd68e6062438b80 (patch) | |
tree | 9144ffea1b6616154ccef063bb63501449d0877e /gtk/gtkscale.c | |
parent | d6f9eb1ff87e9cb0c7e7ced41a4e2b9e7dcc2bdd (diff) | |
download | gtk+-345d865ac6b2f7760503ab144dd68e6062438b80.tar.gz |
GtkScale: Fix late setting of marks
Diffstat (limited to 'gtk/gtkscale.c')
-rw-r--r-- | gtk/gtkscale.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 70522a6067..6862ca35b3 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -195,10 +195,26 @@ gtk_scale_notify (GObject *object, else if (strcmp (pspec->name, "inverted") == 0) { GtkScale *scale = GTK_SCALE (object); + GtkScaleMark *mark; + GSList *m; + gint i, n; + gdouble *values; scale->priv->marks = g_slist_sort_with_data (scale->priv->marks, compare_marks, GINT_TO_POINTER (gtk_range_get_inverted (GTK_RANGE (scale)))); + + n = g_slist_length (scale->priv->marks); + values = g_new (gdouble, n); + for (m = scale->priv->marks, i = 0; m; m = m->next, i++) + { + mark = m->data; + values[i] = mark->value; + } + + _gtk_range_set_stop_values (GTK_RANGE (scale), values, n); + + g_free (values); } if (G_OBJECT_CLASS (gtk_scale_parent_class)->notify) @@ -1145,19 +1161,6 @@ gtk_scale_draw (GtkWidget *widget, orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (range)); n_marks = _gtk_range_get_stop_positions (range, &marks); - /* We always draw the marks in increasing direction, so flip - * the stop positions to match the marks (which we flip in - * gtk_scale_notify) - */ - if (gtk_range_get_inverted (range)) - { - for (i = 0; i < n_marks / 2; i++) - { - x1 = marks[i]; - marks[i] = marks[n_marks - 1 - i]; - marks[n_marks - 1 - i] = x1; - } - } layout = gtk_widget_create_pango_layout (widget, NULL); gtk_range_get_range_rect (range, &range_rect); @@ -1615,8 +1618,9 @@ gtk_scale_add_mark (GtkScale *scale, else mark->position = GTK_POS_BOTTOM; - priv->marks = g_slist_insert_sorted (priv->marks, mark, - (GCompareFunc) compare_marks); + priv->marks = g_slist_insert_sorted_with_data (priv->marks, mark, + compare_marks, + GINT_TO_POINTER (gtk_range_get_inverted (GTK_RANGE (scale)))); #define MARKS_ABOVE 1 #define MARKS_BELOW 2 |