Heraia  0.1.8
stat.c
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  stat.c
4  an heraia plugin to calculate some stats on the opened file
5 
6  (C) Copyright 2007 - 2011 Olivier Delhomme
7  e-mail : heraia@delhomme.org
8  URL : http://heraia.tuxfamily.org
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2, or (at your option)
13  any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24 /**
25  * @file stat.c
26  * does some basic statistics on the file and displays them
27  * in a numerical or graphical way (histograms : 1D and 2D)
28  */
29 #include "stat.h"
30 
31 /* The functions for the plugin's usage */
32 static void stat_window_connect_signals(heraia_plugin_t *plugin);
33 
34 static void statw_close_clicked(GtkWidget *widget, gpointer data);
35 static void destroy_stat_window(GtkWidget *widget, GdkEvent *event, gpointer data);
36 
37 static void statw_save_as_clicked(GtkWidget *widget, gpointer data);
38 static void statw_export_to_csv_clicked(GtkWidget *widget, gpointer data);
39 static void statw_export_to_gnuplot_clicked(GtkWidget *widget, gpointer data);
40 static void statw_export_to_pcv_clicked(GtkWidget *widget, gpointer data);
41 
42 static gchar *stat_select_file_to_save(const gchar *window_text, stat_t *extra);
43 static void histo_radiobutton_toggled(GtkWidget *widget, gpointer data);
44 static gboolean delete_stat_window_event(GtkWidget *widget, GdkEvent *event, gpointer data );
45 static void realize_some_numerical_stat(heraia_struct_t *main_struct, heraia_plugin_t *plugin);
46 static void init_stats_histos(heraia_plugin_t *plugin);
47 static void set_statw_button_state(GtkBuilder *xml, gboolean sensitive);
48 static void populate_stats_histos(heraia_struct_t *main_struct, heraia_plugin_t *plugin);
49 static void calc_infos_histo_1D(stat_t *extra);
50 static void calc_infos_histo_2D(stat_t *extra);
51 static void init_stats_pixbufs(stat_t *extra);
52 static void make_pixbufs_from_histos(stat_t *extra);
53 static void plot_in_pixbuf(GdkPixbuf *pixbuf, gint64 x, gint64 y, guchar red, guchar green, guchar blue, guchar alpha);
54 static void do_pixbuf_1D_from_histo1D(stat_t *extra);
55 static void do_pixbuf_2D_from_histo2D(stat_t *extra, guint max_2D);
56 
57 
58 /**
59  * Initialisation plugin function called when the plugin is loaded
60  * (some sort of pre-init)
61  * @param[in,out] plugin : plugin's structure
62  * @return returns the plugin structure
63  */
65 {
66  stat_t *extra = NULL; /**< extra structure specific to this plugin */
67  window_prop_t *stat_prop = NULL; /**< window properties */
68 
70  plugin->xml = NULL;
71 
72  plugin->info->api_version = API_VERSION;
73  plugin->info->type = PLUGIN_TYPE;
75  plugin->info->name = PLUGIN_NAME;
76  plugin->info->version = PLUGIN_VERSION;
77  plugin->info->summary = PLUGIN_SUMMARY;
79  plugin->info->author = PLUGIN_AUTHOR;
80  plugin->info->homepage = PLUGIN_HOMEPAGE;
81 
82  plugin->init_proc = init;
83  plugin->quit_proc = quit;
84  plugin->run_proc = run;
85  plugin->refresh_proc = refresh;
86 
87  plugin->filter->extensions = NULL;
88  plugin->filter->import = NULL;
89  plugin->filter->export = NULL;
90 
91  /* add the extra struct to the plugin one */
92  extra = (stat_t *) g_malloc0 (sizeof(stat_t));
93  extra->infos_1D = (histo_infos_t *) g_malloc0 (sizeof(histo_infos_t));
94  extra->infos_2D = (histo_infos_t *) g_malloc0 (sizeof(histo_infos_t));
95  extra->dirname = NULL;
96 
97  /* window properties */
98  stat_prop = (window_prop_t *) g_malloc0(sizeof(window_prop_t));
99  stat_prop->displayed = FALSE; /* by default, it might be anything else */
100  stat_prop->x = 0;
101  stat_prop->y = 0;
102 
103  plugin->win_prop = stat_prop;
104 
105  plugin->extra = extra;
106 
107 
108  return plugin;
109 }
110 
111 
112 /* the plugin interface functions */
113 /**
114  * The real init function of the plugin (called at init time)
115  * @param main_struct : main structure
116  */
117 void init(heraia_struct_t *main_struct)
118 {
119  heraia_plugin_t *plugin = NULL;
120 
121  log_message(main_struct, G_LOG_LEVEL_INFO, Q_("Initializing plugin %s"), PLUGIN_NAME);
122  /* first, know who we are ! */
123  plugin = find_plugin_by_name(main_struct->plugins_list, PLUGIN_NAME);
124 
125  if (plugin != NULL)
126  {
127  /* load the xml interface */
128  log_message(main_struct, G_LOG_LEVEL_INFO, Q_("Plugin from %s found !"), plugin->info->author);
129  if (load_plugin_xml(main_struct, plugin) == TRUE)
130  {
131  log_message(main_struct, G_LOG_LEVEL_INFO, Q_("%s xml interface loaded."), plugin->info->name);
132  }
133  else
134  {
135  log_message(main_struct, G_LOG_LEVEL_WARNING, Q_("Unable to load %s xml interface."), plugin->info->name);
136  }
137 
138  /* greyed save as button and others */
139  set_statw_button_state(plugin->xml, FALSE);
140 
141  /* shows or hide the interface (hides it at first as all windows shows up) */
142  if (plugin->win_prop->displayed == FALSE)
143  {
144  gtk_widget_hide(GTK_WIDGET(heraia_get_widget(plugin->xml, "stat_window")));
145  }
146  else
147  {
148  gtk_check_menu_item_set_active(plugin->cmi_entry, TRUE);
149  }
150 
151  /* connect some signals handlers */
153  }
154 }
155 
156 
157 /**
158  * Normaly this is called when the plugin is unloaded
159  * One may wait it's entire life for this to be called !! ;)
160  */
161 void quit(void)
162 {
163  g_print(Q_("Quitting %s\n"), PLUGIN_NAME);
164 }
165 
166 
167 /**
168  * This function is called via a signal handler when the menu entry is toggled
169  * @param widget : widget which called the function (unused)
170  * @param data : user data for the plugin, here MUST be heraia_struct_t * main
171  * structure
172  */
173 void run(GtkWidget *widget, gpointer data)
174 {
175  heraia_struct_t *main_struct = (heraia_struct_t *) data; /* the signal send the pointer to this structure */
176  heraia_plugin_t *plugin = NULL;
177  gboolean menu_state = FALSE;
178 
179  /* first, know who we are ! */
180  plugin = find_plugin_by_name(main_struct->plugins_list, PLUGIN_NAME);
181 
182  if (plugin != NULL)
183  {
184  menu_state = gtk_check_menu_item_get_active(plugin->cmi_entry);
185 
186  show_hide_widget(GTK_WIDGET(heraia_get_widget(plugin->xml, "stat_window")), menu_state, plugin->win_prop);
187 
188  if (menu_state == TRUE)
189  {
190  plugin->state = PLUGIN_STATE_RUNNING;
191  realize_some_numerical_stat(main_struct, plugin);
192  }
193  else
194  {
195  plugin->state = PLUGIN_STATE_NONE;
196  }
197  }
198 }
199 
200 
201 /**
202  * Sets stat window's button's sensitive property
203  * @param xml : The plugin's xml description
204  * @param sensitive : whether the buttons are greyed (FALSE) or not (TRUE)
205  */
206 static void set_statw_button_state(GtkBuilder *xml, gboolean sensitive)
207 {
208  if (xml != NULL)
209  {
210  gtk_widget_set_sensitive(heraia_get_widget(xml, "statw_save_as"), sensitive);
211  gtk_widget_set_sensitive(heraia_get_widget(xml, "statw_export_to_csv"), sensitive);
212  gtk_widget_set_sensitive(heraia_get_widget(xml, "statw_export_to_gnuplot"), sensitive);
213  gtk_widget_set_sensitive(heraia_get_widget(xml, "statw_export_to_pcv"), sensitive);
214  }
215 }
216 
217 
218 /**
219  * The refresh function is called when a new file is loaded or when the cursor is moved
220  * Here we want to refresh the plugin only if a new file is loaded AND if the plugin
221  * is already displayed (running)
222  * @param main_struct : main structure
223  * @param data : user data (the plugin itself) MUST be heraia_plugin_t *plugin
224  * structure
225  */
226 void refresh(heraia_struct_t *main_struct, void *data)
227 {
228  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
229 
230  if (main_struct != NULL && plugin != NULL)
231  {
232  if (main_struct->event == HERAIA_REFRESH_NEW_FILE || main_struct->event == HERAIA_REFRESH_TAB_CHANGED) /* && plugin->state == PLUGIN_STATE_RUNNING) */
233  {
234  set_statw_button_state(plugin->xml, TRUE);
235  plugin->run_proc(NULL, (gpointer) main_struct);
236  }
237  }
238 }
239 /* end of the plugin interface functions */
240 
241 
242 /**
243  * Usefull functions for the stat plugin
244  * those may be included in an another .c source file ?!
245  */
246 
247 /**
248  * Closes stat window
249  * @param widget : the widget which called this function
250  * @param event : the event that issued the signal (unused here)
251  * @param data : user data, MUST be heraia_plugin_t *plugin
252  * @return resturns always FALSE (does not propagate the signal)
253  */
254 static gboolean delete_stat_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
255 {
256  statw_close_clicked(widget, data);
257 
258  return TRUE;
259 }
260 
261 
262 /**
263 
264  * Closes stat window
265  * @param widget : the widget which called this function
266  * @param event : the event that issued the signal (unused here)
267  * @param data : user data, MUST be heraia_plugin_t *plugin
268  */
269 static void destroy_stat_window(GtkWidget *widget, GdkEvent *event, gpointer data)
270 {
271  statw_close_clicked(widget, data);
272 }
273 
274 
275 /**
276  * What to do when the window is closed
277  * @param widget : the widget which called this function (unused here)
278  * @param data : user data, MUST be heraia_plugin_t *plugin
279  */
280 static void statw_close_clicked(GtkWidget *widget, gpointer data)
281 {
282  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
283 
284  if (plugin != NULL)
285  {
286  show_hide_widget(GTK_WIDGET(heraia_get_widget(plugin->xml, "stat_window")), FALSE, plugin->win_prop);
287  gtk_check_menu_item_set_active(plugin->cmi_entry, FALSE);
288  }
289 }
290 
291 
292 /**
293  * What to do when the save as button is clicked
294  * @param widget : the widget which called this function (unused here)
295  * @param data : user data, MUST be heraia_plugin_t *plugin
296  */
297 static void statw_save_as_clicked(GtkWidget *widget, gpointer data)
298 {
299  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
300  stat_t *extra = NULL;
301  GtkImage *image = NULL;
302  GdkPixbuf *pixbuf = NULL;
303  gchar *filename = NULL;
304  GError **error = NULL;
305 
306  if (plugin != NULL)
307  {
308  extra = (stat_t *) plugin->extra;
309 
310  image = GTK_IMAGE(heraia_get_widget(plugin->xml, "histo_image"));
311  pixbuf = gtk_image_get_pixbuf(image);
312 
313  filename = stat_select_file_to_save(Q_("Enter filename's to save the image to"), extra);
314  if (filename != NULL)
315  {
316  gdk_pixbuf_save(pixbuf, filename, "png", error, "compression", "9", NULL);
317  g_free(filename);
318  }
319  }
320 }
321 
322 
323 /**
324  * Selecting the file filename where to save the file
325  * @param window_text : text to be displayed in the selection window
326  * @return returns the new filename where to save a file
327  */
328 static gchar *stat_select_file_to_save(const gchar *window_text, stat_t *extra)
329 {
330  GtkFileChooser *file_chooser = NULL;
331  gint response_id = 0;
332  gchar *filename;
333 
334  file_chooser = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new(window_text, NULL,
335  GTK_FILE_CHOOSER_ACTION_SAVE,
336  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
337  GTK_STOCK_OPEN, GTK_RESPONSE_OK,
338  NULL));
339 
340  /* for the moment we do not want to retrieve multiples selections */
341  gtk_window_set_modal(GTK_WINDOW(file_chooser), TRUE);
342  gtk_file_chooser_set_select_multiple(file_chooser, FALSE);
343  gtk_file_chooser_set_do_overwrite_confirmation(file_chooser, TRUE);
344 
345  /* If it exists define a new directory name */
346  if (extra != NULL && extra->dirname != NULL)
347  {
348  gtk_file_chooser_set_current_folder(file_chooser, extra->dirname);
349  }
350 
351  response_id = gtk_dialog_run(GTK_DIALOG(file_chooser));
352 
353  switch (response_id)
354  {
355  case GTK_RESPONSE_OK:
356  filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
357 
358  /* Saving directory name in order to use it at a later call */
359  if (filename != NULL)
360  {
361  if (extra->dirname != NULL)
362  {
363  g_free(extra->dirname);
364  }
365  extra->dirname = g_path_get_dirname(filename);
366  }
367 
368  break;
369  case GTK_RESPONSE_CANCEL:
370  default:
371  filename = NULL;
372  break;
373  }
374 
375  gtk_widget_destroy(GTK_WIDGET(file_chooser));
376  return filename;
377 }
378 
379 
380 /**
381  * What to do when "export to csv" button is clicked
382  * @param widget : the widget which called this function
383  * @param data : user data, MUST be heraia_plugin_t *plugin
384  */
385 static void statw_export_to_csv_clicked(GtkWidget *widget, gpointer data)
386 {
387  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
388  stat_t *extra = NULL;
389  gchar *filename = NULL;
390  FILE *fp = NULL;
391  guint i = 0;
392  guint j = 0;
393 
394  if (plugin != NULL)
395  {
396  extra = (stat_t *) plugin->extra;
397 
398  filename = stat_select_file_to_save(Q_("Enter filename to export data as CSV to"), extra);
399 
400  if (filename != NULL)
401  {
402  fp = g_fopen(filename, "w+");
403  }
404 
405  if (fp != NULL && extra != NULL)
406  {
407  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_1D"))) == TRUE)
408  {
409  /* 1D display */
410  fprintf(fp, Q_("\"Byte\";\"Count\"\n"));
411 
412  for (i=0; i<=255; i++)
413  {
414  fprintf(fp, "%d;%llu\n", i, (long long unsigned int) extra->histo1D[i]);
415  }
416 
417  }
418  else
419  {
420  /* 2D display */
421  fprintf(fp, Q_("\"Byte/Byte\";"));
422  for (j=0; j<255; j++)
423  {
424  fprintf(fp, "\"%d\";", j);
425  }
426  fprintf(fp, "\"%d\"\n", 255);
427 
428  for (i=0; i<=255; i++)
429  {
430  fprintf(fp, "\"%d\";", i);
431  for (j=0 ; j<255; j++)
432  {
433  fprintf(fp, "\"%llu\";", (long long unsigned int) extra->histo2D[i][j]);
434  }
435  fprintf(fp, "\"%llu\"\n", (long long unsigned int) extra->histo2D[i][255]);
436  }
437  }
438  fclose(fp);
439  }
440 
441  if (filename != NULL)
442  {
443  g_free(filename);
444  }
445  }
446 }
447 
448 
449 /**
450  * What to do when "export to gnuplot" button is clicked
451  * @param widget : the widget which called this function
452  * @param data : user data, MUST be heraia_plugin_t *plugin
453  */
454 static void statw_export_to_gnuplot_clicked(GtkWidget *widget, gpointer data)
455 {
456  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
457  stat_t *extra = NULL;
458  gchar *filename = NULL;
459  FILE *fp = NULL;
460  guint i = 0;
461  guint j = 0;
462 
463  if (plugin != NULL)
464  {
465  extra = (stat_t *) plugin->extra;
466 
467  filename = stat_select_file_to_save(Q_("Enter filename to export data as gnuplot to"), extra);
468 
469  if (filename != NULL)
470  {
471  fp = g_fopen(filename, "w+");
472  }
473 
474  if (fp != NULL && extra != NULL)
475  {
476  /* common settings */
477  fprintf(fp, "set terminal png transparent nocrop enhanced small size 1280,960\n");
478  fprintf(fp, "set output '%s.png'\n", g_path_get_basename(filename));
479  fprintf(fp, "set xrange [-10:265]\n");
480  fprintf(fp, "set xlabel 'Bytes'\n");
481 
482  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_1D"))) == TRUE)
483  {
484  /* 1D display */
485  fprintf(fp, Q_("set title 'Classical histogram'\n")); /**< @todo we might add here the name of the file being edited */
486  fprintf(fp, "set ylabel 'Count'\n");
487  fprintf(fp, Q_("plot '-' title 'Byte count' with impulses\n")); /* plot and set are gnuplot commands please do not translate them ! */
488 
489  for (i=0; i<=255; i++)
490  {
491  fprintf(fp, "%llu\n", (long long unsigned int) extra->histo1D[i]);
492  }
493  fprintf(fp, "e\n");
494  }
495  else
496  {
497  /* 2D display */
498  fprintf(fp, Q_("set title 'Heatmap histogram'\n")); /**< @todo we might add here the name of the file being edited */
499  fprintf(fp, "set bar 1.000000\n");
500  fprintf(fp, "set style rectangle back fc lt -3 fillstyle solid 1.00 border -1\n");
501  fprintf(fp, "unset key\n");
502  fprintf(fp, "set view map\n");
503  fprintf(fp, "set yrange [-10:265]\n");
504  fprintf(fp, "set ylabel 'Bytes'\n");
505  fprintf(fp, "set palette rgbformulae 36, 13, 15\n");
506  fprintf(fp, "splot '-' matrix with image\n");
507 
508  for (i=0; i<=255; i++)
509  {
510  for (j=0; j<=255; j++)
511  {
512  fprintf(fp, "%llu ", (long long unsigned int) extra->histo2D[i][j]);
513  }
514  fprintf(fp, "\n");
515  }
516 
517  fprintf(fp, "e\n");
518  fprintf(fp, "e\n");
519  }
520  fclose(fp);
521  }
522 
523  if (filename != NULL)
524  {
525  g_free(filename);
526  }
527  }
528 }
529 
530 
531 /**
532  * What to do when "export to pcv" button is clicked
533  * @param widget : the widget which called this function
534  * @param data : user data, MUST be heraia_plugin_t *plugin
535  */
536 static void statw_export_to_pcv_clicked(GtkWidget *widget, gpointer data)
537 {
538  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
539  stat_t *extra = NULL;
540  gchar *filename = NULL;
541  FILE *fp = NULL;
542  guint i = 0;
543  guint j = 0;
544 
545  if (plugin != NULL)
546  {
547  extra = (stat_t *) plugin->extra;
548 
549  filename = stat_select_file_to_save(Q_("Enter filename to export data as PCV to"), extra);
550 
551  if (filename != NULL)
552  {
553  fp = g_fopen(filename, "w+");
554  }
555 
556  if (fp != NULL && extra != NULL)
557  {
558  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_1D"))) == TRUE)
559  {
560  /* 1D display */
561  fprintf(fp, "header {\n");
562  fprintf(fp, "\theight = \"960\";\n");
563  fprintf(fp, "\twidth = \"1280\";\n");
564  fprintf(fp, Q_("\ttitle = \"Classical histogram\";\n"));
565  fprintf(fp, "}\n");
566  fprintf(fp, "axes {\n");
567  fprintf(fp, Q_("\tinteger b [label=\"Bytes\"];\n"));
568  fprintf(fp, Q_("\tinteger c [label=\"Byte count\"];\n"));
569  fprintf(fp, "}\n");
570  fprintf(fp, "data {\n");
571 
572  for (i=0; i<=255; i++)
573  {
574  fprintf(fp, "\tb=\"%d\", c=\"%llu\";\n", i, (long long unsigned int) extra->histo1D[i]);
575  }
576  fprintf(fp, "}\n");
577  }
578  else
579  {
580  /* 2D display */
581  fprintf(fp, "header {\n");
582  fprintf(fp, "\theight = \"960\";\n");
583  fprintf(fp, "\twidth = \"1280\";\n");
584  fprintf(fp, Q_("\ttitle = \"Classical histogram\";\n"));
585  fprintf(fp, "}\n");
586  fprintf(fp, "axes {\n");
587  fprintf(fp, Q_("\tchar a [label=\"Bytes\"];\n"));
588  fprintf(fp, Q_("\tport c [label=\"Byte count\"];\n"));
589  fprintf(fp, Q_("\tchar b [label=\"Bytes\"];\n"));
590  fprintf(fp, "}\n");
591  fprintf(fp, "data {\n");
592 
593  for (i=0; i<=255; i++)
594  {
595  for (j=0; j<=255; j++)
596  {
597  if (extra->histo2D[i][j] == extra->infos_2D->max)
598  {
599  fprintf(fp, "\ta=\"%d\", c=\"%llu\", b=\"%d\" [color=\"red\"];\n", i, (long long unsigned int) extra->histo2D[i][j], j);
600  }
601  else
602  {
603  if (extra->histo2D[i][j] == extra->infos_2D->min)
604  {
605  fprintf(fp, "\ta=\"%d\", c=\"%llu\", b=\"%d\" [color=\"green\"];\n", i, (long long unsigned int) extra->histo2D[i][j], j);
606  }
607  else
608  {
609  fprintf(fp, "\ta=\"%d\", c=\"%llu\", b=\"%d\";\n", i, (long long unsigned int) extra->histo2D[i][j], j);
610  }
611  }
612  }
613  }
614  fprintf(fp, "}\n");
615  }
616  fclose(fp);
617  }
618 
619  if (filename != NULL)
620  {
621  g_free(filename);
622  }
623  }
624 }
625 
626 
627 /**
628  * What to do when the user chooses a 1D or 2D histo
629  * @param widget : the widget which called this function (unused here)
630  * @param data : user data, MUST be heraia_plugin_t *plugin
631  */
632 static void histo_radiobutton_toggled(GtkWidget *widget, gpointer data)
633 {
634  heraia_plugin_t *plugin = (heraia_plugin_t *) data;
635 
636  if (plugin != NULL)
637  {
638  GtkImage *image = GTK_IMAGE(heraia_get_widget(plugin->xml, "histo_image"));
639  stat_t *extra = (stat_t *) plugin->extra;
640 
641  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_1D"))) == TRUE)
642  {
643  gtk_image_set_from_pixbuf(image, extra->pixbuf_1D);
644  }
645  else
646  {
647  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_2D"))) == TRUE)
648  {
649  gtk_image_set_from_pixbuf(image, extra->pixbuf_2D);
650  }
651  }
652  }
653 }
654 
655 
656 /**
657  * Connects all the signals to the correct functions
658  * @param plugin : main plugin structure
659  */
661 {
662 
663  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "stat_window")), "delete_event",
664  G_CALLBACK(delete_stat_window_event), plugin);
665 
666  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "stat_window")), "destroy",
667  G_CALLBACK(destroy_stat_window), plugin);
668 
669  /* Close Button */
670  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "statw_close_b")), "clicked",
671  G_CALLBACK(statw_close_clicked), plugin);
672 
673  /* RadioButton */
674  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "rb_1D")), "toggled",
675  G_CALLBACK(histo_radiobutton_toggled), plugin);
676 
677  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "rb_2D")), "toggled",
678  G_CALLBACK(histo_radiobutton_toggled), plugin);
679 
680  /* Save As Button */
681  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "statw_save_as")), "clicked",
682  G_CALLBACK(statw_save_as_clicked), plugin);
683 
684  /* CVS button */
685  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "statw_export_to_csv")), "clicked",
686  G_CALLBACK(statw_export_to_csv_clicked), plugin);
687 
688  /* Gnuplot button */
689  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "statw_export_to_gnuplot")), "clicked",
690  G_CALLBACK(statw_export_to_gnuplot_clicked), plugin);
691 
692  /* PCV button */
693  g_signal_connect(G_OBJECT(heraia_get_widget(plugin->xml, "statw_export_to_pcv")), "clicked",
694  G_CALLBACK(statw_export_to_pcv_clicked), plugin);
695 
696  /* the toogle button is already connected to the run_proc function ! */
697 }
698 
699 
700 /**
701  * Do format a date form a time_t value
702  * @param time_t value
703  * @return a gchar which represents the value as a date
704  */
705 static gchar *transform_time_t_to_gchar(time_t *a_time)
706 {
707  gchar *buf = NULL;
708  struct tm *tm = NULL;
709  size_t char_size = 0;
710 
711  buf = (gchar *) g_malloc0(22*sizeof(gchar));
712 
713  tm = gmtime(a_time);
714 
715  char_size = strftime(buf, 22, "%x %X", tm);
716 
717  if (char_size <= 0)
718  {
719  return NULL;
720  }
721  else
722  {
723  return buf;
724  }
725 }
726 
727 
728 /**
729  * Do some stats on the selected file (entire file is used)
730  * @param main_struct : main structure from heraia
731  * @param plugin : main plugin structure (the plugin itself in fact)
732  */
734 {
735  struct stat *stat_buf;
736  gchar *buf = NULL; /**< used for date printing */
737  gchar *filename = NULL;
738  stat_t *extra = NULL;
739  GtkTextView *textview = GTK_TEXT_VIEW(heraia_get_widget(plugin->xml, "statw_textview"));
740 
741  if (main_struct != NULL && main_struct->current_doc != NULL)
742  {
743  filename = doc_t_document_get_filename(main_struct->current_doc);
744  }
745 
746  if (filename != NULL)
747  {
748  log_message(main_struct, G_LOG_LEVEL_INFO, Q_("Calculating stats on %s"), filename);
749 
750  stat_buf = (struct stat *) g_malloc0 (sizeof(struct stat));
751  g_lstat(filename, stat_buf);
752  if (S_ISREG(stat_buf->st_mode))
753  {
754  kill_text_from_textview(textview);
755  add_text_to_textview(textview, Q_("File size : %Ld bytes\n\n"), stat_buf->st_size);
756 
757  buf = transform_time_t_to_gchar(&(stat_buf->st_mtime));
758  if (buf != NULL)
759  {
760  add_text_to_textview(textview, Q_("Last intern modification : %s\n"), buf);
761  g_free(buf);
762  }
763 
764  buf = transform_time_t_to_gchar(&(stat_buf->st_atime));
765  if (buf != NULL)
766  {
767  add_text_to_textview(textview, Q_("Last acces to the file : %s\n"), buf);
768  g_free(buf);
769  }
770 
771  buf = transform_time_t_to_gchar(&(stat_buf->st_ctime));
772  if (buf != NULL)
773  {
774  add_text_to_textview(textview, Q_("Last extern modification : %s\n"), buf);
775  g_free(buf);
776  }
777 
778 
779  populate_stats_histos(main_struct, plugin);
780 
781  extra = (stat_t *) plugin->extra;
782 
783  add_text_to_textview(textview, Q_("\n1D histogram statistics :\n"));
784  add_text_to_textview(textview, Q_(" . minimum : %lld\n"), extra->infos_1D->min);
785  add_text_to_textview(textview, Q_(" . maximum : %lld\n"), extra->infos_1D->max);
786  add_text_to_textview(textview, Q_(" . mean : %lld\n"), extra->infos_1D->mean);
787  add_text_to_textview(textview, Q_(" . number of values : %lld\n"), extra->infos_1D->nb_val);
788  add_text_to_textview(textview, Q_("\n2D histogram statistics :\n"));
789  add_text_to_textview(textview, Q_(" . minimum : %lld\n"), extra->infos_2D->min);
790  add_text_to_textview(textview, Q_(" . maximum : %lld\n"), extra->infos_2D->max);
791  add_text_to_textview(textview, Q_(" . mean : %lld\n"), extra->infos_2D->mean);
792  add_text_to_textview(textview, Q_(" . number of values : %lld\n"), extra->infos_2D->nb_val);
793  log_message(main_struct, G_LOG_LEVEL_INFO, Q_("Histos calculated !"));
794 
795  set_statw_button_state(plugin->xml, TRUE);
796  }
797  else
798  {
799  set_statw_button_state(plugin->xml, FALSE);
800  }
801  }
802  else
803  {
804  set_statw_button_state(plugin->xml, FALSE);
805  }
806 }
807 
808 
809 /**
810  * Inits the histograms
811  */
812 static void init_stats_histos(heraia_plugin_t *plugin)
813 {
814  guint i = 0;
815  guint j = 0;
816  stat_t *extra = NULL;
817 
818  /* inits the structures */
819  extra = (stat_t *) plugin->extra;
820  for (i=0; i<=255; i++)
821  {
822  extra->histo1D[i] = 0 ;
823  for (j=0; j<=255; j++)
824  extra->histo2D[i][j] = 0 ;
825  }
826 }
827 
828 
829 /**
830  * Populates the histograms
831  */
832 static void populate_stats_histos(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
833 {
834  Heraia_Hex *gh = GTK_HEX(main_struct->current_doc->hex_widget);
835  guint64 i = 0;
836  guint64 taille = ghex_file_size(gh);
837  guchar c1, c2;
838  stat_t *extra = (stat_t *) plugin->extra;
839  GtkImage *image = GTK_IMAGE(heraia_get_widget(plugin->xml, "histo_image"));
840  GtkToggleButton *rb_1D = GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_1D"));
841  GtkToggleButton *rb_2D = GTK_TOGGLE_BUTTON(heraia_get_widget(plugin->xml, "rb_2D"));
842 
843  init_stats_histos(plugin);
844 
845  while (i < taille)
846  {
847  c1 = gtk_hex_get_byte(gh, i);
848  extra->histo1D[c1]++;
849  if (i+1 < taille)
850  {
851  i++;
852  c2 = gtk_hex_get_byte(gh, i);
853  extra->histo1D[c2]++;
854  extra->histo2D[c1][c2]++;
855  }
856  i++;
857  }
858 
860 
861  if (gtk_toggle_button_get_active(rb_1D) == TRUE)
862  {
863  gtk_image_set_from_pixbuf(image, extra->pixbuf_1D);
864  }
865  else
866  {
867  if (gtk_toggle_button_get_active(rb_2D) == TRUE)
868  {
869  gtk_image_set_from_pixbuf(image, extra->pixbuf_2D);
870  }
871  }
872 }
873 
874 
875 /**
876  * Seeks the histo1D struct to find the maximum value
877  */
878 static void calc_infos_histo_1D(stat_t *extra)
879 {
880  guint i = 0;
881  gint64 n = 1;
882  guint64 max = 0;
883  guint64 min = G_MAXUINT64;
884  gint64 mean = extra->histo1D[0];
885  gint64 diff = 0;
886 
887  extra->infos_1D->nb_val = 0;
888 
889  for (i=0; i<=255; i++)
890  {
891  /* maximum value */
892  if (extra->histo1D[i] > max)
893  max = extra->histo1D[i];
894 
895  /* minimum value */
896  if (extra->histo1D[i] < min)
897  min = extra->histo1D[i];
898 
899  /* number of different values */
900  if (extra->histo1D[i] > 0)
901  extra->infos_1D->nb_val++;
902 
903  /* mean calculation */
904  diff = extra->histo1D[i] - mean;
905  mean = mean + diff/n;
906  n++;
907  }
908 
909  extra->infos_1D->min = min;
910  extra->infos_1D->max = max;
911  extra->infos_1D->mean = (guint64) mean;
912 }
913 
914 
915 /**
916  * Seeks the histo2D struct to find the maximum value
917  */
918 static void calc_infos_histo_2D(stat_t *extra)
919 {
920  guint i = 0;
921  guint j = 0;
922  gint64 n = 1;
923  guint64 max = 0;
924  guint64 min = G_MAXUINT;
925  gint64 mean = extra->histo2D[0][0];
926  gint64 diff = 0;
927 
928  extra->infos_2D->nb_val = 0;
929 
930  for (i=0; i<=255; i++)
931  {
932  for (j=0; j<=255; j++)
933  {
934  /* maximum value */
935  if (extra->histo2D[i][j] > max)
936  max = extra->histo2D[i][j];
937 
938  /* minimum value */
939  if (extra->histo2D[i][j] < min)
940  min = extra->histo2D[i][j];
941 
942  /* number of different values */
943  if (extra->histo2D[i][j] > 0)
944  extra->infos_2D->nb_val++;
945 
946  /* mean calculation */
947  diff = extra->histo2D[i][j] - mean;
948  mean = mean + diff/n;
949  n++;
950  }
951  }
952 
953  extra->infos_2D->min = min;
954  extra->infos_2D->max = max;
955  extra->infos_2D->mean = (guint64) mean;
956 }
957 
958 
959 /**
960  * Inits the image buffers
961  */
962 static void init_stats_pixbufs(stat_t *extra)
963 {
964 
965  extra->pixbuf_1D = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 255, 255);
966  gdk_pixbuf_fill(extra->pixbuf_1D, 0xFFFFFF00);
967  gdk_pixbuf_add_alpha(extra->pixbuf_1D, TRUE, (guchar) 255, (guchar) 255, (guchar) 255);
968 
969  extra->pixbuf_2D = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 255, 255);
970  gdk_pixbuf_fill(extra->pixbuf_2D, 0xFFFFFF00);
971  gdk_pixbuf_add_alpha(extra->pixbuf_2D, TRUE, (guchar) 255, (guchar) 255, (guchar) 255);
972 
973 }
974 
975 
976 /**
977  * Makes the pixbufs from the histograms values
978  */
979 static void make_pixbufs_from_histos(stat_t *extra)
980 {
981  init_stats_pixbufs(extra);
982  calc_infos_histo_1D(extra);
983  calc_infos_histo_2D(extra);
984 
985  if (extra->infos_1D->max > 0)
986  {
988  }
989 
990  if (extra->infos_2D->max > 0)
991  {
992  do_pixbuf_2D_from_histo2D(extra, extra->infos_2D->max);
993  }
994 }
995 
996 
997 /**
998  * Prints a pixel in the corresponding pixbuf
999  */
1000 static void plot_in_pixbuf(GdkPixbuf *pixbuf, gint64 x, gint64 y, guchar red, guchar green, guchar blue, guchar alpha)
1001 {
1002  guchar *pixels = NULL;
1003  guchar *p = NULL;
1004 
1005  pixels = gdk_pixbuf_get_pixels(pixbuf);
1006 
1007  p = pixels + y * gdk_pixbuf_get_rowstride(pixbuf) + x * gdk_pixbuf_get_n_channels(pixbuf);
1008 
1009  p[0] = red;
1010  p[1] = green;
1011  p[2] = blue;
1012  p[3] = alpha;
1013 
1014 }
1015 
1016 
1017 /**
1018  * Prints a line of pixels in the corresponding pixbuf (1D histo)
1019  */
1020 static void line_in_pixbuf(GdkPixbuf *pixbuf, gint64 x, gint64 y)
1021 {
1022  guchar *pixels = NULL;
1023  guchar *p = NULL;
1024 
1025  if (pixbuf != NULL)
1026  {
1027 
1028  gint rowstride = gdk_pixbuf_get_rowstride(pixbuf);
1029  gint n_channels = gdk_pixbuf_get_n_channels(pixbuf);
1030 
1031  pixels = gdk_pixbuf_get_pixels(pixbuf);
1032 
1033  while (y<255)
1034  {
1035  p = pixels + y * rowstride + x * n_channels;
1036  p[0] = (guchar) 255-(y/2);
1037  p[1] = (guchar) 16;
1038  p[2] = (guchar) y/2;
1039  p[3] = (guchar) 255;
1040  y++;
1041  }
1042  }
1043 }
1044 
1045 
1046 /**
1047  * Fills the pixbuf with the corresponding data from the
1048  * histo1D struct
1049  */
1051 {
1052  guint i = 0;
1053  gint64 y = 0;
1054  gdouble inter = 0;
1055  gdouble y_norm = 0;
1056 
1057  for (i=0; i<=255; i++)
1058  {
1059  /* normalisation (here we know that max != 0 (cf make_pixbufs_from_histos) */
1060  y_norm = (gdouble) extra->infos_1D->max - (gdouble) extra->histo1D[i];
1061  inter = (gdouble) (y_norm*255) / (gdouble)(extra->infos_1D->max);
1062  y = (gint64) inter;
1063  line_in_pixbuf(extra->pixbuf_1D, i, y);
1064  }
1065 }
1066 
1067 
1068 /**
1069  * Fills the pixbuf with the corresponding data from the
1070  * histo2D struct
1071  * It is really hard to make something very visible (to make colors
1072  * look really different between to height values)
1073  */
1074 static void do_pixbuf_2D_from_histo2D(stat_t *extra, guint max_2D)
1075 {
1076  /* A sort of color 'normalization' */
1077  guint i = 0;
1078  guint j = 0;
1079  guchar red;
1080  guchar green;
1081  guchar blue;
1082  gdouble height = 0;
1083  gdouble max = 0;
1084  gdouble min = 0;
1085  gdouble mean = 0;
1086  gdouble threshold1 = 0;
1087  gdouble threshold2 = 0;
1088  guchar ceill;
1089  guchar floor;
1090 
1091  max = extra->infos_2D->max;
1092  min = extra->infos_2D->min;
1093  mean = extra->infos_2D->mean;
1094 
1095  threshold1 = min + (mean - min) / 2;
1096  threshold2 = mean + (max - mean) / 2;
1097 
1098  floor = (guchar) 50;
1099  ceill = (guchar) 200;
1100 
1101  for (i=0; i<=255; i++)
1102  {
1103  for (j=0; j<=255; j++)
1104  {
1105  height = extra->histo2D[i][j]; /* min .. max */
1106 
1107  if (height > 0)
1108  {
1109 
1110  if (height >= min && height <= threshold1)
1111  {
1112  red = floor;
1113  green = floor;
1114  blue = (guchar) (height - min)*(ceill-floor) / threshold1;
1115  /*
1116  * height = (gdouble) (height*255) / (gdouble) extra->infos_2D->max;
1117  * red = (guchar) height;
1118  * green = (guchar) 255 - (height);
1119  * blue = (guchar) height/2;
1120  */
1121  plot_in_pixbuf(extra->pixbuf_2D, i, 255-j, red, green, blue, (guchar) 255);
1122  }
1123  else if (height > threshold1 && height <= threshold2)
1124  {
1125  red = (guchar) floor;
1126  green = (guchar) (height - threshold1)*(ceill-floor) / (threshold2 - threshold1);
1127  blue = (guchar) floor; /* ceill - green;*/
1128  plot_in_pixbuf(extra->pixbuf_2D, i, 255-j, red, green, blue, (guchar) 255);
1129  }
1130  else if (height > threshold2 && height <= max)
1131  {
1132  red = (guchar) (height - threshold2)*(ceill-floor) / (max - threshold2);
1133  green = floor; /* ceill - red; */
1134  blue = floor;
1135  /*
1136  * height = (gdouble) height*255 / (gdouble) extra->infos_2D->max;
1137  * red = (guchar) 255 - (height);
1138  * green = (guchar) height/2;
1139  * blue = (guchar) height;
1140  */
1141  plot_in_pixbuf(extra->pixbuf_2D, i, 255-j, red, green, blue, (guchar) 255);
1142  }
1143  }
1144  }
1145  }
1146 }
1147 
1148 
void kill_text_from_textview(GtkTextView *textview)
Kills the text from a textview.
Definition: heraia_ui.c:2049
This is the main structure.
Definition: libheraia.h:332
Window properties.
Definition: libheraia.h:243
static void statw_export_to_pcv_clicked(GtkWidget *widget, gpointer data)
What to do when "export to pcv" button is clicked.
Definition: stat.c:536
static void calc_infos_histo_1D(stat_t *extra)
Seeks the histo1D struct to find the maximum value.
Definition: stat.c:878
gint x
x position (upper left corner)
Definition: libheraia.h:245
gchar * dirname
last openned directory where files were saved
Definition: stat.h:65
void add_text_to_textview(GtkTextView *textview, const char *format,...)
adds a text to a textview
Definition: heraia_ui.c:2025
guint nb_val
number of different values
Definition: stat.h:50
static void histo_radiobutton_toggled(GtkWidget *widget, gpointer data)
What to do when the user chooses a 1D or 2D histo.
Definition: stat.c:632
static void stat_window_connect_signals(heraia_plugin_t *plugin)
Connects all the signals to the correct functions.
Definition: stat.c:660
RefreshProc refresh_proc
Called when the cursor changes it's position.
Definition: plugin.h:155
heraia_plugin_t * find_plugin_by_name(GList *plugins_list, gchar *name)
Finds the desired plugin by its name and return the plugin structure or NULL.
Definition: plugin.c:323
#define PLUGIN_VERSION
Definition: stat.h:38
#define PLUGIN_SUMMARY
Definition: stat.h:39
#define PLUGIN_HOMEPAGE
Definition: stat.h:42
gchar * doc_t_document_get_filename(doc_t *doc)
Retrieves from a doc_t * document it's filename, which ever it is.
guint64 max
maximum value
Definition: stat.h:47
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
RefreshType event
Tells what is happening.
Definition: libheraia.h:341
guint64 histo2D[256][256]
The values for the 2D histogram.
Definition: stat.h:60
static void statw_export_to_gnuplot_clicked(GtkWidget *widget, gpointer data)
What to do when "export to gnuplot" button is clicked.
Definition: stat.c:454
gboolean displayed
TRUE if displayed, FALSE otherwise.
Definition: libheraia.h:249
GtkBuilder * xml
Eventually the plugin's GtkBuilder XML interface.
Definition: plugin.h:158
static void destroy_stat_window(GtkWidget *widget, GdkEvent *event, gpointer data)
Closes stat window.
Definition: stat.c:269
guint64 histo1D[256]
The values for the 1D histogram.
Definition: stat.h:59
InitProc init_proc
Called when the application initialy starts up.
Definition: plugin.h:152
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
guint64 ghex_file_size(Heraia_Hex *gh)
Returns the file size of an opened Heraia_Hex document.
static void calc_infos_histo_2D(stat_t *extra)
Seeks the histo2D struct to find the maximum value.
Definition: stat.c:918
Contains everything needed from stat.c : structures and defines.
histo_infos_t * infos_1D
stores mathematical datas on the histogram (1D)
Definition: stat.h:61
#define HERAIA_PRIORITY_DEFAULT
Priorities ...
Definition: plugin.h:87
static void make_pixbufs_from_histos(stat_t *extra)
Makes the pixbufs from the histograms values.
Definition: stat.c:979
static void do_pixbuf_2D_from_histo2D(stat_t *extra, guint max_2D)
Fills the pixbuf with the corresponding data from the histo2D struct It is really hard to make someth...
Definition: stat.c:1074
#define HERAIA_REFRESH_NEW_FILE
When a new file has been loaded.
Definition: libheraia.h:101
plugin_info_t * info
The plugin information.
Definition: plugin.h:147
GtkHex Heraia_Hex
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
Definition: libheraia.h:77
GdkPixbuf * pixbuf_1D
Pixbuf to be displayed (1D)
Definition: stat.h:63
RunProc run_proc
Called to run an interface everytime the plugin is called.
Definition: plugin.h:154
#define PLUGIN_NAME
Definition: stat.h:37
#define API_VERSION
Definition: stat.h:34
static void init_stats_pixbufs(stat_t *extra)
Inits the image buffers.
Definition: stat.c:962
window_prop_t * win_prop
Stores the window's properties.
Definition: plugin.h:159
char * version
Definition: plugin.h:128
PluginPriority priority
Definition: plugin.h:124
guint64 min
minimum value
Definition: stat.h:48
ImportFunction import
Definition: plugin.h:111
This is the stat structure.
Definition: stat.h:57
char * description
Definition: plugin.h:130
#define PLUGIN_DESCRIPTION
Definition: stat.h:40
static void set_statw_button_state(GtkBuilder *xml, gboolean sensitive)
Sets stat window's button's sensitive property.
Definition: stat.c:206
void * extra
Plugin-specific data.
Definition: plugin.h:150
static void populate_stats_histos(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
Populates the histograms.
Definition: stat.c:832
char * extensions
Definition: plugin.h:109
static void line_in_pixbuf(GdkPixbuf *pixbuf, gint64 x, gint64 y)
Prints a line of pixels in the corresponding pixbuf (1D histo)
Definition: stat.c:1020
char * summary
Definition: plugin.h:129
static void do_pixbuf_1D_from_histo1D(stat_t *extra)
Fills the pixbuf with the corresponding data from the histo1D struct.
Definition: stat.c:1050
PluginType type
Definition: plugin.h:123
static void init_stats_histos(heraia_plugin_t *plugin)
Inits the histograms.
Definition: stat.c:812
static void statw_save_as_clicked(GtkWidget *widget, gpointer data)
What to do when the save as button is clicked.
Definition: stat.c:297
heraia_plugin_t * heraia_plugin_init(heraia_plugin_t *plugin)
Initialisation plugin function called when the plugin is loaded (some sort of pre-init) ...
Definition: stat.c:64
static void realize_some_numerical_stat(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
Do some stats on the selected file (entire file is used)
Definition: stat.c:733
GtkWidget * hex_widget
hexwidget corresponding to the document
Definition: libheraia.h:296
gint y
y position (upper left corner)
Definition: libheraia.h:246
gboolean load_plugin_xml(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
Loads the xml's definition file that describes the plugin (.gtkbuilder suffix) tries the paths found ...
Definition: plugin.c:356
char * name
Definition: plugin.h:127
static void plot_in_pixbuf(GdkPixbuf *pixbuf, gint64 x, gint64 y, guchar red, guchar green, guchar blue, guchar alpha)
Prints a pixel in the corresponding pixbuf.
Definition: stat.c:1000
ExportFunction export
Definition: plugin.h:112
PluginState state
The state of the plugin.
Definition: plugin.h:143
void quit(void)
Normaly this is called when the plugin is unloaded One may wait it's entire life for this to be calle...
Definition: stat.c:161
char * author
Definition: plugin.h:131
Complete plugin structure.
Definition: plugin.h:141
static void statw_close_clicked(GtkWidget *widget, gpointer data)
What to do when the window is closed.
Definition: stat.c:280
void refresh(heraia_struct_t *main_struct, void *data)
The refresh function is called when a new file is loaded or when the cursor is moved Here we want to ...
Definition: stat.c:226
GList * plugins_list
A list of plugins.
Definition: libheraia.h:340
void init(heraia_struct_t *main_struct)
The real init function of the plugin (called at init time)
Definition: stat.c:117
static gchar * transform_time_t_to_gchar(time_t *a_time)
Do format a date form a time_t value.
Definition: stat.c:705
GdkPixbuf * pixbuf_2D
Pixbuf to be displayed (2D)
Definition: stat.h:64
static gchar * stat_select_file_to_save(const gchar *window_text, stat_t *extra)
Selecting the file filename where to save the file.
Definition: stat.c:328
void run(GtkWidget *widget, gpointer data)
This function is called via a signal handler when the menu entry is toggled.
Definition: stat.c:173
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
guint64 mean
mean value
Definition: stat.h:49
char * homepage
Definition: plugin.h:132
static void statw_export_to_csv_clicked(GtkWidget *widget, gpointer data)
What to do when "export to csv" button is clicked.
Definition: stat.c:385
QuitProc quit_proc
Called when the application exits.
Definition: plugin.h:153
#define HERAIA_REFRESH_TAB_CHANGED
When user selects another tab in main notebook.
Definition: libheraia.h:103
#define PLUGIN_AUTHOR
Definition: stat.h:41
plugin_filter_t * filter
The plugin filter.
Definition: plugin.h:148
histo_infos_t * infos_2D
stores mathematical datas on the histogram (2D)
Definition: stat.h:62
GtkCheckMenuItem * cmi_entry
The CheckMenuItem that may be created in the heraia interface.
Definition: plugin.h:157
#define PLUGIN_TYPE
Definition: stat.h:35
unsigned int api_version
Definition: plugin.h:122
static gboolean delete_stat_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Usefull functions for the stat plugin those may be included in an another .c source file ...
Definition: stat.c:254