* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
#include "gtkvscale.h"
-#include "gtksignal.h"
#include "gtkintl.h"
#define VALUE_SPACING 2
static gboolean gtk_vscale_expose (GtkWidget *widget,
GdkEventExpose *event);
-GtkType
+GType
gtk_vscale_get_type (void)
{
- static GtkType vscale_type = 0;
+ static GType vscale_type = 0;
if (!vscale_type)
{
- static const GtkTypeInfo vscale_info =
+ static const GTypeInfo vscale_info =
{
- "GtkVScale",
- sizeof (GtkVScale),
- sizeof (GtkVScaleClass),
- (GtkClassInitFunc) gtk_vscale_class_init,
- (GtkObjectInitFunc) gtk_vscale_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ sizeof (GtkVScaleClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_vscale_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkVScale),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_vscale_init,
};
- vscale_type = gtk_type_unique (GTK_TYPE_SCALE, &vscale_info);
+ vscale_type = g_type_register_static (GTK_TYPE_SCALE, "GtkVScale",
+ &vscale_info, 0);
}
return vscale_type;
static void
gtk_vscale_class_init (GtkVScaleClass *class)
{
- GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkRangeClass *range_class;
- gobject_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
range_class = GTK_RANGE_CLASS (class);
GtkWidget*
gtk_vscale_new (GtkAdjustment *adjustment)
{
- GtkWidget *vscale;
-
- vscale = gtk_widget_new (GTK_TYPE_VSCALE,
- "adjustment", adjustment,
- NULL);
-
- return vscale;
+ return g_object_new (GTK_TYPE_VSCALE, "adjustment", adjustment, NULL);
}
* @max: maximum value
* @step: step increment (tick size) used with keyboard shortcuts
*
- * Creates a new vertical scale widget that lets the user
- * input a number between @min and @max with the increment @step.
- * @step must be nonzero; it's the distance the slider moves when
- * using the arrow keys to adjust the scale value.
+ * Creates a new vertical scale widget that lets the user input a
+ * number between @min and @max (including @min and @max) with the
+ * increment @step. @step must be nonzero; it's the distance the
+ * slider moves when using the arrow keys to adjust the scale value.
*
* Return value: a new #GtkVScale
**/
g_return_val_if_fail (min < max, NULL);
g_return_val_if_fail (step != 0.0, NULL);
- adj = gtk_adjustment_new (min, min, max, step, 10 * step, step);
+ adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
scale = g_object_new (GTK_TYPE_VSCALE,
"adjustment", adj,
scale = GTK_SCALE (widget);
vscale = GTK_VSCALE (widget);
+ /* We need to chain up _first_ so the various geometry members of
+ * GtkRange struct are updated.
+ */
+ if (GTK_WIDGET_CLASS (parent_class)->expose_event)
+ GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+
if (scale->draw_value)
{
PangoLayout *layout;
break;
}
+ x += widget->allocation.x;
+ y += widget->allocation.y;
+
state_type = GTK_STATE_NORMAL;
if (!GTK_WIDGET_IS_SENSITIVE (scale))
state_type = GTK_STATE_INSENSITIVE;
x, y,
layout);
- g_object_unref (G_OBJECT (layout));
+ g_object_unref (layout);
}
- return (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
+ return FALSE;
}