From c00ea30f26399a1e94e923bcb5707434e745530a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 24 Nov 2007 00:33:42 +0000 Subject: - created tkwidgets_list_options() to query which Tk options are supported - removed set_tk_widgets_ids() from places where it wasn't need AFAIK - minor renames and cleanups svn path=/trunk/externals/tkwidgets/; revision=9029 --- shared/tkwidgets.c | 23 ++++++++++++++++++----- shared/tkwidgets.h | 5 ++--- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'shared') diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c index eec524a..65dba8f 100644 --- a/shared/tkwidgets.c +++ b/shared/tkwidgets.c @@ -51,11 +51,11 @@ void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace, int i; for(i = 0; i < argc; i++) { - sys_vgui("set ::%s::ret [%s cget -%s]\n", + sys_vgui("set ::%s::tmp [%s cget -%s]\n", tcl_namespace->s_name, widget_id->s_name, argv[i]); - sys_vgui("if {[string length $::%s::ret] > 0} {\n", + sys_vgui("if {[string length $::%s::tmp] > 0} {\n", tcl_namespace->s_name); - sys_vgui("lappend ::%s::list -%s; lappend ::%s::list $::%s::ret}\n", + sys_vgui("lappend ::%s::list -%s; lappend ::%s::list $::%s::tmp}\n", tcl_namespace->s_name, argv[i], tcl_namespace->s_name, tcl_namespace->s_name); } @@ -64,8 +64,7 @@ void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace, sys_vgui("unset ::%s::list \n", tcl_namespace->s_name); } -void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *tcl_namespace, - t_symbol *widget_id, t_binbuf *options_binbuf) +void tkwidgets_restore_options(t_symbol *widget_id, t_binbuf *options_binbuf) { int length; char *options; @@ -74,6 +73,20 @@ void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *tcl_namespace, sys_vgui("%s configure %s\n", widget_id->s_name, options); } +/* output a list of available options for this widget */ +void tkwidgets_list_options(t_outlet *status_outlet, int argc, char** argv) +{ + int i; + t_binbuf *bb = binbuf_new(); + for(i = 0; i < argc; ++i) + { + binbuf_addv(bb, "s", gensym(argv[i])); + } + outlet_anything(status_outlet, gensym("options"), + binbuf_getnatom(bb), binbuf_getvec(bb)); +} + + /* -------------------- generate names for various elements ----------------- */ t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name) diff --git a/shared/tkwidgets.h b/shared/tkwidgets.h index 342162e..fa444fa 100644 --- a/shared/tkwidgets.h +++ b/shared/tkwidgets.h @@ -71,11 +71,10 @@ void tkwidgets_setcallbackname(void *x, char *widget_name); /* handle options */ void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace, t_symbol *widget_id, int argc, char **argv); -void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *tcl_namespace, - t_symbol *widget_id, t_binbuf *options_binbuf); +void tkwidgets_restore_options(t_symbol *widget_id, t_binbuf *options_binbuf); void tkwidgets_query_options(t_symbol *receive_name, t_symbol *widget_id, int argc, char** argv); - +void tkwidgets_list_options(t_outlet *status_outlet, int argc, char** argv); /* generate ID and tag names for using in Tcl/Tk space */ t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name); -- cgit v1.2.1