fixed errors
[lttv.git] / ltt / branches / poly / lttv / modules / gui / filter / filter.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Simon Bouvier-Zappa
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19 #include <glib.h>
20 #include <string.h>
21 #include <gtk/gtk.h>
22 #include <gdk/gdk.h>
23
24 #include <lttv/lttv.h>
25 #include <lttv/module.h>
26 #include <lttv/hook.h>
27 #include <lttv/filter.h>
28
29 #include <lttvwindow/lttvwindow.h>
30 #include <lttvwindow/lttvwindowtraces.h>
31
32 #include "hGuiFilterInsert.xpm"
33
34 /*
35 * TODO
36 * - connect the gui filter to the core filter
37 */
38
39 /*
40 * NOTE
41 * The version of gtk-2.0 currently installed on
42 * my desktop misses some function of the newer
43 * gtk+ api.
44 *
45 * For the time being, I'll use the older api
46 * to keep compatibility with most systems.
47 */
48
49 typedef struct _FilterViewerData FilterViewerData;
50 typedef struct _FilterViewerDataLine FilterViewerDataLine;
51
52 /*
53 * Prototypes
54 */
55 GtkWidget *guifilter_get_widget(FilterViewerData *fvd);
56 FilterViewerData *gui_filter(Tab *tab);
57 void gui_filter_destructor(FilterViewerData *fvd);
58 FilterViewerDataLine* gui_filter_add_line(FilterViewerData *fvd);
59 void gui_filter_line_set_visible(FilterViewerDataLine *fvdl, gboolean v);
60 void gui_filter_line_reset(FilterViewerDataLine *fvdl);
61 gboolean filter_traceset_changed(void * hook_data, void * call_data);
62 gboolean filter_viewer_data(void * hook_data, void * call_data);
63 GtkWidget* h_guifilter(Tab *tab);
64 void filter_destroy_walk(gpointer data, gpointer user_data);
65
66 /*
67 * Callback functions
68 */
69 void callback_process_button(GtkWidget *widget, gpointer data);
70 void callback_add_button(GtkWidget *widget, gpointer data);
71 void callback_logical_op_box(GtkWidget *widget, gpointer data);
72 void callback_expression_field(GtkWidget *widget, gpointer data);
73
74 struct _FilterViewerDataLine {
75 int row;
76 gboolean visible;
77 GtkWidget *f_logical_op_box;
78 GtkWidget *f_field_box;
79 // GtkWidget *f_struct_box;
80 // GtkWidget *f_subfield_box;
81 GtkWidget *f_math_op_box;
82 GtkWidget *f_value_field;
83 };
84
85 /**
86 * @struct _FilterViewerData
87 * Main struct for the filter gui module
88 */
89 struct _FilterViewerData {
90 Tab *tab;
91
92 GtkWidget *f_main_box;
93
94 GtkWidget *f_hbox1;
95 GtkWidget *f_hbox2;
96
97 GtkWidget *f_expression_field;
98 GtkWidget *f_process_button;
99
100 GtkWidget *f_logical_op_junction_box;
101
102 int rows;
103 GPtrArray *f_lines;
104
105 GPtrArray *f_logical_op_options;
106 GPtrArray *f_field_options;
107 GPtrArray *f_math_op_options;
108
109 GtkWidget *f_add_button;
110
111 GtkWidget *f_textwnd;
112 GtkWidget *f_selectwnd;
113 GtkWidget *f_treewnd;
114
115 };
116
117 /**
118 * This function returns the current main widget
119 * used by this module
120 * @param fvd the module struct
121 * @return The main widget
122 */
123 GtkWidget
124 *guifilter_get_widget(FilterViewerData *fvd)
125 {
126 return fvd->f_main_box;
127 }
128
129 /**
130 * Constructor is used to create FilterViewerData data structure.
131 * @param the tab structure used by the widget
132 * @return The Filter viewer data created.
133 */
134 FilterViewerData*
135 gui_filter(Tab *tab)
136 {
137 g_print("filter::gui_filter()");
138
139 unsigned i;
140 GtkCellRenderer *renderer;
141 GtkTreeViewColumn *column;
142
143 FilterViewerData* fvd = g_new(FilterViewerData,1);
144
145 fvd->tab = tab;
146
147 lttvwindow_register_traceset_notify(fvd->tab,
148 filter_traceset_changed,
149 filter_viewer_data);
150 // request_background_data(filter_viewer_data);
151
152 /*
153 * Initiating items for
154 * combo boxes
155 */
156 fvd->f_logical_op_options = g_ptr_array_new(); //g_array_new(FALSE,FALSE,sizeof(gchar));
157 g_ptr_array_add(fvd->f_logical_op_options,(gpointer) g_string_new(""));
158 g_ptr_array_add(fvd->f_logical_op_options,(gpointer) g_string_new("&"));
159 g_ptr_array_add(fvd->f_logical_op_options,(gpointer) g_string_new("|"));
160 g_ptr_array_add(fvd->f_logical_op_options,(gpointer) g_string_new("!"));
161 g_ptr_array_add(fvd->f_logical_op_options,(gpointer) g_string_new("^"));
162
163 fvd->f_field_options = g_ptr_array_new(); //g_array_new(FALSE,FALSE,16);
164 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new(""));
165 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.name"));
166 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.category"));
167 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.time"));
168 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.tsc"));
169 /*
170 * TODO: Add core.xml fields here !
171 */
172 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("tracefile.name"));
173 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("trace.name"));
174 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.pid"));
175 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.ppid"));
176 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.creation_time"));
177 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.insertion_time"));
178 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.execution_mode"));
179 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.execution_submode"));
180 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.process_status"));
181 g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.cpu"));
182
183 fvd->f_math_op_options = g_ptr_array_new(); //g_array_new(FALSE,FALSE,7);
184 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new(""));
185 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new("="));
186 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new("!="));
187 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new("<"));
188 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new("<="));
189 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new(">"));
190 g_ptr_array_add(fvd->f_math_op_options,(gpointer) g_string_new(">="));
191
192
193 /*
194 * Initiating GtkTable layout
195 * starts with 2 rows and 5 columns and
196 * expands when expressions added
197 */
198 fvd->f_main_box = gtk_table_new(3,6,FALSE);
199 gtk_table_set_row_spacings(GTK_TABLE(fvd->f_main_box),5);
200 gtk_table_set_col_spacings(GTK_TABLE(fvd->f_main_box),5);
201
202 /*
203 * First half of the filter window
204 * - textual entry of filter expression
205 * - processing button
206 */
207 fvd->f_expression_field = gtk_entry_new(); //gtk_scrolled_window_new (NULL, NULL);
208 // gtk_entry_set_text(GTK_ENTRY(fvd->f_expression_field),"state.cpu>0");
209 gtk_widget_show (fvd->f_expression_field);
210
211 g_signal_connect (G_OBJECT (fvd->f_expression_field), "changed",
212 G_CALLBACK (callback_expression_field), (gpointer) fvd);
213
214 fvd->f_process_button = gtk_button_new_with_label("Process");
215 gtk_widget_show (fvd->f_process_button);
216
217 g_signal_connect (G_OBJECT (fvd->f_process_button), "clicked",
218 G_CALLBACK (callback_process_button), (gpointer) fvd);
219
220 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_expression_field,0,5,0,1,GTK_FILL,GTK_FILL,0,0);
221 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_process_button,5,6,0,1,GTK_FILL,GTK_FILL,0,0);
222
223
224
225 /*
226 * Second half of the filter window
227 * - combo boxes featuring filtering options added to the expression
228 */
229 fvd->f_add_button = gtk_button_new_with_label("Add Expression");
230 gtk_widget_show (fvd->f_add_button);
231
232 g_signal_connect (G_OBJECT (fvd->f_add_button), "clicked",
233 G_CALLBACK (callback_add_button), (gpointer) fvd);
234
235 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_add_button,5,6,1,2,GTK_FILL,GTK_FILL,0,0);
236
237 fvd->f_logical_op_junction_box = gtk_combo_box_new_text();
238 for(i=0;i<fvd->f_logical_op_options->len;i++) {
239 GString* s = g_ptr_array_index(fvd->f_logical_op_options,i);
240 gtk_combo_box_append_text(GTK_COMBO_BOX(fvd->f_logical_op_junction_box), s->str);
241 }
242 gtk_combo_box_set_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box),0);
243
244 //gtk_widget_show(fvd->f_logical_op_box);
245
246 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);
247
248 /* initialize a new line */
249 fvd->f_lines = g_ptr_array_new();
250 fvd->rows = 1;
251 FilterViewerDataLine* fvdl = gui_filter_add_line(fvd);
252 g_ptr_array_add(fvd->f_lines,(gpointer) fvdl);
253
254 /*
255 * show main container
256 */
257 gtk_widget_show(fvd->f_main_box);
258
259
260 g_object_set_data_full(
261 G_OBJECT(guifilter_get_widget(fvd)),
262 "filter_viewer_data",
263 fvd,
264 (GDestroyNotify)gui_filter_destructor);
265
266
267 return fvd;
268 }
269
270 /**
271 * Adds a filter option line on the module tab
272 * @param fvd The filter module structure
273 * @return The line structure
274 */
275 FilterViewerDataLine*
276 gui_filter_add_line(FilterViewerData* fvd) {
277
278 FilterViewerDataLine* fvdl = g_new(FilterViewerDataLine,1);
279
280 unsigned i;
281 fvdl->row = fvd->rows;
282 fvdl->visible = TRUE;
283
284 /*
285 fvdl->f_struct_box = gtk_combo_box_new_text();
286 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_struct_box), "");
287 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_struct_box), "event");
288 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_struct_box), "tracefile");
289 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_struct_box), "trace");
290 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_struct_box), "state");
291 gtk_widget_show(fvdl->f_struct_box);
292
293 fvdl->f_subfield_box = gtk_combo_box_new_text();
294 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "");
295 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "name");
296 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "category");
297 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "time");
298 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "tsc");
299 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "pid");
300 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "ppid");
301 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "creation time");
302 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "insertion time");
303 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "process name");
304 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "execution mode");
305 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "execution submode");
306 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "process status");
307 gtk_combo_box_append_text (GTK_COMBO_BOX (fvdl->f_subfield_box), "cpu");
308 gtk_widget_show(fvdl->f_subfield_box);
309 */
310
311 fvdl->f_field_box = gtk_combo_box_new_text();
312 for(i=0;i<fvd->f_field_options->len;i++) {
313 GString* s = g_ptr_array_index(fvd->f_field_options,i);
314 g_print("String field: %s\n",s->str);
315 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl->f_field_box), s->str);
316 }
317
318 fvdl->f_math_op_box = gtk_combo_box_new_text();
319 for(i=0;i<fvd->f_math_op_options->len;i++) {
320 GString* s = g_ptr_array_index(fvd->f_math_op_options,i);
321 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl->f_math_op_box), s->str);
322 }
323
324 fvdl->f_value_field = gtk_entry_new();
325
326 fvdl->f_logical_op_box = gtk_combo_box_new_text();
327 for(i=0;i<fvd->f_logical_op_options->len;i++) {
328 GString* s = g_ptr_array_index(fvd->f_logical_op_options,i);
329 gtk_combo_box_append_text(GTK_COMBO_BOX(fvdl->f_logical_op_box), s->str);
330 }
331 gtk_widget_set_events(fvdl->f_logical_op_box,
332 GDK_ENTER_NOTIFY_MASK |
333 GDK_LEAVE_NOTIFY_MASK |
334 GDK_FOCUS_CHANGE_MASK);
335
336 g_signal_connect (G_OBJECT (fvdl->f_logical_op_box), "changed",
337 G_CALLBACK (callback_logical_op_box), (gpointer) fvd);
338
339 gui_filter_line_reset(fvdl);
340 gui_filter_line_set_visible(fvdl,TRUE);
341
342 // gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_struct_box,0,1,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
343 // gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_subfield_box,1,2,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
344 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_field_box,0,2,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
345 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_math_op_box,2,3,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
346 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_value_field,3,4,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
347 gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvdl->f_logical_op_box,4,5,fvd->rows+1,fvd->rows+2,GTK_SHRINK,GTK_FILL,0,0);
348
349 return fvdl;
350 }
351
352 void gui_filter_line_set_visible(FilterViewerDataLine *fvdl, gboolean v) {
353
354 fvdl->visible = v;
355 if(v) {
356 // gtk_widget_show(fvdl->f_struct_box);
357 // gtk_widget_show(fvdl->f_subfield_box);
358 gtk_widget_show(fvdl->f_field_box);
359 gtk_widget_show(fvdl->f_math_op_box);
360 gtk_widget_show(fvdl->f_value_field);
361 gtk_widget_show(fvdl->f_logical_op_box);
362 } else {
363 // gtk_widget_hide(fvdl->f_struct_box);
364 // gtk_widget_hide(fvdl->f_subfield_box);
365 gtk_widget_hide(fvdl->f_field_box);
366 gtk_widget_hide(fvdl->f_math_op_box);
367 gtk_widget_hide(fvdl->f_value_field);
368 gtk_widget_hide(fvdl->f_logical_op_box);
369 }
370
371 }
372
373 void gui_filter_line_reset(FilterViewerDataLine *fvdl) {
374
375 // gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl->f_struct_box),0);
376 // gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl->f_subfield_box),0);
377 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl->f_field_box),0);
378 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl->f_math_op_box),0);
379 gtk_entry_set_text(GTK_COMBO_BOX(fvdl->f_value_field),"");
380 gtk_combo_box_set_active(GTK_COMBO_BOX(fvdl->f_logical_op_box),0);
381 }
382
383 /**
384 * Destructor for the filter gui module
385 * @param fvd The module structure
386 */
387 void
388 gui_filter_destructor(FilterViewerData *fvd)
389 {
390 Tab *tab = fvd->tab;
391
392 /* May already been done by GTK window closing */
393 if(GTK_IS_WIDGET(guifilter_get_widget(fvd))){
394 g_info("widget still exists");
395 }
396 if(tab != NULL) {
397 lttvwindow_unregister_traceset_notify(fvd->tab,
398 filter_traceset_changed,
399 filter_viewer_data);
400 }
401 lttvwindowtraces_background_notify_remove(fvd);
402
403 g_free(fvd);
404 }
405
406 /**
407 * Hook function
408 * @param hook_data The hook data
409 * @param call_data The call data
410 * @return Success/Failure of operation
411 */
412 gboolean
413 filter_traceset_changed(void * hook_data, void * call_data) {
414
415 return FALSE;
416 }
417
418 /**
419 * Hook function
420 * @param hook_data The hook data
421 * @param call_data The call data
422 * @return Success/Failure of operation
423 */
424 gboolean
425 filter_viewer_data(void * hook_data, void * call_data) {
426
427 return FALSE;
428 }
429
430 /**
431 * Filter Module's constructor hook
432 *
433 * This constructor is given as a parameter to the menuitem and toolbar button
434 * registration. It creates the list.
435 * @param tab A pointer to the parent window.
436 * @return The widget created.
437 */
438 GtkWidget *
439 h_guifilter(Tab *tab)
440 {
441 FilterViewerData* f = gui_filter(tab) ;
442
443 g_print("FilterViewerData:%p\n",f);
444 if(f)
445 return guifilter_get_widget(f);
446 else return NULL;
447
448 }
449
450 /**
451 * This function initializes the Filter Viewer functionnality through the
452 * gtkTraceSet API.
453 */
454 static void init() {
455
456 lttvwindow_register_constructor("guifilter",
457 "/",
458 "Insert Filter Module",
459 hGuiFilterInsert_xpm,
460 "Insert Filter Module",
461 h_guifilter);
462 }
463
464 /**
465 * Initiate the destruction of the current gui module
466 * on the GTK Interface
467 */
468 void filter_destroy_walk(gpointer data, gpointer user_data)
469 {
470 FilterViewerData *fvd = (FilterViewerData*)data;
471
472 g_debug("CFV.c : filter_destroy_walk, %p", fvd);
473 /* May already have been done by GTK window closing */
474 if(GTK_IS_WIDGET(guifilter_get_widget(fvd)))
475 gtk_widget_destroy(guifilter_get_widget(fvd));
476 }
477
478 /**
479 * plugin's destroy function
480 *
481 * This function releases the memory reserved by the module and unregisters
482 * everything that has been registered in the gtkTraceSet API.
483 */
484 static void destroy() {
485
486 lttvwindow_unregister_constructor(h_guifilter);
487
488 }
489
490 /**
491 * The Process Button callback function
492 * @param widget The Button widget passed to the callback function
493 * @param data Data sent along with the callback function
494 */
495 void callback_process_button(GtkWidget *widget, gpointer data) {
496
497 FilterViewerData *fvd = (FilterViewerData*)data;
498
499 if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))) !=0)
500 lttv_filter_new(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field)),NULL);
501 }
502
503 /**
504 * The Add Button callback function
505 * @param widget The Button widget passed to the callback function
506 * @param data Data sent along with the callback function
507 */
508 void callback_expression_field(GtkWidget *widget, gpointer data) {
509
510 FilterViewerData *fvd = (FilterViewerData*)data;
511
512 if(strlen(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))) !=0) {
513 gtk_widget_show(fvd->f_logical_op_junction_box);
514 } else {
515 gtk_widget_hide(fvd->f_logical_op_junction_box);
516 }
517 }
518
519
520 /**
521 * The Add Button callback function
522 * @param widget The Button widget passed to the callback function
523 * @param data Data sent along with the callback function
524 */
525 void callback_add_button(GtkWidget *widget, gpointer data) {
526
527 g_print("filter::callback_add_button()\n");
528
529 FilterViewerData *fvd = (FilterViewerData*)data;
530 FilterViewerDataLine *fvdl = NULL;
531 GString* a_filter_string = g_string_new("");
532
533 GString* s;
534 s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box)));
535 g_print("s:%p\n",s);
536 g_print("string:%s\n",s);
537 g_string_append(a_filter_string,s->str);
538 gtk_combo_box_set_active(fvd->f_logical_op_junction_box,0);
539
540 g_print("passe junction\n");
541
542 g_string_append_c(a_filter_string,'(');
543
544 int i;
545 for(i=0;i<fvd->f_lines->len;i++) {
546 fvdl = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i);
547
548 s = g_ptr_array_index(fvd->f_field_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_field_box)));
549 g_string_append(a_filter_string,s->str);
550
551 s = g_ptr_array_index(fvd->f_math_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_math_op_box)));
552 g_string_append(a_filter_string,s->str);
553
554 g_string_append(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvdl->f_value_field)));
555
556 s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_logical_op_box)));
557 g_string_append(a_filter_string,s->str);
558
559 gui_filter_line_reset(fvdl);
560 if(i) gui_filter_line_set_visible(fvdl,FALSE); // Only keep the first line
561 }
562
563 g_string_append_c(a_filter_string,')');
564
565 g_string_prepend(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field)));
566 gtk_entry_set_text(GTK_ENTRY(fvd->f_expression_field),a_filter_string->str);
567
568 }
569
570 /**
571 * The logical op box callback function
572 * @param widget The Button widget passed to the callback function
573 * @param data Data sent along with the callback function
574 */
575 void callback_logical_op_box(GtkWidget *widget, gpointer data) {
576
577 g_print("filter::callback_logical_op_box()\n");
578
579 FilterViewerData *fvd = (FilterViewerData*)data;
580 FilterViewerDataLine *fvdl = NULL;
581
582 int i;
583 for(i=0;i<fvd->f_lines->len;i++) {
584 fvdl = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i);
585 if(fvdl->f_logical_op_box == widget) {
586 if(gtk_combo_box_get_active(fvdl->f_logical_op_box) == 0) return;
587 if(i==fvd->f_lines->len-1) { /* create a new line */
588 fvd->rows++;
589 FilterViewerDataLine* fvdl2 = gui_filter_add_line(fvd);
590 g_ptr_array_add(fvd->f_lines,(gpointer) fvdl2);
591 } else {
592 FilterViewerDataLine *fvdl2 = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i+1);
593 if(!fvdl2->visible) gui_filter_line_set_visible(fvdl2,TRUE);
594 }
595 }
596 }
597
598 }
599
600 LTTV_MODULE("guifilter", "Filter window", \
601 "Graphical module that let user specify their filtering options", \
602 init, destroy, "lttvwindow")
603
This page took 0.041528 seconds and 5 git commands to generate.