summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fluid/code.cxx9
-rw-r--r--fluid/fluid.cxx29
2 files changed, 30 insertions, 8 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx
index 5cf462236..671cbb1a1 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -370,6 +370,15 @@ static Fl_Type* write_code(Fl_Type* p) {
extern const char* header_file_name;
extern Fl_Class_Type *current_class;
+
+/** \brief Write the source and header files for the current design.
+
+ If the files already exist, they will be overwritten.
+
+ \param[in] s filename of source code file
+ \param[in] t filename of the header file
+ \return 0 if the operation failed, 1 if it was successful
+ */
int write_code(const char *s, const char *t) {
const char *filemode = "w";
if (write_sourceview)
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 49944e5ba..73e9027ff 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -684,7 +684,22 @@ const char* i18n_file = "";
const char* i18n_set = "";
char i18n_program[FL_PATH_MAX] = "";
-void write_cb(Fl_Widget *, void *) {
+/** \brief Generate the C++ source and header filenames and write those files.
+
+ This function creates the source filename by setting the file
+ extension to \c code_file_name and a header filename
+ with the extension \c code_file_name which are both
+ settable by the user.
+
+ In batch_mode, the function will either be silent, or write an error message
+ to \c stderr and exit with exit code 1.
+
+ In interactive mode, we will pop up an error message, or, if the user
+ hasn't isabled that, pop up a confirmation message.
+
+ \return 1 if the operation failed, 0 if it succeeded
+ */
+int write_code_files() {
if (!filename) {
save_cb(0,0);
if (!filename) return;
@@ -721,6 +736,10 @@ void write_cb(Fl_Widget *, void *) {
}
}
+void write_cb(Fl_Widget *, void *) {
+ write_code_files();
+}
+
void write_strings_cb(Fl_Widget *, void *) {
static const char *exts[] = { ".txt", ".po", ".msg" };
if (!filename) {
@@ -1460,14 +1479,10 @@ static bool prepare_shell_command(const char * &command) { // common pre-shell
save_cb(0, 0);
}
if (shell_writecode_button->value()) {
- batch_mode = 1;
- write_cb(0, 0);
- batch_mode = 0;
+ write_code_files();
}
if (shell_writemsgs_button->value()) {
- batch_mode = 1;
write_strings_cb(0, 0);
- batch_mode = 0;
}
return true;
}
@@ -1551,8 +1566,6 @@ void set_filename(const char *c) {
// generated for the last selected item in the header and the source
// file.
//
-// Can we patent this? ;-) - Matt, mm@matthiasm.com
-//
//
// Update the header and source code highlighting depending on the