Heraia  0.1.8
find_replace_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  find_replace_window.c
4  find_replace_window.c - Windows used to find text and find and replace text in
5  the opened hex documents.
6 
7 
8  (C) Copyright 2010 - 2013 Olivier Delhomme
9  e-mail : heraia@delhomme.org
10  URL : http://heraia.tuxfamily.org
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2, or (at your option)
15  any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 */
26 /**
27  * @file find_replace_window.c
28  * Windows used to find text and find and replace text in the opened hex
29  * documents.
30  */
31 #include <libheraia.h>
32 
33 /*** common stuff ***/
34 static guchar *fr_get_search_string(heraia_struct_t * main_struct, doc_t *doc, guint *buffer_size);
36 static void find_replace_add_ghex_widget(xml_t *xmls, gchar *widget_name, doc_t *entry);
37 static void fr_search_forward(heraia_struct_t *main_struct, doc_t *search_doc, goffset offset);
38 
39 /*** find window ***/
40 static gboolean delete_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
41 static void destroy_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
42 static void find_window_close(GtkWidget *widget, gpointer data);
43 static void find_window_connect_signal(heraia_struct_t *main_struct);
44 static void find_all_bt_clicked(GtkWidget *widget, gpointer data);
45 static void find_next_bt_clicked(GtkWidget *widget, gpointer data);
46 static void find_prev_bt_clicked(GtkWidget *widget, gpointer data);
47 
48 /*** find and replace window ***/
49 static gboolean delete_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
50 static void destroy_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
51 static void fr_window_close(GtkWidget *widget, gpointer data);
52 static void fr_window_connect_signal(heraia_struct_t *main_struct);
53 static void fr_search_bt_clicked(GtkWidget *widget, gpointer data);
54 static void fr_replace_bt_clicked(GtkWidget *widget, gpointer data);
55 static void fr_replace_search_bt_clicked(GtkWidget *widget, gpointer data);
56 static goffset fr_replace_data(heraia_struct_t *main_struct);
57 
58 
59 /*** fdft window ***/
60 static gboolean delete_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
61 static void destroy_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
62 static fdft_t *fdft_window_init_widgets(heraia_struct_t * main_struct);
63 static void fdft_window_close(GtkWidget *widget, gpointer data);
64 static void fdft_window_connect_signal(heraia_struct_t *main_struct);
65 
66 /**
67  * Show find window
68  * @param widget : the widget that issued the signal
69  * @param data : user data MUST be heraia_struct_t *main_struct main structure
70  */
71 void find_window_show(GtkWidget *widget, gpointer data)
72 {
73  heraia_struct_t *main_struct = (heraia_struct_t *) data;
74  GtkWidget *window = NULL; /**< find window */
75 
76  if (main_struct != NULL && main_struct->current_doc != NULL)
77  {
78  window = heraia_get_widget(main_struct->xmls->main, "find_window");
79  show_hide_widget(window, TRUE, main_struct->win_prop->find_window);
80  }
81 }
82 
83 
84 /**
85  * Call back function for the find window destruction
86  * @param widget : calling widget (may be NULL as we don't use this here)
87  * @param event : event associated (may be NULL as we don't use this here)
88  * @param data : MUST be heraia_struct_t *main_struct main structure
89  */
90 static gboolean delete_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
91 {
92  find_window_close(widget, data);
93 
94  return TRUE;
95 }
96 
97 
98 /**
99  * Call back function for the find window destruction
100  * @param widget : calling widget (may be NULL as we don't use this here)
101  * @param event : event associated (may be NULL as we don't use this here)
102  * @param data : user data - MUST be heraia_struct_t *main_struct main structure and not NULL
103  */
104 static void destroy_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
105 {
106  find_window_close(widget, data);
107 }
108 
109 
110 /**
111  * Close button has been clicked we want to hide the window
112  * @param widget : calling widget (may be NULL as we don't use this here)
113  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
114  */
115 static void find_window_close(GtkWidget *widget, gpointer data)
116 {
117  heraia_struct_t *main_struct = (heraia_struct_t *) data;
118  GtkWidget *window = NULL; /**< find window */
119 
120  if (main_struct != NULL)
121  {
122  window = heraia_get_widget(main_struct->xmls->main, "find_window");
123  show_hide_widget(window, FALSE, main_struct->win_prop->find_window);
124  }
125 
126 }
127 
128 
129 /**
130  * Tries to find, in the document, what the user entered in the GtkHex entry in
131  * the find window (forward from the current position)
132  * @param widget : calling widget (may be NULL as we don't use this here)
133  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
134  */
135 static void find_next_bt_clicked(GtkWidget *widget, gpointer data)
136 {
137  heraia_struct_t *main_struct = (heraia_struct_t *) data;
138 
139  if (main_struct != NULL && main_struct->find_doc != NULL)
140  {
141  fr_search_forward(main_struct, main_struct->find_doc, 0);
142  }
143 }
144 
145 
146 /**
147  * Tries to find, in the document, what the user entered in the GtkHex entry in
148  * the find window (backward from the current position)
149  * @param widget : calling widget (may be NULL as we don't use this here)
150  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
151  */
152 static void find_prev_bt_clicked(GtkWidget *widget, gpointer data)
153 {
154  heraia_struct_t *main_struct = (heraia_struct_t *) data;
155  guchar *buffer = NULL; /**< Buffer that contains the search string */
156  doc_t *current_doc = NULL; /**< Current doc where we want to search for the string */
157  gboolean result = FALSE;
158  guint64 position = 0;
159  guint buffer_size = 0;
160 
161  if (main_struct != NULL)
162  {
163  buffer = fr_get_search_string(main_struct, main_struct->find_doc, &buffer_size);
164 
165  if (buffer != NULL)
166  {
167  current_doc = main_struct->current_doc;
168  position = ghex_get_cursor_position(current_doc->hex_widget) + 1 ;
169  result = ghex_find_backward(current_doc, buffer, buffer_size, &position);
170 
171  if (result == TRUE)
172  {
173  ghex_set_cursor_position(current_doc->hex_widget, position);
174  }
175  }
176  }
177 }
178 
179 
180 /**
181  * Tries to find, in the document, what the user entered in the GtkHex entry in
182  * the find window (all positions from 0)
183  * @param widget : calling widget (may be NULL as we don't use this here)
184  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
185  */
186 static void find_all_bt_clicked(GtkWidget *widget, gpointer data)
187 {
188  heraia_struct_t *main_struct = (heraia_struct_t *) data;
189  guchar *buffer = NULL; /**< Buffer that contains the search string */
190  doc_t *current_doc = NULL; /**< Current doc where we want to search for the string */
191  gboolean result = FALSE;
192  guint64 position = 0;
193  guint buffer_size = 0;
194  GArray *all_pos = NULL; /**< All positions of the searched string */
195 
196  if (main_struct != NULL)
197  {
198  buffer = fr_get_search_string(main_struct, main_struct->find_doc, &buffer_size);
199 
200  if (buffer != NULL)
201  {
202  all_pos = g_array_new(TRUE, TRUE, sizeof(guint64));
203  current_doc = main_struct->current_doc;
204  position = 0;
205  result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
206 
207  while (result == TRUE)
208  {
209  all_pos = g_array_append_val(all_pos, position);
210  result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
211  }
212  }
213  }
214 
215  if (all_pos != NULL)
216  {
217  rw_add_one_tab_from_find_all_bt(main_struct, all_pos, buffer_size, NULL);
218  g_array_free(all_pos, TRUE);
219  }
220 }
221 
222 
223 /**
224  * Signal connections for the find window
225  * @param main_struct : heraia's main structure
226  */
228 {
229  /* Close button */
230  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_close_bt")), "clicked",
231  G_CALLBACK(find_window_close), main_struct);
232 
233  /* Next button */
234  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_next_bt")), "clicked",
235  G_CALLBACK(find_next_bt_clicked), main_struct);
236 
237  /* Prev button */
238  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_prev_bt")), "clicked",
239  G_CALLBACK(find_prev_bt_clicked), main_struct);
240 
241  /* Find all button */
242  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_all_bt")), "clicked",
243  G_CALLBACK(find_all_bt_clicked), main_struct);
244 
245  /* When find window is killed or destroyed */
246  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_window")), "delete_event",
247  G_CALLBACK(delete_find_window_event), main_struct);
248 
249  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_window")), "destroy",
250  G_CALLBACK(destroy_find_window_event), main_struct);
251 }
252 
253 
254 /**
255  * Inits all the things in the find window (signal and such)
256  * @param main_struct : heraia's main structure
257  */
259 {
260 
261  if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
262  {
263  find_window_connect_signal(main_struct);
264 
265  main_struct->find_doc = create_find_or_replace_doc_t();
266 
267  if (main_struct->find_doc != NULL)
268  {
269  find_replace_add_ghex_widget(main_struct->xmls, "find_al", main_struct->find_doc);
270  }
271  }
272 }
273 
274 
275 /******************************************************************************/
276 /******************************* common stuff *********************************/
277 /******************************************************************************/
278 
279 /**
280  * Gets the string from the document doc
281  * @param main_struct : main structure, needed here to compute endianness
282  * @param doc : the document (HexDocument and HexWidget) used to defined the
283  * search string
284  * @return a newly allocated guchar string that may be g_free'ed when no longer
285  * needed
286  */
287 static guchar *fr_get_search_string(heraia_struct_t * main_struct, doc_t *doc, guint *buffer_size)
288 {
289  guint size = 0; /**< size of the search string (we hope that this value is small) */
290  guchar *buffer = NULL; /**< buffer for the search string */
291  guint endianness = 0; /**< endianness as selected in data interpretor's window */
292  gboolean result = FALSE;
293 
294 
295  size = ghex_file_size(GTK_HEX(doc->hex_widget));
296 
297  if (size > 0 && size < 4096) /* Here fixes some limits ! */
298  {
299  buffer = (guchar *) g_malloc0(sizeof(guchar) * size);
300  endianness = which_endianness(main_struct);
301  result = ghex_get_data_position(doc->hex_widget, 0, size, endianness, buffer);
302 
303  if (result == TRUE)
304  {
305  *buffer_size = size;
306  return buffer;
307  }
308  else
309  {
310  *buffer_size = 0;
311  return NULL;
312  }
313  }
314  else
315  {
316  *buffer_size = 0;
317  return NULL;
318  }
319 }
320 
321 
322 /**
323  * Creates the HexDocument and the GtkHex widget with the right properties and
324  * Fills a doc_t structure with them.
325  * @return a newly allocated doc_t structure with HexDocument and GtkHex widget
326  * correctly configured to fit in the find and find and replace windows
327  */
329 {
330  Heraia_Document *find_hex_doc = NULL;
331  GtkWidget *find_hex_widget = NULL;
332 
333  find_hex_doc = hex_document_new();
334 
335  if (find_hex_doc != NULL)
336  {
337  /* creating a new view to this new document */
338  find_hex_widget = hex_document_add_view(find_hex_doc);
339 
340  /* Sets some options : no offests, insert mode and 4 lines of 16 chars */
341  gtk_hex_show_offsets(GTK_HEX(find_hex_widget), FALSE);
342  gtk_hex_set_insert_mode(GTK_HEX(find_hex_widget), TRUE);
343  gtk_hex_set_geometry(GTK_HEX(find_hex_widget), 16, 4);
344 
345  /* joining those two new structures in one */
346  return new_doc_t(find_hex_doc, find_hex_widget);
347  }
348  else
349  {
350  return NULL;
351  }
352 }
353 
354 
355 /**
356  * Adds the GtkHex widget to the right frame
357  * @param xmls : xmls structure
358  * @param widget_name : the widget that will receive the GtkHex widget (a frame)
359  * @param entry : the doc_t structure that contains document and gtkhex widget
360  * used as an entry field
361  */
362 static void find_replace_add_ghex_widget(xml_t *xmls, gchar *widget_name, doc_t *entry)
363 {
364  GtkWidget *al = NULL;
365 
366  al = heraia_get_widget(xmls->main, widget_name);
367  gtk_container_add(GTK_CONTAINER(al), entry->hex_widget);
368  gtk_container_set_border_width(GTK_CONTAINER(al), 3);
369 }
370 
371 
372 /**
373  * Searches the string entered in the search document in the current one (from
374  * the currenty position + offset) in the main window.
375  * @param main_struct : heraia's main structure
376  * @param search_doc : the document used to enter the searched string
377  * @param offset : the offset from the current position to begin the search.
378  */
379 static void fr_search_forward(heraia_struct_t *main_struct, doc_t *search_doc, goffset offset)
380 {
381  guchar *buffer = NULL; /**< Buffer that contains the search string */
382  doc_t *current_doc = NULL; /**< Current doc where we want to search for the string */
383  gboolean result = FALSE;
384  guint64 position = 0;
385  guint buffer_size = 0;
386 
387  buffer = fr_get_search_string(main_struct, search_doc, &buffer_size);
388 
389  if (buffer != NULL)
390  {
391  current_doc = main_struct->current_doc;
392  position = ghex_get_cursor_position(current_doc->hex_widget);
393  position = position + offset;
394  result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
395 
396  if (result == TRUE)
397  {
398  ghex_set_cursor_position(current_doc->hex_widget, position);
399  }
400  }
401 }
402 
403 
404 /******************************************************************************/
405 /************************** find and replace window ***************************/
406 /******************************************************************************/
407 
408 
409 /**
410  * Show find and replace window
411  * @param widget : the widget that issued the signal
412  * @param data : user data MUST be heraia_struct_t *main_struct main structure
413  */
414 void fr_window_show(GtkWidget *widget, gpointer data)
415 {
416  heraia_struct_t *main_struct = (heraia_struct_t *) data;
417  GtkWidget *window = NULL; /**< find window */
418 
419  if (main_struct != NULL && main_struct->current_doc != NULL)
420  {
421  window = heraia_get_widget(main_struct->xmls->main, "fr_window");
422  show_hide_widget(window, TRUE, main_struct->win_prop->fr_window);
423  }
424 }
425 
426 
427 /**
428  * Call back function for the find and replace window destruction
429  * @param widget : calling widget (may be NULL as we don't use this here)
430  * @param event : event associated (may be NULL as we don't use this here)
431  * @param data : MUST be heraia_struct_t *main_struct main structure
432  */
433 static gboolean delete_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
434 {
435  fr_window_close(widget, data);
436 
437  return TRUE;
438 }
439 
440 
441 /**
442  * Call back function for the find and replace window destruction
443  * @param widget : calling widget (may be NULL as we don't use this here)
444  * @param event : event associated (may be NULL as we don't use this here)
445  * @param data : user data - MUST be heraia_struct_t *main_struct main structure and not NULL
446  */
447 static void destroy_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
448 {
449  fr_window_close(widget, data);
450 }
451 
452 
453 /**
454  * Close button has been clicked we want to hide the window
455  * @param widget : calling widget (may be NULL as we don't use this here)
456  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
457  */
458 static void fr_window_close(GtkWidget *widget, gpointer data)
459 {
460  heraia_struct_t *main_struct = (heraia_struct_t *) data;
461  GtkWidget *window = NULL; /**< find window */
462 
463  if (main_struct != NULL)
464  {
465  window = heraia_get_widget(main_struct->xmls->main, "fr_window");
466  show_hide_widget(window, FALSE, main_struct->win_prop->fr_window);
467  }
468 }
469 
470 
471 /**
472  * Signal connections for the find and replace window
473  * @param main_struct : heraia's main structure
474  */
475 static void fr_window_connect_signal(heraia_struct_t *main_struct)
476 {
477  /* Close button */
478  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_close_bt")), "clicked",
479  G_CALLBACK(fr_window_close), main_struct);
480 
481  /* When find and replace window is killed or destroyed */
482  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_window")), "delete_event",
483  G_CALLBACK(delete_fr_window_event), main_struct);
484 
485  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_window")), "destroy",
486  G_CALLBACK(destroy_fr_window_event), main_struct);
487 
488  /* Search button */
489  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_find_bt")), "clicked",
490  G_CALLBACK(fr_search_bt_clicked), main_struct);
491 
492  /* Replace button */
493  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_replace_bt")), "clicked",
494  G_CALLBACK(fr_replace_bt_clicked), main_struct);
495 
496  /* Replace and search button */
497  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_replace_search_bt")), "clicked",
498  G_CALLBACK(fr_replace_search_bt_clicked), main_struct);
499 }
500 
501 
502 /**
503  * Tries to find, in the document, what the user entered in the GtkHex entry in
504  * the fr window in the find hexwidget (forward from the current position)
505  * @param widget : calling widget (may be NULL as we don't use this here)
506  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
507  */
508 static void fr_search_bt_clicked(GtkWidget *widget, gpointer data)
509 {
510  heraia_struct_t *main_struct = (heraia_struct_t *) data;
511 
512  if (main_struct != NULL && main_struct->fr_find_doc != NULL)
513  {
514  fr_search_forward(main_struct, main_struct->fr_find_doc, 0);
515  }
516 }
517 
518 
519 /**
520  * Tries to replace, in the document, what the user entered in the GtkHex entry
521  * in the fr window in the find hexwidget by what the user entered in the
522  * replace entry in that same window and then goes to the next position (if any)
523  * @param widget : calling widget (may be NULL as we don't use this here)
524  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
525  */
526 static void fr_replace_search_bt_clicked(GtkWidget *widget, gpointer data)
527 {
528  heraia_struct_t *main_struct = (heraia_struct_t *) data;
529  goffset offset = 0;
530 
531  if (main_struct != NULL && main_struct->fr_find_doc != NULL)
532  {
533  offset = fr_replace_data(main_struct);
534  /* fprintf(stdout, "offset : %ld\n", offset); */
535  fr_search_forward(main_struct, main_struct->fr_find_doc, offset);
536  }
537 }
538 
539 
540 /**
541  * Tries to replace, in the document, what the user entered in the GtkHex entry
542  * in the fr window in the find hexwidget by what the user entered in the
543  * replace entry in that same window
544  * @param main_struct : main structure
545  * @return a goffset that indicates the length difference between the length of
546  * the replaced data and the length of the inserted data
547  */
548 static goffset fr_replace_data(heraia_struct_t *main_struct)
549 {
550  guchar *buffer = NULL; /**< Buffer that contains the search string */
551  guchar *rep_buffer = NULL; /**< Buffer that contains the replace string */
552  doc_t *current_doc = NULL; /**< Current doc where we want to search for the string */
553  guint buffer_size = 0; /**< Size of the searched string */
554  guint rep_buf_size = 0; /**< Size of the replace string */
555  guint64 position = 0; /**< Current position in the current document ! */
556  goffset length = 0; /**< length of the result of that replace */
557 
558  if (main_struct != NULL && main_struct->current_doc != NULL && main_struct->fr_find_doc != NULL && main_struct->fr_replace_doc != NULL)
559  {
560  current_doc = main_struct->current_doc;
561  buffer = fr_get_search_string(main_struct, main_struct->fr_find_doc, &buffer_size);
562  rep_buffer = fr_get_search_string(main_struct, main_struct->fr_replace_doc, &rep_buf_size);
563  position = ghex_get_cursor_position(current_doc->hex_widget);
564  if (ghex_compare_data(current_doc, buffer, buffer_size, position) == 0)
565  {
566  /* The strings are equal and can be replaced in the current document */
567  ghex_set_data(current_doc, position, buffer_size, rep_buf_size, rep_buffer);
568  length = (goffset) rep_buf_size - buffer_size;
569  return length;
570  }
571  else
572  {
573  return length;
574  }
575  }
576  else
577  {
578  return length;
579  }
580 }
581 
582 
583 /**
584  * @param widget : calling widget (may be NULL as we don't use this here)
585  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
586  */
587 static void fr_replace_bt_clicked(GtkWidget *widget, gpointer data)
588 {
589  heraia_struct_t *main_struct = (heraia_struct_t *) data;
590  /* goffset length = 0; */ /* Unused here but returned by fr_replace_data() function */
591 
592  fr_replace_data(main_struct);
593 }
594 
595 
596 /**
597  * Inits all the things in the find and replace window (signal and such)
598  * @param main_struct : heraia's main structure
599  */
601 {
602 
603  if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
604  {
605  fr_window_connect_signal(main_struct);
606 
607  /* Creating a new hex document */
608  main_struct->fr_find_doc = create_find_or_replace_doc_t();
610 
611  if (main_struct->fr_replace_doc != NULL && main_struct->fr_find_doc != NULL)
612  {
613  find_replace_add_ghex_widget(main_struct->xmls, "fr_find_al", main_struct->fr_find_doc);
614  find_replace_add_ghex_widget(main_struct->xmls, "fr_replace_al", main_struct->fr_replace_doc);
615  }
616 
617  }
618 }
619 
620 
621 /******************************************************************************/
622 /**************************** Find data from type *****************************/
623 /******************************************************************************/
624 
625 
626 /***
627  * Populates the category combobox from the structures of the data interpretor
628  * window
629  * @param main_struct : main structure of the program
630  */
632 {
633  GtkWidget *cb = NULL; /**< category's combobox */
634  GtkWidget *label = NULL;
635  tab_t *tab = NULL;
636  gint i = 0;
637  const gchar *text = NULL;
638 
639  if (main_struct != NULL)
640  {
641  cb = main_struct->fdft->category_cb;
642 
643  for (i = 0; i < main_struct->current_DW->nb_tabs; i++)
644  {
645  tab = g_ptr_array_index(main_struct->current_DW->tabs, i);
646  label = tab->label;
647  text = gtk_label_get_text(GTK_LABEL(label));
648 
649  #if GTK_MAJOR_VERSION == 2
650  #if GTK_MINOR_VERSION >= 24
651  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
652  #endif
653  #if GTK_MINOR_VERSION <= 23
654  gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
655  #endif
656  #endif
657  #if GTK_MAJOR_VERSION > 2
658  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
659  #endif
660  }
661  }
662 }
663 
664 
665 /**
666  * Show find data from type window
667  * @param widget : the widget that issued the signal
668  * @param data : user data MUST be heraia_struct_t *main_struct main structure
669  */
670 void fdft_window_show(GtkWidget *widget, gpointer data)
671 {
672  heraia_struct_t *main_struct = (heraia_struct_t *) data;
673  GtkWidget *window = NULL; /**< find data from type window */
674 
675  if (main_struct != NULL && main_struct->current_doc != NULL)
676  {
677  window = heraia_get_widget(main_struct->xmls->main, "fdft_window");
678  show_hide_widget(window, TRUE, main_struct->win_prop->fdft_window);
679  }
680 }
681 
682 
683 /**
684  * Call back function for the find data from type window destruction
685  * @param widget : calling widget (may be NULL as we don't use this here)
686  * @param event : event associated (may be NULL as we don't use this here)
687  * @param data : MUST be heraia_struct_t *main_struct main structure
688  */
689 static gboolean delete_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
690 {
691  fdft_window_close(widget, data);
692 
693  return TRUE;
694 }
695 
696 
697 /**
698  * Call back function for the find data from type window destruction
699  * @param widget : calling widget (may be NULL as we don't use this here)
700  * @param event : event associated (may be NULL as we don't use this here)
701  * @param data : user data - MUST be heraia_struct_t *main_struct main structure and not NULL
702  */
703 static void destroy_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
704 {
705  fdft_window_close(widget, data);
706 }
707 
708 
709 /**
710  * Close button has been clicked we want to hide the window
711  * @param widget : calling widget (may be NULL as we don't use this here)
712  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
713  */
714 static void fdft_window_close(GtkWidget *widget, gpointer data)
715 {
716  heraia_struct_t *main_struct = (heraia_struct_t *) data;
717  GtkWidget *window = NULL; /**< find window */
718 
719  if (main_struct != NULL)
720  {
721  window = heraia_get_widget(main_struct->xmls->main, "fdft_window");
722  show_hide_widget(window, FALSE, main_struct->win_prop->fdft_window);
723  }
724 }
725 
726 /**
727  * return the decode structure that corresponds to the indexes from category,
728  * type and feature as stated in the parameters
729  * @param main_struct : heraia's main structure
730  * @param cat_index : category index (tab's number in the data interpertor's window
731  * @param typ_index : type index (the row number in the category's tab)
732  * @param fea_index : feature index (column number in the row of the tab of the data
733  * interpretor's window
734  * @param[out] data_size : size of the data to be filled to the decoding function
735  * @return the correspondinf decode structure that contains, the function, the
736  * entry (gtkwidget) and an error message to be displayed in case of an error
737  */
738 static decode_t *get_decode_struct(heraia_struct_t *main_struct, gint cat_index, gint typ_index, gint fea_index, guint *data_size)
739 {
740  decode_generic_t *decod = NULL; /**< stores row structure (boxes, labels, entries and functions) */
741  tab_t *tab = NULL; /**< stores description for one tab */
742 
743  /* Everything is selected and we know what data type the user is looking for */
744  if (cat_index >= 0 && typ_index >= 0 && fea_index >= 0)
745  {
746  tab = g_ptr_array_index(main_struct->current_DW->tabs, cat_index);
747  if (tab != NULL)
748  {
749  decod = g_ptr_array_index(tab->rows, typ_index);
750  if (decod != NULL)
751  {
752  *data_size = decod->data_size;
753  return g_ptr_array_index(decod->decode_array, fea_index);
754  }
755  else
756  {
757  return NULL;
758  }
759  }
760  else
761  {
762  return NULL;
763  }
764  }
765  else
766  {
767  return NULL;
768  }
769 }
770 
771 /**
772  * Searches the string entered in the search document in the current one (from
773  * the currenty position + offset) in the main window.
774  * @param main_struct : heraia's main structure
775  * @param dircetion : says wether we should go forward or backward
776  * @param decode_struct : the decoding structure
777  * @param data_size : the size of the data to be send to the decode function
778  * @param buffer : Buffer that contains the string to look for
779  */
780 static void fdft_search_direction(heraia_struct_t *main_struct, gint direction, decode_t *decode_struct, gint data_size, gchar *buffer)
781 {
782  decode_parameters_t *decode_parameters = NULL;
783  doc_t *current_doc = NULL; /**< Current doc where we want to search for the string */
784  gboolean result = FALSE;
785  guint64 position = 0;
786  guint endianness = 0;
787  guint stream_size = 0;
788  GArray *all_pos = NULL; /**< All positions of the searched string */
789 
790 
791  endianness = which_endianness(main_struct); /** Endianness is computed only once here */
792  stream_size = which_stream_size(main_struct); /** stream size is computed only once here */
793 
794  decode_parameters = new_decode_parameters_t(endianness, stream_size);
795 
796 
797  if (buffer != NULL)
798  {
799  current_doc = main_struct->current_doc;
800 
801  if (direction == HERAIA_FIND_FORWARD || direction == HERAIA_FIND_BACKWARD)
802  {
803  position = ghex_get_cursor_position(current_doc->hex_widget);
804  result = ghex_find_decode(direction, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
805 
806  log_message(main_struct, G_LOG_LEVEL_DEBUG, "endianness : %d ; stream_size : %d - result : %d", endianness, stream_size, result);
807 
808  if (result == TRUE)
809  {
810  ghex_set_cursor_position(current_doc->hex_widget, position);
811  }
812  }
813  else if (direction == HERAIA_FIND_ALL)
814  {
815  all_pos = g_array_new(TRUE, TRUE, sizeof(guint64));
816 
817  position = 0;
818  result = ghex_find_decode(HERAIA_FIND_ALL, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
819 
820  log_message(main_struct, G_LOG_LEVEL_DEBUG, "endianness : %d ; stream_size : %d - result : %d", endianness, stream_size, result);
821 
822  while (result == TRUE)
823  {
824  all_pos = g_array_append_val(all_pos, position);
825  result = ghex_find_decode(HERAIA_FIND_FORWARD, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
826  }
827 
828  if (all_pos != NULL)
829  {
830  rw_add_one_tab_from_find_all_bt(main_struct, all_pos, data_size, (guchar *) buffer);
831  g_array_free(all_pos, TRUE);
832  }
833  }
834  }
835 
836  g_free(decode_parameters);
837 }
838 
839 
840 /**
841  * Searches data from the selected type (if any) in the current document (if any)
842  * and returns the results in the result window
843  * @param widget : Calling widget (Is used to determine the direction of the search)
844  * @param data : MUST be heraia_struct_t *main_struct main structure and not NULL
845  */
846 static void fdft_prev_next_bt_clicked(GtkWidget *widget, gpointer data)
847 {
848  heraia_struct_t *main_struct = (heraia_struct_t *) data;
849  gint cat_index = 0; /**< index for the selected category in the combo box */
850  gint typ_index = 0; /**< index for the selected type in the combo box */
851  gint fea_index = 0; /**< index for the selected feature in the combo box */
852  GtkWidget *cb = NULL; /**< represents the combo boxes (category, type and feature combo boxes) */
853  decode_t *decode_struct = NULL; /**< The structure that contains the function we need */
854  const gchar *buffer = NULL; /**< contains what the user enterer in the search window */
855  guint data_size = 0;
856  GtkWidget *button = NULL;
857 
858  if (main_struct != NULL && main_struct->current_doc != NULL && main_struct->current_DW != NULL && main_struct->fdft != NULL)
859  {
860  cb = main_struct->fdft->category_cb;
861  cat_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
862 
863  cb = main_struct->fdft->type_cb;
864  typ_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
865 
866  cb = main_struct->fdft->feature_cb;
867  fea_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
868 
869  decode_struct = get_decode_struct(main_struct, cat_index, typ_index, fea_index, &data_size);
870 
871  buffer = gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(heraia_get_widget(main_struct->xmls->main, "fdft_value_entry"))));
872 
873  log_message(main_struct, G_LOG_LEVEL_DEBUG, "cat : %d, typ : %d, fea : %d - decode_struct : %p , data_size : %d ; buffer : %s", cat_index, typ_index, fea_index, decode_struct, data_size, buffer);
874 
875  if (decode_struct != NULL && buffer != NULL && data_size > 0)
876  {
877  button = heraia_get_widget(main_struct->xmls->main, "fdft_next_bt");
878 
879  if (widget == button)
880  {
881  fdft_search_direction(main_struct, HERAIA_FIND_FORWARD, decode_struct, data_size, (gchar *) buffer);
882  }
883  else
884  {
885  button = heraia_get_widget(main_struct->xmls->main, "fdft_prev_bt");
886  if (widget == button)
887  {
888  fdft_search_direction(main_struct, HERAIA_FIND_BACKWARD, decode_struct, data_size, (gchar *) buffer);
889  }
890  else
891  {
892  fdft_search_direction(main_struct, HERAIA_FIND_ALL, decode_struct, data_size, (gchar *) buffer);
893  }
894  }
895  }
896  }
897 }
898 
899 
900 /**
901  * Signal connections for the find data from type window
902  * @param main_struct : heraia's main structure
903  */
905 {
906  /* Close button */
907  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_close_bt")), "clicked",
908  G_CALLBACK(fdft_window_close), main_struct);
909 
910  /* When fdft window is killed or destroyed */
911  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_window")), "delete_event",
912  G_CALLBACK(delete_fdft_window_event), main_struct);
913 
914  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_window")), "destroy",
915  G_CALLBACK(destroy_fdft_window_event), main_struct);
916 
917  /* next button */
918  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_next_bt")), "clicked",
919  G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
920 
921  /* prev button */
922  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_prev_bt")), "clicked",
923  G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
924 
925  /* find all button */
926  g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_all_bt")), "clicked",
927  G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
928 }
929 
930 
931 /**
932  * Fills the type ComboBox with the right values
933  * @param widget : the combobox that issued the changed signal
934  * @param data : must be heraia_struct_t *main_struct
935  */
936 static void fdft_category_cb_changed(GtkWidget *widget, gpointer data)
937 {
938  heraia_struct_t *main_struct = (heraia_struct_t *) data;
939  decode_generic_t *decod = NULL; /**< stores row structure (boxes, labels, entries and functions) */
940  tab_t *tab = NULL; /**< stores description for one tab */
941  GtkWidget *cb = NULL; /**< represents the combo boxes (category, type and feature combo boxes) */
942  gint index = 0; /**< active index of the category combo box */
943  gint i = 0;
944  GtkWidget *label = NULL; /**< used to retrieve labels from the GtkLabel widgets */
945  const gchar *text = NULL; /**< contains text from the labels */
946  GtkTreeModel *model = NULL; /**< the models from the combo box (used to delete everything in the combo boxes */
947 
948  if (main_struct != NULL && main_struct->fdft != NULL)
949  {
950  /* retrieve the selected category */
951  cb = main_struct->fdft->category_cb;
952  index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
953  tab = g_ptr_array_index(main_struct->current_DW->tabs, index);
954 
955  /* Type combobox */
956  /* First delete all entries if any */
957  cb = main_struct->fdft->type_cb;
958  model = gtk_combo_box_get_model(GTK_COMBO_BOX(cb));
959  gtk_list_store_clear(GTK_LIST_STORE(model));
960 
961  /* Second fill the combobox with the values */
962  for (i = 0; i < tab->nb_rows; i++)
963  {
964  decod = g_ptr_array_index(tab->rows, i);
965  label = decod->label;
966  text = gtk_label_get_text(GTK_LABEL(label));
967 
968  #if GTK_MAJOR_VERSION == 2
969  #if GTK_MINOR_VERSION >= 24
970  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
971  #endif
972  #if GTK_MINOR_VERSION <= 23
973  gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
974  #endif
975  #endif
976  #if GTK_MAJOR_VERSION > 2
977  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
978  #endif
979  }
980 
981  /* Feature combobox */
982  /* First delete all entries if any */
983  cb = main_struct->fdft->feature_cb;
984  model = gtk_combo_box_get_model(GTK_COMBO_BOX(cb));
985  gtk_list_store_clear(GTK_LIST_STORE(model));
986 
987  /* Second fill the combobox with the values */
988  /* Here we start from 1, because column 0 is the row's title column */
989  for (i = 1; i < tab->nb_cols; i++)
990  {
991  label = g_ptr_array_index(tab->col_labels, i);
992  text = gtk_label_get_text(GTK_LABEL(label));
993 
994  #if GTK_MAJOR_VERSION == 2
995  #if GTK_MINOR_VERSION >= 24
996  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
997  #endif
998  #if GTK_MINOR_VERSION <= 23
999  gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
1000  #endif
1001  #endif
1002  #if GTK_MAJOR_VERSION > 2
1003  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cb), text);
1004  #endif
1005  }
1006  }
1007 }
1008 
1009 
1010 /**
1011  * Inits the fdft structure and adds the widgets to the window
1012  * @param main_struct : heraia's main structure
1013  */
1015 {
1016  fdft_t *fdft = NULL;
1017  GtkWidget *vbox = NULL;
1018 
1019  if (main_struct != NULL && main_struct->fdft == NULL)
1020  {
1021  fdft = (fdft_t *) g_malloc0 (sizeof(fdft_t));
1022 
1023  #if GTK_MAJOR_VERSION == 2
1024  #if GTK_MINOR_VERSION >= 24
1025  fdft->category_cb = gtk_combo_box_text_new();
1026  fdft->type_cb = gtk_combo_box_text_new();
1027  fdft->feature_cb = gtk_combo_box_text_new();
1028  #endif
1029  #if GTK_MINOR_VERSION <= 23
1030  fdft->category_cb = gtk_combo_box_new_text();
1031  fdft->type_cb = gtk_combo_box_new_text();
1032  fdft->feature_cb = gtk_combo_box_new_text();
1033  #endif
1034  #endif
1035 
1036  #if GTK_MAJOR_VERSION > 2
1037  fdft->category_cb = gtk_combo_box_text_new();
1038  fdft->type_cb = gtk_combo_box_text_new();
1039  fdft->feature_cb = gtk_combo_box_text_new();
1040  #endif
1041 
1042  main_struct->fdft = fdft;
1043 
1044  vbox = heraia_get_widget(main_struct->xmls->main, "fdft_category_vbox");
1045  gtk_box_pack_end(GTK_BOX(vbox), fdft->category_cb, FALSE, FALSE, 0);
1046 
1047  vbox = heraia_get_widget(main_struct->xmls->main, "fdft_type_vbox");
1048  gtk_box_pack_end(GTK_BOX(vbox), fdft->type_cb, FALSE, FALSE, 0);
1049 
1050  vbox = heraia_get_widget(main_struct->xmls->main, "fdft_feature_vbox");
1051  gtk_box_pack_end(GTK_BOX(vbox), fdft->feature_cb, FALSE, FALSE, 0);
1052 
1053  /* Combo box button */
1054  g_signal_connect(G_OBJECT(fdft->category_cb), "changed",
1055  G_CALLBACK(fdft_category_cb_changed), main_struct);
1056 
1057  return fdft;
1058  }
1059  else
1060  {
1061  return NULL;
1062  }
1063 }
1064 
1065 
1066 /**
1067  * Inits all the things in the find data from type window (signal and such)
1068  * @param main_struct : heraia's main structure
1069  */
1071 {
1072 
1073  if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
1074  {
1075  fdft_window_connect_signal(main_struct);
1076  main_struct->fdft = fdft_window_init_widgets(main_struct);
1077  fdft_window_populate_category_cb(main_struct);
1078  }
1079 }
window_prop_t * find_window
find window
Definition: libheraia.h:270
This is the main structure.
Definition: libheraia.h:332
void find_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find window (signal and such)
gboolean ghex_find_backward(doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position)
Wrapper to the hex_document_find_backward function Tries to find search_buffer in doc...
doc_t * fr_find_doc
find and replace window, find document and hexwidget
Definition: libheraia.h:345
#define HERAIA_FIND_ALL
When one wants to do a global search in th whole document.
Definition: libheraia.h:118
static void destroy_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find and replace window destruction.
GtkWidget * feature_cb
ComboBox Widget for the type of the data in the category.
Definition: libheraia.h:322
static void find_all_bt_clicked(GtkWidget *widget, gpointer data)
Tries to find, in the document, what the user entered in the GtkHex entry in the find window (all pos...
static void fdft_window_connect_signal(heraia_struct_t *main_struct)
Signal connections for the find data from type window.
Tabulation structure to be used in the GtkNoteBook of data_interpretor's window.
Definition: libheraia.h:190
static void fdft_window_close(GtkWidget *widget, gpointer data)
Close button has been clicked we want to hide the window.
window_prop_t * fr_window
find and replace window
Definition: libheraia.h:271
static void find_replace_add_ghex_widget(xml_t *xmls, gchar *widget_name, doc_t *entry)
Adds the GtkHex widget to the right frame.
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
GtkWidget * type_cb
ComboBox Widget for the category of the search.
Definition: libheraia.h:321
static void fdft_prev_next_bt_clicked(GtkWidget *widget, gpointer data)
Searches data from the selected type (if any) in the current document (if any) and returns the result...
gint ghex_compare_data(doc_t *doc, guchar *string, guint buffer_size, guint64 position)
Wrapper to the hex_document_compare_data function Compares data from string to the one contained in d...
gboolean ghex_get_data_position(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness, guchar *c)
Gets the data from the hexwidget, a wrapper to the ghex_memcpy function.
static void destroy_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find window destruction.
static gboolean delete_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find data from type window destruction.
static gboolean delete_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find and replace window destruction.
void fdft_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find data from type window (signal and such)
GtkWidget * category_cb
Definition: libheraia.h:320
static gboolean delete_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find window destruction.
guint data_size
size of what we may decode
Definition: libheraia.h:180
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.
Definition: heraia_ui.c:2613
DecodeFunc func
a function to decode into something
Definition: libheraia.h:162
guint nb_rows
number of rows in this tab - this is automatically updated
Definition: libheraia.h:194
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.
GtkWidget * label
label for this tab
Definition: libheraia.h:195
window_prop_t * fdft_window
find data from type window
Definition: libheraia.h:272
static void find_next_bt_clicked(GtkWidget *widget, gpointer data)
Tries to find, in the document, what the user entered in the GtkHex entry in the find window (forward...
static guchar * fr_get_search_string(heraia_struct_t *main_struct, doc_t *doc, guint *buffer_size)
Gets the string from the document doc.
fdft_t * fdft
Keeps comboboxes created for the fdft window.
Definition: libheraia.h:347
Proposal for a structure that will group all informations about a single document.
Definition: libheraia.h:293
static void fdft_search_direction(heraia_struct_t *main_struct, gint direction, decode_t *decode_struct, gint data_size, gchar *buffer)
Searches the string entered in the search document in the current one (from the currenty position + o...
void fdft_window_show(GtkWidget *widget, gpointer data)
Show find data from type window.
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.
xml_t * xmls
All the xmls used in the program, loaded at running time.
Definition: libheraia.h:337
static void fr_replace_bt_clicked(GtkWidget *widget, gpointer data)
void fr_window_init_interface(heraia_struct_t *main_struct)
Inits all the things in the find and replace window (signal and such)
guint which_stream_size(heraia_struct_t *main_struct)
returns stream size as selected in the spin button
static void fr_window_connect_signal(heraia_struct_t *main_struct)
Signal connections for the find and replace window.
void find_window_show(GtkWidget *widget, gpointer data)
Show find window.
void ghex_set_data(doc_t *doc, guint64 position, guint rep_len, guint len, guchar *data)
Wrapper to the hex_document_set_data function.
void fr_window_show(GtkWidget *widget, gpointer data)
Show find and replace window.
static void fr_replace_search_bt_clicked(GtkWidget *widget, gpointer data)
Tries to replace, in the document, what the user entered in the GtkHex entry in the fr window in the ...
Basic way to associate a decode function and an entry that will receive the result.
Definition: libheraia.h:160
GtkWidget * hex_widget
hexwidget corresponding to the document
Definition: libheraia.h:296
static void fr_window_close(GtkWidget *widget, gpointer data)
Close button has been clicked we want to hide the window.
decode_parameters_t * new_decode_parameters_t(guint endianness, guint stream_size)
Make an new decode_parameters_t in order to pass to the functions.
Definition: decode.c:961
static void fdft_window_populate_category_cb(heraia_struct_t *main_struct)
GtkBuilder * main
the main interface xml description
Definition: libheraia.h:222
static doc_t * create_find_or_replace_doc_t(void)
Creates the HexDocument and the GtkHex widget with the right properties and Fills a doc_t structure w...
GPtrArray * decode_array
Pointer Array of decode_t functions and corresponding entries.
Definition: libheraia.h:178
gboolean ghex_find_decode(gint direction, doc_t *doc, DecodeFunc decode_it, decode_parameters_t *decode_parameters, guint data_size, gchar *search_buffer, guint64 *position)
Wrappers to the functions that will do the search (here it has nothing to do with ghex in fact)...
guint64 ghex_get_cursor_position(GtkWidget *hex_widget)
Retrieves the cursor's position from the current hexwidget.
static void find_window_close(GtkWidget *widget, gpointer data)
Close button has been clicked we want to hide the window.
data_window_t * current_DW
data_interpretor pointer
Definition: libheraia.h:338
HexDocument Heraia_Document
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
Definition: libheraia.h:76
GPtrArray * tabs
an array of tabs displayed in data interpretor's notebook (tab_t)
Definition: libheraia.h:211
GPtrArray * col_labels
array of GtkWidgets of columns labels
Definition: libheraia.h:196
GtkWidget * label
label for these decoding functions
Definition: libheraia.h:179
This file contains all the definitions and includes all other .h files.
Structure that contains all the xml definitions loaded at running time using GtkBuilder.
Definition: libheraia.h:220
void ghex_set_cursor_position(GtkWidget *hex_widget, guint64 position)
Sets the cursor at the defined position in the hexwidget.
static void find_prev_bt_clicked(GtkWidget *widget, gpointer data)
Tries to find, in the document, what the user entered in the GtkHex entry in the find window (backwar...
guint nb_tabs
keeps Number of tabs in the GPtrArray
Definition: libheraia.h:210
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 decode_t * get_decode_struct(heraia_struct_t *main_struct, gint cat_index, gint typ_index, gint fea_index, guint *data_size)
return the decode structure that corresponds to the indexes from category, type and feature as stated...
static void find_window_connect_signal(heraia_struct_t *main_struct)
Signal connections for the find window.
static void fr_search_forward(heraia_struct_t *main_struct, doc_t *search_doc, goffset offset)
Searches the string entered in the search document in the current one (from the currenty position + o...
doc_t * find_doc
find document and hexwidget for find window
Definition: libheraia.h:344
static void destroy_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Call back function for the find data from type window destruction.
static void fr_search_bt_clicked(GtkWidget *widget, gpointer data)
Tries to find, in the document, what the user entered in the GtkHex entry in the fr window in the fin...
gboolean ghex_find_forward(doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position)
Wrapper to the hex_document_find_forward function Tries to find search_buffer in doc.
Basic way to have as many as we want decoding functions corresponding to one label.
Definition: libheraia.h:176
static void fdft_category_cb_changed(GtkWidget *widget, gpointer data)
Fills the type ComboBox with the right values.
#define HERAIA_FIND_FORWARD
When one wants to do a search in the forward direction.
Definition: libheraia.h:116
doc_t * new_doc_t(Heraia_Document *hex_doc, GtkWidget *hex_widget)
Inits a doc_t structure.
static goffset fr_replace_data(heraia_struct_t *main_struct)
Tries to replace, in the document, what the user entered in the GtkHex entry in the fr window in the ...
doc_t * fr_replace_doc
find and replace window, replace document and hexwidget
Definition: libheraia.h:346
Used to pass decoding options to the functions.
Definition: libheraia.h:147
guint which_endianness(heraia_struct_t *main_struct)
Determines which endianness is selected that is to say which radio button is active in the window...
GPtrArray * rows
array of pointers to decode_generic_t variables.
Definition: libheraia.h:198
#define HERAIA_FIND_BACKWARD
When one wants to do a search in the backward direction.
Definition: libheraia.h:117
static fdft_t * fdft_window_init_widgets(heraia_struct_t *main_struct)
Inits the fdft structure and adds the widgets to the window.
guint nb_cols
number of columns in this tab - this MUST NOT change in any way
Definition: libheraia.h:193