149 |
|
|
150 |
note_saveable (); |
note_saveable (); |
151 |
|
|
152 |
print_msg("File has been modified..."); |
print_msg(_("File has been modified.")); |
153 |
#ifdef DEBUG_FCN |
#ifdef DEBUG_FCN |
154 |
g_print(__FILE__": %s(): End\n", __func__); |
g_print(__FILE__": %s(): End\n", __func__); |
155 |
#endif |
#endif |
169 |
gtk_text_view_set_editable (GTK_TEXT_VIEW(FPROPS(CurrentPage, Text)), FALSE); |
gtk_text_view_set_editable (GTK_TEXT_VIEW(FPROPS(CurrentPage, Text)), FALSE); |
170 |
FPROPS(CurrentPage, ReadOnly) = 1; |
FPROPS(CurrentPage, ReadOnly) = 1; |
171 |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
172 |
print_msg ("Readonly mode activated"); |
print_msg (_("Read-only mode activated")); |
173 |
} |
} |
174 |
else if (FPROPS(CurrentPage, ReadOnly) == 1) |
else if (FPROPS(CurrentPage, ReadOnly) == 1) |
175 |
{ |
{ |
176 |
gtk_text_view_set_editable (GTK_TEXT_VIEW(FPROPS(CurrentPage, Text)), TRUE); |
gtk_text_view_set_editable (GTK_TEXT_VIEW(FPROPS(CurrentPage, Text)), TRUE); |
177 |
FPROPS(CurrentPage, ReadOnly) = 0; |
FPROPS(CurrentPage, ReadOnly) = 0; |
178 |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
179 |
print_msg ("Readonly mode deactivated"); |
print_msg (_("Read-only mode deactivated")); |
180 |
} |
} |
181 |
else print_msg (g_strconcat ("Readonly mode cannot be toggled: \"", |
else print_msg (g_strdup_printf(_("Readonly mode cannot be toggled - \"%s\" is write protected"), FPROPS(CurrentPage, BaseName))); |
|
FPROPS(CurrentPage, BaseName), |
|
|
"\" is write protected", NULL)); |
|
182 |
} |
} |
183 |
|
|
184 |
|
|
379 |
|
|
380 |
if (stat (FileName, &Stats) == -1) |
if (stat (FileName, &Stats) == -1) |
381 |
{ |
{ |
382 |
print_msg ("This file doesn't exist anymore..."); |
print_msg (_("This file does not exist anymore.")); |
383 |
return; |
return; |
384 |
} |
} |
385 |
else |
else |
425 |
const gchar *file; |
const gchar *file; |
426 |
gboolean rv = TRUE; |
gboolean rv = TRUE; |
427 |
|
|
428 |
Title = g_strconcat("Save \"", FPROPS(gtk_notebook_get_current_page |
Title = g_strdup_printf(_("Save \"%s\" as..."), |
429 |
(GTK_NOTEBOOK(MainNotebook)), |
FPROPS(gtk_notebook_get_current_page(GTK_NOTEBOOK(MainNotebook)), BaseName)); |
|
BaseName), |
|
|
"\" As...", NULL); |
|
430 |
FileSelector = gtk_file_selection_new (Title); |
FileSelector = gtk_file_selection_new (Title); |
431 |
Directory = DIRECTORY; |
Directory = DIRECTORY; |
432 |
gtk_file_selection_set_filename (GTK_FILE_SELECTION(FileSelector), |
gtk_file_selection_set_filename (GTK_FILE_SELECTION(FileSelector), |
463 |
gint i; |
gint i; |
464 |
gboolean rv = TRUE; |
gboolean rv = TRUE; |
465 |
|
|
466 |
FileSelector = gtk_file_selection_new ("Open Files..."); |
FileSelector = gtk_file_selection_new (_("Open file(s)...")); |
467 |
gtk_file_selection_set_filename (GTK_FILE_SELECTION(FileSelector), |
gtk_file_selection_set_filename (GTK_FILE_SELECTION(FileSelector), |
468 |
DIRECTORY); |
DIRECTORY); |
469 |
gtk_window_set_modal (GTK_WINDOW(FileSelector), TRUE); |
gtk_window_set_modal (GTK_WINDOW(FileSelector), TRUE); |
523 |
refresh_editor(FPROPS(CurrentPage, Text), SYHI_AUTODETECT); |
refresh_editor(FPROPS(CurrentPage, Text), SYHI_AUTODETECT); |
524 |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
set_label (GTK_NOTEBOOK(MainNotebook), CurrentPage); |
525 |
set_title (CurrentPage); |
set_title (CurrentPage); |
526 |
print_msg (g_strconcat ("File \"", FPROPS(CurrentPage, BaseName), |
print_msg (g_strdup_printf (_("File \"%s\" saved."), FPROPS(CurrentPage, BaseName))); |
|
"\" saved...", NULL)); |
|
527 |
FPROPS(CurrentPage, LastSave) = time (NULL); |
FPROPS(CurrentPage, LastSave) = time (NULL); |
528 |
gtk_text_buffer_set_modified (FPROPS(CurrentPage, Buffer), FALSE); |
gtk_text_buffer_set_modified (FPROPS(CurrentPage, Buffer), FALSE); |
529 |
} |
} |
530 |
else |
else |
531 |
{ |
{ |
532 |
print_msg (g_strconcat ("\"", FPROPS(CurrentPage, BaseName), |
print_msg (g_strdup_printf (_("Unable to save - \"%s\" is write-protected."), FPROPS(CurrentPage, BaseName))); |
|
"\" cannot be saved: \"", |
|
|
str_get_last_part (FileName, PATH_SEP, TRUE), |
|
|
"\" is write protected", NULL)); |
|
533 |
} |
} |
534 |
} |
} |
535 |
|
|
555 |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), filename); |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), filename); |
556 |
open_file_in_editor(GTK_WIDGET(FPROPS(OpenedFilesCnt - 1, Text)), filename, OpenedFilesCnt - 1); |
open_file_in_editor(GTK_WIDGET(FPROPS(OpenedFilesCnt - 1, Text)), filename, OpenedFilesCnt - 1); |
557 |
if (FPROPS(OpenedFilesCnt - 1, ReadOnly)) |
if (FPROPS(OpenedFilesCnt - 1, ReadOnly)) |
558 |
print_msg (g_strconcat ("File \"", FPROPS(OpenedFilesCnt - 1, BaseName), |
print_msg (g_strdup_printf (_("Opened file \"%s\" read-only."), FPROPS(OpenedFilesCnt - 1, BaseName))); |
|
"\" opened in Readonly mode...", NULL)); |
|
559 |
else |
else |
560 |
print_msg (g_strconcat ("File \"", FPROPS(OpenedFilesCnt - 1, BaseName), |
print_msg (g_strdup_printf (_("Opened file \"%s\"."), FPROPS(OpenedFilesCnt - 1, BaseName))); |
|
"\" opened...", NULL)); |
|
561 |
|
|
562 |
END_FCN |
END_FCN |
563 |
} |
} |
565 |
|
|
566 |
void new_file (void) |
void new_file (void) |
567 |
{ |
{ |
|
print_msg("New file..."); |
|
568 |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), NULL); |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), NULL); |
569 |
open_file_in_editor(GTK_WIDGET(FPROPS(OpenedFilesCnt - 1, Text)), NULL, OpenedFilesCnt - 1); |
open_file_in_editor(GTK_WIDGET(FPROPS(OpenedFilesCnt - 1, Text)), NULL, OpenedFilesCnt - 1); |
570 |
gtk_text_buffer_set_modified (FPROPS(OpenedFilesCnt - 1, Buffer), TRUE); |
gtk_text_buffer_set_modified (FPROPS(OpenedFilesCnt - 1, Buffer), TRUE); |
591 |
CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook)); |
CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook)); |
592 |
if (!gtk_text_buffer_get_modified (FPROPS(CurrentPage, Buffer))) |
if (!gtk_text_buffer_get_modified (FPROPS(CurrentPage, Buffer))) |
593 |
{ |
{ |
594 |
print_msg ("File needn't be saved"); |
print_msg (_("File does not need to be saved")); |
595 |
return; |
return; |
596 |
} |
} |
597 |
if (FPROPS(CurrentPage, ReadOnly)) |
if (FPROPS(CurrentPage, ReadOnly)) |
598 |
save_file_as(); |
save_file_as(); |
599 |
else if ((stat (FPROPS(CurrentPage, Name), &FPROPS(CurrentPage, Stats)) == -1) |
else if ((stat (FPROPS(CurrentPage, Name), &FPROPS(CurrentPage, Stats)) == -1) |
600 |
&& (!strncmp (FPROPS(CurrentPage, Name), "Untitled ", 9))) |
&& (!strncmp (FPROPS(CurrentPage, Name), _("Untitled "), 9))) |
601 |
save_file_as(); |
save_file_as(); |
602 |
else |
else |
603 |
{ |
{ |
623 |
fwrite (Buffer, length, 1, File); |
fwrite (Buffer, length, 1, File); |
624 |
g_free (Buffer); |
g_free (Buffer); |
625 |
fclose (File); |
fclose (File); |
626 |
print_msg (g_strconcat ("File \"", FPROPS(CurrentPage, Name), |
print_msg (g_strdup_printf (_("File \"%s\" saved."), FPROPS(CurrentPage, Name))); |
|
"\" saved...", NULL)); |
|
627 |
FPROPS(CurrentPage, LastSave) = time (NULL); |
FPROPS(CurrentPage, LastSave) = time (NULL); |
628 |
gtk_text_buffer_set_modified (FPROPS(CurrentPage, Buffer), FALSE); |
gtk_text_buffer_set_modified (FPROPS(CurrentPage, Buffer), FALSE); |
629 |
} |
} |
630 |
else |
else |
631 |
{ |
{ |
632 |
print_msg (g_strconcat ("\"", FPROPS(CurrentPage, BaseName), |
print_msg (g_strdup_printf (_("Unable to save - \"%s\" is write-protected."), FPROPS(CurrentPage, BaseName))); |
|
"\" cannot be saved: it is write protected", |
|
|
NULL)); |
|
633 |
save_file_as(); |
save_file_as(); |
634 |
} |
} |
635 |
} |
} |
680 |
else |
else |
681 |
time_str = g_strdup_printf ("%i minute%s", elapsed_time / 60, ((elapsed_time / 60) == 1) ? "" : "s"); |
time_str = g_strdup_printf ("%i minute%s", elapsed_time / 60, ((elapsed_time / 60) == 1) ? "" : "s"); |
682 |
|
|
683 |
primary = g_strdup_printf ("Save changes to document \"%s\" before closing?", |
primary = g_strdup_printf (_("Save changes to \"%s\"?"), |
684 |
FPROPS(CurrentPage, BaseName)); |
FPROPS(CurrentPage, BaseName)); |
685 |
secondary = g_strdup_printf ("If you close without saving, changes " |
secondary = g_strdup_printf (_("If you close without saving, changes from the past %s will be discarded."), time_str); |
|
"from the past %s will be discarded.", time_str); |
|
686 |
dialog = alert_new (GTK_WINDOW(MainWindow), GTK_STOCK_DIALOG_WARNING, |
dialog = alert_new (GTK_WINDOW(MainWindow), GTK_STOCK_DIALOG_WARNING, |
687 |
primary, secondary); |
primary, secondary); |
688 |
gtk_dialog_add_buttons (GTK_DIALOG (dialog), "_Close without saving", 1, |
gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Close without saving"), 1, |
689 |
GTK_STOCK_CANCEL, 2, GTK_STOCK_SAVE, 3, NULL); |
GTK_STOCK_CANCEL, 2, GTK_STOCK_SAVE, 3, NULL); |
690 |
gtk_dialog_set_default_response (GTK_DIALOG (dialog), 3); |
gtk_dialog_set_default_response (GTK_DIALOG (dialog), 3); |
691 |
response = gtk_dialog_run (GTK_DIALOG (dialog)); |
response = gtk_dialog_run (GTK_DIALOG (dialog)); |
725 |
&FPROPS(CurrentPage, Text)); |
&FPROPS(CurrentPage, Text)); |
726 |
g_array_remove_index (FileProperties, CurrentPage); |
g_array_remove_index (FileProperties, CurrentPage); |
727 |
OpenedFilesCnt--; |
OpenedFilesCnt--; |
728 |
print_msg ("File closed..."); |
print_msg (_("File closed.")); |
729 |
menu_manage_documents (); |
menu_manage_documents (); |
730 |
if (!OpenedFilesCnt) |
if (!OpenedFilesCnt) |
731 |
{ |
{ |
769 |
gint i; |
gint i; |
770 |
|
|
771 |
if (!OpenedFilesCnt) return; |
if (!OpenedFilesCnt) return; |
772 |
print_msg ("Closing all files..."); |
print_msg (_("Closing all files...")); |
773 |
|
|
774 |
for (i = OpenedFilesCnt-1; i >= 0; i--) |
for (i = OpenedFilesCnt-1; i >= 0; i--) |
775 |
{ |
{ |
791 |
} |
} |
792 |
if (!OpenedFilesCnt) |
if (!OpenedFilesCnt) |
793 |
{ |
{ |
794 |
print_msg ("All files closed..."); |
print_msg (_("All files closed.")); |
795 |
set_title (-1); |
set_title (-1); |
796 |
NewFilesCnt = 0; |
NewFilesCnt = 0; |
797 |
} |
} |