From fb9f99b52de319497918e4d862350595da965c1c Mon Sep 17 00:00:00 2001 From: waker Date: Sun, 11 Aug 2013 22:03:48 +0200 Subject: gtkui: changed widget API to support extensibility / backwards compat --- plugins/gtkui/gtkui_api.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'plugins/gtkui/gtkui_api.h') diff --git a/plugins/gtkui/gtkui_api.h b/plugins/gtkui/gtkui_api.h index a1e88afd..9f11ed9b 100644 --- a/plugins/gtkui/gtkui_api.h +++ b/plugins/gtkui/gtkui_api.h @@ -58,11 +58,14 @@ typedef struct ddb_gtkui_widget_s { // strncat (s, "100 200", sz); void (*save) (struct ddb_gtkui_widget_s *w, char *s, int sz); - // this is to read custom widget parameters, e.g. width and height + // this is to read custom widget parameters, e.g. width and height; // you will be passed a string looking like "100 200 {" // you will need to read params, and return the new pointer, normally it // should be pointing to the "{" - const char *(*load) (struct ddb_gtkui_widget_s *w, const char *s); + // + // type string is necessary for backwards compatibility, so that load + // function knows which type it's loading + const char *(*load) (struct ddb_gtkui_widget_s *w, const char *type, const char *s); // custom destructor code void (*destroy) (struct ddb_gtkui_widget_s *w); @@ -105,8 +108,13 @@ typedef struct { // returns main window ptr GtkWidget * (*get_mainwin) (void); - // register new widget type - void (*w_reg_widget) (const char *type, const char *title, ddb_gtkui_widget_t *(*create_func) (void)); + // register new widget type; + // type strings are passed at the end of argument list terminated with NULL + // for example: + // w_reg_widget("My Visualization", my_viz_create, "my_viz_ng", "my_viz", NULL); + // this call will register new type "my_viz_ng", with support for another + // "my_viz" type string + void (*w_reg_widget) (const char *title, ddb_gtkui_widget_t *(*create_func) (void), ...); // unregister existing widget type void (*w_unreg_widget) (const char *type); -- cgit v1.2.3