From 4bb1cfb8a38250713210e1fde2e4d944e76e4712 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 6 Jul 2008 10:55:34 +0200 Subject: add print command dialog --- NEWS | 2 ++ src/flpsed.cxx | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0cdf1be..93a120a 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ flpsed ChangeLog ================= +flpsed-0.5.1 + - Add print command dialog. flpsed-0.5.0 - fix scroll drawing problem. diff --git a/src/flpsed.cxx b/src/flpsed.cxx index ce2f3e6..850d270 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -217,11 +217,19 @@ void print_cb() { char tmpname[256]; char buf[256]; int tmp_fd; + char *prefCommand; + const char *printCommand; + Fl_Preferences prefs(Fl_Preferences::USER, + "Johannes.HofmannATgmx.de", "flpsed"); - int r = fl_choice("Print file?", "Cancel", "Print", NULL); - if (r != 1) { + prefs.get("printCommand", prefCommand, "lpr"); + + printCommand = fl_input("Print Command", prefCommand); + if (!printCommand || printCommand[0] == '\0') return; - } + + if (strcmp(printCommand, prefCommand)) + prefs.set("printCommand", printCommand); strncpy(tmpname, "/tmp/PSEditWidgetXXXXXX", 256); tmp_fd = mkstemp(tmpname); @@ -231,7 +239,7 @@ void print_cb() { if (psed_p->save(tmpname) != 0) { fprintf(stderr, "Failed to print file\n"); } else { - snprintf(buf, 256, "lpr %s", tmpname); + snprintf(buf, 256, "%s %s", printCommand, tmpname); system(buf); } unlink(tmpname); -- cgit v1.2.3