fixing GtkScale default quantization
- From: Tim Janik <timj gtk org>
- To: Havoc Pennington <hp redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: fixing GtkScale default quantization
- Date: Fri, 25 Jan 2002 13:07:10 +0100 (CET)
hi havoc,
i just meant to fix default value quantization in scales to
%.1f digits, and ran across GtkScale.digits. what's the deal
with that field? there's not even a compatibility issue there,
as 1.2 doesn't have it.
it just completely duplicates GTK_RANGE (scale)->round_digits.
i intend to apply the following patch, any comments?
cvs server: Diffing .
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2855
diff -u -p -u -r1.2855 ChangeLog
--- ChangeLog 2002/01/24 01:36:26 1.2855
+++ ChangeLog 2002/01/25 12:04:24
@@ -1,3 +1,21 @@
+Fri Jan 25 12:56:32 2002 Tim Janik <timj gtk org>
+
+ * gtk/gtkscale.h (struct _GtkScale): remove digits field,
+ which just duplicates GTK_RANGE (scale)->round_digits.
+
+ * gtk/gtkscale.c (gtk_scale_class_init): fix default value and
+ extend range to allow -1 be specified for the ::digits property.
+ (gtk_scale_init): removed initialization of ->digits field,
+ as GTK_RANGE (scale)->round_digits is already initialized.
+ and, even more importantly, don't default initialize
+ GTK_RANGE (scale)->round_digits to +1, so we don't perform
+ gross quantization by default.
+ (_gtk_scale_format_value):
+ (gtk_scale_get_digits):
+ (gtk_scale_set_digits):
+ (gtk_scale_get_property): use GTK_RANGE (scale)->round_digits
+ instead of scale->digits.
+
Wed Jan 23 20:28:59 2002 Owen Taylor <otaylor redhat com>
* gtk/gtknotebook.c (gtk_notebook_draw_arrow):
Index: gtk/gtkscale.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkscale.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 gtkscale.c
--- gtk/gtkscale.c 2001/11/17 23:28:50 1.33
+++ gtk/gtkscale.c 2002/01/25 12:04:25
@@ -147,9 +147,9 @@ gtk_scale_class_init (GtkScaleClass *cla
g_param_spec_int ("digits",
_("Digits"),
_("The number of decimal places that are displayed in the value"),
- 0,
+ -1,
G_MAXINT,
- 0,
+ -1,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
@@ -346,7 +346,7 @@ gtk_scale_get_property (GObject *ob
switch (prop_id)
{
case PROP_DIGITS:
- g_value_set_int (value, scale->digits);
+ g_value_set_int (value, GTK_RANGE (scale)->round_digits);
break;
case PROP_DRAW_VALUE:
g_value_set_boolean (value, scale->draw_value);
@@ -377,8 +377,6 @@ gtk_scale_init (GtkScale *scale)
scale->draw_value = TRUE;
scale->value_pos = GTK_POS_TOP;
- scale->digits = 1;
- range->round_digits = scale->digits;
}
void
@@ -393,9 +391,8 @@ gtk_scale_set_digits (GtkScale *scale,
digits = CLAMP (digits, -1, 16);
- if (scale->digits != digits)
+ if (range->round_digits != digits)
{
- scale->digits = digits;
range->round_digits = digits;
gtk_widget_queue_resize (GTK_WIDGET (scale));
@@ -409,7 +406,7 @@ gtk_scale_get_digits (GtkScale *scale)
{
g_return_val_if_fail (GTK_IS_SCALE (scale), -1);
- return scale->digits;
+ return GTK_RANGE (scale)->round_digits;
}
void
@@ -602,6 +599,6 @@ _gtk_scale_format_value (GtkScale *scale
if (fmt)
return fmt;
else
- return g_strdup_printf ("%0.*f", scale->digits,
+ return g_strdup_printf ("%0.*f", GTK_RANGE (scale)->round_digits,
value);
}
Index: gtk/gtkscale.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkscale.h,v
retrieving revision 1.16
diff -u -p -u -r1.16 gtkscale.h
--- gtk/gtkscale.h 2002/01/16 19:12:45 1.16
+++ gtk/gtkscale.h 2002/01/25 12:04:25
@@ -52,7 +52,7 @@ struct _GtkScale
{
GtkRange range;
- gint digits;
+
guint draw_value : 1;
guint value_pos : 2;
};
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]