55 GtkWidget *window = NULL;
57 if (main_struct != NULL && main_struct->
current_doc != NULL)
72 if (main_struct != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
113 GtkWidget *window = NULL;
115 if (main_struct != NULL)
134 GtkTreeModel *model = NULL;
135 GtkWidget *result_notebook = NULL;
138 doc_t *the_doc = NULL;
140 if (main_struct != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
144 if (gtk_tree_selection_get_selected(selection, &model, &iter))
146 gtk_tree_model_get(model, &iter,
R_LS_POS, &a_pos, -1);
147 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(result_notebook));
148 the_doc = g_ptr_array_index(main_struct->
results, index);
149 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Search result index : %d "), index);
175 guint a_buf_size = 0;
179 a_buf_size = *buffer_size;
181 if ((a_pos + a_buf_size) > file_size)
183 gap = file_size - a_pos - size;
193 a_buf_size = (2 * gap) + size;
200 a_buf_size = 8 + size;
204 a_buf_size = (2 * a_pos) + size;
210 *buffer_size = a_buf_size;
222 GtkWidget *notebook = NULL;
228 g_ptr_array_remove_index(main_struct->
results, tab_number);
232 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), tab_number);
245 GtkWidget *vbox = NULL;
246 GtkWidget *scrolledw = NULL;
247 GtkWidget *notebook = NULL;
248 GtkWidget *tview = NULL;
249 GtkWidget *tab_label = NULL;
250 GtkWidget *hbox = NULL;
251 GtkCellRenderer *renderer = NULL;
252 GtkTreeViewColumn *column = NULL;
253 GtkTreeSelection *select = NULL;
255 gchar *markup = NULL;
256 gchar *menu_markup = NULL;
257 GtkWidget *menu_label = NULL;
258 gchar *whole_filename = NULL;
263 #if GTK_MAJOR_VERSION < 3
265 vbox = gtk_vbox_new(FALSE, 2);
267 #if GTK_MAJOR_VERSION >= 3
268 #if GTK_MINOR_VERSION <= 1
270 vbox = gtk_vbox_new(FALSE, 2);
272 #if GTK_MINOR_VERSION >= 2
274 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
278 scrolledw = gtk_scrolled_window_new(NULL, NULL);
279 tview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(lstore));
280 gtk_box_pack_start(GTK_BOX(vbox), scrolledw, TRUE, TRUE, 0);
281 gtk_container_add(GTK_CONTAINER(scrolledw), tview);
283 g_object_unref(lstore);
286 renderer = gtk_cell_renderer_text_new();
287 column = gtk_tree_view_column_new_with_attributes(Q_(
"Number"), renderer,
"text",
R_LS_N, NULL);
288 gtk_tree_view_append_column(GTK_TREE_VIEW(tview), column);
291 renderer = gtk_cell_renderer_text_new();
292 column = gtk_tree_view_column_new_with_attributes(Q_(
"Position"), renderer,
"text",
R_LS_POS, NULL);
293 gtk_tree_view_append_column(GTK_TREE_VIEW(tview), column);
296 renderer = gtk_cell_renderer_text_new();
297 column = gtk_tree_view_column_new_with_attributes(Q_(
"Hex"), renderer,
"text",
R_LS_HEX, NULL);
298 gtk_tree_view_append_column(GTK_TREE_VIEW(tview), column);
301 renderer = gtk_cell_renderer_text_new();
302 column = gtk_tree_view_column_new_with_attributes(Q_(
"Ascii"), renderer,
"text",
R_LS_ASCII, NULL);
303 gtk_tree_view_append_column(GTK_TREE_VIEW(tview), column);
306 select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tview));
307 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
313 if (label_text != NULL)
315 tab_label = gtk_label_new(NULL);
316 markup = g_markup_printf_escaped(
"%s", label_text);
317 gtk_label_set_markup(GTK_LABEL(tab_label), markup);
319 menu_label = gtk_label_new(NULL);
320 menu_markup = g_markup_printf_escaped(
"%s", label_text);
321 gtk_label_set_markup(GTK_LABEL(menu_label), menu_markup);
322 gtk_label_set_justify(GTK_LABEL(menu_label), GTK_JUSTIFY_LEFT);
325 gtk_widget_set_tooltip_text(tab_label, g_filename_display_name(whole_filename));
334 gtk_widget_show_all(vbox);
335 tab_num = gtk_notebook_append_page_menu(GTK_NOTEBOOK(notebook), vbox, hbox, menu_label);
338 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), tab_num);
340 gtk_widget_show_all(notebook);
354 GtkListStore *lstore = NULL;
357 guint64 real_pos = 0;
358 guint64 file_size = 0 ;
359 doc_t *current_doc = NULL;
361 guint buffer_size = 0;
363 guchar *ascii_buffer = NULL;
364 guchar *hex_buffer = NULL;
366 guchar *label_text = NULL;
370 g_ptr_array_add(main_struct->
results, current_doc);
377 lstore = gtk_list_store_new(
R_LS_N_COLUMNS, G_TYPE_UINT, G_TYPE_UINT64, G_TYPE_STRING, G_TYPE_STRING);
379 for (i = 0; i < all_pos->len; i++)
381 pos = g_array_index(all_pos, guint64, i);
389 if (ascii_buffer != NULL && hex_buffer != NULL)
391 gtk_list_store_append(lstore, &iter);
392 gtk_list_store_set(lstore, &iter,
R_LS_N, i + 1,
R_LS_POS, real_pos + 1,
R_LS_HEX, hex_buffer,
R_LS_ASCII, ascii_buffer, -1);
394 log_message(main_struct, G_LOG_LEVEL_DEBUG,
"%lld : %d, %s - %s", pos, buffer_size, ascii_buffer, hex_buffer);
396 g_free(ascii_buffer);
408 label_text = (guchar *) g_strdup((gchar *) text);
425 GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(widget);
426 gboolean checked = gtk_check_menu_item_get_active(cmi);
451 GList *widget_list = NULL;
452 GtkWidget *widget = NULL;
454 GtkTreeSelection *selection = NULL;
459 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Page : %p, %d"), page, page_num);
461 widget_list = gtk_container_get_children(GTK_CONTAINER(gtk_notebook_get_nth_page(notebook, page_num)));
463 while (widget_list != NULL && ok != TRUE)
465 widget = widget_list->data;
468 log_message(main_struct, G_LOG_LEVEL_DEBUG,
"Widget : %p, %s",widget, gtk_widget_get_name(widget));
470 if GTK_IS_SCROLLED_WINDOW(widget)
472 widget = gtk_bin_get_child(GTK_BIN(widget));
475 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
476 if (selection != NULL)
481 gtk_tree_selection_unselect_all(selection);
485 widget_list = g_list_next(widget_list);
528 GtkWidget *notebook = NULL;
531 if (main_struct != NULL && main_struct->
results != NULL)
535 len = main_struct->
results->len;
541 value = g_ptr_array_index(main_struct->
results, i);
545 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Removing index %d."), i);
546 g_ptr_array_remove_index(main_struct->
results, i);
547 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i);
548 len = main_struct->
results->len;
static void result_window_close(GtkWidget *widget, gpointer data)
Close button has been clicked we want to hide the window.
GPtrArray * results
An array of pointers (doc_t *) for each tab in the result window.
This is the main structure.
static void rw_on_close_activate(GtkWidget *widget, gpointer data)
Closes a result tab.
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
gchar * doc_t_document_get_filename(doc_t *doc)
Retrieves from a doc_t * document it's filename, which ever it is.
static void menu_result_toggle(GtkWidget *widget, gpointer data)
The Check menu item for the result 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.
void record_and_hide_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Record position and hide a dialog box.
all_window_prop_t * win_prop
Keeps window properties.
guint64 ghex_file_size(Heraia_Hex *gh)
Returns the file size of an opened Heraia_Hex document.
guchar * ghex_get_data_to_ascii(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness)
Gets data from a defined position and formats it in an ascii displayable form.
static void determine_pos_and_buffer_size(guint64 *pos, guint *buffer_size, guint size, guint64 file_size)
Calculates the position and the associated buffer size in order that the text searched for will be ce...
Proposal for a structure that will group all informations about a single document.
static void rw_on_notebook_switch_page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data)
Function called when the user switches the pages from the notebook.
#define H_DI_LITTLE_ENDIAN
Stands for little endian representation (this is the default)
xml_t * xmls
All the xmls used in the program, loaded at running time.
void rw_add_one_tab_from_find_all_bt(heraia_struct_t *main_struct, GArray *all_pos, guint size, guchar *text)
Add one tab for the results from the find all button.
static void tree_selection_changed(GtkTreeSelection *selection, gpointer data)
Function called upon selection change.
static gboolean delete_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the result window destruction.
static void destroy_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the result window destruction.
GtkWidget * hex_widget
hexwidget corresponding to the document
void result_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the result window (signal and such)
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...
This file contains all the definitions and includes all other .h files.
void ghex_set_cursor_position(GtkWidget *hex_widget, guint64 position)
Sets the cursor at the defined position in the hexwidget.
guchar * ghex_get_data_to_hex(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness)
Gets data from a defined position and formats it in an hex displayable form.
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.
static void add_gtk_tree_view_to_result_notebook(heraia_struct_t *main_struct, GtkListStore *lstore, guchar *label_text, doc_t *doc)
Add one tab to the result window's notebook with a gtk_tree_view in it.
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. ...
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...
void result_window_show(GtkWidget *widget, gpointer data)
Show result window.
static void result_window_connect_signal(heraia_struct_t *main_struct)
Signal connections for the result window.