* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "gtkcurve.h"
#include "gtkdrawingarea.h"
#include "gtkmain.h"
+#include "gtkmarshalers.h"
#include "gtkradiobutton.h"
-#include "gtksignal.h"
#include "gtktable.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkalias.h"
#define RADIUS 3 /* radius of the control points */
#define MIN_DISTANCE 8 /* min distance between control points */
static void gtk_curve_get_property (GObject *object,
guint param_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void gtk_curve_set_property (GObject *object,
guint param_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void gtk_curve_finalize (GObject *object);
static gint gtk_curve_graph_events (GtkWidget *widget,
GdkEvent *event,
GtkCurve *c);
static void gtk_curve_size_graph (GtkCurve *curve);
-GtkType
+GType
gtk_curve_get_type (void)
{
- static GtkType curve_type = 0;
+ static GType curve_type = 0;
if (!curve_type)
{
- static const GtkTypeInfo curve_info =
+ static const GTypeInfo curve_info =
{
- "GtkCurve",
- sizeof (GtkCurve),
sizeof (GtkCurveClass),
- (GtkClassInitFunc) gtk_curve_class_init,
- (GtkObjectInitFunc) gtk_curve_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_curve_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkCurve),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_curve_init,
};
- curve_type = gtk_type_unique (GTK_TYPE_DRAWING_AREA, &curve_info);
+ curve_type = g_type_register_static (GTK_TYPE_DRAWING_AREA, I_("GtkCurve"),
+ &curve_info, 0);
}
return curve_type;
}
gtk_curve_class_init (GtkCurveClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
- parent_class = gtk_type_class (GTK_TYPE_DRAWING_AREA);
+ parent_class = g_type_class_peek_parent (class);
gobject_class->finalize = gtk_curve_finalize;
g_object_class_install_property (gobject_class,
PROP_CURVE_TYPE,
- g_param_spec_enum ("curve_type",
- _("Curve type"),
- _("Is this curve linear, spline interpolated, or free-form"),
+ g_param_spec_enum ("curve-type",
+ P_("Curve type"),
+ P_("Is this curve linear, spline interpolated, or free-form"),
GTK_TYPE_CURVE_TYPE,
GTK_CURVE_TYPE_LINEAR,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MIN_X,
- g_param_spec_float ("min_x",
- _("Minimum X"),
- _("Minimum possible value for X"),
+ g_param_spec_float ("min-x",
+ P_("Minimum X"),
+ P_("Minimum possible value for X"),
-G_MAXFLOAT,
G_MAXFLOAT,
0.0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MAX_X,
- g_param_spec_float ("max_x",
- _("Maximum X"),
- _("Maximum possible X value."),
+ g_param_spec_float ("max-x",
+ P_("Maximum X"),
+ P_("Maximum possible X value"),
-G_MAXFLOAT,
G_MAXFLOAT,
1.0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MIN_Y,
- g_param_spec_float ("min_y",
- _("Minimum Y"),
- _("Minimum possible value for Y"),
+ g_param_spec_float ("min-y",
+ P_("Minimum Y"),
+ P_("Minimum possible value for Y"),
-G_MAXFLOAT,
G_MAXFLOAT,
0.0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MAX_Y,
- g_param_spec_float ("max_y",
- _("Maximum Y"),
- _("Maximum possible value for Y"),
+ g_param_spec_float ("max-y",
+ P_("Maximum Y"),
+ P_("Maximum possible value for Y"),
-G_MAXFLOAT,
G_MAXFLOAT,
1.0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
curve_type_changed_signal =
- gtk_signal_new ("curve_type_changed", GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
- GTK_SIGNAL_OFFSET (GtkCurveClass, curve_type_changed),
- gtk_marshal_VOID__VOID, GTK_TYPE_NONE, 0);
+ g_signal_new (I_("curve_type_changed"),
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkCurveClass, curve_type_changed),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
curve->grab_point = -1;
curve->num_points = 0;
- curve->point = 0;
+ curve->point = NULL;
curve->num_ctlpoints = 0;
curve->ctlpoint = NULL;
old_mask = gtk_widget_get_events (GTK_WIDGET (curve));
gtk_widget_set_events (GTK_WIDGET (curve), old_mask | GRAPH_MASK);
- gtk_signal_connect (GTK_OBJECT (curve), "event",
- (GtkSignalFunc) gtk_curve_graph_events, curve);
+ g_signal_connect (curve, "event",
+ G_CALLBACK (gtk_curve_graph_events), curve);
gtk_curve_size_graph (curve);
}
-static void gtk_curve_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+static void
+gtk_curve_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GtkCurve *curve = GTK_CURVE (object);
}
}
-static void gtk_curve_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+static void
+gtk_curve_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkCurve *curve = GTK_CURVE (object);
/* clear the pixmap: */
gtk_paint_flat_box (style, c->pixmap, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
- NULL, GTK_WIDGET(c), "curve_bg",
+ NULL, GTK_WIDGET (c), "curve_bg",
0, 0, width + RADIUS * 2, height + RADIUS * 2);
/* draw the grid lines: (XXX make more meaningful) */
for (i = 0; i < 5; i++)
gdk_draw_arc (c->pixmap, style->fg_gc[state], TRUE, x, y,
RADIUS * 2, RADIUS*2, 0, 360*64);
}
- gdk_draw_pixmap (GTK_WIDGET (c)->window, style->fg_gc[state], c->pixmap,
- 0, 0, 0, 0, width + RADIUS * 2, height + RADIUS * 2);
+ gdk_draw_drawable (GTK_WIDGET (c)->window, style->fg_gc[state], c->pixmap,
+ 0, 0, 0, 0, width + RADIUS * 2, height + RADIUS * 2);
}
static gint
gfloat rx, ry, min_x;
guint distance;
gint x1, x2, y1, y2;
+ gint retval = FALSE;
w = GTK_WIDGET (c);
width = w->allocation.width - RADIUS * 2;
{
case GDK_CONFIGURE:
if (c->pixmap)
- gdk_pixmap_unref (c->pixmap);
- c->pixmap = 0;
+ g_object_unref (c->pixmap);
+ c->pixmap = NULL;
/* fall through */
case GDK_EXPOSE:
if (!c->pixmap)
break;
}
gtk_curve_draw (c, width, height);
+ retval = TRUE;
break;
case GDK_BUTTON_RELEASE:
}
new_type = GDK_FLEUR;
c->grab_point = -1;
+ retval = TRUE;
break;
case GDK_MOTION_NOTIFY:
c->cursor_type = new_type;
- cursor = gdk_cursor_new (c->cursor_type);
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (w),
+ c->cursor_type);
gdk_window_set_cursor (w->window, cursor);
- gdk_cursor_destroy (cursor);
+ gdk_cursor_unref (cursor);
}
+ retval = TRUE;
break;
default:
break;
}
- return FALSE;
+
+ return retval;
}
void
{
gint width, height;
- width = GTK_WIDGET(c)->allocation.width - RADIUS * 2;
- height = GTK_WIDGET(c)->allocation.height - RADIUS * 2;
+ width = GTK_WIDGET (c)->allocation.width - RADIUS * 2;
+ height = GTK_WIDGET (c)->allocation.height - RADIUS * 2;
if (new_type == GTK_CURVE_TYPE_FREE)
{
c->curve_type = new_type;
gtk_curve_interpolate (c, width, height);
}
- gtk_signal_emit (GTK_OBJECT (c), curve_type_changed_signal);
+ g_signal_emit (c, curve_type_changed_signal, 0);
g_object_notify (G_OBJECT (c), "curve_type");
gtk_curve_draw (c, width, height);
}
{
gint width, height;
gfloat aspect;
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (curve));
width = (curve->max_x - curve->min_x) + 1;
height = (curve->max_y - curve->min_y) + 1;
aspect = width / (gfloat) height;
- if (width > gdk_screen_width () / 4)
- width = gdk_screen_width () / 4;
- if (height > gdk_screen_height () / 4)
- height = gdk_screen_height () / 4;
+ if (width > gdk_screen_get_width (screen) / 4)
+ width = gdk_screen_get_width (screen) / 4;
+ if (height > gdk_screen_get_height (screen) / 4)
+ height = gdk_screen_get_height (screen) / 4;
if (aspect < 1.0)
width = height * aspect;
else
height = width / aspect;
- gtk_drawing_area_size (GTK_DRAWING_AREA (curve),
- width + RADIUS * 2, height + RADIUS * 2);
+ gtk_widget_set_size_request (GTK_WIDGET (curve),
+ width + RADIUS * 2,
+ height + RADIUS * 2);
}
static void
gtk_curve_reset_vector (c);
if (old_type != GTK_CURVE_TYPE_SPLINE)
- gtk_signal_emit (GTK_OBJECT (c), curve_type_changed_signal);
+ {
+ g_signal_emit (c, curve_type_changed_signal, 0);
+ g_object_notify (G_OBJECT (c), "curve_type");
+ }
}
void
}
if (old_type != GTK_CURVE_TYPE_FREE)
- gtk_signal_emit (GTK_OBJECT (c), curve_type_changed_signal);
+ g_signal_emit (c, curve_type_changed_signal, 0);
gtk_curve_draw (c, c->num_points, c->height);
}
gfloat min_y,
gfloat max_y)
{
+ g_object_freeze_notify (G_OBJECT (curve));
if (curve->min_x != min_x) {
curve->min_x = min_x;
g_object_notify (G_OBJECT (curve), "min_x");
curve->max_y = max_y;
g_object_notify (G_OBJECT (curve), "max_y");
}
+ g_object_thaw_notify (G_OBJECT (curve));
gtk_curve_size_graph (curve);
gtk_curve_reset_vector (curve);
GtkCurveType old_type;
gfloat rx, dx, ry;
gint i, height;
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (c));
old_type = c->curve_type;
c->curve_type = GTK_CURVE_TYPE_FREE;
else
{
height = (c->max_y - c->min_y);
- if (height > gdk_screen_height () / 4)
- height = gdk_screen_height () / 4;
+ if (height > gdk_screen_get_height (screen) / 4)
+ height = gdk_screen_get_height (screen) / 4;
c->height = height;
c->num_points = veclen;
RADIUS + height - project (ry, c->min_y, c->max_y, height);
}
if (old_type != GTK_CURVE_TYPE_FREE)
- gtk_signal_emit (GTK_OBJECT (c), curve_type_changed_signal);
+ {
+ g_signal_emit (c, curve_type_changed_signal, 0);
+ g_object_notify (G_OBJECT (c), "curve_type");
+ }
gtk_curve_draw (c, c->num_points, height);
}
GtkWidget*
gtk_curve_new (void)
{
- return gtk_type_new (gtk_curve_get_type ());
+ return g_object_new (GTK_TYPE_CURVE, NULL);
}
static void
{
GtkCurve *curve;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_CURVE (object));
curve = GTK_CURVE (object);
if (curve->pixmap)
- gdk_pixmap_unref (curve->pixmap);
+ g_object_unref (curve->pixmap);
if (curve->point)
g_free (curve->point);
if (curve->ctlpoint)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+
+#define __GTK_CURVE_C__
+#include "gtkaliasdef.c"