Skip to content

Commit

Permalink
Surge UserInteractions stubbed with Zenity (surge-synthesizer#918)
Browse files Browse the repository at this point in the history
Surge UserInteractions on Linux should really use
the vst event loop and vstgui and be hand written because
otherwise you have to popen zenity which can cause audio
pauses and pops.

But audio pauses and pops on anciliary actions are better than
nothing, so stick in a crudy zenity implementation which is
a start, and someone inspired to remove it at least has a spec
in the future.

Addresses surge-synthesizer#562
Closes surge-synthesizer#637 and surge-synthesizer#917
  • Loading branch information
baconpaul authored Jun 17, 2019
1 parent ba855b9 commit 42b70bb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/Developer Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ sudo apt-get install ajmidid
The run jac and ajmidid in separate terminals

```
jack -d alsa -X alsa_midi
ajmidid -e
jackd -d alsa -X alsa_midi
a2jmidid -e
```

Now start surge with carla-single
Expand Down
18 changes: 17 additions & 1 deletion src/common/gui/PopupEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,27 @@ void spawn_miniedit_text(char* c, int maxchars)
#elif LINUX

#include "UserInteractions.h"
#include <string.h>

void spawn_miniedit_text(char* c, int maxchars)
{
// FIXME: Implement text edit popup on Linux.
Surge::UserInteractions::promptError( "miniedit_text is not implemented on linux", "Unimplemented Feature" );
char cmd[1024];
snprintf(cmd, 1024, "zenity --entry --entry-text \"%s\"", c );
FILE *z = popen( cmd, "r" );
if( ! z )
{
return;
}
char buffer[ 1024 ];
if (!fscanf(z, "%1024s", buffer))
{
return;
}
pclose(z);

strncpy( c, buffer, maxchars);

}

#endif
40 changes: 38 additions & 2 deletions src/linux/UserInteractionsLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
#include <iomanip>
#include <sys/types.h>
#include <unistd.h>
#include <thread>

/*
** In June 2019, @baconpaul chose to implement these with an attempt
** to fork/exec a zenity. (He also did this for mini edit). This is not
** ideal. Properly you would somehow asynchronously interact with
** vstgui and so on, which @jjs started. But we kinda gotta do something.
**
** If you want to come along and rip out these zenity calls and replace them
** with vstgui, please do so! This is purely tactical stuff to get us
** not silently failing.
*/
namespace Surge
{

Expand All @@ -13,6 +24,17 @@ namespace UserInteractions
void promptError(const std::string &message, const std::string &title,
SurgeGUIEditor *guiEditor)
{
if (vfork()==0)
{
if (execlp("zenity", "zenity",
"--error",
"--text", message.c_str(),
"--title", title.c_str(),
(char*)nullptr) < 0)
{
exit(0);
}
}
std::cerr << "Surge Error\n"
<< title << "\n"
<< message << "\n" << std::flush;
Expand Down Expand Up @@ -55,8 +77,22 @@ void promptFileOpenDialog(const std::string& initialDirectory,
std::function<void(std::string)> callbackOnOpen,
SurgeGUIEditor* guiEditor)
{
UserInteractions::promptError("OpenFileDialog is unimplemented in this version of Surge. Sorry!",
"Unimplemented Function", guiEditor);
/*
** This is a blocking model which will cause us problems I am sure
*/
FILE *z = popen( "zenity --file-selection", "r" );
if( ! z )
{
return;
}
char buffer[ 1024 ];
if (!fscanf(z, "%1024s", buffer))
{
return;
}
pclose(z);

callbackOnOpen(buffer);
}
};

Expand Down

0 comments on commit 42b70bb

Please sign in to comment.