+ if (file == "") return FALSE;
+
+ FILE *fp;
+
+ if (!(fp = fopen ((char*) (const char*) file, "w")))
+ {
+ return FALSE;
+ }
+ else
+ {
+ char *text = NULL;
+ gint len = 0;
+
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ len = gtk_text_get_length( GTK_TEXT(m_text) );
+ text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
+ }
+ else
+ {
+ text = gtk_entry_get_text( GTK_ENTRY(m_text) );
+ }
+
+ if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
+ {
+ // Did not write whole file
+ }
+
+ // Make sure newline terminates the file
+ if (text[len - 1] != '\n')
+ fputc ('\n', fp);
+
+ fclose (fp);
+
+ if (m_windowStyle & wxTE_MULTILINE) g_free( text );
+
+ m_modified = FALSE;
+ return TRUE;
+ }
+
+ return TRUE;