1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 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,
24 #include <lttv/lttv.h>
25 #include <lttv/module.h>
26 #include <lttv/hook.h>
27 #include <lttv/filter.h>
29 #include <lttvwindow/lttvwindow.h>
30 #include <lttvwindow/lttvwindowtraces.h>
32 #include "hGuiFilterInsert.xpm"
36 * - connect the gui filter to the core filter
39 typedef struct _FilterViewerData FilterViewerData
;
44 GtkWidget
*guifilter_get_widget(FilterViewerData
*fvd
);
45 FilterViewerData
*gui_filter(Tab
*tab
);
46 void gui_filter_destructor(FilterViewerData
*fvd
);
47 gboolean
filter_traceset_changed(void * hook_data
, void * call_data
);
48 gboolean
filter_viewer_data(void * hook_data
, void * call_data
);
49 GtkWidget
* h_guifilter(Tab
*tab
);
50 void statistic_destroy_walk(gpointer data
, gpointer user_data
);
52 struct _FilterViewerData
{
55 GtkWidget
*f_main_box
;
60 GtkWidget
*f_expression_field
;
61 GtkWidget
*f_process_button
;
63 GtkWidget
*f_logical_op_box
;
64 GtkWidget
*f_struct_box
;
65 GtkWidget
*f_subfield_box
;
66 GtkWidget
*f_math_op_box
;
67 GtkWidget
*f_value_field
;
70 GtkWidget
*f_selectwnd
;
76 *guifilter_get_widget(FilterViewerData
*fvd
)
78 return fvd
->f_main_box
;
82 * Statistic Viewer's constructor
84 * This constructor is used to create StatisticViewerData data structure.
85 * @return The Statistic viewer data created.
90 g_print("filter::gui_filter()");
92 GtkCellRenderer
*renderer
;
93 GtkTreeViewColumn
*column
;
95 FilterViewerData
* fvd
= g_new(FilterViewerData
,1);
99 lttvwindow_register_traceset_notify(fvd
->tab
,
100 filter_traceset_changed
,
102 // request_background_data(filter_viewer_data);
105 * Initiating GtkTable layout
106 * starts with 2 rows and 5 columns and
107 * expands when expressions added
109 fvd
->f_main_box
= gtk_table_new(2,5,FALSE
);
110 gtk_table_set_row_spacings(GTK_TABLE(fvd
->f_main_box
),5);
111 gtk_table_set_col_spacings(GTK_TABLE(fvd
->f_main_box
),5);
114 * First half of the filter window
115 * - textual entry of filter expression
116 * - processing button
118 fvd
->f_expression_field
= gtk_entry_new(); //gtk_scrolled_window_new (NULL, NULL);
119 gtk_entry_set_text(GTK_ENTRY(fvd
->f_expression_field
),"state.cpu>0");
120 gtk_widget_show (fvd
->f_expression_field
);
122 fvd
->f_process_button
= gtk_button_new_with_label("Process");
123 gtk_widget_show (fvd
->f_process_button
);
125 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_expression_field
,0,4,0,1,GTK_FILL
,GTK_FILL
,0,0);
126 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_process_button
,4,5,0,1,GTK_SHRINK
,GTK_FILL
,0,0);
127 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_process_button
,4,5,0,1,GTK_SHRINK
,GTK_FILL
,0,0);
130 * Second half of the filter window
131 * - combo boxes featuring filtering options added to the expression
133 fvd
->f_logical_op_box
= gtk_combo_box_new_text();
134 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_logical_op_box
), "&");
135 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_logical_op_box
), "|");
136 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_logical_op_box
), "^");
137 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_logical_op_box
), "!");
138 gtk_widget_show(fvd
->f_logical_op_box
);
140 fvd
->f_struct_box
= gtk_combo_box_new_text();
141 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_struct_box
), "event");
142 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_struct_box
), "tracefile");
143 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_struct_box
), "trace");
144 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_struct_box
), "state");
145 gtk_widget_show(fvd
->f_struct_box
);
147 fvd
->f_subfield_box
= gtk_combo_box_new_text();
148 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "name");
149 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "category");
150 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "time");
151 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "tsc");
152 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "pid");
153 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "ppid");
154 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "creation time");
155 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "insertion time");
156 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "process name");
157 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "execution mode");
158 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "execution submode");
159 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "process status");
160 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_subfield_box
), "cpu");
161 gtk_widget_show(fvd
->f_subfield_box
);
163 fvd
->f_math_op_box
= gtk_combo_box_new_text();
164 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), "=");
165 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), "!=");
166 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), "<");
167 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), "<=");
168 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), ">");
169 gtk_combo_box_append_text (GTK_COMBO_BOX (fvd
->f_math_op_box
), ">=");
170 gtk_widget_show(fvd
->f_math_op_box
);
172 fvd
->f_value_field
= gtk_entry_new();
173 gtk_widget_show(fvd
->f_value_field
);
175 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_logical_op_box
,0,1,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
176 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_struct_box
,1,2,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
177 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_subfield_box
,2,3,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
178 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_math_op_box
,3,4,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
179 gtk_table_attach( GTK_TABLE(fvd
->f_main_box
),fvd
->f_value_field
,4,5,1,2,GTK_SHRINK
,GTK_FILL
,0,0);
181 /* show main container */
182 gtk_widget_show(fvd
->f_main_box
);
185 g_object_set_data_full(
186 G_OBJECT(guifilter_get_widget(fvd
)),
187 "filter_viewer_data",
189 (GDestroyNotify
)gui_filter_destructor
);
196 gui_filter_destructor(FilterViewerData
*fvd
)
200 /* May already been done by GTK window closing */
201 if(GTK_IS_WIDGET(guifilter_get_widget(fvd
))){
202 g_info("widget still exists");
205 lttvwindow_unregister_traceset_notify(fvd
->tab
,
206 filter_traceset_changed
,
209 lttvwindowtraces_background_notify_remove(fvd
);
215 filter_traceset_changed(void * hook_data
, void * call_data
) {
221 filter_viewer_data(void * hook_data
, void * call_data
) {
227 * Filter Module's constructor hook
229 * This constructor is given as a parameter to the menuitem and toolbar button
230 * registration. It creates the list.
231 * @param parent_window A pointer to the parent window.
232 * @return The widget created.
235 h_guifilter(Tab
*tab
)
237 FilterViewerData
* f
= gui_filter(tab
) ;
239 g_print("FilterViewerData:%p\n",f
);
241 return guifilter_get_widget(f
);
249 * plugin's init function
251 * This function initializes the Statistic Viewer functionnality through the
256 lttvwindow_register_constructor("guifilter",
258 "Insert Filter Module",
259 hGuiFilterInsert_xpm
,
260 "Insert Filter Module",
264 void filter_destroy_walk(gpointer data
, gpointer user_data
)
266 FilterViewerData
*fvd
= (FilterViewerData
*)data
;
268 g_debug("CFV.c : statistic_destroy_walk, %p", fvd
);
269 /* May already have been done by GTK window closing */
270 if(GTK_IS_WIDGET(guifilter_get_widget(fvd
)))
271 gtk_widget_destroy(guifilter_get_widget(fvd
));
275 * plugin's destroy function
277 * This function releases the memory reserved by the module and unregisters
278 * everything that has been registered in the gtkTraceSet API.
280 static void destroy() {
282 lttvwindow_unregister_constructor(h_guifilter
);
287 LTTV_MODULE("guifilter", "Filter window", \
288 "Graphical module that let user specify their filtering options", \
289 init
, destroy
, "lttvwindow")