60 gboolean quit_heraia = FALSE;
64 if (quit_heraia == TRUE)
81 GtkWidget *new_hex_widget = NULL;
84 new_hex_doc = hex_document_new();
86 if (new_hex_doc != NULL)
88 new_hex_doc->file_name = g_strdup_printf(Q_(
"No name"));
89 new_hex_doc->changed = TRUE;
92 new_hex_widget = hex_document_add_view(new_hex_doc);
95 gtk_hex_set_insert_mode(GTK_HEX(new_hex_widget), TRUE);
102 doc =
new_doc_t(new_hex_doc, new_hex_widget);
105 g_ptr_array_add(main_struct->
documents, doc);
138 GtkWidget *pref_window = NULL;
142 if (pref_window != NULL)
158 if (about_dialog != NULL)
160 gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about_dialog),
PACKAGE_NAME);
161 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about_dialog),
PACKAGE_VERSION);
175 GtkWidget *about_dialog = NULL;
179 if (about_dialog != NULL)
195 if (dialog_prop != NULL)
200 if (dialog_prop->
x > 0 && dialog_prop->
y > 0)
202 gtk_window_move(GTK_WINDOW(dialog_box), dialog_prop->
x, dialog_prop->
y);
205 if (dialog_prop->
width > 0 && dialog_prop->
height > 0)
207 gtk_window_resize(GTK_WINDOW(dialog_box), dialog_prop->
width, dialog_prop->
height);
210 gtk_widget_show_all(dialog_box);
230 if (dialog_prop != NULL && dialog_prop->
displayed == TRUE)
232 if (dialog_box != NULL)
234 gtk_window_get_position(GTK_WINDOW(dialog_box), &x, &y);
235 gtk_window_get_size(GTK_WINDOW(dialog_box), &width, &height);
238 dialog_prop->
width = width;
239 dialog_prop->
height = height;
252 GtkWidget *dialog_box = NULL;
254 if (main_struct != NULL &&
255 main_struct->
xmls != NULL &&
321 gtk_widget_hide(dialog_box);
334 GtkWidget *about_dialog = NULL;
338 if (about_dialog != NULL)
398 GtkBuilder *xml = NULL;
399 gboolean result = FALSE;
401 if (main_struct != NULL && main_struct->
current_doc != NULL && main_struct->
xmls->
main != NULL)
437 GtkBuilder *xml = NULL;
438 gboolean result = FALSE;
440 if (main_struct != NULL && main_struct->
current_doc != NULL && main_struct->
xmls->
main != NULL)
474 if (main_struct != NULL && main_struct->
current_doc != NULL)
491 if (main_struct != NULL && main_struct->
current_doc != NULL)
508 if (main_struct != NULL && main_struct->
current_doc != NULL)
524 if (main_struct != NULL && main_struct->
current_doc != NULL)
541 if (main_struct != NULL && main_struct->
current_doc != NULL)
557 if (main_struct != NULL && main_struct->
current_doc != NULL)
573 if (main_struct != NULL && main_struct->
current_doc != NULL)
590 GtkWidget *position_label = NULL;
591 GtkWidget *file_size_label = NULL;
592 GtkWidget *file_sel_label = NULL;
593 GtkWidget *file_sel_size_label = NULL;
594 guint64 position = 0;
595 guint64 file_size = 0;
597 gchar *position_text = NULL;
598 gchar *file_size_text = NULL;
599 gchar *file_sel_text = NULL;
600 gchar *file_sel_size_text = NULL;
602 if (main_struct != NULL)
620 position_text = g_strdup_printf(
"<small>%'lu</small>", (
unsigned long int) (position + 1));
621 file_size_text = g_strdup_printf(
"<small>%'lu</small>", (
unsigned long int) file_size);
622 file_sel_text = g_strdup_printf(
"<small>%'lu -> %'lu</small>", (
unsigned long int) (sel->
start + 1), (
unsigned long int) (sel->
end + 1));
623 file_sel_size_text = g_strdup_printf(
"<small>%'li</small>", (
unsigned long int) ((sel->
end - sel->
start) + 1));
627 position_text = g_strdup_printf(
"<small>%lu</small>", (
unsigned long int) (position + 1));
628 file_size_text = g_strdup_printf(
"<small>%lu</small>", (
unsigned long int) file_size);
629 file_sel_text = g_strdup_printf(
"<small>%lu -> %lu</small>", (
unsigned long int) (sel->
start + 1), (
unsigned long int) (sel->
end + 1));
630 file_sel_size_text = g_strdup_printf(
"<small>%li</small>", (
unsigned long int) ((sel->
end - sel->
start) + 1));
633 gtk_label_set_markup(GTK_LABEL(position_label), position_text);
634 gtk_label_set_markup(GTK_LABEL(file_size_label), file_size_text);
635 gtk_label_set_markup(GTK_LABEL(file_sel_label), file_sel_text);
636 gtk_label_set_markup(GTK_LABEL(file_sel_size_label), file_sel_size_text);
638 g_free(position_text);
639 g_free(file_size_text);
640 g_free(file_sel_text);
641 g_free(file_sel_size_text);
658 gtk_label_set_text(GTK_LABEL(position_label),
"");
659 gtk_label_set_text(GTK_LABEL(file_size_label),
"");
660 gtk_label_set_text(GTK_LABEL(file_sel_label),
"");
661 gtk_label_set_text(GTK_LABEL(file_sel_size_label),
"");
680 if (main_struct != NULL)
710 gboolean success = FALSE;
721 list = g_slist_next(list);
726 if (success == TRUE && main_struct->
current_doc != NULL)
747 GtkWidget *notebook = NULL;
748 GtkWidget *page = NULL;
749 GtkWidget *tab_label = NULL;
752 gboolean found = FALSE;
753 GList *children = NULL;
757 nb_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
761 while (i < nb_pages && found == FALSE)
763 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
767 tab_label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page);
769 if (GTK_IS_BOX(tab_label))
771 children = gtk_container_get_children(GTK_CONTAINER(tab_label));
774 while (children != NULL && found == FALSE)
776 if (children->data == to_find)
782 children = g_list_next(children);
813 if (main_struct != NULL)
828 gchar *filename = NULL;
830 if (main_struct != NULL)
834 if (filename != NULL)
852 gchar *filename = NULL;
855 if (main_struct != NULL)
860 if (list != NULL && list->data != NULL)
866 filename = list->data;
867 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Loading project %s"), filename);
889 GtkWidget *notebook = NULL;
891 if (main_struct != NULL && main_struct->
documents != NULL)
894 g_ptr_array_remove_index(main_struct->
documents, index);
901 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), index);
917 doc_t *closing_doc = NULL;
918 doc_t *document = NULL;
919 GtkWidget *notebook = NULL;
920 GtkWidget *dialog = NULL;
921 GtkWidget *parent = NULL;
926 gboolean is_current_doc = FALSE;
929 if (main_struct != NULL && main_struct->
current_doc != NULL)
932 if (GTK_IS_BUTTON(widget))
936 closing_doc = g_ptr_array_index(main_struct->
documents, tab_number);
937 is_current_doc = (closing_doc == main_struct->
current_doc);
942 is_current_doc = TRUE;
952 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, Q_(
"This document has been edited and is not saved !"));
953 gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), Q_(
"Do you want to close it without saving it ?"));
955 result = gtk_dialog_run(GTK_DIALOG(dialog));
957 gtk_widget_destroy(dialog);
961 case GTK_RESPONSE_YES:
973 while (i < main_struct->documents->len && index == -1)
975 document = g_ptr_array_index(main_struct->
documents, i);
976 if (document == closing_doc)
989 if (is_current_doc == TRUE)
997 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
1002 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), index - 1);
1031 gchar *filename = NULL;
1033 if (main_struct != NULL && main_struct->
current_doc != NULL)
1040 log_message(main_struct, G_LOG_LEVEL_ERROR, Q_(
"Error while saving file %s !"), filename);
1061 gchar *filename = NULL;
1063 if (main_struct != NULL && main_struct->
current_doc != NULL)
1067 if (filename != NULL)
1080 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Saving file as... : operation cancelled."));
1111 GtkNotebook *notebook = NULL;
1113 if (main_struct != NULL)
1119 if (dw->
diw == NULL)
1124 if (dw->
diw != NULL)
1141 dw->
tab_displayed = gtk_notebook_get_current_page(notebook);
1158 gboolean result = FALSE;
1160 if (main_struct != NULL)
1166 log_message(main_struct, G_LOG_LEVEL_INFO, Q_(
"All tests went Ok."));
1170 log_message(main_struct, G_LOG_LEVEL_WARNING, Q_(
"Some tests failed."));
1237 if (main_struct != NULL)
1239 if (tab_num >= 0 && tab_num <= main_struct->documents->len)
1273 gchar *current_dir = NULL;
1274 gchar *new_dir = NULL;
1276 if (g_path_is_absolute(filename) == TRUE)
1279 return g_path_get_dirname(filename);
1283 current_dir = g_get_current_dir();
1284 new_dir = g_path_get_dirname(filename);
1286 if (g_chdir(new_dir) == 0)
1289 new_dir = g_get_current_dir();
1290 g_chdir(current_dir);
1291 g_free(current_dir);
1297 g_free(current_dir);
1313 gchar *dirname = NULL;
1317 if (dirname != NULL)
1319 gtk_file_chooser_set_current_folder(file_chooser, dirname);
1335 GtkWidget *parent = NULL;
1336 GtkFileChooser *file_chooser = NULL;
1337 GSList *list = NULL;
1341 file_chooser = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new(message,
1343 GTK_FILE_CHOOSER_ACTION_OPEN,
1344 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1345 GTK_STOCK_OPEN, GTK_RESPONSE_OK,
1348 gtk_window_set_modal(GTK_WINDOW(file_chooser), TRUE);
1349 gtk_file_chooser_set_select_multiple(file_chooser, multiple);
1360 switch (gtk_dialog_run(GTK_DIALOG(file_chooser)))
1362 case GTK_RESPONSE_OK:
1364 list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(file_chooser));
1365 gtk_widget_destroy(GTK_WIDGET(file_chooser));
1370 case GTK_RESPONSE_CANCEL:
1372 gtk_widget_destroy(GTK_WIDGET(file_chooser));
1388 GtkWidget *parent = NULL;
1389 GtkFileChooser *fcd = NULL;
1390 gchar *filename = NULL;
1395 fcd = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new(Q_(
"Save As..."),
1397 GTK_FILE_CHOOSER_ACTION_SAVE,
1398 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1399 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
1403 gtk_window_set_modal(GTK_WINDOW(fcd), TRUE);
1404 gtk_file_chooser_set_select_multiple(fcd, FALSE);
1405 gtk_file_chooser_set_do_overwrite_confirmation(fcd, TRUE);
1413 switch(gtk_dialog_run(GTK_DIALOG(fcd)))
1415 case GTK_RESPONSE_OK:
1417 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fcd));
1424 gtk_widget_destroy(GTK_WIDGET(fcd));
1436 GtkWidget *widget = NULL;
1437 gchar *filename = NULL;
1438 gchar *whole_filename = NULL;
1440 if (main_struct != NULL && main_struct->
current_doc != NULL)
1446 filename = g_filename_display_basename(whole_filename);
1448 gtk_window_set_title(GTK_WINDOW(widget), filename);
1450 else if (main_struct != NULL)
1453 gtk_window_set_title(GTK_WINDOW(widget),
"Heraia");
1465 GList *children = NULL;
1466 gboolean found = FALSE;
1470 children = gtk_container_get_children(GTK_CONTAINER(hbox));
1473 while (children != NULL && found == FALSE)
1475 if (GTK_IS_LABEL(children->data))
1481 children = g_list_next(children);
1487 return children->data;
1508 GtkWidget *notebook = NULL;
1509 GtkWidget *page = NULL;
1510 GtkWidget *hbox = NULL;
1511 GtkWidget *label = NULL;
1513 gchar *filename = NULL;
1514 gchar *whole_filename;
1516 gchar *markup= NULL;
1518 if (main_struct != NULL && main_struct->
current_doc != NULL)
1521 current = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
1522 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), current);
1523 hbox = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page);
1528 doc = g_ptr_array_index(main_struct->
documents, current);
1531 if (whole_filename != NULL)
1533 filename = g_filename_display_basename(whole_filename);
1534 markup = g_markup_printf_escaped(
"%s", filename);
1535 gtk_label_set_markup(GTK_LABEL(label), markup);
1536 gtk_widget_set_tooltip_text(label, g_filename_display_name(whole_filename));
1552 GtkWidget *notebook = NULL;
1553 GtkWidget *page = NULL;
1554 GtkWidget *label = NULL;
1555 GtkWidget *menu_label = NULL;
1556 GtkWidget *hbox = NULL;
1558 gchar *markup= NULL;
1561 if (main_struct != NULL && main_struct->
current_doc != NULL)
1564 current = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
1565 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), current);
1566 hbox = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page);
1571 text = g_strdup(gtk_label_get_text(GTK_LABEL(label)));
1575 markup = g_markup_printf_escaped(
"<span foreground=\"blue\">%s</span>", text);
1579 markup = g_markup_printf_escaped(
"%s", text);
1582 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Changing color for filename %s in tab : %d"), markup, current);
1583 gtk_label_set_markup(GTK_LABEL(label), markup);
1584 menu_label = gtk_label_new(NULL);
1585 gtk_label_set_markup(GTK_LABEL(menu_label), markup);
1586 gtk_notebook_set_menu_label(GTK_NOTEBOOK(notebook), page, menu_label);
1603 GtkWidget *notebook = NULL;
1621 gtk_widget_set_sensitive(
heraia_get_widget(xml,
"menu_projects_save_as"), FALSE);
1622 gtk_widget_hide(notebook);
1636 gtk_widget_set_sensitive(
heraia_get_widget(xml,
"menu_projects_save_as"), TRUE);
1637 gtk_widget_show_all(notebook);
1653 if (main_struct != NULL)
1687 gchar *filename = NULL;
1689 if (main_struct != NULL && main_struct->
xmls != NULL)
1691 filename = g_strdup_printf(
"heraia.gtkbuilder");
1695 if (main_struct->
xmls->
main == NULL)
1723 g_signal_connect(G_OBJECT(hex_widget),
"cursor_moved",
1871 gboolean success = FALSE;
1876 if (success == TRUE)
1879 if (main_struct->
debug == TRUE)
1881 fprintf(stdout, Q_(
"Connecting heraia_ui signals "));
1886 if (main_struct->
debug == TRUE)
1888 fprintf(stdout, Q_(
" [Done]\n"));
1893 if (main_struct->
debug == TRUE)
1895 fprintf(stdout, Q_(
"log window init interface "));
1900 if (main_struct->
debug == TRUE)
1902 fprintf(stdout, Q_(
" [Done]\n"));
1907 if (main_struct->
debug == TRUE)
1909 fprintf(stdout, Q_(
"preferences window init interface "));
1914 if (main_struct->
debug == TRUE)
1916 fprintf(stdout, Q_(
" [Done]\n"));
1921 if (main_struct->
debug == TRUE)
1923 fprintf(stdout, Q_(
"data interpretor init interface "));
1928 if (main_struct->
debug == TRUE)
1930 fprintf(stdout, Q_(
" [Done]\n"));
1935 if (main_struct->
debug == TRUE)
1937 fprintf(stdout, Q_(
"goto dialog window init interface "));
1942 if (main_struct->
debug == TRUE)
1944 fprintf(stdout, Q_(
" [Done]\n"));
1949 if (main_struct->
debug == TRUE)
1951 fprintf(stdout, Q_(
"result window init interface "));
1956 if (main_struct->
debug == TRUE)
1958 fprintf(stdout, Q_(
" [Done]\n"));
1963 if (main_struct->
debug == TRUE)
1965 fprintf(stdout, Q_(
"find window init interface "));
1970 if (main_struct->
debug == TRUE)
1972 fprintf(stdout, Q_(
" [Done]\n"));
1977 if (main_struct->
debug == TRUE)
1979 fprintf(stdout, Q_(
"find and replace window init interface "));
1984 if (main_struct->
debug == TRUE)
1986 fprintf(stdout, Q_(
" [Done]\n"));
1991 if (main_struct->
debug == TRUE)
1993 fprintf(stdout, Q_(
"find data from type window init interface"));
1998 if (main_struct->
debug == TRUE)
2000 fprintf(stdout, Q_(
" [Done]\n"));
2005 if (main_struct->
debug == TRUE)
2007 fprintf(stdout, Q_(
"Loading heraia preference file\n"));
2008 fprintf(stdout, Q_(
"Setting up preferences...\n"));
2028 GtkTextBuffer *tb = NULL;
2030 gchar *display = NULL;
2033 va_start(args, format);
2034 display = g_locale_to_utf8(g_strdup_vprintf(format, args), -1, NULL, NULL, &err);
2037 tb = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)));
2038 gtk_text_buffer_get_end_iter(tb, &iEnd);
2039 gtk_text_buffer_insert(tb, &iEnd, display, -1);
2051 GtkTextBuffer *tb = NULL;
2055 tb = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)));
2056 gtk_text_buffer_get_start_iter(tb, &iStart);
2057 gtk_text_buffer_get_end_iter(tb, &iEnd);
2058 gtk_text_buffer_delete (tb, &iStart, &iEnd);
2072 GSList *tmp_slist = group;
2073 GtkToggleButton *toggle_button = NULL;
2077 toggle_button = tmp_slist->data;
2079 if (gtk_toggle_button_get_active(toggle_button))
2081 return GTK_WIDGET(toggle_button);
2084 tmp_slist = g_slist_next(tmp_slist);
2100 if (radio_button != NULL)
2117 GSList *group = NULL;
2118 GtkToggleButton *toggle_button = NULL;
2120 group = gtk_radio_button_get_group(radio_button);
2124 toggle_button = group->data;
2126 if (toggle_button == GTK_TOGGLE_BUTTON(radio_button))
2128 gtk_toggle_button_set_active(toggle_button, TRUE);
2132 gtk_toggle_button_set_active(toggle_button, FALSE);
2135 group = g_slist_next(group);
2148 return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(check_menu_item));
2163 gboolean activated = FALSE;
2165 if (main_xml != NULL)
2167 activated = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
heraia_get_widget(main_xml, check_button)));
2191 if (xml != NULL && widget_name != NULL)
2193 return GTK_WIDGET(gtk_builder_get_object(xml, widget_name));
2211 gtk_widget_destroy(widget);
2224 doc_t *current_doc = NULL;
2225 gboolean result = FALSE;
2228 if (main_struct != NULL && main_struct->
documents != NULL)
2230 for(i = 0; i < main_struct->
documents->len; i++)
2232 current_doc = g_ptr_array_index(main_struct->
documents, i);
2233 result = result | current_doc->
modified;
2253 gboolean unsaved = FALSE;
2254 gboolean quit_heraia = TRUE;
2255 GtkWidget *dialog = NULL;
2256 GtkWidget *parent = NULL;
2258 doc_t *closing_doc = NULL;
2262 if (unsaved == TRUE)
2267 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, Q_(
"Unsaved document(s) remains."));
2268 gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),
"%s", question);
2271 result = gtk_dialog_run(GTK_DIALOG(dialog));
2275 case GTK_RESPONSE_YES:
2280 quit_heraia = FALSE;
2284 gtk_widget_destroy(dialog);
2287 if (quit_heraia == TRUE)
2298 closing_doc = g_ptr_array_index(main_struct->
documents, 0);
2310 main_struct->
prefs = NULL;
2325 return close_a_project(main_struct, Q_(
"Do you want to quit without saving ?"));
2338 gboolean activated = FALSE;
2340 if (dialog_box != NULL && cmi != NULL && dialog_prop != NULL)
2343 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(cmi), activated);
2344 if (activated == TRUE)
2346 gtk_window_move(GTK_WINDOW(dialog_box), dialog_prop->
x, dialog_prop->
y);
2347 gtk_window_resize(GTK_WINDOW(dialog_box), dialog_prop->
width, dialog_prop->
height);
2348 gtk_widget_show_all(dialog_box);
2361 GtkWidget *cmi = NULL;
2362 GtkWidget *dialog_box = NULL;
2364 if (main_struct != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
2374 gtk_widget_show(dialog_box);
2406 gtk_widget_show_all(dialog_box);
2415 gtk_widget_show_all(dialog_box);
2430 gtk_widget_show_all(dialog_box);
2444 gtk_widget_show_all(dialog_box);
2458 gtk_widget_show_all(dialog_box);
2472 gtk_widget_show_all(dialog_box);
2488 gtk_widget_show_all(dialog_box);
2507 GtkWidget *hbox = NULL;
2508 GtkWidget *button = NULL;
2511 #if GTK_MAJOR_VERSION < 3
2513 hbox = gtk_hbox_new(FALSE, 0);
2515 #if GTK_MAJOR_VERSION >= 3
2516 #if GTK_MINOR_VERSION <= 1
2518 hbox = gtk_hbox_new(FALSE, 0);
2520 #if GTK_MINOR_VERSION >= 2
2522 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2527 button = gtk_button_new_with_label(
"x");
2528 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2529 gtk_widget_set_size_request(button, 18, 17);
2530 gtk_widget_set_tooltip_text(button, Q_(
"Close button"));
2531 g_signal_connect(G_OBJECT(button),
"clicked", G_CALLBACK(signal_handler), main_struct);
2534 gtk_box_pack_start(GTK_BOX(hbox), tab_label, FALSE, FALSE, 0);
2535 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 2);
2536 gtk_widget_show_all(hbox);
2549 GtkWidget *vbox = NULL;
2550 GtkNotebook *notebook = NULL;
2551 GtkWidget *tab_label = NULL;
2552 GtkWidget *menu_label = NULL;
2554 gchar *filename = NULL;
2555 gchar *whole_filename = NULL;
2556 gchar *markup = NULL;
2557 gchar *menu_markup = NULL;
2558 GtkWidget *hbox = NULL;
2562 #if GTK_MAJOR_VERSION < 3
2564 vbox = gtk_vbox_new(FALSE, 2);
2566 #if GTK_MAJOR_VERSION >= 3
2567 #if GTK_MINOR_VERSION <= 1
2569 vbox = gtk_vbox_new(FALSE, 2);
2571 #if GTK_MINOR_VERSION >= 2
2573 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
2577 gtk_box_pack_start(GTK_BOX(vbox), doc->
hex_widget, TRUE, TRUE, 3);
2580 tab_label = gtk_label_new(NULL);
2581 menu_label = gtk_label_new(NULL);
2584 if (whole_filename != NULL)
2586 filename = g_filename_display_basename(whole_filename);
2587 markup = g_markup_printf_escaped(
"%s", filename);
2588 menu_markup = g_markup_printf_escaped(
"%s", filename);
2589 gtk_label_set_markup(GTK_LABEL(tab_label), markup);
2590 gtk_label_set_markup(GTK_LABEL(menu_label), menu_markup);
2591 gtk_label_set_justify(GTK_LABEL(menu_label), GTK_JUSTIFY_LEFT);
2592 gtk_widget_set_tooltip_text(tab_label, g_filename_display_name(whole_filename));
2594 g_free(menu_markup);
2599 gtk_widget_show_all(vbox);
2600 tab_num = gtk_notebook_append_page_menu(notebook, vbox, hbox, menu_label);
2603 gtk_notebook_set_current_page(notebook, tab_num);
2617 if (win_prop != NULL)
2632 gtk_widget_show(widget);
2636 gtk_widget_hide(widget);
static void close_one_document(heraia_struct_t *main_struct, doc_t *closing_doc, gint index)
Closes one document in heraia.
void kill_text_from_textview(GtkTextView *textview)
Kills the text from a textview.
window_prop_t * find_window
find window
This is the main structure.
static gboolean a_propos_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
To close the A propos dialog box.
void find_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find window (signal and such)
window_prop_t * data_interpretor
data interpretor window
static void on_projects_open_activate(GtkWidget *widget, gpointer data)
Opens a project from a file : closes all documents an imports new ones ...
GtkWidget * find_label_from_hbox(GtkWidget *hbox)
Tries to find the label contained in the hbox.
static gchar * make_absolute_path(gchar *filename)
Returns an absolute path to the filename the string should be freed when no longer needed very UGLy !...
void init_heraia_interface(heraia_struct_t *main_struct)
Here we might init some call backs and menu options and display the interface (main && sub-windows) This ...
gint x
x position (upper left corner)
static void on_projects_save_as_activate(GtkWidget *widget, gpointer data)
Saves a project in a new file (does not close the project itself)
void on_save_activate(GtkWidget *widget, gpointer data)
Here we attemp to save the edited file.
void on_DIMenu_activate(GtkWidget *widget, gpointer data)
This handles the menuitem "Data Interpretor" that shows or hides the data interpretor window...
void add_text_to_textview(GtkTextView *textview, const char *format,...)
adds a text to a textview
void set_notebook_tab_name(heraia_struct_t *main_struct)
Sets notebook's tab's name.
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.
GtkWidget * create_tab_close_button(heraia_struct_t *main_struct, GtkWidget *tab_label, void *signal_handler)
Creates an hbox containning a cross button (in order to close the tab) and a label (from tab_label)...
window_prop_t * result_window
result window properties
gint tab_displayed
keeps the last displayed tab's number before closing
void on_preferences_activate(GtkWidget *widget, gpointer data)
Preferences, file menu : Displays the preference window (as a modal window)
void set_notebook_tab_label_color(heraia_struct_t *main_struct, gboolean color)
Set the style for the label.
GSList * select_file_to_load(heraia_struct_t *main_struct, gboolean multiple, gchar *message)
This function does open a file selector dialog box and returns the selected filename.
static void record_and_hide_about_box(heraia_struct_t *main_struct)
Record position and hide about dialog box.
gchar * doc_t_document_get_filename(doc_t *doc)
Retrieves from a doc_t * document it's filename, which ever it is.
prefs_t * init_preference_struct(gchar *pathname, gchar *filename)
Look out if the preference structure exists or not.
window_prop_t * fr_window
find and replace window
#define WPT_DEFAULT_HEIGHT
Defines the default height for a window (set in window_prop_t)
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.
static void init_one_cmi_window_state(GtkWidget *dialog_box, GtkWidget *cmi, window_prop_t *dialog_prop)
init one cmi window based state
RefreshType event
Tells what is happening.
void gtk_radio_button_set_active(GtkRadioButton *radio_button)
Sets the radio button active.
void on_redo_activate(GtkWidget *widget, gpointer data)
Redo, edit menu.
gboolean delete_main_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
window_prop_t * main_dialog
heraia's main window
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...
gboolean displayed
TRUE if displayed, FALSE otherwise.
window_prop_t * plugin_list
plugin description window
void fdft_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find data from type window (signal and such)
void on_find_activate(GtkWidget *widget, gpointer data)
Find, Search menu.
void record_and_hide_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Record position and hide a dialog box.
void on_save_as_activate(GtkWidget *widget, gpointer data)
This handle the save_as menu entry (here the filename changes)
gboolean file_notebook_tab_changed(GtkNotebook *notebook, GtkWidget *page, gint tab_num, gpointer data)
What to do when a change occurs in tabs (user selected a particular tab)
void show_hide_widget(GtkWidget *widget, gboolean show, window_prop_t *win_prop)
To help plugins to deal with widgets, shows or hide a specific widget.
gboolean delete_dt_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
call back function for the data interpretor window destruction
void on_fdft_activate(GtkWidget *widget, gpointer data)
Find data from type, Search menu.
void refresh_file_labels(heraia_struct_t *main_struct)
This function is refreshing the labels on the main window in order to reflect cursor position...
all_window_prop_t * win_prop
Keeps window properties.
void rw_remove_all_tabs(heraia_struct_t *main_struct, doc_t *doc)
Remove all tabs from the result window that correspond to the specified document. ...
guint64 ghex_file_size(Heraia_Hex *gh)
Returns the file size of an opened Heraia_Hex document.
window_prop_t * main_pref_window
main preference window
window_prop_t * fdft_window
find data from type window
#define WPT_DEFAULT_WIDTH
Defines the default width for a window (set in window_prop_t)
Data interpretor window structure.
Proposal for a structure that will group all informations about a single document.
#define HERAIA_REFRESH_NEW_FILE
When a new file has been loaded.
guint64 start
Starting position of the selection.
GtkHex Heraia_Hex
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
gchar * select_a_file_to_save(heraia_struct_t *main_struct)
This function opens a dialog box that allow one to choose a file name to the file which is about to b...
void fdft_window_show(GtkWidget *widget, gpointer data)
Show find data from type window.
Heraia_Document * hex_doc
Document definition related to Heraia_Hex (GtkHex)
void on_tests_menu_activate(GtkWidget *widget, gpointer data)
Called when tests submenu is activated.
A structure to manage a single selection.
guint64 end
Ending position of the selection.
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.
void fr_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find and replace window (signal and such)
void on_cut_activate(GtkWidget *widget, gpointer data)
Cut, edit menu.
void on_copy_activate(GtkWidget *widget, gpointer data)
Copy, edit menu.
gboolean debug
Used to tell the program wether we want to display debug messages or not.
void record_all_dialog_box_positions(heraia_struct_t *main_struct)
Records all the positions of the displayed windows.
static gboolean unsaved_documents(heraia_struct_t *main_struct)
Verify if we can safely close everything.
static void a_propos_response(GtkWidget *widget, gint response, gpointer data)
To close the A propos dialog box (with the "close" button)
void free_preference_struct(prefs_t *prefs)
Destroys a preference structure.
void goto_dialog_init_interface(heraia_struct_t *main_struct)
Inits all the things in the goto dialog window (signal and such)
void refresh_all_plugins(heraia_struct_t *main_struct)
To help the main program to send events to the plugins.
void find_window_show(GtkWidget *widget, gpointer data)
Show find window.
static gboolean load_heraia_xml(heraia_struct_t *main_struct)
Loads the GtkBuilder xml files that describes the heraia project tries the following paths in that or...
void refresh_data_interpretor_window(GtkWidget *widget, gpointer data)
Refreshes the data interpretor window with the new values.
void record_dialog_box_position(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Records one dialog position.
#define HERAIA_REFRESH_CURSOR_MOVE
When the cursor is moving.
void on_quit_activate(GtkWidget *widget, gpointer data)
Quit, file menu.
void on_open_activate(GtkWidget *widget, gpointer data)
This handles the menuitem "Ouvrir" to open a file.
window_prop_t * about_box
void fr_window_show(GtkWidget *widget, gpointer data)
Show find and replace window.
prefs_t * prefs
All datas related to main preferences.
GtkWidget * gtk_radio_button_get_active(GSList *group)
Try to find the active radio button widget in a group This does not take into account inconsistant st...
void destroy_a_single_widget(GtkWidget *widget)
Destroys a single widget if it exists.
GtkWidget * hex_widget
hexwidget corresponding to the document
gint y
y position (upper left corner)
void log_window_init_interface(heraia_struct_t *main_struct)
Inits the log window interface Called once at init time.
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
void move_and_show_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Move the dialog box to the wanted position, shows it and says it in the displayed prop...
#define HERAIA_REFRESH_NOTHING
When nothing is refreshed.
#define HERAIA_NOERR
No error occured, everything is fine.
gint HERAIA_ERROR
Defines heraia error type (this should be used !)
void on_undo_activate(GtkWidget *widget, gpointer data)
Undo, edit menu.
void a_propos_activate(GtkWidget *widget, gpointer data)
Shows apropos's dialog box.
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
static void heraia_ui_connect_signals(heraia_struct_t *main_struct)
Connect the signals at the interface.
gboolean is_cmi_checked(GtkWidget *check_menu_item)
Tells whether a GtkCheckMenuItem is Checked or not.
HexDocument Heraia_Document
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
static void set_a_propos_properties(GtkWidget *about_dialog)
Sets name and version in the dialog box.
window_prop_t * log_box
log window
static void a_propos_close(GtkWidget *widget, gpointer data)
To close the A propos dialog box.
#define HERAIA_CANCELLED
an operation has been cancelled
void on_close_activate(GtkWidget *widget, gpointer data)
Closes an opened file.
This file contains all the definitions and includes all other .h files.
guint height
y+height (bottom right corner)
void result_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the result window (signal and such)
void on_goto_activate(GtkWidget *widget, gpointer data)
Go to..., edit menu.
gboolean tests_ui(heraia_struct_t *main_struct)
functions to tests heraia's UI
HERAIA_ERROR heraia_hex_document_save(doc_t *current_doc)
GtkWidget * diw
data interpretor window
static gboolean close_a_project(heraia_struct_t *main_struct, const gchar *question)
Closes all documents and saves preferences if the users wants to close the documents.
doc_t * current_doc
This is a pointer to the current edited document.
void on_delete_activate(GtkWidget *widget, gpointer data)
Delete, edit menu.
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
void set_the_working_directory(GtkFileChooser *file_chooser, gchar *filename)
Sets the working directory for the file chooser to the directory of the filename (even if filename is...
window_prop_t * goto_window
goto dialog window
#define HERAIA_REFRESH_TAB_CHANGED
When user selects another tab in main notebook.
void data_interpretor_init_interface(heraia_struct_t *main_struct)
Inits the data interpretor structure and window with default values.
static void on_projects_close_activate(GtkWidget *widget, gpointer data)
Closes an entire project.
void main_pref_window_init_interface(heraia_struct_t *main_struct)
Inits the main preferences window interface.
void save_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Save all preferences to the user preference file.
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 ...
void refresh_event_handler(GtkWidget *widget, gpointer data)
This function is here to ensure that everything will be refreshed upon a signal event.
guint width
x+width (bottom right corner)
void close_doc_t(doc_t *current_doc)
Closes a previously malloced doc_t structure.
GPtrArray * documents
An array of doc_t in order to be able to open more than one doc.
gboolean modified
If hex_doc->changed <> modified then the document has something changed that may need an upate...
gint find_tab_number_from_widget(heraia_struct_t *main_struct, gchar *notebook_name, GtkWidget *to_find)
Searches in a notebook's tabs for a particular widget and returns the number of the corresponding tab...
GtkWidget * gtk_radio_button_get_active_from_widget(GtkRadioButton *radio_button)
gets the active radio button from a radio group
selection_t * ghex_get_selection(GtkWidget *hex_widget)
Retrieves the selection made (if any) in the hex widget.
HERAIA_ERROR heraia_hex_document_save_as(doc_t *current_doc, gchar *filename)
Saves an opened and edited document to a new file.
void on_fr_activate(GtkWidget *widget, gpointer data)
Find and replace, Search menu.
doc_t * new_doc_t(Heraia_Document *hex_doc, GtkWidget *hex_widget)
Inits a doc_t structure.
GList * location_list
this is the location list where we store some paths
void on_new_activate(GtkWidget *widget, gpointer data)
New, file menu.
void destroy_dt_window(GtkWidget *widget, GdkEvent *event, gpointer data)
call back function for the data interpretor window destruction
void on_paste_activate(GtkWidget *widget, gpointer data)
Paste, edit menu.
void init_window_states(heraia_struct_t *main_struct)
Inits all windows states (positions, displayed, and so on...)
void load_preferences(heraia_struct_t *main_struct, prefs_t *prefs)
Sets up the preferences as loaded in the preference file.
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...
int load_heraia_ui(heraia_struct_t *main_struct)
Loads, if possible, the gtkbuilder xml file and then connects the signals and inits the following win...
static gboolean close_heraia(heraia_struct_t *main_struct)
Before closing heraia we need to do few things.
void connect_cursor_moved_signal(heraia_struct_t *main_struct, GtkWidget *hex_widget)
Connects the signal that the cursor has moved to the refreshing function.