From 1dbea939c15ba5bf16484216950f7bd53cd47584 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 12 Nov 2012 07:30:28 +0100 Subject: allow munged macros to quit and echo messages on stdout/stderr * makes it possible to write standalone scripts * message echoing is only a preliminary way of stdio --- main.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 2a06491..e2f1df6 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -42,12 +43,25 @@ message_display(GtkMessageType type, const gchar *fmt, ...) va_list ap; gchar buf[255]; - gtk_info_bar_set_message_type(GTK_INFO_BAR(info_widget), type); - va_start(ap, fmt); g_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); + switch (type) { + case GTK_MESSAGE_ERROR: + g_fprintf(stderr, "Error: %s\n", buf); + break; + case GTK_MESSAGE_WARNING: + g_fprintf(stderr, "Warning: %s\n", buf); + break; + case GTK_MESSAGE_INFO: + g_printf("Info: %s\n", buf); + break; + default: + g_printf("%s\n", buf); + } + + gtk_info_bar_set_message_type(GTK_INFO_BAR(info_widget), type); gtk_label_set_text(GTK_LABEL(message_widget), buf); } @@ -210,6 +224,11 @@ main(int argc, char **argv) if (g_file_test(mung_file, G_FILE_TEST_IS_REGULAR)) { if (!file_execute(mung_file)) exit(EXIT_FAILURE); + /* FIXME: make quit immediate in commandline mode (non-UNDO)? */ + if (quit_requested) { + /* FIXME */ + exit(EXIT_SUCCESS); + } } g_free(mung_file); -- cgit v1.2.3