42 struct stat *stat_buf = NULL;
43 gboolean success = FALSE;
46 g_return_val_if_fail(filename != NULL, FALSE);
47 g_return_val_if_fail(main_struct != NULL, FALSE);
49 stat_buf = (
struct stat *) g_malloc0 (
sizeof(
struct stat));
50 stat(filename, stat_buf);
52 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"filename to load : %s"), filename);
54 if (S_ISREG(stat_buf->st_mode) && stat_buf->st_size > 0)
73 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"file %s loaded !"), filename);
77 log_message(main_struct, G_LOG_LEVEL_ERROR, Q_(
"Error while trying to load file %s"), filename);
84 if (S_ISREG(stat_buf->st_mode))
86 log_message(main_struct, G_LOG_LEVEL_WARNING, Q_(
"The file %s is empty !"), filename);
90 log_message(main_struct, G_LOG_LEVEL_WARNING, Q_(
"The file %s does not exist !"), filename);
109 struct stat *stat_buf;
110 GtkBuilder *xml = NULL;
112 stat_buf = (
struct stat *) g_malloc0 (
sizeof(
struct stat));
114 stat(file_to_load, stat_buf);
115 if (S_ISREG(stat_buf->st_mode) && stat_buf->st_size>0)
117 GError* error = NULL;
118 xml = gtk_builder_new ();
120 if (!gtk_builder_add_from_file(xml, file_to_load, &error))
122 g_warning (Q_(
"Couldn't load builder file: %s"), error->message);
123 g_error_free (error);
147 gchar *file_to_load = NULL;
148 GList *list = g_list_first(location_list);
149 GtkBuilder *xml = NULL;
151 while (list != NULL && xml == NULL)
153 file_to_load = g_build_filename((gchar *) list->data, filename, NULL);
161 g_free(file_to_load);
175 if (prefs != NULL && prefs->
file != NULL && prefs->
filename != NULL)
177 return g_key_file_load_from_file(prefs->
file, prefs->
filename, G_KEY_FILE_KEEP_COMMENTS & G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
194 gchar *contents = NULL;
195 gboolean result = FALSE;
197 if (prefs != NULL && prefs->
file != NULL && prefs->
filename != NULL)
199 contents = g_key_file_to_data(prefs->
file, &length, NULL);
200 result = g_file_set_contents(prefs->
filename, contents, length, NULL);
This is the main structure.
void add_new_tab_in_main_window(heraia_struct_t *main_struct, doc_t *doc)
Adds a new tab to the main window in file's notebook.
void log_message(heraia_struct_t *main_struct, GLogLevelFlags log_level, const char *format,...)
A function that helps logging a message a the specified level.
GtkBuilder * load_xml_file(GList *location_list, gchar *filename)
loads the GtkBuilder xml file ('filename') that describes an interface, tries all the paths defined i...
gchar * filename
user preference file file name
Proposal for a structure that will group all informations about a single document.
void grey_main_widgets(GtkBuilder *xml, gboolean greyed)
Hides or grey all widgets that needs an open file when boolean greyed is TRUE.
xml_t * xmls
All the xmls used in the program, loaded at running time.
Data type related to preferences.
gboolean load_preference_file(prefs_t *prefs)
Load the preference file from the disk.
GKeyFile * file
preference file contents
static GtkBuilder * load_xml_if_it_exists(char *file_to_load)
gboolean save_preferences_to_file(prefs_t *prefs)
Saves the preferences to the file preferences.
doc_t * heraia_hex_document_new(heraia_struct_t *main_struct, char *filename)
Removes the old document if it exists and adds a new one from the filename 'filename'.
GtkWidget * hex_widget
hexwidget corresponding to the document
void update_main_window_name(heraia_struct_t *main_struct)
Update main window heraia's name to reflect the current edited file.
GtkBuilder * main
the main interface xml description
This file contains all the definitions and includes all other .h files.
gboolean load_file_to_analyse(heraia_struct_t *main_struct, gchar *filename)
Loads the file 'filename' to analyse and populates the corresponfing structure 'main_struct' as neede...