summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--ChangeLog.pre-2-016
-rw-r--r--ChangeLog.pre-2-1016
-rw-r--r--ChangeLog.pre-2-216
-rw-r--r--ChangeLog.pre-2-416
-rw-r--r--ChangeLog.pre-2-616
-rw-r--r--ChangeLog.pre-2-816
-rw-r--r--gtk/gtkhscale.c8
-rw-r--r--gtk/gtkscale.c98
-rw-r--r--gtk/gtkscale.h2
-rw-r--r--gtk/gtkvscale.c4
11 files changed, 211 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index c43c80d510..59c0f636c6 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,19 @@
+Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
+ meaningfull range (we need to stay below a certain limit anyways
+ to avoid string buffer overflows).
+
+ * gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
+ area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
+ * gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
+ (gtk_hscale_draw_value): safety CLAMP the value's x position for
+ GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
+ our allocation.
+
+ * gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
+ and GtkScale::value_pos arguments.
+
Mon Jan 18 14:26:17 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Some editing, a little more
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c
index 62513627f4..4e349fb085 100644
--- a/gtk/gtkhscale.c
+++ b/gtk/gtkhscale.c
@@ -455,14 +455,14 @@ gtk_hscale_pos_background (GtkHScale *hscale,
*w -= twidth;
break;
case GTK_POS_RIGHT:
- *x = tx;
+ *x += twidth;
*w -= twidth;
break;
case GTK_POS_TOP:
*h -= theight;
break;
case GTK_POS_BOTTOM:
- *y = ty;
+ *y += theight;
*h -= theight;
break;
}
@@ -541,6 +541,8 @@ gtk_hscale_draw_value (GtkScale *scale)
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
x += widget->allocation.x + (width - text_width) / 2;
+ x = CLAMP (x, widget->allocation.x,
+ widget->allocation.x + widget->allocation.width - text_width);
y -= GTK_WIDGET (scale)->style->font->descent;
break;
case GTK_POS_BOTTOM:
@@ -550,6 +552,8 @@ gtk_hscale_draw_value (GtkScale *scale)
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
x += widget->allocation.x + (width - text_width) / 2;
+ x = CLAMP (x, widget->allocation.x,
+ widget->allocation.x + widget->allocation.width - text_width);
y += height + GTK_WIDGET (scale)->style->font->ascent;
break;
}
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index d44a4681c2..57fce9bc0f 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -23,9 +23,22 @@
#define SCALE_CLASS(w) GTK_SCALE_CLASS (GTK_OBJECT (w)->klass)
+enum {
+ ARG_0,
+ ARG_DIGITS,
+ ARG_DRAW_VALUE,
+ ARG_VALUE_POS
+};
+
static void gtk_scale_class_init (GtkScaleClass *klass);
static void gtk_scale_init (GtkScale *scale);
+static void gtk_scale_set_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id);
+static void gtk_scale_get_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id);
static void gtk_scale_map (GtkWidget *widget);
static void gtk_scale_unmap (GtkWidget *widget);
@@ -70,12 +83,28 @@ gtk_scale_class_init (GtkScaleClass *class)
object_class = (GtkObjectClass*) class;
range_class = (GtkRangeClass*) class;
widget_class = (GtkWidgetClass*) class;
-
+
parent_class = gtk_type_class (GTK_TYPE_RANGE);
+
+ gtk_object_add_arg_type ("GtkScale::digits",
+ GTK_TYPE_INT,
+ GTK_ARG_READWRITE,
+ ARG_DIGITS);
+ gtk_object_add_arg_type ("GtkScale::draw_value",
+ GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE,
+ ARG_DRAW_VALUE);
+ gtk_object_add_arg_type ("GtkScale::value_pos",
+ GTK_TYPE_POSITION_TYPE,
+ GTK_ARG_READWRITE,
+ ARG_VALUE_POS);
+
+ object_class->set_arg = gtk_scale_set_arg;
+ object_class->get_arg = gtk_scale_get_arg;
widget_class->map = gtk_scale_map;
widget_class->unmap = gtk_scale_unmap;
-
+
range_class->draw_background = gtk_scale_draw_background;
class->slider_length = 31;
@@ -84,6 +113,57 @@ gtk_scale_class_init (GtkScaleClass *class)
}
static void
+gtk_scale_set_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id)
+{
+ GtkScale *scale;
+
+ scale = GTK_SCALE (object);
+
+ switch (arg_id)
+ {
+ case ARG_DIGITS:
+ gtk_scale_set_digits (scale, GTK_VALUE_INT (*arg));
+ break;
+ case ARG_DRAW_VALUE:
+ gtk_scale_set_draw_value (scale, GTK_VALUE_BOOL (*arg));
+ break;
+ case ARG_VALUE_POS:
+ gtk_scale_set_value_pos (scale, GTK_VALUE_ENUM (*arg));
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gtk_scale_get_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id)
+{
+ GtkScale *scale;
+
+ scale = GTK_SCALE (object);
+
+ switch (arg_id)
+ {
+ case ARG_DIGITS:
+ GTK_VALUE_INT (*arg) = GTK_RANGE (scale)->digits;
+ break;
+ case ARG_DRAW_VALUE:
+ GTK_VALUE_BOOL (*arg) = scale->draw_value;
+ break;
+ case ARG_VALUE_POS:
+ GTK_VALUE_ENUM (*arg) = scale->value_pos;
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
gtk_scale_init (GtkScale *scale)
{
GTK_WIDGET_SET_FLAGS (scale, GTK_CAN_FOCUS);
@@ -131,28 +211,30 @@ gtk_scale_set_digits (GtkScale *scale,
g_return_if_fail (scale != NULL);
g_return_if_fail (GTK_IS_SCALE (scale));
+ digits = CLAMP (digits, -1, 16);
+
if (GTK_RANGE (scale)->digits != digits)
{
GTK_RANGE (scale)->digits = digits;
- if (GTK_WIDGET_VISIBLE (scale) && GTK_WIDGET_MAPPED (scale))
- gtk_widget_queue_resize (GTK_WIDGET (scale));
+ gtk_widget_queue_resize (GTK_WIDGET (scale));
}
}
void
gtk_scale_set_draw_value (GtkScale *scale,
- gint draw_value)
+ gboolean draw_value)
{
g_return_if_fail (scale != NULL);
g_return_if_fail (GTK_IS_SCALE (scale));
+ draw_value = draw_value != FALSE;
+
if (scale->draw_value != draw_value)
{
- scale->draw_value = (draw_value != 0);
+ scale->draw_value = draw_value;
- if (GTK_WIDGET_VISIBLE (scale) && GTK_WIDGET_MAPPED (scale))
- gtk_widget_queue_resize (GTK_WIDGET (scale));
+ gtk_widget_queue_resize (GTK_WIDGET (scale));
}
}
diff --git a/gtk/gtkscale.h b/gtk/gtkscale.h
index 31a6b31f37..d573ca4b43 100644
--- a/gtk/gtkscale.h
+++ b/gtk/gtkscale.h
@@ -62,7 +62,7 @@ GtkType gtk_scale_get_type (void);
void gtk_scale_set_digits (GtkScale *scale,
gint digits);
void gtk_scale_set_draw_value (GtkScale *scale,
- gint draw_value);
+ gboolean draw_value);
void gtk_scale_set_value_pos (GtkScale *scale,
GtkPositionType pos);
gint gtk_scale_get_value_width (GtkScale *scale);
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c
index cacf96426b..cb88083f90 100644
--- a/gtk/gtkvscale.c
+++ b/gtk/gtkvscale.c
@@ -459,14 +459,14 @@ gtk_vscale_pos_background (GtkVScale *vscale,
*w -= twidth;
break;
case GTK_POS_RIGHT:
- *x = tx;
+ *x += twidth;
*w -= twidth;
break;
case GTK_POS_TOP:
*h -= theight;
break;
case GTK_POS_BOTTOM:
- *y = ty;
+ *y += theight;
*h -= theight;
break;
}