2 * h/t https://ptomato.name/advanced-gtk-techniques/html/custom-container.html
3 * for examples of how to make GTK widgets
9 #define BV_CHART_PRIVATE(obj) \
10 (G_TYPE_INSTANCE_GET_PRIVATE((obj), BV_CHART_TYPE, BVChartPrivate))
12 typedef struct _BVChartPrivate BVChartPrivate
;
14 struct _BVChartPrivate
{
22 G_DEFINE_TYPE_WITH_CODE(BVChart
, bv_chart
, GTK_TYPE_DRAWING_AREA
,
23 G_ADD_PRIVATE(BVChart
))
25 static void bv_chart_class_init(BVChartClass
*klass
__attribute__((unused
))) {}
27 static void bv_chart_init(BVChart
*chart
) {
28 gtk_widget_set_has_window(GTK_WIDGET(chart
), FALSE
);
29 BVChartPrivate
*priv
= bv_chart_get_instance_private(chart
);
30 gboolean zero_terminated
= FALSE
;
31 gboolean clear_
= FALSE
;
33 g_array_new(zero_terminated
, clear_
, sizeof(struct BVChartPoint
));
36 GtkWidget
*bv_chart_new() {
37 return GTK_WIDGET(g_object_new(bv_chart_get_type(), NULL
));
40 void bv_chart_add_point(BVChart
*chart
, float x
, float y
) {
41 BVChartPrivate
*priv
= bv_chart_get_instance_private(chart
);
42 struct BVChartPoint p
= {.x
= x
, .y
= y
};
43 g_array_append_val(priv
->points
, p
);