![]() |
![]() |
Gwyddion Application Library Reference Manual | ![]() |
|
---|---|---|---|---|
const gchar* gwy_app_get_current_directory (void); void gwy_app_set_current_directory (const gchar *directory); GwyContainer* gwy_app_file_load (const gchar *filename_utf8, const gchar *filename_sys, const gchar *name); void gwy_app_file_open (void); gboolean gwy_app_file_write (GwyContainer *data, const gchar *filename_utf8, const gchar *filename_sys, const gchar *name); void gwy_app_file_save (void); void gwy_app_file_save_as (void); gboolean gwy_app_file_confirm_overwrite (GtkWidget *chooser);
High-level functions gwy_app_file_load()
and gwy_app_file_write()
wrap low-level file handling functions from
gwymodule-file
and handle registration of loaded containers in data browser, showing
windows, remembering file types, or the differenced between save and export.
They are complemented by application-level functions gwy_app_file_open()
,
gwy_app_file_save()
, and gwy_app_file_save_as()
that perform the
corresponding operations of File menu. These are probably not of general
interest.
Beside that, functions to maintain application-level idea of current
directory are provided: gwy_app_get_current_directory()
,
gwy_app_set_current_directory()
. They should be used in place of system
chdir()
which has various unwanted side-effect, like change of the directory
where core is dumped on segfault.
const gchar* gwy_app_get_current_directory (void);
Returns what the app uses as `current directory'.
Warning: This function is probably temporary.
Returns : | A string in GLib file name encoding that should not be modified
neither freed, valid only until next call to
gwy_app_set_current_directory() . It ends with a
G_DIR_SEPARATOR_S .
|
void gwy_app_set_current_directory (const gchar *directory);
Sets what the app should use as `current directory'.
Warning: This function is probably temporary.
directory : |
The directory to set, or a filename to take directory part from, it must be an absolute path. In GLib file name encoding. |
GwyContainer* gwy_app_file_load (const gchar *filename_utf8, const gchar *filename_sys, const gchar *name);
Loads a file into application (a high-level function).
At least one of filename_utf8
, filename_sys
must be non-NULL
.
The file is loaded in interactive mode, modules can ask for user input. Upon a successful load all necessary setup tasks are performed. If the load fails, an error dialog is presented.
void gwy_app_file_open (void);
Opens a user-selected file (very high-level app function).
gboolean gwy_app_file_write (GwyContainer *data, const gchar *filename_utf8, const gchar *filename_sys, const gchar *name);
Writes container to a file (a high-level function).
At least one of filename_utf8
, filename_sys
must be non-NULL
.
The file is saved in interactive mode, modules can ask for user input. If the write fails, an error dialog is presented.
void gwy_app_file_save (void);
Saves current data to a file (very high-level app function).
May fall back to gwy_app_file_save_as()
when current data has no file name
associated with it, or the format it was loaded from is not saveable.
void gwy_app_file_save_as (void);
Saves current data to a user-selected file (very high-level app function).