Update of /cvsroot/pure-data/externals/unauthorized/playlist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31044
Modified Files: CHANGES.LOG Makefile playlist.c playlist.tk Added Files: help-playlist.pd playlist.tk2c tk2c.bash Log Message: playlist 0.8
Index: playlist.tk =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/playlist/playlist.tk,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** playlist.tk 16 Aug 2003 08:28:27 -0000 1.1 --- playlist.tk 30 Mar 2004 03:59:41 -0000 1.2 *************** *** 11,14 **** --- 11,24 ---- set var_graph_height [concat graph_height$vid] global $var_graph_height + set var_graph_font [concat graph_font$vid] + global $var_graph_font + set var_graph_bgcolor [concat graph_bgcolor$vid] + global $var_graph_bgcolor + set var_graph_sbcolor [concat graph_sbcolor$vid] + global $var_graph_sbcolor + set var_graph_fgcolor [concat graph_fgcolor$vid] + global $var_graph_fgcolor + set var_graph_secolor [concat graph_secolor$vid] + global $var_graph_secolor
set cmd [concat $id dialog \ *************** *** 16,19 **** --- 26,34 ---- [eval concat $$var_graph_width] \ [eval concat $$var_graph_height] \ + [eval concat $$var_graph_font] \ + [eval concat $$var_graph_bgcolor] \ + [eval concat $$var_graph_sbcolor] \ + [eval concat $$var_graph_fgcolor] \ + [eval concat $$var_graph_secolor] \ ;] #puts stderr $cmd *************** *** 32,36 **** }
! proc pdtk_playlist_dialog {id extension width height} { set vid [string trimleft $id .] set var_graph_extension [concat graph_extension_$vid] --- 47,51 ---- }
! proc pdtk_playlist_dialog {id extension width height font bgcolor sbcolor fgcolor secolor} { set vid [string trimleft $id .] set var_graph_extension [concat graph_extension_$vid] *************** *** 40,47 **** set var_graph_height [concat graph_height$vid] global $var_graph_height
set $var_graph_extension $extension ! set $var_graph_width $width ! set $var_graph_height $height
toplevel $id --- 55,77 ---- set var_graph_height [concat graph_height$vid] global $var_graph_height + set var_graph_font [concat graph_font$vid] + global $var_graph_font + set var_graph_bgcolor [concat graph_bgcolor$vid] + global $var_graph_bgcolor + set var_graph_sbcolor [concat graph_sbcolor$vid] + global $var_graph_sbcolor + set var_graph_fgcolor [concat graph_fgcolor$vid] + global $var_graph_fgcolor + set var_graph_secolor [concat graph_secolor$vid] + global $var_graph_secolor
set $var_graph_extension $extension ! set $var_graph_width $width ! set $var_graph_height $height ! set $var_graph_font $font ! set $var_graph_bgcolor $bgcolor ! set $var_graph_sbcolor $sbcolor ! set $var_graph_fgcolor $fgcolor ! set $var_graph_secolor $secolor
toplevel $id *************** *** 82,88 **** pack $id.3rangef.lheight $id.3rangef.height -side left
bind $id.1rangef.extension <KeyPress-Return> [concat playlist_ok $id] ! bind $id.2rangef.width <KeyPress-Return> [concat playlist_ok $id] ! bind $id.3rangef.height <KeyPress-Return> [concat playlist_ok $id] }
--- 112,153 ---- pack $id.3rangef.lheight $id.3rangef.height -side left
+ frame $id.3_5rangef + pack $id.3_5rangef -side top + label $id.3_5rangef.lfont -text "Font :" + entry $id.3_5rangef.font -textvariable $var_graph_font -width 30 + pack $id.3_5rangef.lfont $id.3_5rangef.font -side left + + frame $id.4rangef + pack $id.4rangef -side top + label $id.4rangef.lbgcolor -text "Background Color :" + entry $id.4rangef.bgcolor -textvariable $var_graph_bgcolor -width 7 + pack $id.4rangef.lbgcolor $id.4rangef.bgcolor -side left + + frame $id.5rangef + pack $id.5rangef -side top + label $id.5rangef.lsbcolor -text "Scroll Bar Color :" + entry $id.5rangef.sbcolor -textvariable $var_graph_sbcolor -width 7 + pack $id.5rangef.lsbcolor $id.5rangef.sbcolor -side left + + frame $id.6rangef + pack $id.6rangef -side top + label $id.6rangef.lfgcolor -text "Foreground Color :" + entry $id.6rangef.fgcolor -textvariable $var_graph_fgcolor -width 7 + pack $id.6rangef.lfgcolor $id.6rangef.fgcolor -side left + + frame $id.7rangef + pack $id.7rangef -side top + label $id.7rangef.lsecolor -text "Selection Color :" + entry $id.7rangef.secolor -textvariable $var_graph_secolor -width 7 + pack $id.7rangef.lsecolor $id.7rangef.secolor -side left + bind $id.1rangef.extension <KeyPress-Return> [concat playlist_ok $id] ! bind $id.2rangef.width <KeyPress-Return> [concat playlist_ok $id] ! bind $id.3rangef.height <KeyPress-Return> [concat playlist_ok $id] ! bind $id.3_5rangef.font <KeyPress-Return> [concat playlist_ok $id] ! bind $id.4rangef.bgcolor <KeyPress-Return> [concat playlist_ok $id] ! bind $id.5rangef.sbcolor <KeyPress-Return> [concat playlist_ok $id] ! bind $id.6rangef.fgcolor <KeyPress-Return> [concat playlist_ok $id] ! bind $id.7rangef.secolor <KeyPress-Return> [concat playlist_ok $id] }
--- NEW FILE: help-playlist.pd --- #N canvas 94 79 817 563 10; #X text 28 57 Constructor : playlist <extension> <width> <height>; #X text 88 95 playlist all 200 200; #X text 88 107 playlist mp3 200 200; #X text 30 78 Examples :; #X text 80 454 Comments and bugs @ ydegoyon@free.fr; #X symbolatom 292 399 50 0 0 0 - - -; #X text 17 342 Note : you can scroll the list by dragging; #X text 15 353 the mouse in the yellow area; #X text 17 364 You can select and scroll in the blue area; #X obj 292 181 playlist all 400 200; #X msg 301 84 seek $1; #X text 406 66 You can seek a file in the list; #X text 405 77 It will skip the first two items ( '.' and '..'); #X text 405 89 and behave like a round list; #X text 28 14 Playlist lets you switch files in one click; #X text 27 25 It's handling most non-alpha characters gracefully; #X floatatom 355 85 5 0 0 0 - - -; #X symbolatom 333 426 50 0 0 0 - - -; #X symbolatom 379 453 50 0 0 0 - - -; #X msg 151 163 location ..; #X msg 150 140 location /tmp; #X text 60 211 You can change change location; #X text 60 221 with a message.; #X text 60 233 Thus , you can initialize the object; #X text 59 242 in a particular folder.; #X msg 151 185 location patches; #X msg 299 111 sort $1; #X obj 355 110 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X text 405 109 Use alphabetical or creation time order; #X obj 87 140 loadbang; #X text 597 135 Change the font; #X msg 300 136 font Helvetica normal 14; #X msg 458 135 font Courier bold 24; #X connect 9 0 5 0; #X connect 9 1 17 0; #X connect 9 2 18 0; #X connect 10 0 9 0; #X connect 16 0 10 0; #X connect 19 0 9 0; #X connect 20 0 9 0; #X connect 25 0 9 0; #X connect 26 0 9 0; #X connect 27 0 26 0; #X connect 29 0 20 0; #X connect 31 0 9 0; #X connect 32 0 9 0;
Index: CHANGES.LOG =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/playlist/CHANGES.LOG,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CHANGES.LOG 16 Aug 2003 08:28:27 -0000 1.1 --- CHANGES.LOG 30 Mar 2004 03:59:41 -0000 1.2 *************** *** 1,2 **** --- 1,8 ---- + 0.8 + added colors and font properties + added a "font" message + added a "sort" message ( using alphabetical or creation order ) + 0.7 + adapted for pd 0.37 0.6 added properties menu
Index: playlist.c =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/playlist/playlist.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** playlist.c 25 Sep 2003 20:58:54 -0000 1.5 --- playlist.c 30 Mar 2004 03:59:41 -0000 1.6 *************** *** 36,40 **** #include <ctype.h> #include <regex.h> ! #include <m_pd.h> #include "m_imp.h" #include "g_canvas.h" --- 36,40 ---- #include <ctype.h> #include <regex.h> ! #include "m_pd.h" #include "m_imp.h" #include "g_canvas.h" *************** *** 54,60 **** static int guidebug=0;
! static char *playlist_version = "playlist: 1 click file chooser : version 0.6, written by Yves Degoyon (ydegoyon@free.fr)";
- #define CHAR_WIDTH 6 // average character width with font Helvetica 8 #define MAX_DIR_LENGTH 2048 // maximum length for a directory name
--- 54,59 ---- static int guidebug=0;
! static char *playlist_version = "playlist: 1 click file chooser : version 0.8, written by Yves Degoyon (ydegoyon@free.fr)";
#define MAX_DIR_LENGTH 2048 // maximum length for a directory name
*************** *** 93,96 **** --- 92,103 ---- sys_vgui(a,b,c,d,e,f,g,h,i)
+ #define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j );\ + sys_vgui(a,b,c,d,e,f,g,h,i,j) + + #define SYS_VGUI11(a,b,c,d,e,f,g,h,i,j,k) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j,k );\ + sys_vgui(a,b,c,d,e,f,g,h,i,j,k) +
typedef struct _playlist *************** *** 112,116 **** --- 119,131 ---- t_int x_lastseen; /* last displayed entry */ t_int x_cdy; /* cumulated y drag */ + t_int x_sort; /* sorting option flag */ char *x_curdir; /* current directory informations */ + char *x_font; /* font used for entries */ + t_int x_charheight; /* height of characters */ + t_int x_charwidth; /* width of characters */ + char *x_bgcolor; /* background color */ + char *x_sbcolor; /* scrollbar color */ + char *x_fgcolor; /* foreground color */ + char *x_secolor; /* selection color */ } t_playlist;
*************** *** 124,129 **** // set title SYS_VGUI3(".x%x.c delete %xTITLE\n", glist_getcanvas(glist), x); ! SYS_VGUI7(".x%x.c create text %d %d -width %d -text "%s" \ ! -anchor w -font {Helvetica 8 bold} -tags %xTITLE\n", canvas, x->x_obj.te_xpix+5, --- 139,144 ---- // set title SYS_VGUI3(".x%x.c delete %xTITLE\n", glist_getcanvas(glist), x); ! SYS_VGUI8(".x%x.c create text %d %d -width %d -text "%s" \ ! -anchor w -font %s -tags %xTITLE\n", canvas, x->x_obj.te_xpix+5, *************** *** 131,134 **** --- 146,150 ---- x->x_width, x->x_curdir, + x->x_font, x );
*************** *** 145,149 ****
// post( "playlist : scandir : %s", x->x_curdir ); ! if ( ( nentries = scandir(x->x_curdir, &dentries, NULL, alphasort ) ) == -1 ) { post( "playlist : could not scan current directory ( where the hell are you ??? )" ); --- 161,165 ----
// post( "playlist : scandir : %s", x->x_curdir ); ! if ( ( nentries = scandir(x->x_curdir, &dentries, NULL, (x->x_sort==1)?alphasort:NULL ) ) == -1 ) { post( "playlist : could not scan current directory ( where the hell are you ??? )" ); *************** *** 196,211 ****
// display the entry if displayable ! if ( x->x_nentries*10+5 < x->x_height ) { x->x_lastseen = x->x_nentries; ! strncpy( wrappedname, x->x_dentries[x->x_nentries], MIN(x->x_width/CHAR_WIDTH, MAX_DIR_LENGTH) ); ! wrappedname[ x->x_width/CHAR_WIDTH ] = '\0'; ! SYS_VGUI8(".x%x.c create text %d %d -fill #000000 -activefill #FF0000 -width %d -text "%s" \ ! -anchor w -font {Helvetica 8 bold} -tags %xENTRY%d\n", canvas, x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(x->x_nentries-x->x_firstseen)*10, x->x_width, wrappedname, x, x->x_nentries ); } --- 212,230 ----
// display the entry if displayable ! if ( x->x_nentries*x->x_charheight+5 < x->x_height ) { x->x_lastseen = x->x_nentries; ! strncpy( wrappedname, x->x_dentries[x->x_nentries], MIN(x->x_width/x->x_charwidth, MAX_DIR_LENGTH) ); ! wrappedname[ x->x_width/x->x_charwidth ] = '\0'; ! SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text "%s" \ ! -anchor w -font %s -tags %xENTRY%d\n", canvas, x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(x->x_nentries-x->x_firstseen)*x->x_charheight, ! x->x_fgcolor, ! x->x_secolor, x->x_width, wrappedname, + x->x_font, x, x->x_nentries ); } *************** *** 232,247 **** }
void playlist_draw_new(t_playlist *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist);
! SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #457782 -tags %xPLAYLIST\n", canvas, x->x_obj.te_xpix, x->x_obj.te_ypix, x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height, ! x); ! SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill yellow -tags %xSCROLLLIST\n", canvas, x->x_obj.te_xpix+4*x->x_width/5, x->x_obj.te_ypix, x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height, ! x);
playlist_update_dir( x, glist ); --- 251,292 ---- }
+ void playlist_sort(t_playlist* x, t_floatarg fsort) + { + if ( ( (t_int)fsort != 0 ) && ( (t_int)fsort != 1 ) ) + { + post( "plyalist : wrong argument to playlist message : %d", (t_int)fsort ); + return; + } + + x->x_sort = (t_int) fsort; + playlist_update_dir( x, x->x_glist ); + } + + void playlist_font(t_playlist* x, t_symbol *fname, t_symbol *fcase, t_floatarg fsize) + { + if ( (t_int)fsize <= 4 ) + { + post( "playlist : wrong font size in font message : %d", (t_int)fsize ); + return; + } + sprintf( x->x_font, "{%s %d %s}", fname->s_name, (t_int)fsize, fcase->s_name ); + x->x_charheight = (t_int)fsize; + x->x_charwidth = (2*x->x_charheight)/3; + post( "playlist : setting font to : %s", x->x_font ); + playlist_update_dir( x, x->x_glist ); + } + void playlist_draw_new(t_playlist *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist);
! SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xPLAYLIST\n", canvas, x->x_obj.te_xpix, x->x_obj.te_ypix, x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height, ! x->x_bgcolor, x); ! SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xSCROLLLIST\n", canvas, x->x_obj.te_xpix+4*x->x_width/5, x->x_obj.te_ypix, x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height, ! x->x_sbcolor, x);
playlist_update_dir( x, glist ); *************** *** 272,276 **** canvas, x, i, x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*10); }
--- 317,321 ---- canvas, x, i, x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*x->x_charheight); }
*************** *** 327,333 ****
// post( "saving playlist : %s", x->x_extension ); ! binbuf_addv(b, "ssiissii", gensym("#X"),gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, ! gensym("playlist"), gensym(x->x_extension), x->x_width, x->x_height ); binbuf_addv(b, ";"); } --- 372,380 ----
// post( "saving playlist : %s", x->x_extension ); ! binbuf_addv(b, "ssiissiisssss", gensym("#X"), gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, ! gensym("playlist"), gensym(x->x_extension), x->x_width, x->x_height, ! gensym(x->x_font), gensym(x->x_bgcolor), gensym(x->x_sbcolor), ! gensym(x->x_fgcolor), gensym(x->x_secolor) ); binbuf_addv(b, ";"); } *************** *** 389,393 **** // eventually, move down if ( ( x->x_cdy >= 3 ) && ! ( x->x_firstseen < x->x_nentries - ( x->x_height/10 ) ) ) { x->x_cdy = 0; --- 436,440 ---- // eventually, move down if ( ( x->x_cdy >= 3 ) && ! ( x->x_firstseen < x->x_nentries - ( x->x_height/x->x_charheight ) ) ) { x->x_cdy = 0; *************** *** 403,423 **** char *wrappedname = (char *) getbytes( x->x_width );
! if ( (i-x->x_firstseen)*10+5 < x->x_height ) { x->x_lastseen = i; ! strncpy( wrappedname, x->x_dentries[i], x->x_width/CHAR_WIDTH ); ! wrappedname[ x->x_width/CHAR_WIDTH ] = '\0'; ! SYS_VGUI8(".x%x.c create text %d %d -fill #000000 -activefill #FF0000 -width %d -text "%s" \ ! -anchor w -font {Helvetica 8 bold} -tags %xENTRY%d\n", glist_getcanvas(x->x_glist), x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*10, x->x_width, wrappedname, x, i ); } else break; } ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #FF0000\n", x->x_glist, x, x->x_itemselected); // post( "playlist : moved down first=%d last=%d", x->x_firstseen, x->x_lastseen ); } --- 450,474 ---- char *wrappedname = (char *) getbytes( x->x_width );
! if ( (i-x->x_firstseen)*x->x_charheight+5 < x->x_height ) { x->x_lastseen = i; ! strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); ! wrappedname[ x->x_width/x->x_charwidth ] = '\0'; ! SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text "%s" \ ! -anchor w -font %s -tags %xENTRY%d\n", glist_getcanvas(x->x_glist), x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*x->x_charheight, ! x->x_fgcolor, ! x->x_secolor, x->x_width, wrappedname, + x->x_font, x, i ); } else break; } ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", ! x->x_glist, x, x->x_itemselected, x->x_secolor); // post( "playlist : moved down first=%d last=%d", x->x_firstseen, x->x_lastseen ); } *************** *** 425,429 **** // eventually, move up if ( ( x->x_cdy <= -3 ) && ! ( x->x_lastseen >= ( x->x_height/10 ) ) ) { x->x_cdy = 0; --- 476,480 ---- // eventually, move up if ( ( x->x_cdy <= -3 ) && ! ( x->x_lastseen >= ( x->x_height/x->x_charheight ) ) ) { x->x_cdy = 0; *************** *** 439,459 **** char *wrappedname = (char *) getbytes( x->x_width );
! if ( (i-x->x_firstseen)*10+5 < x->x_height ) { x->x_lastseen = i; ! strncpy( wrappedname, x->x_dentries[i], x->x_width/CHAR_WIDTH ); ! wrappedname[ x->x_width/CHAR_WIDTH ] = '\0'; ! SYS_VGUI8(".x%x.c create text %d %d -fill #000000 -activefill #FF0000 -width %d -text "%s" \ ! -anchor w -font {Helvetica 8 bold} -tags %xENTRY%d\n", glist_getcanvas(x->x_glist), x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*10, x->x_width, wrappedname, x, i ); } else break; } ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #FF0000\n", x->x_glist, x, x->x_itemselected); // post( "playlist : moved up first=%d last=%d", x->x_firstseen, x->x_lastseen ); } --- 490,514 ---- char *wrappedname = (char *) getbytes( x->x_width );
! if ( (i-x->x_firstseen)*x->x_charheight+5 < x->x_height ) { x->x_lastseen = i; ! strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); ! wrappedname[ x->x_width/x->x_charwidth ] = '\0'; ! SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text "%s" \ ! -anchor w -font %s -tags %xENTRY%d\n", glist_getcanvas(x->x_glist), x->x_obj.te_xpix+5, ! x->x_obj.te_ypix+5+(i-x->x_firstseen)*x->x_charheight, ! x->x_fgcolor, ! x->x_secolor, x->x_width, wrappedname, + x->x_font, x, i ); } else break; } ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", ! x->x_glist, x, x->x_itemselected, x->x_secolor); // post( "playlist : moved up first=%d last=%d", x->x_firstseen, x->x_lastseen ); } *************** *** 474,480 **** { // deselect previously selected item ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #000000\n", x->x_glist, x, x->x_itemselected); ! x->x_itemselected = x->x_firstseen + (ypix-x->x_obj.te_ypix)/10; ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #FF0000\n", x->x_glist, x, x->x_itemselected); // post( "playlist : selected item : %d", x->x_itemselected ); if ( x->x_dentries && ( x->x_itemselected < x->x_nentries ) ) --- 529,537 ---- { // deselect previously selected item ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", ! x->x_glist, x, x->x_itemselected, x->x_fgcolor); ! x->x_itemselected = x->x_firstseen + (ypix-x->x_obj.te_ypix)/x->x_charheight; ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", ! x->x_glist, x, x->x_itemselected, x->x_secolor); // post( "playlist : selected item : %d", x->x_itemselected ); if ( x->x_dentries && ( x->x_itemselected < x->x_nentries ) ) *************** *** 538,543 **** t_playlist *x=(t_playlist *)z;
! sprintf(buf, "pdtk_playlist_dialog %%s %s %d %d\n", ! x->x_extension, x->x_width, x->x_height); // post("playlist_properties : %s", buf ); gfxstub_new(&x->x_obj.ob_pd, x, buf); --- 595,602 ---- t_playlist *x=(t_playlist *)z;
! sprintf(buf, "pdtk_playlist_dialog %%s %s %d %d %s %s %s %s %s\n", ! x->x_extension, x->x_width, x->x_height, ! x->x_font, x->x_bgcolor, x->x_sbcolor, ! x->x_fgcolor, x->x_secolor ); // post("playlist_properties : %s", buf ); gfxstub_new(&x->x_obj.ob_pd, x, buf); *************** *** 549,559 **** post( "playlist : error :tried to set properties on an unexisting object" ); } ! if ( argc != 3 ) { ! post( "playlist : error in the number of arguments ( %d instead of 3 )", argc ); return; } ! if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || ! argv[2].a_type != A_FLOAT ) { post( "playlist : wrong arguments" ); return; --- 608,621 ---- post( "playlist : error :tried to set properties on an unexisting object" ); } ! if ( argc != 10 ) { ! post( "playlist : error in the number of arguments ( %d instead of 10 )", argc ); return; } ! if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || ! argv[2].a_type != A_FLOAT || argv[3].a_type != A_SYMBOL || ! argv[4].a_type != A_FLOAT || argv[5].a_type != A_SYMBOL || ! argv[6].a_type != A_SYMBOL || argv[7].a_type != A_SYMBOL || ! argv[8].a_type != A_SYMBOL || argv[9].a_type != A_SYMBOL ) { post( "playlist : wrong arguments" ); return; *************** *** 562,565 **** --- 624,634 ---- x->x_width = (int)argv[1].a_w.w_float; x->x_height = (int)argv[2].a_w.w_float; + sprintf( x->x_font, "{%s %d %s}", argv[3].a_w.w_symbol->s_name, + (t_int)argv[4].a_w.w_float, argv[5].a_w.w_symbol->s_name ); + x->x_charheight = (t_int)argv[4].a_w.w_float; + strcpy( x->x_bgcolor, argv[6].a_w.w_symbol->s_name ); + strcpy( x->x_sbcolor, argv[7].a_w.w_symbol->s_name ); + strcpy( x->x_fgcolor, argv[8].a_w.w_symbol->s_name ); + strcpy( x->x_secolor, argv[9].a_w.w_symbol->s_name );
playlist_draw_erase(x, x->x_glist); *************** *** 568,626 ****
! t_playlist *playlist_new(t_symbol *extension, t_floatarg fwidth, t_floatarg fheight ) { ! int i; ! t_playlist *x; ! char *tmpcurdir; ! ! if ( !strcmp( extension->s_name, "" ) ) ! { ! error( "playlist : no extension specified" ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! }
! if ( fwidth <= 0 ) ! { ! error( "playlist : wrong width (%d)", fwidth ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! }
! if ( fheight <= 0 ) ! { ! error( "playlist : wrong height (%d)", fheight ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! }
! x = (t_playlist *)pd_new(playlist_class);
! x->x_width = fwidth; ! x->x_height = fheight; ! x->x_extension = ( char * ) getbytes( strlen( extension->s_name ) + 2 ); ! sprintf( x->x_extension, "%s", extension->s_name );
! x->x_fullpath = outlet_new(&x->x_obj, &s_symbol ); ! x->x_file = outlet_new(&x->x_obj, &s_symbol ); ! x->x_dir = outlet_new(&x->x_obj, &s_symbol );
! x->x_glist = (t_glist *) canvas_getcurrent(); ! x->x_nentries = 0; ! x->x_pnentries = 0; ! x->x_dentries = NULL;
! // get current directory full path ! x->x_curdir = ( char * ) getbytes( MAX_DIR_LENGTH ); ! if ( ( tmpcurdir = getenv( "PWD" ) ) == NULL ) ! { ! post( "playlist : could not get current directory ( where the hell are you ??? )" ); ! return NULL; ! } ! strncpy( x->x_curdir, tmpcurdir, strlen( tmpcurdir ) ); ! x->x_curdir[ strlen( tmpcurdir ) ] = '\0';
! x->x_selected = 0; ! x->x_itemselected = -1;
// post( "playlist : built extension=%s width=%d height=%d", x->x_extension, x->x_width, x->x_height ); --- 637,782 ----
! t_playlist *playlist_new(t_symbol *s, int argc, t_atom *argv ) { ! t_int i; ! t_playlist *x; ! char *tmpcurdir;
! x = (t_playlist *)pd_new(playlist_class);
! x->x_extension = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_extension, "all" ); ! x->x_width = 400; ! x->x_height = 300; ! x->x_font = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_font, "{Helvetica 10 bold}" ); ! x->x_charheight = 10; ! x->x_charwidth = (2*10)/3; ! x->x_bgcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_bgcolor, "#457782" ); ! x->x_sbcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_sbcolor, "yellow" ); ! x->x_fgcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_fgcolor, "black" ); ! x->x_secolor = ( char * ) getbytes( MAX_DIR_LENGTH ); ! sprintf( x->x_secolor, "red" );
! if ( argc >= 1 ) ! { ! if ( argv[0].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong argument (extension : 1)" ); ! return NULL; ! } ! if ( !strcmp( argv[0].a_w.w_symbol->s_name, "" ) ) ! { ! error( "playlist : no extension specified" ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! } ! strcpy( x->x_extension, argv[0].a_w.w_symbol->s_name ); ! } ! if ( argc >= 2 ) ! { ! if ( argv[1].a_type != A_FLOAT ) ! { ! error( "playlist : wrong argument (width : 2)" ); ! return NULL; ! } ! if ( (int)argv[1].a_w.w_float <= 0 ) ! { ! error( "playlist : wrong width (%d)", (t_int)(int)argv[1].a_w.w_float ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! } ! x->x_width = (int)argv[1].a_w.w_float; ! } ! if ( argc >= 3 ) ! { ! if ( argv[2].a_type != A_FLOAT ) ! { ! error( "playlist : wrong argument (height : 3)" ); ! return NULL; ! } ! if ( (int)argv[2].a_w.w_float <= 0 ) ! { ! error( "playlist : wrong height (%d)", (t_int)(int)argv[2].a_w.w_float ); ! error( "playlist : usage : playlist <extension> <width> <height>" ); ! return NULL; ! } ! x->x_height = (int)argv[2].a_w.w_float; ! } ! if ( argc >= 6 ) ! { ! if ( argv[3].a_type != A_SYMBOL || argv[4].a_type != A_FLOAT || ! argv[5].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong arguments (font : 4,5,6)" ); ! return NULL; ! } ! sprintf( x->x_font, "%s %d %s", argv[3].a_w.w_symbol->s_name, ! (t_int)argv[4].a_w.w_float, argv[5].a_w.w_symbol->s_name ); ! x->x_charheight = (t_int)argv[4].a_w.w_float; ! } ! if ( argc >= 7 ) ! { ! if ( argv[6].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong arguments (background color : 7)" ); ! return NULL; ! } ! strcpy( x->x_bgcolor, argv[6].a_w.w_symbol->s_name ); ! } ! if ( argc >= 8 ) ! { ! if ( argv[7].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong arguments (scrollbar color : 8)" ); ! return NULL; ! } ! strcpy( x->x_sbcolor, argv[7].a_w.w_symbol->s_name ); ! } ! if ( argc >= 9 ) ! { ! if ( argv[8].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong arguments (foreground color : 9)" ); ! return NULL; ! } ! strcpy( x->x_fgcolor, argv[8].a_w.w_symbol->s_name ); ! } ! if ( argc >= 10 ) ! { ! if ( argv[9].a_type != A_SYMBOL ) ! { ! error( "playlist : wrong arguments (selection color : 10)" ); ! return NULL; ! } ! strcpy( x->x_secolor, argv[9].a_w.w_symbol->s_name ); ! }
! x->x_fullpath = outlet_new(&x->x_obj, &s_symbol ); ! x->x_file = outlet_new(&x->x_obj, &s_symbol ); ! x->x_dir = outlet_new(&x->x_obj, &s_symbol );
! x->x_glist = (t_glist *) canvas_getcurrent(); ! x->x_nentries = 0; ! x->x_pnentries = 0; ! x->x_dentries = NULL;
! // get current directory full path ! x->x_curdir = ( char * ) getbytes( MAX_DIR_LENGTH ); ! if ( ( tmpcurdir = getenv( "PWD" ) ) == NULL ) ! { ! post( "playlist : could not get current directory ( where the hell are you ??? )" ); ! return NULL; ! } ! strncpy( x->x_curdir, tmpcurdir, strlen( tmpcurdir ) ); ! x->x_curdir[ strlen( tmpcurdir ) ] = '\0';
! x->x_selected = 0; ! x->x_itemselected = -1;
! x->x_sort = 1;
// post( "playlist : built extension=%s width=%d height=%d", x->x_extension, x->x_width, x->x_height ); *************** *** 634,638 **** if ( x->x_extension ) { ! freebytes( x->x_extension, strlen( x->x_extension ) ); } if ( x->x_curdir ) --- 790,794 ---- if ( x->x_extension ) { ! freebytes( x->x_extension, MAX_DIR_LENGTH ); } if ( x->x_curdir ) *************** *** 640,643 **** --- 796,819 ---- freebytes( x->x_curdir, MAX_DIR_LENGTH ); } + if ( x->x_font ) + { + freebytes( x->x_font, MAX_DIR_LENGTH ); + } + if ( x->x_bgcolor ) + { + freebytes( x->x_bgcolor, MAX_DIR_LENGTH ); + } + if ( x->x_sbcolor ) + { + freebytes( x->x_sbcolor, MAX_DIR_LENGTH ); + } + if ( x->x_fgcolor ) + { + freebytes( x->x_fgcolor, MAX_DIR_LENGTH ); + } + if ( x->x_secolor ) + { + freebytes( x->x_secolor, MAX_DIR_LENGTH ); + } }
*************** *** 661,667 **** return; } ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #000000\n", x->x_glist, x, x->x_itemselected); x->x_itemselected = iout; ! SYS_VGUI4(".x%x.c itemconfigure %xENTRY%d -fill #FF0000\n", x->x_glist, x, x->x_itemselected); playlist_output_current(x); } --- 837,844 ---- return; } ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", x->x_glist, x, x->x_itemselected, x->x_fgcolor); x->x_itemselected = iout; ! SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", ! x->x_glist, x, x->x_itemselected, x->x_secolor); playlist_output_current(x); } *************** *** 731,738 **** playlist_class = class_new(gensym("playlist"), (t_newmethod)playlist_new, (t_method)playlist_free, sizeof(t_playlist), ! CLASS_DEFAULT, A_SYMBOL, A_FLOAT, A_FLOAT, 0); ! class_addmethod(playlist_class, (t_method)playlist_seek, gensym("seek"), A_FLOAT, 0 ); ! class_addmethod(playlist_class, (t_method)playlist_location, gensym("location"), A_SYMBOL, 0 ); ! class_addmethod(playlist_class, (t_method)playlist_dialog, gensym("dialog"), A_GIMME, 0 );
playlist_widgetbehavior.w_getrectfn = playlist_getrect; --- 908,918 ---- playlist_class = class_new(gensym("playlist"), (t_newmethod)playlist_new, (t_method)playlist_free, sizeof(t_playlist), ! CLASS_DEFAULT, A_GIMME, 0); ! class_addmethod(playlist_class, (t_method)playlist_seek, gensym("seek"), A_DEFFLOAT, A_NULL ); ! class_addmethod(playlist_class, (t_method)playlist_location, gensym("location"), A_SYMBOL, A_NULL ); ! class_addmethod(playlist_class, (t_method)playlist_dialog, gensym("dialog"), A_GIMME, A_NULL ); ! class_addmethod(playlist_class, (t_method)playlist_sort, gensym("sort"), A_DEFFLOAT, A_NULL ); ! class_addmethod(playlist_class, (t_method)playlist_font, gensym("font"), A_SYMBOL, ! A_SYMBOL, A_DEFFLOAT, A_NULL );
playlist_widgetbehavior.w_getrectfn = playlist_getrect; *************** *** 743,760 **** playlist_widgetbehavior.w_visfn = playlist_vis; playlist_widgetbehavior.w_clickfn = playlist_click; ! /* ! * hans@eds.org: As of 0.37, pd does not have these last ! * two elements in t_widgetbehavoir anymore. ! * see pd/src/notes.txt: ! * savefunction and dialog into class structure ! */ ! #if PD_MINOR_VERSION < 37 || !defined(PD_MINOR_VERSION) playlist_widgetbehavior.w_propertiesfn = playlist_properties; playlist_widgetbehavior.w_savefn = playlist_save; - #else - class_setsavefn(playlist_class, &playlist_save); - class_setpropertiesfn(playlist_class, &playlist_properties); #endif
class_setwidget(playlist_class, &playlist_widgetbehavior); } --- 923,936 ---- playlist_widgetbehavior.w_visfn = playlist_vis; playlist_widgetbehavior.w_clickfn = playlist_click; ! ! #if PD_MINOR_VERSION >= 37 ! class_setpropertiesfn(playlist_class, playlist_properties); ! class_setsavefn(playlist_class, playlist_save); ! #else playlist_widgetbehavior.w_propertiesfn = playlist_properties; playlist_widgetbehavior.w_savefn = playlist_save; #endif
class_setwidget(playlist_class, &playlist_widgetbehavior); + class_sethelpsymbol(playlist_class, gensym("playlist.pd")); }
--- NEW FILE: playlist.tk2c --- // ########### playlist procedures -- ydegoyon@free.fr ######### sys_gui("proc playlist_apply {id} {\n"); // strip "." from the TK id to make a variable name suffix sys_gui("set vid [string trimleft $id .]\n"); // for each variable, make a local variable to hold its name... sys_gui("set var_graph_extension [concat graph_extension_$vid]\n"); sys_gui("global $var_graph_extension\n"); sys_gui("set var_graph_width [concat graph_width_$vid]\n"); sys_gui("global $var_graph_width\n"); sys_gui("set var_graph_height [concat graph_height$vid]\n"); sys_gui("global $var_graph_height\n"); sys_gui("set var_graph_font [concat graph_font$vid]\n"); sys_gui("global $var_graph_font\n"); sys_gui("set var_graph_bgcolor [concat graph_bgcolor$vid]\n"); sys_gui("global $var_graph_bgcolor\n"); sys_gui("set var_graph_sbcolor [concat graph_sbcolor$vid]\n"); sys_gui("global $var_graph_sbcolor\n"); sys_gui("set var_graph_fgcolor [concat graph_fgcolor$vid]\n"); sys_gui("global $var_graph_fgcolor\n"); sys_gui("set var_graph_secolor [concat graph_secolor$vid]\n"); sys_gui("global $var_graph_secolor\n"); sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_extension] [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_font] [eval concat $$var_graph_bgcolor] [eval concat $$var_graph_sbcolor] [eval concat $$var_graph_fgcolor] [eval concat $$var_graph_secolor] \;]\n"); // puts stderr $cmd sys_gui("pd $cmd\n"); sys_gui("}\n"); sys_gui("proc playlist_cancel {id} {\n"); sys_gui("set cmd [concat $id cancel \;]\n"); // puts stderr $cmd sys_gui("pd $cmd\n"); sys_gui("}\n"); sys_gui("proc playlist_ok {id} {\n"); sys_gui("playlist_apply $id\n"); sys_gui("playlist_cancel $id\n"); sys_gui("}\n"); sys_gui("proc pdtk_playlist_dialog {id extension width height font bgcolor sbcolor fgcolor secolor} {\n"); sys_gui("set vid [string trimleft $id .]\n"); sys_gui("set var_graph_extension [concat graph_extension_$vid]\n"); sys_gui("global $var_graph_extension\n"); sys_gui("set var_graph_width [concat graph_width_$vid]\n"); sys_gui("global $var_graph_width\n"); sys_gui("set var_graph_height [concat graph_height$vid]\n"); sys_gui("global $var_graph_height\n"); sys_gui("set var_graph_font [concat graph_font$vid]\n"); sys_gui("global $var_graph_font\n"); sys_gui("set var_graph_bgcolor [concat graph_bgcolor$vid]\n"); sys_gui("global $var_graph_bgcolor\n"); sys_gui("set var_graph_sbcolor [concat graph_sbcolor$vid]\n"); sys_gui("global $var_graph_sbcolor\n"); sys_gui("set var_graph_fgcolor [concat graph_fgcolor$vid]\n"); sys_gui("global $var_graph_fgcolor\n"); sys_gui("set var_graph_secolor [concat graph_secolor$vid]\n"); sys_gui("global $var_graph_secolor\n"); sys_gui("set $var_graph_extension $extension\n"); sys_gui("set $var_graph_width $width\n"); sys_gui("set $var_graph_height $height\n"); sys_gui("set $var_graph_font $font\n"); sys_gui("set $var_graph_bgcolor $bgcolor\n"); sys_gui("set $var_graph_sbcolor $sbcolor\n"); sys_gui("set $var_graph_fgcolor $fgcolor\n"); sys_gui("set $var_graph_secolor $secolor\n"); sys_gui("toplevel $id\n"); sys_gui("wm title $id {playlist}\n"); sys_gui("wm protocol $id WM_DELETE_WINDOW [concat playlist_cancel $id]\n"); sys_gui("label $id.label -text {PLAYLIST PROPERTIES}\n"); sys_gui("pack $id.label -side top\n"); sys_gui("frame $id.buttonframe\n"); sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); sys_gui("button $id.buttonframe.cancel -text {Cancel} -command "playlist_cancel $id"\n"); sys_gui("button $id.buttonframe.apply -text {Apply} -command "playlist_apply $id"\n"); sys_gui("button $id.buttonframe.ok -text {OK} -command "playlist_ok $id"\n"); sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); sys_gui("frame $id.1rangef\n"); sys_gui("pack $id.1rangef -side top\n"); sys_gui("label $id.1rangef.lextension -text "Files Extension :"\n"); sys_gui("entry $id.1rangef.extension -textvariable $var_graph_extension -width 7\n"); sys_gui("pack $id.1rangef.lextension $id.1rangef.extension -side left\n"); sys_gui("frame $id.2rangef\n"); sys_gui("pack $id.2rangef -side top\n"); sys_gui("label $id.2rangef.lwidth -text "Width :"\n"); sys_gui("entry $id.2rangef.width -textvariable $var_graph_width -width 7\n"); sys_gui("pack $id.2rangef.lwidth $id.2rangef.width -side left\n"); sys_gui("frame $id.3rangef\n"); sys_gui("pack $id.3rangef -side top\n"); sys_gui("label $id.3rangef.lheight -text "Height :"\n"); sys_gui("entry $id.3rangef.height -textvariable $var_graph_height -width 7\n"); sys_gui("pack $id.3rangef.lheight $id.3rangef.height -side left\n"); sys_gui("frame $id.3_5rangef\n"); sys_gui("pack $id.3_5rangef -side top\n"); sys_gui("label $id.3_5rangef.lfont -text "Font :"\n"); sys_gui("entry $id.3_5rangef.font -textvariable $var_graph_font -width 30\n"); sys_gui("pack $id.3_5rangef.lfont $id.3_5rangef.font -side left\n"); sys_gui("frame $id.4rangef\n"); sys_gui("pack $id.4rangef -side top\n"); sys_gui("label $id.4rangef.lbgcolor -text "Background Color :"\n"); sys_gui("entry $id.4rangef.bgcolor -textvariable $var_graph_bgcolor -width 7\n"); sys_gui("pack $id.4rangef.lbgcolor $id.4rangef.bgcolor -side left\n"); sys_gui("frame $id.5rangef\n"); sys_gui("pack $id.5rangef -side top\n"); sys_gui("label $id.5rangef.lsbcolor -text "Scroll Bar Color :"\n"); sys_gui("entry $id.5rangef.sbcolor -textvariable $var_graph_sbcolor -width 7\n"); sys_gui("pack $id.5rangef.lsbcolor $id.5rangef.sbcolor -side left\n"); sys_gui("frame $id.6rangef\n"); sys_gui("pack $id.6rangef -side top\n"); sys_gui("label $id.6rangef.lfgcolor -text "Foreground Color :"\n"); sys_gui("entry $id.6rangef.fgcolor -textvariable $var_graph_fgcolor -width 7\n"); sys_gui("pack $id.6rangef.lfgcolor $id.6rangef.fgcolor -side left\n"); sys_gui("frame $id.7rangef\n"); sys_gui("pack $id.7rangef -side top\n"); sys_gui("label $id.7rangef.lsecolor -text "Selection Color :"\n"); sys_gui("entry $id.7rangef.secolor -textvariable $var_graph_secolor -width 7\n"); sys_gui("pack $id.7rangef.lsecolor $id.7rangef.secolor -side left\n"); sys_gui("bind $id.1rangef.extension <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.2rangef.width <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.3rangef.height <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.3_5rangef.font <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.4rangef.bgcolor <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.5rangef.sbcolor <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.6rangef.fgcolor <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("bind $id.7rangef.secolor <KeyPress-Return> [concat playlist_ok $id]\n"); sys_gui("}\n"); // ########### playlist procedures END -- ydegoyon@free.fr #########
Index: Makefile =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/playlist/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 16 Aug 2003 08:28:04 -0000 1.1 --- Makefile 30 Mar 2004 03:59:41 -0000 1.2 *************** *** 68,72 ****
.c.pd_linux: ! ../tk2c.bash < $*.tk > $*.tk2c gcc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm --- 68,72 ----
.c.pd_linux: ! ./tk2c.bash < $*.tk > $*.tk2c gcc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
--- NEW FILE: tk2c.bash --- #!/bin/bash
#set -x
while read line do for word in $line do if [ "X"$word != "X"${word##} ] then echo // ${line##} break else line=${line//'/\'} #useless, slashes never gets in line=${line//\/\\} #this one's dirty, i know line=${line//;/\\;} line=${line//"/\"} echo 'sys_gui("'$line'\n");' break fi done done