64 struct stat *buf = NULL;
67 buf = (
struct stat *) g_malloc0(
sizeof(
struct stat));
68 result = g_stat(pathname, buf);
72 g_mkdir_with_parents(pathname, 488);
86 fp = g_fopen(filename,
"r");
90 fp = g_fopen(filename,
"w");
93 fprintf(stderr, Q_(
"Unable to open and create the main preference file %s\n"), filename);
97 fprintf(stderr, Q_(
"Main preference file %s created successfully\n"), filename);
136 prefs->
file = g_key_file_new();
154 g_key_file_free(prefs->
file);
167 gchar *keyname = NULL;
169 keyname = g_strconcat(name,
" Displayed", NULL);
173 keyname = g_strconcat(name,
" X_pos", NULL);
177 keyname = g_strconcat(name,
" Y_pos", NULL);
181 keyname = g_strconcat(name,
" Height", NULL);
185 keyname = g_strconcat(name,
" Width", NULL);
198 gboolean activated = FALSE;
201 if (main_struct != NULL && prefs != NULL)
208 if (activated == TRUE)
228 if (activated == TRUE)
242 const gchar **list = NULL;
243 gchar *filename = NULL;
244 gint *pos_list = NULL;
248 gint current_tab = 0;
249 doc_t *document = NULL;
250 GtkWidget *notebook = NULL;
252 if (main_struct != NULL && prefs != NULL)
258 list = (
const gchar **) g_malloc0 (
sizeof(gchar *)*len);
259 pos_list = (gint *) g_malloc0 (
sizeof(gint)*len);
263 document = g_ptr_array_index(main_struct->
documents, i);
265 if (document != NULL)
282 current_tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
295 gboolean activated = FALSE;
297 if (main_struct != NULL && prefs != NULL)
317 gint selected_tab = -1;
318 gint stream_size = -1;
319 gint endianness = -1;
321 if (main_struct != NULL && main_struct->
current_DW != NULL && prefs != NULL)
324 if (selected_tab >= 0)
330 if (stream_size >= 0)
351 GtkNotebook *notebook = NULL;
352 gint selected_tab = -1;
354 if (main_struct != NULL && main_struct->
current_DW != NULL && prefs != NULL)
358 if (notebook != NULL)
360 selected_tab = gtk_notebook_get_current_page(notebook);
362 if (selected_tab >= 0)
378 if (main_struct != NULL && prefs != NULL)
406 gchar *keyname = NULL;
408 keyname = g_strconcat(name,
" Displayed", NULL);
412 keyname = g_strconcat(name,
" X_pos", NULL);
413 window_prop->
x = g_key_file_get_integer(file,
GN_GLOBAL_PREFS, keyname, NULL);
416 keyname = g_strconcat(name,
" Y_pos", NULL);
417 window_prop->
y = g_key_file_get_integer(file,
GN_GLOBAL_PREFS, keyname, NULL);
420 keyname = g_strconcat(name,
" Height", NULL);
424 keyname = g_strconcat(name,
" Width", NULL);
438 GtkWidget *save_window_position_bt = NULL;
439 GtkWidget *save_filenames_bt = NULL;
440 gboolean activated = FALSE;
442 if (main_struct != NULL && prefs != NULL)
444 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading window's positions"));
448 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_window_position_bt), activated);
450 if (activated == TRUE)
470 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_filenames_bt), activated);
472 if (activated == TRUE)
474 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading files..."));
489 gint *pos_list = NULL;
493 gint current_tab = 0;
494 GtkWidget *notebook = NULL;
496 if (main_struct != NULL && prefs != NULL)
504 for (i = 0; i < len; i++)
520 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), current_tab);
532 GtkWidget *toggle_button = NULL;
533 gboolean activated = FALSE;
535 if (main_struct != NULL && prefs != NULL)
540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button), activated);
545 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button), activated);
557 gint selected_tab = -1;
558 gint stream_size = -1;
559 gint endianness = -1;
561 if (main_struct != NULL && main_struct->
current_DW != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL && prefs != NULL)
581 GtkNotebook *notebook = NULL;
582 GtkWidget *button = NULL;
585 if (main_struct != NULL && main_struct->
current_DW != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL && prefs != NULL)
589 if (notebook != NULL)
593 switch (selected_tab)
596 gtk_notebook_set_current_page(notebook, selected_tab);
598 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE);
602 gtk_notebook_set_current_page(notebook, selected_tab);
604 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE);
622 if (main_struct != NULL && prefs != NULL)
628 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading main preferences"));
632 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading main display preferences"));
636 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading data interpretor preferences"));
640 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading window preference's main preferences"));
window_prop_t * find_window
find window
This is the main structure.
static void load_mp_file_preferences_options(heraia_struct_t *main_struct, prefs_t *prefs)
Load only main preferences related options.
window_prop_t * data_interpretor
data interpretor window
gint x
x position (upper left corner)
window_prop_t * result_window
result window properties
static void load_di_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Load data interpretor state and preferences.
#define KN_FILES_CURSOR_POSITIONS
gchar * doc_t_document_get_filename(doc_t *doc)
Retrieves from a doc_t * document it's filename, which ever it is.
window_prop_t * fr_window
find and replace window
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.
window_prop_t * main_dialog
heraia's main window
gboolean displayed
TRUE if displayed, FALSE otherwise.
#define KN_MPWP_SELECTED_TAB
gchar * filename
user preference file file name
window_prop_t * plugin_list
plugin description window
all_window_prop_t * win_prop
Keeps window properties.
gint di_get_stream_size(heraia_struct_t *main_struct)
Gets the stream_size (if any) from data interpretor's window.
window_prop_t * main_pref_window
main preference window
window_prop_t * fdft_window
find data from type window
#define KN_DATA_INTERPRETOR
Proposal for a structure that will group all informations about a single document.
prefs_t * init_preference_struct(gchar *pathname, gchar *filename)
Look out if the preference structure exists or not.
static void verify_preference_file_name_presence(gchar *filename)
Verify preference file's presence and creates it if it does not exists already.
xml_t * xmls
All the xmls used in the program, loaded at running time.
gchar * pathname
user preference file path name
Data type related to preferences.
static void save_mp_files_filenames(heraia_struct_t *main_struct, prefs_t *prefs)
Saves files filenames to the config file.
#define KN_SAVE_OPENED_FILES_FILENAMES
gboolean load_preference_file(prefs_t *prefs)
Load the preference file from the disk.
GKeyFile * file
preference file contents
#define KN_SAVE_WINDOW_PREFS
window_prop_t * ldt
list data types window
static void save_di_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Saves data interpretor state and preferences.
void di_set_selected_tab(heraia_struct_t *main_struct, gint selected_tab)
Sets the selected tab (if possible) to data interpretor's notebook.
static void save_mp_file_preferences_options(heraia_struct_t *main_struct, prefs_t *prefs)
Save only file preferences related options.
void verify_preference_file(prefs_t *prefs)
Verify preference file presence and creates it if it does not already exists.
#define KN_DI_SELECTED_TAB
gboolean save_preferences_to_file(prefs_t *prefs)
Saves the preferences to the file preferences.
window_prop_t * about_box
GtkWidget * hex_widget
hexwidget corresponding to the document
gint y
y position (upper left corner)
static void save_mp_display_preferences_options(heraia_struct_t *main_struct, prefs_t *prefs)
Save only display related preferences.
void free_preference_struct(prefs_t *prefs)
Destroys a preference structure.
static void save_window_preferences(GKeyFile *file, gchar *name, window_prop_t *window_prop)
Window preferences.
GtkBuilder * main
the main interface xml description
void di_set_stream_size(heraia_struct_t *main_struct, gint stream_size)
Sets the stream size (if possible) to data interpretor's notebook.
guint64 ghex_get_cursor_position(GtkWidget *hex_widget)
Retrieves the cursor's position from the current hexwidget.
data_window_t * current_DW
data_interpretor pointer
void save_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Save all preferences to the user preference file.
void di_set_endianness(heraia_struct_t *main_struct, gint endianness)
Sets the endianness as stated by the second parameter.
window_prop_t * log_box
log window
static void load_window_preferences(GKeyFile *file, gchar *name, window_prop_t *window_prop)
Window preferences.
This file contains all the definitions and includes all other .h files.
guint height
y+height (bottom right corner)
void ghex_set_cursor_position(GtkWidget *hex_widget, guint64 position)
Sets the cursor at the defined position in the hexwidget.
static void load_mpwp_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Load main preferences window state and preferences.
#define KN_DI_STREAM_SIZE
doc_t * current_doc
This is a pointer to the current edited document.
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
window_prop_t * goto_window
goto dialog window
gint di_get_endianness(heraia_struct_t *main_struct)
Gets the endianness as selected in the radio group button.
gboolean is_toggle_button_activated(GtkBuilder *main_xml, gchar *check_button)
returns the state of a named check button contained in the GtkBuilder XML description ...
static void load_mp_display_preferences_options(heraia_struct_t *main_struct, prefs_t *prefs)
Load display related preferences.
guint width
x+width (bottom right corner)
GPtrArray * documents
An array of doc_t in order to be able to open more than one doc.
gint di_get_selected_tab(heraia_struct_t *main_struct)
Gets the selected tab (if any) from data interpretor's notebook.
static void load_mp_files_filenames(heraia_struct_t *main_struct, prefs_t *prefs)
Load files filenames from the config file.
static void save_mpwp_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Saves main preferences window state and preferences.
void load_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Sets up the preferences as loaded in the preference file.
#define KN_FILES_FILENAMES
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...
static void verify_preference_file_path_presence(gchar *pathname)
verify preference file path presence and creates it if it does not already exists ...