2 * h/t https://ptomato.name/advanced-gtk-techniques/html/custom-container.html
3 * for examples of how to make GTK widgets
10 #define BV_CHART_PRIVATE(obj) \
11 (G_TYPE_INSTANCE_GET_PRIVATE((obj), BV_CHART_TYPE, BVChartPrivate))
13 typedef struct _BVChartPrivate BVChartPrivate
;
15 struct _BVChartPrivate
{
17 float minx
, miny
, maxx
, maxy
;
24 G_DEFINE_TYPE_WITH_CODE(BVChart
, bv_chart
, GTK_TYPE_DRAWING_AREA
,
25 G_ADD_PRIVATE(BVChart
))
27 static void bv_chart_class_init(BVChartClass
*klass
__attribute__((unused
))) {}
29 static void bv_chart_init(BVChart
*chart
) {
30 gtk_widget_set_has_window(GTK_WIDGET(chart
), FALSE
);
31 BVChartPrivate
*priv
= bv_chart_get_instance_private(chart
);
32 gboolean zero_terminated
= FALSE
;
33 gboolean clear_
= FALSE
;
35 g_array_new(zero_terminated
, clear_
, sizeof(struct BVChartPoint
));
42 GtkWidget
*bv_chart_new() {
43 return GTK_WIDGET(g_object_new(bv_chart_get_type(), NULL
));
46 void bv_chart_add_point(BVChart
*chart
, float x
, float y
) {
47 BVChartPrivate
*priv
= bv_chart_get_instance_private(chart
);
56 struct BVChartPoint p
= {.x
= x
, .y
= y
};
57 g_array_append_val(priv
->points
, p
);