00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <libheraia.h>
00032
00033
00034 static guchar *fr_get_search_string(heraia_struct_t * main_struct, doc_t *doc, guint *buffer_size);
00035 static doc_t *create_find_or_replace_doc_t(void);
00036 static void find_replace_add_ghex_widget(xml_t *xmls, gchar *widget_name, doc_t *entry);
00037 static void fr_search_forward(heraia_struct_t *main_struct, doc_t *search_doc, goffset offset);
00038
00039
00040 static gboolean delete_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00041 static void destroy_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00042 static void find_window_close(GtkWidget *widget, gpointer data);
00043 static void find_window_connect_signal(heraia_struct_t *main_struct);
00044 static void find_all_bt_clicked(GtkWidget *widget, gpointer data);
00045 static void find_next_bt_clicked(GtkWidget *widget, gpointer data);
00046 static void find_prev_bt_clicked(GtkWidget *widget, gpointer data);
00047
00048
00049 static gboolean delete_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00050 static void destroy_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00051 static void fr_window_close(GtkWidget *widget, gpointer data);
00052 static void fr_window_connect_signal(heraia_struct_t *main_struct);
00053 static void fr_search_bt_clicked(GtkWidget *widget, gpointer data);
00054 static void fr_replace_bt_clicked(GtkWidget *widget, gpointer data);
00055 static void fr_replace_search_bt_clicked(GtkWidget *widget, gpointer data);
00056 static goffset fr_replace_data(heraia_struct_t *main_struct);
00057
00058
00059
00060 static gboolean delete_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00061 static void destroy_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00062 static fdft_t *fdft_window_init_widgets(heraia_struct_t * main_struct);
00063 static void fdft_window_close(GtkWidget *widget, gpointer data);
00064 static void fdft_window_connect_signal(heraia_struct_t *main_struct);
00065
00066
00067
00068
00069
00070
00071 void find_window_show(GtkWidget *widget, gpointer data)
00072 {
00073 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00074 GtkWidget *window = NULL;
00075
00076 if (main_struct != NULL && main_struct->current_doc != NULL)
00077 {
00078 window = heraia_get_widget(main_struct->xmls->main, "find_window");
00079 show_hide_widget(window, TRUE, main_struct->win_prop->find_window);
00080 }
00081 }
00082
00083
00084
00085
00086
00087
00088
00089
00090 static gboolean delete_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00091 {
00092 find_window_close(widget, data);
00093
00094 return TRUE;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104 static void destroy_find_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00105 {
00106 find_window_close(widget, data);
00107 }
00108
00109
00110
00111
00112
00113
00114
00115 static void find_window_close(GtkWidget *widget, gpointer data)
00116 {
00117 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00118 GtkWidget *window = NULL;
00119
00120 if (main_struct != NULL)
00121 {
00122 window = heraia_get_widget(main_struct->xmls->main, "find_window");
00123 show_hide_widget(window, FALSE, main_struct->win_prop->find_window);
00124 }
00125
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135 static void find_next_bt_clicked(GtkWidget *widget, gpointer data)
00136 {
00137 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00138
00139 if (main_struct != NULL && main_struct->find_doc != NULL)
00140 {
00141 fr_search_forward(main_struct, main_struct->find_doc, 0);
00142 }
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152 static void find_prev_bt_clicked(GtkWidget *widget, gpointer data)
00153 {
00154 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00155 guchar *buffer = NULL;
00156 doc_t *current_doc = NULL;
00157 gboolean result = FALSE;
00158 guint64 position = 0;
00159 guint buffer_size = 0;
00160
00161 if (main_struct != NULL)
00162 {
00163 buffer = fr_get_search_string(main_struct, main_struct->find_doc, &buffer_size);
00164
00165 if (buffer != NULL)
00166 {
00167 current_doc = main_struct->current_doc;
00168 position = ghex_get_cursor_position(current_doc->hex_widget) + 1 ;
00169 result = ghex_find_backward(current_doc, buffer, buffer_size, &position);
00170
00171 if (result == TRUE)
00172 {
00173 ghex_set_cursor_position(current_doc->hex_widget, position);
00174 }
00175 }
00176 }
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186 static void find_all_bt_clicked(GtkWidget *widget, gpointer data)
00187 {
00188 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00189 guchar *buffer = NULL;
00190 doc_t *current_doc = NULL;
00191 gboolean result = FALSE;
00192 guint64 position = 0;
00193 guint buffer_size = 0;
00194 GArray *all_pos = NULL;
00195
00196 if (main_struct != NULL)
00197 {
00198 buffer = fr_get_search_string(main_struct, main_struct->find_doc, &buffer_size);
00199
00200 if (buffer != NULL)
00201 {
00202 all_pos = g_array_new(TRUE, TRUE, sizeof(guint64));
00203 current_doc = main_struct->current_doc;
00204 position = 0;
00205 result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
00206
00207 while (result == TRUE)
00208 {
00209 all_pos = g_array_append_val(all_pos, position);
00210 result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
00211 }
00212 }
00213 }
00214
00215 if (all_pos != NULL)
00216 {
00217 rw_add_one_tab_from_find_all_bt(main_struct, all_pos, buffer_size, NULL);
00218 g_array_free(all_pos, TRUE);
00219 }
00220 }
00221
00222
00223
00224
00225
00226
00227 static void find_window_connect_signal(heraia_struct_t *main_struct)
00228 {
00229
00230 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_close_bt")), "clicked",
00231 G_CALLBACK(find_window_close), main_struct);
00232
00233
00234 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_next_bt")), "clicked",
00235 G_CALLBACK(find_next_bt_clicked), main_struct);
00236
00237
00238 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_prev_bt")), "clicked",
00239 G_CALLBACK(find_prev_bt_clicked), main_struct);
00240
00241
00242 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_all_bt")), "clicked",
00243 G_CALLBACK(find_all_bt_clicked), main_struct);
00244
00245
00246 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_window")), "delete_event",
00247 G_CALLBACK(delete_find_window_event), main_struct);
00248
00249 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "find_window")), "destroy",
00250 G_CALLBACK(destroy_find_window_event), main_struct);
00251 }
00252
00253
00254
00255
00256
00257
00258 void find_window_init_interface(heraia_struct_t * main_struct)
00259 {
00260
00261 if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
00262 {
00263 find_window_connect_signal(main_struct);
00264
00265 main_struct->find_doc = create_find_or_replace_doc_t();
00266
00267 if (main_struct->find_doc != NULL)
00268 {
00269 find_replace_add_ghex_widget(main_struct->xmls, "find_al", main_struct->find_doc);
00270 }
00271 }
00272 }
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 static guchar *fr_get_search_string(heraia_struct_t * main_struct, doc_t *doc, guint *buffer_size)
00288 {
00289 guint size = 0;
00290 guchar *buffer = NULL;
00291 guint endianness = 0;
00292 gboolean result = FALSE;
00293
00294
00295 size = ghex_file_size(GTK_HEX(doc->hex_widget));
00296
00297 if (size > 0 && size < 4096)
00298 {
00299 buffer = (guchar *) g_malloc0(sizeof(guchar) * size);
00300 endianness = which_endianness(main_struct);
00301 result = ghex_get_data_position(doc->hex_widget, 0, size, endianness, buffer);
00302
00303 if (result == TRUE)
00304 {
00305 *buffer_size = size;
00306 return buffer;
00307 }
00308 else
00309 {
00310 *buffer_size = 0;
00311 return NULL;
00312 }
00313 }
00314 else
00315 {
00316 *buffer_size = 0;
00317 return NULL;
00318 }
00319 }
00320
00321
00322
00323
00324
00325
00326
00327
00328 static doc_t *create_find_or_replace_doc_t(void)
00329 {
00330 Heraia_Document *find_hex_doc = NULL;
00331 GtkWidget *find_hex_widget = NULL;
00332
00333 find_hex_doc = hex_document_new();
00334
00335 if (find_hex_doc != NULL)
00336 {
00337
00338 find_hex_widget = hex_document_add_view(find_hex_doc);
00339
00340
00341 gtk_hex_show_offsets(GTK_HEX(find_hex_widget), FALSE);
00342 gtk_hex_set_insert_mode(GTK_HEX(find_hex_widget), TRUE);
00343 gtk_hex_set_geometry(GTK_HEX(find_hex_widget), 16, 4);
00344
00345
00346 return new_doc_t(find_hex_doc, find_hex_widget);
00347 }
00348 else
00349 {
00350 return NULL;
00351 }
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 static void find_replace_add_ghex_widget(xml_t *xmls, gchar *widget_name, doc_t *entry)
00363 {
00364 GtkWidget *al = NULL;
00365
00366 al = heraia_get_widget(xmls->main, widget_name);
00367 gtk_container_add(GTK_CONTAINER(al), entry->hex_widget);
00368 gtk_container_set_border_width(GTK_CONTAINER(al), 3);
00369
00370
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 static void fr_search_forward(heraia_struct_t *main_struct, doc_t *search_doc, goffset offset)
00382 {
00383 guchar *buffer = NULL;
00384 doc_t *current_doc = NULL;
00385 gboolean result = FALSE;
00386 guint64 position = 0;
00387 guint buffer_size = 0;
00388
00389 buffer = fr_get_search_string(main_struct, search_doc, &buffer_size);
00390
00391 if (buffer != NULL)
00392 {
00393 current_doc = main_struct->current_doc;
00394 position = ghex_get_cursor_position(current_doc->hex_widget);
00395 position = position + offset;
00396 result = ghex_find_forward(current_doc, buffer, buffer_size, &position);
00397
00398 if (result == TRUE)
00399 {
00400 ghex_set_cursor_position(current_doc->hex_widget, position);
00401 }
00402 }
00403 }
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416 void fr_window_show(GtkWidget *widget, gpointer data)
00417 {
00418 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00419 GtkWidget *window = NULL;
00420
00421 if (main_struct != NULL && main_struct->current_doc != NULL)
00422 {
00423 window = heraia_get_widget(main_struct->xmls->main, "fr_window");
00424 show_hide_widget(window, TRUE, main_struct->win_prop->fr_window);
00425 }
00426 }
00427
00428
00429
00430
00431
00432
00433
00434
00435 static gboolean delete_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00436 {
00437 fr_window_close(widget, data);
00438
00439 return TRUE;
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449 static void destroy_fr_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00450 {
00451 fr_window_close(widget, data);
00452 }
00453
00454
00455
00456
00457
00458
00459
00460 static void fr_window_close(GtkWidget *widget, gpointer data)
00461 {
00462 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00463 GtkWidget *window = NULL;
00464
00465 if (main_struct != NULL)
00466 {
00467 window = heraia_get_widget(main_struct->xmls->main, "fr_window");
00468 show_hide_widget(window, FALSE, main_struct->win_prop->fr_window);
00469 }
00470 }
00471
00472
00473
00474
00475
00476
00477 static void fr_window_connect_signal(heraia_struct_t *main_struct)
00478 {
00479
00480 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_close_bt")), "clicked",
00481 G_CALLBACK(fr_window_close), main_struct);
00482
00483
00484 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_window")), "delete_event",
00485 G_CALLBACK(delete_fr_window_event), main_struct);
00486
00487 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_window")), "destroy",
00488 G_CALLBACK(destroy_fr_window_event), main_struct);
00489
00490
00491 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_find_bt")), "clicked",
00492 G_CALLBACK(fr_search_bt_clicked), main_struct);
00493
00494
00495 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_replace_bt")), "clicked",
00496 G_CALLBACK(fr_replace_bt_clicked), main_struct);
00497
00498
00499 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fr_replace_search_bt")), "clicked",
00500 G_CALLBACK(fr_replace_search_bt_clicked), main_struct);
00501 }
00502
00503
00504
00505
00506
00507
00508
00509
00510 static void fr_search_bt_clicked(GtkWidget *widget, gpointer data)
00511 {
00512 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00513
00514 if (main_struct != NULL && main_struct->fr_find_doc != NULL)
00515 {
00516 fr_search_forward(main_struct, main_struct->fr_find_doc, 0);
00517 }
00518 }
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528 static void fr_replace_search_bt_clicked(GtkWidget *widget, gpointer data)
00529 {
00530 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00531 goffset offset = 0;
00532
00533 if (main_struct != NULL && main_struct->fr_find_doc != NULL)
00534 {
00535 offset = fr_replace_data(main_struct);
00536
00537 fr_search_forward(main_struct, main_struct->fr_find_doc, offset);
00538 }
00539 }
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 static goffset fr_replace_data(heraia_struct_t *main_struct)
00551 {
00552 guchar *buffer = NULL;
00553 guchar *rep_buffer = NULL;
00554 doc_t *current_doc = NULL;
00555 guint buffer_size = 0;
00556 guint rep_buf_size = 0;
00557 guint64 position = 0;
00558 goffset length = 0;
00559
00560 if (main_struct != NULL && main_struct->current_doc != NULL && main_struct->fr_find_doc != NULL && main_struct->fr_replace_doc != NULL)
00561 {
00562 current_doc = main_struct->current_doc;
00563 buffer = fr_get_search_string(main_struct, main_struct->fr_find_doc, &buffer_size);
00564 rep_buffer = fr_get_search_string(main_struct, main_struct->fr_replace_doc, &rep_buf_size);
00565 position = ghex_get_cursor_position(current_doc->hex_widget);
00566 if (ghex_compare_data(current_doc, buffer, buffer_size, position) == 0)
00567 {
00568
00569 ghex_set_data(current_doc, position, buffer_size, rep_buf_size, rep_buffer);
00570 length = (goffset) rep_buf_size - buffer_size;
00571 return length;
00572 }
00573 else
00574 {
00575 return length;
00576 }
00577 }
00578 else
00579 {
00580 return length;
00581 }
00582 }
00583
00584
00585
00586
00587
00588
00589 static void fr_replace_bt_clicked(GtkWidget *widget, gpointer data)
00590 {
00591 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00592 goffset offset = 0;
00593
00594 offset = fr_replace_data(main_struct);
00595 }
00596
00597
00598
00599
00600
00601
00602 void fr_window_init_interface(heraia_struct_t * main_struct)
00603 {
00604
00605 if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
00606 {
00607 fr_window_connect_signal(main_struct);
00608
00609
00610 main_struct->fr_find_doc = create_find_or_replace_doc_t();
00611 main_struct->fr_replace_doc = create_find_or_replace_doc_t();
00612
00613 if (main_struct->fr_replace_doc != NULL && main_struct->fr_find_doc != NULL)
00614 {
00615 find_replace_add_ghex_widget(main_struct->xmls, "fr_find_al", main_struct->fr_find_doc);
00616 find_replace_add_ghex_widget(main_struct->xmls, "fr_replace_al", main_struct->fr_replace_doc);
00617 }
00618
00619 }
00620 }
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633 static void fdft_window_populate_category_cb(heraia_struct_t *main_struct)
00634 {
00635 GtkWidget *cb = NULL;
00636 GtkWidget *label = NULL;
00637 tab_t *tab = NULL;
00638 gint i = 0;
00639 const gchar *text = NULL;
00640
00641 if (main_struct != NULL)
00642 {
00643 cb = main_struct->fdft->category_cb;
00644
00645 for (i = 0; i < main_struct->current_DW->nb_tabs; i++)
00646 {
00647 tab = g_ptr_array_index(main_struct->current_DW->tabs, i);
00648 label = tab->label;
00649 text = gtk_label_get_text(GTK_LABEL(label));
00650 gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
00651 }
00652 }
00653 }
00654
00655
00656
00657
00658
00659
00660
00661 void fdft_window_show(GtkWidget *widget, gpointer data)
00662 {
00663 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00664 GtkWidget *window = NULL;
00665
00666 if (main_struct != NULL && main_struct->current_doc != NULL)
00667 {
00668 window = heraia_get_widget(main_struct->xmls->main, "fdft_window");
00669 show_hide_widget(window, TRUE, main_struct->win_prop->fdft_window);
00670 }
00671 }
00672
00673
00674
00675
00676
00677
00678
00679
00680 static gboolean delete_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00681 {
00682 fdft_window_close(widget, data);
00683
00684 return TRUE;
00685 }
00686
00687
00688
00689
00690
00691
00692
00693
00694 static void destroy_fdft_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00695 {
00696 fdft_window_close(widget, data);
00697 }
00698
00699
00700
00701
00702
00703
00704
00705 static void fdft_window_close(GtkWidget *widget, gpointer data)
00706 {
00707 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00708 GtkWidget *window = NULL;
00709
00710 if (main_struct != NULL)
00711 {
00712 window = heraia_get_widget(main_struct->xmls->main, "fdft_window");
00713 show_hide_widget(window, FALSE, main_struct->win_prop->fdft_window);
00714 }
00715 }
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 static decode_t *get_decode_struct(heraia_struct_t *main_struct, gint cat_index, gint typ_index, gint fea_index, guint *data_size)
00730 {
00731 decode_generic_t *decod = NULL;
00732 tab_t *tab = NULL;
00733
00734
00735 if (cat_index >= 0 && typ_index >= 0 && fea_index >= 0)
00736 {
00737 tab = g_ptr_array_index(main_struct->current_DW->tabs, cat_index);
00738 if (tab != NULL)
00739 {
00740 decod = g_ptr_array_index(tab->rows, typ_index);
00741 if (decod != NULL)
00742 {
00743 *data_size = decod->data_size;
00744 return g_ptr_array_index(decod->decode_array, fea_index);
00745 }
00746 else
00747 {
00748 return NULL;
00749 }
00750 }
00751 else
00752 {
00753 return NULL;
00754 }
00755 }
00756 else
00757 {
00758 return NULL;
00759 }
00760 }
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771 static void fdft_search_direction(heraia_struct_t *main_struct, gint direction, decode_t *decode_struct, gint data_size, gchar *buffer)
00772 {
00773 decode_parameters_t *decode_parameters = NULL;
00774 doc_t *current_doc = NULL;
00775 gboolean result = FALSE;
00776 guint64 position = 0;
00777 guint endianness = 0;
00778 guint stream_size = 0;
00779 GArray *all_pos = NULL;
00780
00781
00782 endianness = which_endianness(main_struct);
00783 stream_size = which_stream_size(main_struct);
00784
00785 decode_parameters = new_decode_parameters_t(endianness, stream_size);
00786
00787
00788 if (buffer != NULL)
00789 {
00790 current_doc = main_struct->current_doc;
00791
00792 if (direction == HERAIA_FIND_FORWARD || direction == HERAIA_FIND_BACKWARD)
00793 {
00794 position = ghex_get_cursor_position(current_doc->hex_widget);
00795 result = ghex_find_decode(direction, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
00796
00797 log_message(main_struct, G_LOG_LEVEL_DEBUG, "endianness : %d ; stream_size : %d - result : %d", endianness, stream_size, result);
00798
00799 if (result == TRUE)
00800 {
00801 ghex_set_cursor_position(current_doc->hex_widget, position);
00802 }
00803 }
00804 else if (direction == HERAIA_FIND_ALL)
00805 {
00806 all_pos = g_array_new(TRUE, TRUE, sizeof(guint64));
00807
00808 position = 0;
00809 result = ghex_find_decode(HERAIA_FIND_ALL, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
00810
00811 log_message(main_struct, G_LOG_LEVEL_DEBUG, "endianness : %d ; stream_size : %d - result : %d", endianness, stream_size, result);
00812
00813 while (result == TRUE)
00814 {
00815 all_pos = g_array_append_val(all_pos, position);
00816 result = ghex_find_decode(HERAIA_FIND_FORWARD, current_doc, decode_struct->func, decode_parameters, data_size, buffer, &position);
00817 }
00818
00819 if (all_pos != NULL)
00820 {
00821 rw_add_one_tab_from_find_all_bt(main_struct, all_pos, data_size, (guchar *) buffer);
00822 g_array_free(all_pos, TRUE);
00823 }
00824 }
00825 }
00826
00827 g_free(decode_parameters);
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837 static void fdft_prev_next_bt_clicked(GtkWidget *widget, gpointer data)
00838 {
00839 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00840 gint cat_index = 0;
00841 gint typ_index = 0;
00842 gint fea_index = 0;
00843 GtkWidget *cb = NULL;
00844 decode_t *decode_struct = NULL;
00845 const gchar *buffer = NULL;
00846 guint data_size = 0;
00847 GtkWidget *button = NULL;
00848
00849 if (main_struct != NULL && main_struct->current_doc != NULL && main_struct->current_DW != NULL && main_struct->fdft != NULL)
00850 {
00851 cb = main_struct->fdft->category_cb;
00852 cat_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
00853
00854 cb = main_struct->fdft->type_cb;
00855 typ_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
00856
00857 cb = main_struct->fdft->feature_cb;
00858 fea_index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
00859
00860 decode_struct = get_decode_struct(main_struct, cat_index, typ_index, fea_index, &data_size);
00861
00862 buffer = gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(heraia_get_widget(main_struct->xmls->main, "fdft_value_entry"))));
00863
00864 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);
00865
00866 if (decode_struct != NULL && buffer != NULL && data_size > 0)
00867 {
00868 button = heraia_get_widget(main_struct->xmls->main, "fdft_next_bt");
00869
00870 if (widget == button)
00871 {
00872 fdft_search_direction(main_struct, HERAIA_FIND_FORWARD, decode_struct, data_size, (gchar *) buffer);
00873 }
00874 else
00875 {
00876 button = heraia_get_widget(main_struct->xmls->main, "fdft_prev_bt");
00877 if (widget == button)
00878 {
00879 fdft_search_direction(main_struct, HERAIA_FIND_BACKWARD, decode_struct, data_size, (gchar *) buffer);
00880 }
00881 else
00882 {
00883 fdft_search_direction(main_struct, HERAIA_FIND_ALL, decode_struct, data_size, (gchar *) buffer);
00884 }
00885 }
00886 }
00887 }
00888 }
00889
00890
00891
00892
00893
00894
00895 static void fdft_window_connect_signal(heraia_struct_t *main_struct)
00896 {
00897
00898 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_close_bt")), "clicked",
00899 G_CALLBACK(fdft_window_close), main_struct);
00900
00901
00902 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_window")), "delete_event",
00903 G_CALLBACK(delete_fdft_window_event), main_struct);
00904
00905 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_window")), "destroy",
00906 G_CALLBACK(destroy_fdft_window_event), main_struct);
00907
00908
00909 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_next_bt")), "clicked",
00910 G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
00911
00912
00913 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_prev_bt")), "clicked",
00914 G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
00915
00916
00917 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "fdft_all_bt")), "clicked",
00918 G_CALLBACK(fdft_prev_next_bt_clicked), main_struct);
00919 }
00920
00921
00922
00923
00924
00925
00926
00927 static void fdft_category_cb_changed(GtkWidget *widget, gpointer data)
00928 {
00929 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00930 decode_generic_t *decod = NULL;
00931 tab_t *tab = NULL;
00932 GtkWidget *cb = NULL;
00933 gint index = 0;
00934 gint i = 0;
00935 GtkWidget *label = NULL;
00936 const gchar *text = NULL;
00937 GtkTreeModel *model = NULL;
00938
00939 if (main_struct != NULL && main_struct->fdft != NULL)
00940 {
00941
00942 cb = main_struct->fdft->category_cb;
00943 index = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
00944 tab = g_ptr_array_index(main_struct->current_DW->tabs, index);
00945
00946
00947
00948 cb = main_struct->fdft->type_cb;
00949 model = gtk_combo_box_get_model(GTK_COMBO_BOX(cb));
00950 gtk_list_store_clear(GTK_LIST_STORE(model));
00951
00952
00953 for (i = 0; i < tab->nb_rows; i++)
00954 {
00955 decod = g_ptr_array_index(tab->rows, i);
00956 label = decod->label;
00957 text = gtk_label_get_text(GTK_LABEL(label));
00958 gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
00959 }
00960
00961
00962
00963 cb = main_struct->fdft->feature_cb;
00964 model = gtk_combo_box_get_model(GTK_COMBO_BOX(cb));
00965 gtk_list_store_clear(GTK_LIST_STORE(model));
00966
00967
00968
00969 for (i = 1; i < tab->nb_cols; i++)
00970 {
00971 label = g_ptr_array_index(tab->col_labels, i);
00972 text = gtk_label_get_text(GTK_LABEL(label));
00973 gtk_combo_box_append_text(GTK_COMBO_BOX(cb), text);
00974 }
00975 }
00976 }
00977
00978
00979
00980
00981
00982
00983 static fdft_t *fdft_window_init_widgets(heraia_struct_t * main_struct)
00984 {
00985 fdft_t *fdft = NULL;
00986 GtkWidget *vbox = NULL;
00987
00988 if (main_struct != NULL && main_struct->fdft == NULL)
00989 {
00990 fdft = (fdft_t *) g_malloc0 (sizeof(fdft_t));
00991
00992 fdft->category_cb = gtk_combo_box_new_text();
00993 fdft->type_cb = gtk_combo_box_new_text();
00994 fdft->feature_cb = gtk_combo_box_new_text();
00995
00996 main_struct->fdft = fdft;
00997
00998 vbox = heraia_get_widget(main_struct->xmls->main, "fdft_category_vbox");
00999 gtk_box_pack_end(GTK_BOX(vbox), fdft->category_cb, FALSE, FALSE, 0);
01000
01001 vbox = heraia_get_widget(main_struct->xmls->main, "fdft_type_vbox");
01002 gtk_box_pack_end(GTK_BOX(vbox), fdft->type_cb, FALSE, FALSE, 0);
01003
01004 vbox = heraia_get_widget(main_struct->xmls->main, "fdft_feature_vbox");
01005 gtk_box_pack_end(GTK_BOX(vbox), fdft->feature_cb, FALSE, FALSE, 0);
01006
01007
01008 g_signal_connect(G_OBJECT(fdft->category_cb), "changed",
01009 G_CALLBACK(fdft_category_cb_changed), main_struct);
01010
01011 return fdft;
01012 }
01013 else
01014 {
01015 return NULL;
01016 }
01017 }
01018
01019
01020
01021
01022
01023
01024 void fdft_window_init_interface(heraia_struct_t * main_struct)
01025 {
01026
01027 if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
01028 {
01029 fdft_window_connect_signal(main_struct);
01030 main_struct->fdft = fdft_window_init_widgets(main_struct);
01031 fdft_window_populate_category_cb(main_struct);
01032 }
01033 }