diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 7190a597eec1cfd5bf70b7eba35869dbd1751b6b..e64ede155b2f581432131ac28c93f8a5b2f5273f 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -4733,7 +4733,7 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce) int force = fforce; t_glist *g; if (x->gl_owner && (force == 0 || force == 1)) { - fprintf(stderr," invis\n"); + //fprintf(stderr," invis\n"); canvas_vis(x, 0); /* if subpatch, just invis it */ } else if (force == 0) diff --git a/pd/src/pd.tk b/pd/src/pd.tk index 609fdf6d2a707add0fcdcde2cc99c5c828d70f2b..bdd2474cb17edb3dc17deb4308df843ed79bdc7a 100644 --- a/pd/src/pd.tk +++ b/pd/src/pd.tk @@ -24,6 +24,10 @@ fconfigure stderr -encoding utf-8 fconfigure stdout -encoding utf-8 ##--/moo +set appname [tk appname] +tk appname $appname-startup +#puts stderr "APPNAME [tk appname]" + if { [info tclversion] >= 8.5 } { # EDIT THIS PART TO CUSTOMIZE LINUX THEME @@ -8854,3 +8858,30 @@ proc pdtk_gettip { w item xletno name helpname dir } { pdtk_tip $w 0 1 $msg } +# ---------------- allow for unique instance --------------------- + +proc pdtk_open_files_via_unique {filenames} { + #puts stderr "pdtk_open_files_via_unique $filenames" + if { $filenames != 0 } { + foreach file $filenames { + #puts stderr "open_file $file" + open_file $file + } + } +} + +proc pdtk_check_unique {unique filenames} { + #puts stderr "pdtk_check_unique $unique $filenames" + global appname + if { $unique == 0 } { + #puts stderr "send pd-l2ork pdtk_open_files_via_unique $filenames" + set outcome [catch {send pd-l2ork pdtk_open_files_via_unique $filenames}] + #puts stderr "outcome = $outcome" + if { $outcome == 0 } { + menu_really_quit + exit + } + } + tk appname $appname + #puts stderr "this is unique instance [tk appname]" +} \ No newline at end of file diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 30da6382496359eb98ce92e27257c43b4fab1d0b..4a00c5a912d7f88da06c91c5de9e9b99c4a70efd 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -50,6 +50,7 @@ int sys_guisetportnumber; /* if started from the GUI, this is the port # */ int sys_nosleep = 0; /* skip all "sleep" calls and spin instead */ int sys_console = 0; /* default settings for the console is off */ int sys_k12_mode = 0; /* by default k12 mode is off */ +int sys_unique = 0; /* by default off, prevents multiple instances of pd-l2ork */ char *sys_guicmd; t_symbol *sys_libdir; @@ -247,7 +248,7 @@ static void pd_makeversion(void) //snprintf(foo, sizeof(foo), "Pd-l2ork version %d.%d-%d%s\n", PD_MAJOR_VERSION, // PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION); - snprintf(foo, sizeof(foo), "Pd-l2ork version %s\n", PD_TEST_VERSION); + snprintf(foo, sizeof(foo), "Pd-L2Ork version %s\n", PD_TEST_VERSION); pd_version = strdup(foo); } @@ -258,8 +259,9 @@ int sys_main(int argc, char **argv) int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; + char * filenames; #ifdef PD_DEBUG - fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); + fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n"); #endif pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ @@ -283,6 +285,30 @@ int sys_main(int argc, char **argv) return (0); if (sys_startgui(sys_guidir->s_name)) /* start the gui */ return(1); + /* check if we are unique, otherwise, just focus existing + instance, and if necessary open file inside it */\ + if (sys_openlist) { + // let's create one continuous string from all files + int length = 0; + t_namelist *nl; + for (nl = sys_openlist; nl; nl = nl->nl_next) + length = length + strlen(nl->nl_string) + 1; + if((filenames = malloc(length)) != NULL) { + filenames[0] = '\0'; // ensures the memory is an empty string + if (sys_openlist) { + for (nl = sys_openlist; nl; nl = nl->nl_next) { + strcat(filenames,nl->nl_string); + if (nl->nl_next) + strcat(filenames," "); + } + } + //fprintf(stderr,"final list: <%s>\n", filenames); + } else { + error("filelist malloc failed!\n"); + return(1); + } + } + sys_vgui("pdtk_check_unique %d %s\n", sys_unique, (filenames ? filenames : "0")); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); @@ -308,8 +334,8 @@ int sys_main(int argc, char **argv) } static char *(usagemessage[]) = { -"usage: pd [-flags] [file]...\n", -"\naudio configuration flags:\n", +"Usage: pd-l2ork [-flags <value>] [file1 file2 ... filen]\n", +"\nAudio configuration flags:\n", "-r <n> -- specify sample rate\n", "-audioindev ... -- audio in devices; e.g., \"1,3\" for first and third\n", "-audiooutdev ... -- audio out devices (same)\n", @@ -350,7 +376,7 @@ static char *(usagemessage[]) = { #ifdef USEAPI_MMIO "-mmio -- use MMIO audio API (default for Windows)\n", #endif -" (default audio API for this platform: ", API_DEFSTRING, ")\n\n", +" (default audio API for this platform: ", API_DEFSTRING, ")\n", "\nMIDI configuration flags:\n", "-midiindev ... -- midi in device list; e.g., \"1,3\" for first and third\n", @@ -364,7 +390,7 @@ static char *(usagemessage[]) = { #endif -"\nother flags:\n", +"\nOther flags:\n", "-path <path> -- add to file search path\n", "-nostdpath -- don't search standard (\"extra\") directory\n", "-stdpath -- search standard directory (true by default)\n", @@ -395,6 +421,8 @@ static char *(usagemessage[]) = { "-batch -- run off-line as a batch process\n", "-autopatch -- enable auto-patching new from selected objects\n", "-k12 -- enable K-12 education mode (requires L2Ork K12 lib)\n", +"-unique -- enable multiple instances (disabled by default)\n", +"\n", }; static void sys_parsedevlist(int *np, int *vecp, int max, char *str) @@ -788,6 +816,12 @@ int sys_argparse(int argc, char **argv) sys_k12_mode = 1; argc--; argv++; } + else if (!strcmp(*argv, "-unique")) + { + sys_unique = 1; + argc -= 1; + argv += 1; + } else if (!strcmp(*argv, "-guiport") && argc > 1 && sscanf(argv[1], "%d", &sys_guisetportnumber) >= 1) { diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h index d77668a02d02af44a5e92f64fd118f1766e1220f..565af95f5994311906f6cab6468beaba21bcfd80 100644 --- a/pd/src/s_stuff.h +++ b/pd/src/s_stuff.h @@ -199,8 +199,8 @@ void sys_setvirtualalarm( void); #define API_SGI 6 #ifdef __linux__ -#define API_DEFAULT API_OSS -#define API_DEFSTRING "OSS" +#define API_DEFAULT API_ALSA +#define API_DEFSTRING "ALSA" #endif #ifdef MSW #define API_DEFAULT API_MMIO