1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Simon Bouvier-Zappa
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 #include <gdk/gdkkeysyms.h>
29 #include <lttv/lttv.h>
30 #include <lttv/module.h>
31 #include <lttv/hook.h>
32 #include <lttv/filter.h>
34 #include <lttvwindow/lttvwindow.h>
35 #include <lttvwindow/lttvwindowtraces.h>
37 #include "hGuiFilterInsert.xpm"
40 GSList
*g_filter_list
= NULL
;
42 /*! \file lttv/modules/gui/filter/filter.c
43 * \brief Graphic filter interface.
45 * The gui filter facility gives the user an easy to use
46 * basic interface to construct and modify at will a filter
47 * expression. User may either decide to write it himself in
48 * expression text entry or add simple expressions using the
51 * \note The version of gtk-2.0 currently installed on
52 * my desktop misses some function of the newer
53 * gtk+ api. For the time being, I'll use the older api
54 * to keep compatibility with most systems.
57 typedef struct _FilterViewerData FilterViewerData
;
58 typedef struct _FilterViewerDataLine FilterViewerDataLine
;
63 GtkWidget
*guifilter_get_widget(FilterViewerData
*fvd
);
64 FilterViewerData
*gui_filter(Tab
*tab
);
65 void gui_filter_destructor(FilterViewerData
*fvd
);
66 FilterViewerDataLine
* gui_filter_add_line(FilterViewerData
*fvd
);
67 void gui_filter_line_set_visible(FilterViewerDataLine
*fvdl
, gboolean v
);
68 void gui_filter_line_reset(FilterViewerDataLine
*fvdl
);
69 GtkWidget
* h_guifilter(Tab
*tab
);
70 void filter_destroy_walk(gpointer data
, gpointer user_data
);
75 void callback_process_button(GtkWidget
*widget
, gpointer data
);
76 gboolean
callback_enter_check(GtkWidget
*widget
,
79 void callback_add_button(GtkWidget
*widget
, gpointer data
);
80 void callback_logical_op_box(GtkWidget
*widget
, gpointer data
);
81 void callback_expression_field(GtkWidget
*widget
, gpointer data
);
84 * @struct _FilterViewerDataLine
86 * @brief Defines a simple expression
87 * This structures defines a simple
88 * expression whithin the main filter
91 struct _FilterViewerDataLine
{
92 int row
; /**< row number */
93 gboolean visible
; /**< visible state */
94 GtkWidget
*f_not_op_box
; /**< '!' operator (GtkComboBox) */
95 GtkWidget
*f_logical_op_box
; /**< '&,|,^' operators (GtkComboBox) */
96 GtkWidget
*f_field_box
; /**< field types (GtkComboBox) */
97 GtkWidget
*f_math_op_box
; /**< '>,>=,<,<=,=,!=' operators (GtkComboBox) */
98 GtkWidget
*f_value_field
; /**< expression's value (GtkComboBox) */
102 * @struct _FilterViewerData
104 * @brief Main structure of gui filter
105 * Main struct for the filter gui module
107 struct _FilterViewerData
{
108 Tab
*tab
; /**< current tab of module */
110 GtkWidget
*f_window
; /**< filter window */
112 GtkWidget
*f_main_box
; /**< main container */
114 GtkWidget
*f_expression_field
; /**< entire expression (GtkEntry) */
115 GtkWidget
*f_process_button
; /**< process expression button (GtkButton) */
117 GtkWidget
*f_logical_op_junction_box
; /**< linking operator box (GtkComboBox) */
119 int rows
; /**< number of rows */
120 GPtrArray
*f_lines
; /**< array of FilterViewerDataLine */
122 GPtrArray
*f_not_op_options
; /**< array of operators types for not_op box */
123 GPtrArray
*f_logical_op_options
; /**< array of operators types for logical_op box */
124 GPtrArray
*f_field_options
; /**< array of field types for field box */
125 GPtrArray
*f_math_op_options
; /**< array of operators types for math_op box */
127 GtkWidget
*f_add_button
; /**< add expression to current expression (GtkButton) */
132 * @fn GtkWidget* guifilter_get_widget(FilterViewerData*)
134 * This function returns the current main widget
135 * used by this module
136 * @param fvd the module struct
137 * @return The main widget
140 guifilter_get_widget(FilterViewerData
*fvd
)
142 return fvd
->f_window
;
146 * @fn FilterViewerData* gui_filter(Tab*)
148 * Constructor is used to create FilterViewerData data structure.
149 * @param tab The tab structure used by the widget
150 * @return The Filter viewer data created.
155 g_debug("filter::gui_filter()");
158 GtkCellRenderer
*renderer
;
159 GtkTreeViewColumn
*column
;
161 FilterViewerData
* fvd
= g_new(FilterViewerData
,1);
165 // lttvwindow_register_traceset_notify(fvd->tab,
166 // filter_traceset_changed,
167 // filter_viewer_data);
168 // request_background_data(filter_viewer_data);
171 * Initiating items for
174 fvd
->f_not_op_options
= g_ptr_array_new();
175 g_ptr_array_add(fvd
->f_not_op_options
,(gpointer
) g_string_new(""));
176 g_ptr_array_add(fvd
->f_not_op_options
,(gpointer
) g_string_new("!"));
178 fvd
->f_logical_op_options
= g_ptr_array_new(); //g_array_new(FALSE,FALSE,sizeof(gchar));
179 g_ptr_array_add(fvd
->f_logical_op_options
,(gpointer
) g_string_new(""));
180 g_ptr_array_add(fvd
->f_logical_op_options
,(gpointer
) g_string_new("&"));
181 g_ptr_array_add(fvd
->f_logical_op_options
,(gpointer
) g_string_new("|"));
182 g_ptr_array_add(fvd
->f_logical_op_options
,(gpointer
) g_string_new("!"));
183 g_ptr_array_add(fvd
->f_logical_op_options
,(gpointer
) g_string_new("^"));
185 fvd
->f_field_options
= g_ptr_array_new(); //g_array_new(FALSE,FALSE,16);
186 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new(""));
187 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("event.name"));
188 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("event.facility"));
189 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("event.category"));
190 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("event.time"));
191 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("event.tsc"));
193 * TODO: Add core.xml fields here !
195 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("tracefile.name"));
196 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("trace.name"));
197 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.process_name"));
198 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.pid"));
199 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.ppid"));
200 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.creation_time"));
201 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.insertion_time"));
202 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.execution_mode"));
203 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.execution_submode"));
204 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.process_status"));
205 g_ptr_array_add(fvd
->f_field_options
,(gpointer
) g_string_new("state.cpu"));
207 fvd
->f_math_op_options
= g_ptr_array_new(); //g_array_new(FALSE,FALSE,7);
208 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new(""));
209 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new("="));
210 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new("!="));
211 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new("<"));
212 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new("<="));
213 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new(">"));
214 g_ptr_array_add(fvd
->f_math_op_options
,(gpointer
) g_string_new(">="));
217 fvd
->f_window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
218 gtk_window_set_title(GTK_WINDOW(fvd
->f_window
), "LTTV Filter");
219 gtk_window_set_transient_for(GTK_WINDOW(fvd
->f_window
),
220 GTK_WINDOW(main_window_get_widget(tab
)));
221 gtk_window_set_destroy_with_parent(GTK_WINDOW(fvd
->f_window
), TRUE
);
224 * Initiating GtkTable layout
225 * starts with 2 rows and 5 columns and
226 * expands when expressions added
228 fvd
->f_main_box
= gtk_table_new(3,7,FALSE
);
229 gtk_table_set_row_spacings(GTK_TABLE(fvd
->f_main_box
),5);
230 gtk_table_set_col_spacings(GTK_TABLE(fvd
->f_main_box
),5);
232 gtk_container_add(GTK_CONTAINER(fvd
->f_window
), GTK_WIDGET(fvd
->f_main_box
));
235 * First half of the filter window
236 * - textual entry of filter expression
237 * - processing button
239 fvd
->f_expression_field
= gtk_entry_new(); //gtk_scrolled_window_new (NULL, NULL);
240 g_signal_connect (G_OBJECT(fvd
->f_expression_field
),
241 "key-press-event", G_CALLBACK (callback_enter_check
), (gpointer
)fvd
);
242 // gtk_entry_set_text(GTK_ENTRY(fvd->f_expression_field),"state.cpu>0");
243 gtk_widget_show (fvd
->f_expression_field
);
245 g_signal_connect (G_OBJECT (fvd
->f_expression_field
), "changed",
246 G_CALLBACK (callback_expression_field
), (gpointer
) fvd
);
248 fvd
->f_process_button
= gtk_button_new_with_label("Process");
249 gtk_widget_show (fvd
->f_process_button
);
251 g_signal_connect (G_OBJECT (fvd
->f_process_button
), "clicked",
252 G_CALLBACK (callback_process_button
), (gpointer
) fvd
);
254 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_expression_field
,0,6,0,1,GTK_FILL
,GTK_FILL
,0,0);
255 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_process_button
,6,7,0,1,GTK_FILL
,GTK_FILL
,0,0);
260 * Second half of the filter window
261 * - combo boxes featuring filtering options added to the expression
263 fvd
->f_add_button
= gtk_button_new_with_label("Add Expression");
264 gtk_widget_show (fvd
->f_add_button
);
266 g_signal_connect (G_OBJECT (fvd
->f_add_button
), "clicked",
267 G_CALLBACK (callback_add_button
), (gpointer
) fvd
);
269 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_add_button
,6,7,1,2,GTK_FILL
,GTK_FILL
,0,0);
271 fvd
->f_logical_op_junction_box
= gtk_combo_box_new_text();
272 for(i
=0;i
<fvd
->f_logical_op_options
->len
;i
++) {
273 GString
* s
= g_ptr_array_index(fvd
->f_logical_op_options
,i
);
274 gtk_combo_box_append_text(GTK_COMBO_BOX(fvd
->f_logical_op_junction_box
), s
->str
);
276 gtk_combo_box_set_active(GTK_COMBO_BOX(fvd
->f_logical_op_junction_box
),0);
278 //gtk_widget_show(fvd->f_logical_op_box);
280 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_logical_op_junction_box
,0,1,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
282 gtk_container_set_border_width(GTK_CONTAINER(fvd
->f_main_box
), 1);
284 /* initialize a new line */
285 fvd
->f_lines
= g_ptr_array_new();
287 FilterViewerDataLine
* fvdl
= gui_filter_add_line(fvd
);
288 g_ptr_array_add(fvd
->f_lines
,(gpointer
) fvdl
);
291 * show main container
293 gtk_widget_show(fvd
->f_main_box
);
294 gtk_widget_show(fvd
->f_window
);
297 g_object_set_data_full(
298 G_OBJECT(guifilter_get_widget(fvd
)),
299 "filter_viewer_data",
301 (GDestroyNotify
)gui_filter_destructor
);
303 g_filter_list
= g_slist_append(
311 * @fn FilterViewerDataLine* gui_filter_add_line(FilterViewerData*)
313 * Adds a filter option line on the module tab
314 * @param fvd The filter module structure
315 * @return The line structure
317 FilterViewerDataLine
*
318 gui_filter_add_line(FilterViewerData
* fvd
) {
320 FilterViewerDataLine
* fvdl
= g_new(FilterViewerDataLine
,1);
323 fvdl
->row
= fvd
->rows
;
324 fvdl
->visible
= TRUE
;
326 fvdl
->f_not_op_box
= gtk_combo_box_new_text();
327 for(i
=0;i
<fvd
->f_not_op_options
->len
;i
++) {
328 GString
* s
= g_ptr_array_index(fvd
->f_not_op_options
,i
);
329 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl
->f_not_op_box
), s
->str
);
332 fvdl
->f_field_box
= gtk_combo_box_new_text();
333 for(i
=0;i
<fvd
->f_field_options
->len
;i
++) {
334 GString
* s
= g_ptr_array_index(fvd
->f_field_options
,i
);
335 // g_print("String field: %s\n",s->str);
336 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl
->f_field_box
), s
->str
);
339 fvdl
->f_math_op_box
= gtk_combo_box_new_text();
340 for(i
=0;i
<fvd
->f_math_op_options
->len
;i
++) {
341 GString
* s
= g_ptr_array_index(fvd
->f_math_op_options
,i
);
342 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl
->f_math_op_box
), s
->str
);
345 fvdl
->f_value_field
= gtk_entry_new();
347 fvdl
->f_logical_op_box
= gtk_combo_box_new_text();
348 for(i
=0;i
<fvd
->f_logical_op_options
->len
;i
++) {
349 GString
* s
= g_ptr_array_index(fvd
->f_logical_op_options
,i
);
350 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl
->f_logical_op_box
), s
->str
);
352 gtk_widget_set_events(fvdl
->f_logical_op_box
,
353 GDK_ENTER_NOTIFY_MASK
|
354 GDK_LEAVE_NOTIFY_MASK
|
355 GDK_FOCUS_CHANGE_MASK
);
357 g_signal_connect (G_OBJECT (fvdl
->f_logical_op_box
), "changed",
358 G_CALLBACK (callback_logical_op_box
), (gpointer
) fvd
);
360 gui_filter_line_reset(fvdl
);
361 gui_filter_line_set_visible(fvdl
,TRUE
);
363 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvdl
->f_not_op_box
,0,1,fvd
->rows
+1,fvd
->rows
+2,GTK_SHRINK
,GTK_FILL
,0,0);
364 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvdl
->f_field_box
,1,3,fvd
->rows
+1,fvd
->rows
+2,GTK_SHRINK
,GTK_FILL
,0,0);
365 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvdl
->f_math_op_box
,3,4,fvd
->rows
+1,fvd
->rows
+2,GTK_SHRINK
,GTK_FILL
,0,0);
366 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvdl
->f_value_field
,4,5,fvd
->rows
+1,fvd
->rows
+2,GTK_SHRINK
,GTK_FILL
,0,0);
367 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvdl
->f_logical_op_box
,5,6,fvd
->rows
+1,fvd
->rows
+2,GTK_SHRINK
,GTK_FILL
,0,0);
373 * @fn void gui_filter_line_set_visible(FilterViewerDataLine*,gboolean)
375 * Change visible state of current FilterViewerDataLine
376 * @param fvdl pointer to the current FilterViewerDataLine
377 * @param v TRUE: sets visible, FALSE: sets invisible
380 gui_filter_line_set_visible(FilterViewerDataLine
*fvdl
, gboolean v
) {
384 gtk_widget_show(fvdl
->f_not_op_box
);
385 gtk_widget_show(fvdl
->f_field_box
);
386 gtk_widget_show(fvdl
->f_math_op_box
);
387 gtk_widget_show(fvdl
->f_value_field
);
388 gtk_widget_show(fvdl
->f_logical_op_box
);
390 gtk_widget_hide(fvdl
->f_not_op_box
);
391 gtk_widget_hide(fvdl
->f_field_box
);
392 gtk_widget_hide(fvdl
->f_math_op_box
);
393 gtk_widget_hide(fvdl
->f_value_field
);
394 gtk_widget_hide(fvdl
->f_logical_op_box
);
400 * @fn void gui_filter_line_reset(FilterViewerDataLine*)
402 * Sets selections of all boxes in current FilterViewerDataLine
403 * to default value (0)
404 * @param fvdl pointer to current FilterViewerDataLine
407 gui_filter_line_reset(FilterViewerDataLine
*fvdl
) {
409 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl
->f_not_op_box
),0);
410 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl
->f_field_box
),0);
411 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl
->f_math_op_box
),0);
412 gtk_entry_set_text(GTK_ENTRY(fvdl
->f_value_field
),"");
413 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl
->f_logical_op_box
),0);
417 * @fn void gui_filter_destructor(FilterViewerData*)
419 * Destructor for the filter gui module
420 * @param fvd The module structure
423 gui_filter_destructor(FilterViewerData
*fvd
)
427 /* May already been done by GTK window closing */
428 if(GTK_IS_WIDGET(guifilter_get_widget(fvd
))){
429 g_info("widget still exists");
432 // lttvwindow_unregister_traceset_notify(fvd->tab,
433 // filter_traceset_changed,
434 // filter_viewer_data);
436 lttvwindowtraces_background_notify_remove(fvd
);
438 g_filter_list
= g_slist_remove(g_filter_list
, fvd
);
445 * @fn GtkWidget* h_guifilter(Tab*)
447 * Filter Module's constructor hook
449 * This constructor is given as a parameter to the menuitem and toolbar button
450 * registration. It creates the list.
451 * @param tab A pointer to the parent window.
452 * @return The widget created.
455 h_guifilter(Tab
*tab
)
457 FilterViewerData
* f
= gui_filter(tab
) ;
463 * @fn static void init()
465 * This function initializes the Filter Viewer functionnality through the
470 lttvwindow_register_constructor("guifilter",
472 "Insert Filter Module",
473 hGuiFilterInsert_xpm
,
474 "Insert Filter Module",
479 * @fn void filter_destroy_walk(gpointer,gpointer)
481 * Initiate the destruction of the current gui module
482 * on the GTK Interface
485 filter_destroy_walk(gpointer data
, gpointer user_data
)
487 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
489 g_debug("CFV.c : filter_destroy_walk, %p", fvd
);
491 /* May already have been done by GTK window closing */
492 if(GTK_IS_WIDGET(guifilter_get_widget(fvd
)))
493 gtk_widget_destroy(guifilter_get_widget(fvd
));
497 * @fn static void destroy()
498 * @brief plugin's destroy function
500 * This function releases the memory reserved by the module and unregisters
501 * everything that has been registered in the gtkTraceSet API.
503 static void destroy() {
505 g_slist_foreach(g_filter_list
, filter_destroy_walk
, NULL
);
507 lttvwindow_unregister_constructor(h_guifilter
);
512 * @fn void callback_process_button(GtkWidget*,gpointer)
514 * The Process Button callback function
515 * @param widget The Button widget passed to the callback function
516 * @param data Data sent along with the callback function
519 callback_process_button(GtkWidget
*widget
, gpointer data
) {
521 g_debug("callback_process_button(): Processing expression");
523 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
526 if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd
->f_expression_field
))) !=0) {
527 filter
= lttv_filter_new();
528 GString
* s
= g_string_new(gtk_entry_get_text(GTK_ENTRY(fvd
->f_expression_field
)));
529 lttv_filter_append_expression(filter
,s
->str
);
530 g_string_free(s
,TRUE
);
531 //SetFilter(fvd->tab,filter);
535 lttvwindow_report_filter(fvd
->tab
, filter
);
538 gboolean
callback_enter_check(GtkWidget
*widget
,
542 g_debug("typed : %x", event
->keyval
);
543 switch(event
->keyval
) {
548 callback_process_button(widget
, user_data
);
557 * @fn void callback_expression_field(GtkWidget*,gpointer)
559 * The Add Button callback function
560 * @param widget The Button widget passed to the callback function
561 * @param data Data sent along with the callback function
564 callback_expression_field(GtkWidget
*widget
, gpointer data
) {
566 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
568 if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd
->f_expression_field
))) !=0) {
569 gtk_widget_show(fvd
->f_logical_op_junction_box
);
571 gtk_widget_hide(fvd
->f_logical_op_junction_box
);
577 * @fn void callback_add_button(GtkWidget*,gpointer)
579 * The Add Button callback function
580 * @param widget The Button widget passed to the callback function
581 * @param data Data sent along with the callback function
584 callback_add_button(GtkWidget
*widget
, gpointer data
) {
586 g_debug("callback_add_button(): processing simple expressions");
590 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
591 FilterViewerDataLine
*fvdl
= NULL
;
592 GString
* a_filter_string
= g_string_new("");
595 * adding linking operator to
599 s
= g_ptr_array_index(fvd
->f_logical_op_options
,gtk_combo_box_get_active(GTK_COMBO_BOX(fvd
->f_logical_op_junction_box
)));
600 g_string_append(a_filter_string
,s
->str
);
601 gtk_combo_box_set_active(GTK_COMBO_BOX(fvd
->f_logical_op_junction_box
),0);
603 /* begin expression */
604 g_string_append_c(a_filter_string
,'(');
607 * For each simple expression, add the resulting string
608 * to the filter string
610 * Each simple expression takes the following schema
611 * [not operator '!',' '] [field type] [math operator '<','<=','>','>=','=','!='] [value]
613 for(i
=0;i
<fvd
->f_lines
->len
;i
++) {
614 fvdl
= (FilterViewerDataLine
*)g_ptr_array_index(fvd
->f_lines
,i
);
616 s
= g_ptr_array_index(fvd
->f_not_op_options
,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl
->f_not_op_box
)));
617 g_string_append(a_filter_string
,s
->str
);
619 s
= g_ptr_array_index(fvd
->f_field_options
,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl
->f_field_box
)));
620 g_string_append(a_filter_string
,s
->str
);
622 s
= g_ptr_array_index(fvd
->f_math_op_options
,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl
->f_math_op_box
)));
623 g_string_append(a_filter_string
,s
->str
);
625 g_string_append(a_filter_string
,gtk_entry_get_text(GTK_ENTRY(fvdl
->f_value_field
)));
627 s
= g_ptr_array_index(fvd
->f_logical_op_options
,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl
->f_logical_op_box
)));
628 g_string_append(a_filter_string
,s
->str
);
631 * resetting simple expression lines
633 gui_filter_line_reset(fvdl
);
634 if(i
) gui_filter_line_set_visible(fvdl
,FALSE
); // Only keep the first line
638 g_string_append_c(a_filter_string
,')');
640 g_string_prepend(a_filter_string
,gtk_entry_get_text(GTK_ENTRY(fvd
->f_expression_field
)));
641 gtk_entry_set_text(GTK_ENTRY(fvd
->f_expression_field
),a_filter_string
->str
);
646 * @fn void callback_logical_op_box(GtkWidget*,gpointer)
648 * The logical op box callback function
649 * @param widget The Button widget passed to the callback function
650 * @param data Data sent along with the callback function
653 callback_logical_op_box(GtkWidget
*widget
, gpointer data
) {
655 g_debug("callback_logical_op_box(): adding new simple expression");
657 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
658 FilterViewerDataLine
*fvdl
= NULL
;
661 for(i
=0;i
<fvd
->f_lines
->len
;i
++) {
662 fvdl
= (FilterViewerDataLine
*)g_ptr_array_index(fvd
->f_lines
,i
);
663 if(fvdl
->f_logical_op_box
== widget
) {
664 if(gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl
->f_logical_op_box
)) == 0) return;
665 if(i
==fvd
->f_lines
->len
-1) { /* create a new line */
667 FilterViewerDataLine
* fvdl2
= gui_filter_add_line(fvd
);
668 g_ptr_array_add(fvd
->f_lines
,(gpointer
) fvdl2
);
670 FilterViewerDataLine
*fvdl2
= (FilterViewerDataLine
*)g_ptr_array_index(fvd
->f_lines
,i
+1);
671 if(!fvdl2
->visible
) gui_filter_line_set_visible(fvdl2
,TRUE
);
678 LTTV_MODULE("guifilter", "Filter window", \
679 "Graphical module that let user specify their filtering options", \
680 init
, destroy
, "lttvwindow")