38 |
#include "prefs.h" |
#include "prefs.h" |
39 |
#include "filesops.h" |
#include "filesops.h" |
40 |
#include "tools.h" |
#include "tools.h" |
41 |
|
#include <errno.h> |
42 |
|
|
43 |
#define OPEN_FILE 0 |
#define OPEN_FILE 0 |
44 |
#define SAVE_FILE_AS 1 |
#define SAVE_FILE_AS 1 |
685 |
/* actually does the work of opening a file */ |
/* actually does the work of opening a file */ |
686 |
void open_filename (const gchar *filename) |
void open_filename (const gchar *filename) |
687 |
{ |
{ |
|
// gint CurrentPage; |
|
688 |
struct stat Stats; |
struct stat Stats; |
689 |
gchar *dir; |
gchar *dir; |
690 |
|
gboolean new_file = FALSE; |
691 |
|
|
692 |
START_FCN |
START_FCN |
693 |
|
|
694 |
if (stat (filename, &Stats) == -1) return; |
if (stat (filename, &Stats) == -1) |
695 |
|
{ |
696 |
|
if (errno == ENOENT) /* the file is allowed to not exist */ |
697 |
|
{ |
698 |
|
new_file = TRUE; |
699 |
|
} |
700 |
|
else |
701 |
|
{ |
702 |
|
return; |
703 |
|
} |
704 |
|
} |
705 |
if ((Stats.st_mode & S_IFMT) == S_IFDIR) return; |
if ((Stats.st_mode & S_IFMT) == S_IFDIR) return; |
706 |
|
|
707 |
g_free (DIRECTORY); |
g_free (DIRECTORY); |
713 |
put_recent_file (filename); |
put_recent_file (filename); |
714 |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), filename); |
add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), filename); |
715 |
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); |
716 |
|
|
717 |
|
if (new_file) |
718 |
|
{ |
719 |
|
gtk_text_buffer_set_modified (FPROPS (OpenedFilesCnt - 1, Buffer), TRUE); |
720 |
|
} |
721 |
|
|
722 |
if (FPROPS(OpenedFilesCnt - 1, ReadOnly)) |
if (FPROPS(OpenedFilesCnt - 1, ReadOnly)) |
723 |
print_msg (g_strdup_printf (_("Opened file \"%s\" read-only."), FPROPS(OpenedFilesCnt - 1, BaseName))); |
print_msg (g_strdup_printf (_("Opened file \"%s\" read-only."), FPROPS(OpenedFilesCnt - 1, BaseName))); |
724 |
else |
else |