Commit b793788c authored by Eddie Kohler's avatar Eddie Kohler

Clicky: The "Run" button runs the current configuration buffer.

Signed-off-by: 's avatarEddie Kohler <ekohler@gmail.com>
parent aa57fe35
......@@ -318,9 +318,11 @@ void crouter::run(ErrorHandler *errh)
int pos = 0;
while (pos != _conf.length()) {
ssize_t r = write(configpipe[1], _conf.begin() + pos, _conf.length() - pos);
if (r == 0 || (r == -1 && errno != EAGAIN && errno != EINTR))
if (r == 0 || (r == -1 && errno != EAGAIN && errno != EINTR)) {
if (r == -1)
errh->message("%s while writing configuration", strerror(errno));
break;
else if (r != -1)
} else if (r != -1)
pos += r;
}
if (pos != _conf.length()) {
......
......@@ -103,6 +103,7 @@ static void on_view_diagram_toggled(GtkCheckMenuItem *check, gpointer user_data)
static void on_toolbar_run_activate(GtkToolButton *, gpointer user_data)
{
wmain *rw = reinterpret_cast<wmain *>(user_data);
rw->buffer_to_config();
rw->run(ErrorHandler::default_handler());
}
......@@ -423,6 +424,16 @@ void wmain::on_open_kernel()
}
}
void wmain::buffer_to_config()
{
GtkTextIter i1, i2;
gtk_text_buffer_get_start_iter(_config_buffer, &i1);
gtk_text_buffer_get_end_iter(_config_buffer, &i2);
char *data = gtk_text_buffer_get_text(_config_buffer, &i1, &i2, FALSE);
set_config(String(data), true);
g_free(data);
}
void wmain::on_save_file(bool save_as)
{
if (save_as || !_savefile) {
......@@ -455,21 +466,17 @@ void wmain::on_save_file(bool save_as)
}
}
GtkTextIter i1, i2;
gtk_text_buffer_get_start_iter(_config_buffer, &i1);
gtk_text_buffer_get_end_iter(_config_buffer, &i2);
char *data = gtk_text_buffer_get_text(_config_buffer, &i1, &i2, FALSE);
buffer_to_config();
GError *err = NULL;
if (!g_file_set_contents(_savefile.c_str(), data, -1, &err)) {
String conf = config();
if (!g_file_set_contents(_savefile.c_str(), conf.data(), conf.length(), &err)) {
GatherErrorHandler gerrh(true);
gerrh.error("Save error: %s", err->message);
gerrh.run_dialog(GTK_WINDOW(_window));
g_error_free(err);
} else
set_save_file(_savefile, true);
g_free(data);
}
void wmain::on_export_diagram()
......
......@@ -78,6 +78,7 @@ class wmain : public crouter { public:
void on_driver_changed();
void config_set_driver(int driver);
void config_check(bool install);
void buffer_to_config();
const String &element_showing() const {
return _eview_name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment