Heraia  0.1.8
result_window.c
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  result_window.c
4  result_window.c - A window that will collect all results of functions such as
5  find, find a data from type, ...
6 
7  (C) Copyright 2010 - 2011 Olivier Delhomme
8  e-mail : heraia@delhomme.org
9  URL : http://heraia.tuxfamily.org
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2, or (at your option)
14  any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 */
25 /**
26  * @file result_window.c
27  * Manage results coming from functions such as find, find a data from type,
28  * and so on.
29  */
30 #include <libheraia.h>
31 
32 static gboolean delete_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
33 static void destroy_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
34 static void result_window_close(GtkWidget *widget, gpointer data);
35 static void result_window_connect_signal(heraia_struct_t *main_struct);
36 
37 static void tree_selection_changed(GtkTreeSelection *selection, gpointer data);
38 static void rw_on_close_activate(GtkWidget *widget, gpointer data);
39 
40 static void determine_pos_and_buffer_size(guint64 *pos, guint *buffer_size, guint size, guint64 file_size);
41 static void add_gtk_tree_view_to_result_notebook(heraia_struct_t *main_struct, GtkListStore *lstore, guchar *label_text, doc_t *doc);
42 
43 static void menu_result_toggle(GtkWidget *widget, gpointer data);
44 
45 
46 /**
47  * Show result window
48  * @param widget : the widget that issued the signal (may be NULL as we do not
49  * use it).
50  * @param data : user data MUST be heraia_struct_t *main_struct main structure
51  */
52 void result_window_show(GtkWidget *widget, gpointer data)
53 {
54  heraia_struct_t *main_struct = (heraia_struct_t *) data;
55  GtkWidget *window = NULL; /**< result window itself */
56 
57  if (main_struct != NULL && main_struct->current_doc != NULL)
58  {
59  window = heraia_get_widget(main_struct->xmls->main, "result_window");
60  move_and_show_dialog_box(window, main_struct->win_prop->result_window);
61  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(heraia_get_widget(main_struct->xmls->main, "menu_result")), TRUE);
62  }
63 }
64 
65 
66 /**
67  * Inits all the things in the result window (signal and such)
68  * @param main_struct : heraia's main structure
69  */
71 {
72  if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
73  {
74  result_window_connect_signal(main_struct);
75  }
76 }
77 
78 
79 /**
80  * Call back function for the result window destruction
81  * @param widget : calling widget (may be NULL as we don't use this here)
82  * @param event : event associated (may be NULL as we don't use this here)
83  * @param data : MUST be heraia_struct_t *main_struct main structure
84  */
85 static gboolean delete_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
86 {
87  result_window_close(widget, data);
88 
89  return TRUE;
90 }
91 
92 
93 /**
94  * Call back function for the result window destruction
95  * @param widget : calling widget (may be NULL as we don't use this here)
96  * @param event : event associated (may be NULL as we don't use this here)
97  * @param data : user data - MUST be heraia_struct_t *main_struct main structure and not NULL
98  */
99 static void destroy_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
100 {
101  result_window_close(widget, data);
102 }
103 
104 
105 /**
106  * Close button has been clicked we want to hide the window
107  * @param widget : calling widget
108  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
109  */
110 static void result_window_close(GtkWidget *widget, gpointer data)
111 {
112  heraia_struct_t *main_struct = (heraia_struct_t *) data;
113  GtkWidget *window = NULL; /**< result window itself */
114 
115  if (main_struct != NULL)
116  {
117  window = heraia_get_widget(main_struct->xmls->main, "result_window");
118  record_and_hide_dialog_box(window, main_struct->win_prop->result_window);
119  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(heraia_get_widget(main_struct->xmls->main, "menu_result")), FALSE);
120  }
121 }
122 
123 
124 /**
125  * Function called upon selection change. Changes the cursor position to the
126  * right place (should also change to the right document).
127  * @param selection : the selection that changed
128  * @param data : user data MUST be main program's structure
129  */
130 static void tree_selection_changed(GtkTreeSelection *selection, gpointer data)
131 {
132  heraia_struct_t *main_struct = (heraia_struct_t *) data;
133  GtkTreeIter iter;
134  GtkTreeModel *model = NULL;
135  GtkWidget *result_notebook = NULL;
136  guint64 a_pos = 0;
137  gint index = 0;
138  doc_t *the_doc = NULL;
139 
140  if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
141  {
142  result_notebook = heraia_get_widget(main_struct->xmls->main, "result_notebook");
143 
144  if (gtk_tree_selection_get_selected(selection, &model, &iter))
145  {
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);
150 
151  if (the_doc != NULL)
152  {
153  /* Change file's notebook tab in main window to display the_doc document if it is possible */
154  ghex_set_cursor_position(the_doc->hex_widget, a_pos - 1);
155  }
156  }
157  }
158 }
159 
160 
161 /**
162  * Calculates the position and the associated buffer size in order that the text
163  * searched for will be centered in the results
164  * @param pos : Must be the position of the searched text, is returned as the
165  * position where we will extract the text
166  * @param buffer_size : is returned as the total buffer size (the extracted text
167  * will be buffer_size + 1 in size)
168  * @param size : size of the string searched for (in bytes)
169  * @param file_size : size of the file (to verify that we are still in the
170  * limits
171  */
172 static void determine_pos_and_buffer_size(guint64 *pos, guint *buffer_size, guint size, guint64 file_size)
173 {
174  guint64 a_pos = 0;
175  guint a_buf_size = 0;
176  gint gap = 0;
177 
178  a_pos = *pos;
179  a_buf_size = *buffer_size;
180 
181  if ((a_pos + a_buf_size) > file_size)
182  {
183  gap = file_size - a_pos - size;
184  if (gap < 0)
185  {
186  gap = 0;
187  }
188  else if (gap > 4)
189  {
190  gap = 4;
191  }
192  a_pos = a_pos - gap;
193  a_buf_size = (2 * gap) + size;
194  }
195  else
196  {
197  if (a_pos >= 4)
198  {
199  a_pos = a_pos - 4;
200  a_buf_size = 8 + size; /* we want to have 4 bytes before and 4 bytes after the result to be displayed */
201  }
202  else
203  {
204  a_buf_size = (2 * a_pos) + size;
205  a_pos = 0;
206  }
207  }
208 
209  *pos = a_pos;
210  *buffer_size = a_buf_size;
211 }
212 
213 
214 /**
215  * Closes a result tab
216  * @param widget : the widget that issued the signal
217  * @param data : user data MUST be heraia_struct_t *main_struct main structure
218  */
219 static void rw_on_close_activate(GtkWidget *widget, gpointer data)
220 {
221  heraia_struct_t *main_struct = (heraia_struct_t *) data;
222  GtkWidget *notebook = NULL; /**< result_notebook from heraia.gtkbuilder */
223  gint tab_number = 0; /**< index of the tab (and thus from the array) */
224 
225  tab_number = find_tab_number_from_widget(main_struct, "result_notebook", widget);
226 
227  /* Removing the index in the array */
228  g_ptr_array_remove_index(main_struct->results, tab_number);
229 
230  /* And removing it in the notebook */
231  notebook = heraia_get_widget(main_struct->xmls->main, "result_notebook");
232  gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), tab_number);
233 }
234 
235 
236 /**
237  * Add one tab to the result window's notebook with a gtk_tree_view in it
238  * @param main_struct : main structure of heraia
239  * @param lstore : the populated list store (for the tree view)
240  * @param label_text : the text for the label of the tab
241  * @param doc : the document from which the search was done
242  */
243 static void add_gtk_tree_view_to_result_notebook(heraia_struct_t *main_struct, GtkListStore *lstore, guchar *label_text, doc_t *doc)
244 {
245  GtkWidget *vbox = NULL; /**< used for vbox creation */
246  GtkWidget *scrolledw = NULL; /**< the scrolled window */
247  GtkWidget *notebook = NULL; /**< result_notebook from heraia.gtkbuilder */
248  GtkWidget *tview = NULL; /**< the tree view */
249  GtkWidget *tab_label = NULL; /**< tab's label */
250  GtkWidget *hbox = NULL; /**< the hbox that will receive the close button */
251  GtkCellRenderer *renderer = NULL; /**< a rennderer for the cells */
252  GtkTreeViewColumn *column = NULL; /**< columns to be added to the treeview */
253  GtkTreeSelection *select = NULL; /**< selection to the treeview */
254  gint tab_num = -1; /**< new tab's index */
255  gchar *markup = NULL; /**< markup text */
256  gchar *menu_markup = NULL; /**< menu markup text (menu in the notebook) */
257  GtkWidget *menu_label = NULL; /**<menu's label (notebook's menu) */
258  gchar *whole_filename = NULL; /**< filename of the document from where the
259  search took place */
260 
261  notebook = heraia_get_widget(main_struct->xmls->main, "result_notebook");
262 
263  #if GTK_MAJOR_VERSION < 3
264  /* valid in GTK+ 2.x */
265  vbox = gtk_vbox_new(FALSE, 2);
266  #endif
267  #if GTK_MAJOR_VERSION >= 3
268  #if GTK_MINOR_VERSION <= 1
269  /* valid in GTK+ 3.0 and 3.1 */
270  vbox = gtk_vbox_new(FALSE, 2);
271  #endif
272  #if GTK_MINOR_VERSION >= 2
273  /* only valid from GTK 3.2 */
274  vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
275  #endif
276  #endif
277 
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);
282 
283  g_object_unref(lstore);
284 
285  /* Column Number (1....21321) the number of columns */
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);
289 
290  /* Column Position (23, 545, 879, 1324, ...) the positions of the text found */
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);
294 
295  /* Column Hex : Hexadecimal text as found in the file */
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);
299 
300  /* Column Ascii : Normal text found in the file (if printable) */
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);
304 
305  /* Signal handling */
306  select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tview));
307  gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
308  g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(tree_selection_changed), main_struct);
309 
310  tree_selection_changed(gtk_tree_view_get_selection(GTK_TREE_VIEW(tview)), main_struct);
311 
312  /* tab's label, menu label and tooltips */
313  if (label_text != NULL)
314  {
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);
318 
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);
323 
324  whole_filename = doc_t_document_get_filename(doc);
325  gtk_widget_set_tooltip_text(tab_label, g_filename_display_name(whole_filename));
326 
327  g_free(markup);
328  g_free(menu_markup);
329  }
330 
331  /* Creating the close button */
332  hbox = create_tab_close_button(main_struct, tab_label, rw_on_close_activate);
333 
334  gtk_widget_show_all(vbox);
335  tab_num = gtk_notebook_append_page_menu(GTK_NOTEBOOK(notebook), vbox, hbox, menu_label);
336 
337  /* Displaying the just added tab */
338  gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), tab_num);
339 
340  gtk_widget_show_all(notebook);
341 }
342 
343 
344 /**
345  * Add one tab for the results from the find all button
346  * @param main_struct : main structure of heraia
347  * @param all_pos : A GArray of all found positions
348  * @param size : size of the string searched for (in bytes)
349  * @param text : the text for the label of the newly created tab. If NULL, a text
350  * is guessed from the last found position and the text found
351  */
352 void rw_add_one_tab_from_find_all_bt(heraia_struct_t *main_struct, GArray *all_pos, guint size, guchar *text)
353 {
354  GtkListStore *lstore = NULL; /**< List store that will contain results */
355  guint i = 0;
356  guint64 pos = 0; /**< a calculated position to center the search string */
357  guint64 real_pos = 0; /**< real position */
358  guint64 file_size = 0 ; /**< size of the file during the search (should not change) */
359  doc_t *current_doc = NULL; /**< Current document on which we want to do the search */
360  gint endianness = H_DI_LITTLE_ENDIAN; /**< endianness as selected in the data interpretor window */
361  guint buffer_size = 0; /**< buffer size (bigger than size in order to display */
362  /** some byte before and after the results) */
363  guchar *ascii_buffer = NULL; /**< the ascii buffer */
364  guchar *hex_buffer = NULL; /**< the hex buffer */
365  GtkTreeIter iter;
366  guchar *label_text = NULL; /**< text label */
367 
368 
369  current_doc = main_struct->current_doc;
370  g_ptr_array_add(main_struct->results, current_doc);
371 
372  endianness = H_DI_LITTLE_ENDIAN; /** Endianness by default (we want the search to be flat) -> However this may
373  be modified if someone asks for */
374  file_size = ghex_file_size(GTK_HEX(current_doc->hex_widget));
375 
376  /* The columns : R_LS_N (G_TYPE_UINT), R_LS_POS (G_TYPE_UINT64), R_LS_HEX (G_TYPE_STRING), R_LS_ASCII (G_TYPE_STRING) */
377  lstore = gtk_list_store_new(R_LS_N_COLUMNS, G_TYPE_UINT, G_TYPE_UINT64, G_TYPE_STRING, G_TYPE_STRING);
378 
379  for (i = 0; i < all_pos->len; i++)
380  {
381  pos = g_array_index(all_pos, guint64, i);
382  real_pos = pos;
383 
384  determine_pos_and_buffer_size(&pos, &buffer_size, size, file_size);
385 
386  ascii_buffer = ghex_get_data_to_ascii(current_doc->hex_widget, pos, buffer_size, endianness);
387  hex_buffer = ghex_get_data_to_hex(current_doc->hex_widget, pos, buffer_size, endianness);
388 
389  if (ascii_buffer != NULL && hex_buffer != NULL)
390  {
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);
393 
394  log_message(main_struct, G_LOG_LEVEL_DEBUG, "%lld : %d, %s - %s", pos, buffer_size, ascii_buffer, hex_buffer);
395 
396  g_free(ascii_buffer);
397  g_free(hex_buffer);
398  }
399  }
400 
401  if (text == NULL)
402  {
403  /* Using last pos to retrieve the text for the label */
404  label_text = ghex_get_data_to_ascii(current_doc->hex_widget, real_pos, size, endianness);
405  }
406  else
407  {
408  label_text = (guchar *) g_strdup((gchar *) text);
409  }
410 
411  add_gtk_tree_view_to_result_notebook(main_struct, lstore, label_text, current_doc);
412 
413  result_window_show(NULL, main_struct);
414 }
415 
416 
417 /**
418  * The Check menu item for the result window
419  * @param widget : the widget that issued the signal (here the menu_result check
420  * menu item
421  * @param data : user data, MUST be main_struct main structure
422  */
423 static void menu_result_toggle(GtkWidget *widget, gpointer data)
424 {
425  GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(widget);
426  gboolean checked = gtk_check_menu_item_get_active(cmi);
427 
428  if (checked == TRUE)
429  {
430  result_window_show(widget, data);
431  }
432  else
433  {
434  result_window_close(widget, data);
435  }
436 }
437 
438 
439 /**
440  * Function called when the user switches the pages from the notebook. Here we
441  * unselect the selection if any. This is to let the user be able to select
442  * again the first row if there is only one row in the treeview.
443  * @param notebook : result window's notebook object which received the signal.
444  * @param page : the new current page
445  * @param page_num : the index of the page (the new one)
446  * @param data :user data, MUST be main_struct main structure
447  */
448 static void rw_on_notebook_switch_page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data)
449 {
450  heraia_struct_t *main_struct = (heraia_struct_t *) data;
451  GList *widget_list = NULL; /** The list of the widgets in the page */
452  GtkWidget *widget = NULL;
453  gboolean ok = FALSE;
454  GtkTreeSelection *selection = NULL; /** The selection (if any) to be unselected */
455 
456  if (page != NULL)
457  {
458  /* Page indicates the selected notebook's page */
459  log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_("Page : %p, %d"), page, page_num);
460 
461  widget_list = gtk_container_get_children(GTK_CONTAINER(gtk_notebook_get_nth_page(notebook, page_num)));
462 
463  while (widget_list != NULL && ok != TRUE)
464  {
465  widget = widget_list->data;
466 
467  /* Widget is the GtkWidget being processed */
468  log_message(main_struct, G_LOG_LEVEL_DEBUG, "Widget : %p, %s",widget, gtk_widget_get_name(widget));
469 
470  if GTK_IS_SCROLLED_WINDOW(widget) /* If this is the scrolled window, get the tree view that is in it */
471  {
472  widget = gtk_bin_get_child(GTK_BIN(widget));
473  ok = TRUE;
474 
475  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
476  if (selection != NULL)
477  {
478  /* Unselect the selection -> this allows one to reselect the same
479  * raw (in case that there is only one raw in the results
480  */
481  gtk_tree_selection_unselect_all(selection);
482  }
483  }
484 
485  widget_list = g_list_next(widget_list);
486  }
487  }
488 }
489 
490 
491 /**
492  * Signal connections for the result window
493  * @param main_struct : heraia's main structure
494  */
496 {
497  /* Close button */
498  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "rw_close_bt")), "clicked",
499  G_CALLBACK(result_window_close), main_struct);
500 
501  /* When result window is killed or destroyed */
502  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "result_window")), "delete_event",
503  G_CALLBACK(delete_result_window_event), main_struct);
504 
505  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "result_window")), "destroy",
506  G_CALLBACK(destroy_result_window_event), main_struct);
507 
508  /* The toogle button in the main menu*/
509  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "menu_result")), "toggled",
510  G_CALLBACK(menu_result_toggle), main_struct);
511 
512  /* Switch pages on the notebook */
513  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "result_notebook")), "switch-page",
514  G_CALLBACK(rw_on_notebook_switch_page), main_struct);
515 }
516 
517 
518 /**
519  * Remove all tabs from the result window that correspond to the specified
520  * document.
521  * @param main_struct : heraia's main structure
522  * @param doc : the document beeing close in main window's notebook
523  */
524 void rw_remove_all_tabs(heraia_struct_t *main_struct, doc_t *doc)
525 {
526  gint i = 0;
527  gint len = 0; /**< total len of result array */
528  GtkWidget *notebook = NULL; /**< result_notebook from heraia.gtkbuilder */
529  doc_t *value = NULL; /**< Value to compare with doc */
530 
531  if (main_struct != NULL && main_struct->results != NULL)
532  {
533  notebook = heraia_get_widget(main_struct->xmls->main, "result_notebook");
534 
535  len = main_struct->results->len;
536 
537  /* looking for the results */
538  i = 0;
539  while (i < len)
540  {
541  value = g_ptr_array_index(main_struct->results, i);
542 
543  if (value == doc)
544  {
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;
549  }
550  else
551  {
552  i = i + 1;
553  }
554  }
555  }
556 }
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.
Definition: libheraia.h:348
This is the main structure.
Definition: libheraia.h:332
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)...
Definition: heraia_ui.c:2505
window_prop_t * result_window
result window properties
Definition: libheraia.h:269
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.
Definition: log.c:195
void record_and_hide_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Record position and hide a dialog box.
Definition: heraia_ui.c:314
all_window_prop_t * win_prop
Keeps window properties.
Definition: libheraia.h:342
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.
Definition: libheraia.h:293
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.
Definition: libheraia.h:337
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.
Definition: result_window.c:85
static void destroy_result_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the result window destruction.
Definition: result_window.c:99
GtkWidget * hex_widget
hexwidget corresponding to the document
Definition: libheraia.h:296
void result_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the result window (signal and such)
Definition: result_window.c:70
GtkBuilder * main
the main interface xml description
Definition: libheraia.h:222
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...
Definition: heraia_ui.c:193
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.
Definition: libheraia.h:335
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
Definition: heraia_ui.c:2184
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...
Definition: heraia_ui.c:745
void result_window_show(GtkWidget *widget, gpointer data)
Show result window.
Definition: result_window.c:52
static void result_window_connect_signal(heraia_struct_t *main_struct)
Signal connections for the result window.