+/**
+ * @fn void callback_process_button(GtkWidget*,gpointer)
+ *
+ * The Process Button callback function
+ * @param widget The Button widget passed to the callback function
+ * @param data Data sent along with the callback function
+ */
+void
+callback_process_button(GtkWidget *widget, gpointer data) {
+
+ g_debug("callback_process_button(): Processing expression");
+
+ FilterViewerData *fvd = (FilterViewerData*)data;
+ LttvFilter* filter;
+
+ if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))) !=0) {
+ filter = lttv_filter_new();
+ GString* s = g_string_new(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field)));
+ lttv_filter_append_expression(filter,s->str);
+ g_string_free(s,TRUE);
+ //SetFilter(fvd->tab,filter);
+ } else {
+ filter = NULL;
+ }
+ lttvwindow_report_filter(fvd->tab, filter);
+}
+
+gboolean callback_enter_check(GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer user_data)
+{
+ g_debug("typed : %x", event->keyval);
+ switch(event->keyval) {
+ case GDK_Return:
+ case GDK_KP_Enter:
+ case GDK_ISO_Enter:
+ case GDK_3270_Enter:
+ callback_expression_field(widget, user_data);
+ break;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+/**
+ * @fn void callback_expression_field(GtkWidget*,gpointer)
+ *
+ * The Add Button callback function
+ * @param widget The Button widget passed to the callback function
+ * @param data Data sent along with the callback function
+ */
+void
+callback_expression_field(GtkWidget *widget, gpointer data) {
+
+ FilterViewerData *fvd = (FilterViewerData*)data;
+
+ if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))) !=0) {
+ gtk_widget_show(fvd->f_logical_op_junction_box);
+ } else {
+ gtk_widget_hide(fvd->f_logical_op_junction_box);
+ }
+}
+
+
+/**
+ * @fn void callback_add_button(GtkWidget*,gpointer)
+ *
+ * The Add Button callback function
+ * @param widget The Button widget passed to the callback function
+ * @param data Data sent along with the callback function
+ */
+void
+callback_add_button(GtkWidget *widget, gpointer data) {
+
+ g_debug("callback_add_button(): processing simple expressions");
+
+ unsigned i;
+
+ FilterViewerData *fvd = (FilterViewerData*)data;
+ FilterViewerDataLine *fvdl = NULL;
+ GString* a_filter_string = g_string_new("");
+
+ /*
+ * adding linking operator to
+ * string
+ */
+ GString* s;
+ s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box)));
+ g_string_append(a_filter_string,s->str);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box),0);
+
+ /* begin expression */
+ g_string_append_c(a_filter_string,'(');
+
+ /*
+ * For each simple expression, add the resulting string
+ * to the filter string
+ *
+ * Each simple expression takes the following schema
+ * [not operator '!',' '] [field type] [math operator '<','<=','>','>=','=','!='] [value]
+ */
+ for(i=0;i<fvd->f_lines->len;i++) {
+ fvdl = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i);
+
+ s = g_ptr_array_index(fvd->f_not_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_not_op_box)));
+ g_string_append(a_filter_string,s->str);
+
+ s = g_ptr_array_index(fvd->f_field_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_field_box)));
+ g_string_append(a_filter_string,s->str);
+
+ s = g_ptr_array_index(fvd->f_math_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_math_op_box)));
+ g_string_append(a_filter_string,s->str);
+
+ g_string_append(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvdl->f_value_field)));
+
+ s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_logical_op_box)));
+ g_string_append(a_filter_string,s->str);
+
+ /*
+ * resetting simple expression lines
+ */
+ gui_filter_line_reset(fvdl);
+ if(i) gui_filter_line_set_visible(fvdl,FALSE); // Only keep the first line
+ }
+
+ /* end expression */
+ g_string_append_c(a_filter_string,')');
+
+ g_string_prepend(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field)));
+ gtk_entry_set_text(GTK_ENTRY(fvd->f_expression_field),a_filter_string->str);
+
+}
+
+/**
+ * @fn void callback_logical_op_box(GtkWidget*,gpointer)
+ *
+ * The logical op box callback function
+ * @param widget The Button widget passed to the callback function
+ * @param data Data sent along with the callback function
+ */
+void
+callback_logical_op_box(GtkWidget *widget, gpointer data) {
+
+ g_debug("callback_logical_op_box(): adding new simple expression");
+
+ FilterViewerData *fvd = (FilterViewerData*)data;
+ FilterViewerDataLine *fvdl = NULL;
+
+ int i;
+ for(i=0;i<fvd->f_lines->len;i++) {
+ fvdl = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i);
+ if(fvdl->f_logical_op_box == widget) {
+ if(gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_logical_op_box)) == 0) return;
+ if(i==fvd->f_lines->len-1) { /* create a new line */
+ fvd->rows++;
+ FilterViewerDataLine* fvdl2 = gui_filter_add_line(fvd);
+ g_ptr_array_add(fvd->f_lines,(gpointer) fvdl2);
+ } else {
+ FilterViewerDataLine *fvdl2 = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i+1);
+ if(!fvdl2->visible) gui_filter_line_set_visible(fvdl2,TRUE);
+ }
+ }
+ }
+
+}