reshaped the gui filter module
[lttv.git] / ltt / branches / poly / lttv / modules / gui / filter / filter.c
CommitLineData
91ad3f0a 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
4ed9b7ba 34/*
35 * TODO
36 * - connect the gui filter to the core filter
37 */
38
91ad3f0a 39typedef struct _FilterViewerData FilterViewerData;
40
4ed9b7ba 41/*
42 * Prototypes
43 */
91ad3f0a 44GtkWidget *guifilter_get_widget(FilterViewerData *fvd);
45FilterViewerData *gui_filter(Tab *tab);
46void gui_filter_destructor(FilterViewerData *fvd);
47gboolean filter_traceset_changed(void * hook_data, void * call_data);
48gboolean filter_viewer_data(void * hook_data, void * call_data);
2b99ec10 49GtkWidget* h_guifilter(Tab *tab);
91ad3f0a 50void statistic_destroy_walk(gpointer data, gpointer user_data);
51
52struct _FilterViewerData {
53 Tab *tab;
54
4ed9b7ba 55 GtkWidget *f_main_box;
56
57 GtkWidget *f_hbox1;
58 GtkWidget *f_hbox2;
59
60 GtkWidget *f_expression_field;
61 GtkWidget *f_process_button;
62
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;
68
2b99ec10 69 GtkWidget *f_textwnd;
70 GtkWidget *f_selectwnd;
71 GtkWidget *f_treewnd;
72
91ad3f0a 73};
74
75GtkWidget
76*guifilter_get_widget(FilterViewerData *fvd)
77{
4ed9b7ba 78 return fvd->f_main_box;
91ad3f0a 79}
80
81/**
82 * Statistic Viewer's constructor
83 *
84 * This constructor is used to create StatisticViewerData data structure.
85 * @return The Statistic viewer data created.
86 */
87FilterViewerData*
88gui_filter(Tab *tab)
89{
4ed9b7ba 90 g_print("filter::gui_filter()");
91
91ad3f0a 92 GtkCellRenderer *renderer;
93 GtkTreeViewColumn *column;
94
95 FilterViewerData* fvd = g_new(FilterViewerData,1);
96
97 fvd->tab = tab;
98
99 lttvwindow_register_traceset_notify(fvd->tab,
100 filter_traceset_changed,
101 filter_viewer_data);
102// request_background_data(filter_viewer_data);
4ed9b7ba 103
104 /*
105 * Initiating GtkTable layout
106 * starts with 2 rows and 5 columns and
107 * expands when expressions added
108 */
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);
91ad3f0a 112
4ed9b7ba 113 /*
114 * First half of the filter window
115 * - textual entry of filter expression
116 * - processing button
117 */
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);
121
122 fvd->f_process_button = gtk_button_new_with_label("Process");
123 gtk_widget_show (fvd->f_process_button);
124
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);
128
129 /*
130 * Second half of the filter window
131 * - combo boxes featuring filtering options added to the expression
132 */
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);
139
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);
146
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);
2b99ec10 162
4ed9b7ba 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);
171
172 fvd->f_value_field = gtk_entry_new();
173 gtk_widget_show(fvd->f_value_field);
174
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);
180
181 /* show main container */
182 gtk_widget_show(fvd->f_main_box);
183
91ad3f0a 184
185 g_object_set_data_full(
186 G_OBJECT(guifilter_get_widget(fvd)),
187 "filter_viewer_data",
188 fvd,
189 (GDestroyNotify)gui_filter_destructor);
190
4ed9b7ba 191
91ad3f0a 192 return fvd;
193}
194
195void
196gui_filter_destructor(FilterViewerData *fvd)
197{
198 Tab *tab = fvd->tab;
199
200 /* May already been done by GTK window closing */
201 if(GTK_IS_WIDGET(guifilter_get_widget(fvd))){
202 g_info("widget still exists");
203 }
204 if(tab != NULL) {
205 lttvwindow_unregister_traceset_notify(fvd->tab,
206 filter_traceset_changed,
207 filter_viewer_data);
208 }
209 lttvwindowtraces_background_notify_remove(fvd);
210
211 g_free(fvd);
212}
213
214gboolean
215filter_traceset_changed(void * hook_data, void * call_data) {
216
217 return FALSE;
218}
219
220gboolean
221filter_viewer_data(void * hook_data, void * call_data) {
222
223 return FALSE;
224}
225
226/**
227 * Filter Module's constructor hook
228 *
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.
233 */
234GtkWidget *
2b99ec10 235h_guifilter(Tab *tab)
91ad3f0a 236{
237 FilterViewerData* f = gui_filter(tab) ;
238
2b99ec10 239 g_print("FilterViewerData:%p\n",f);
91ad3f0a 240 if(f)
241 return guifilter_get_widget(f);
242 else return NULL;
243
244}
245
246
247
248/**
249 * plugin's init function
250 *
251 * This function initializes the Statistic Viewer functionnality through the
252 * gtkTraceSet API.
253 */
254static void init() {
255
256 lttvwindow_register_constructor("guifilter",
257 "/",
258 "Insert Filter Module",
259 hGuiFilterInsert_xpm,
260 "Insert Filter Module",
2b99ec10 261 h_guifilter);
91ad3f0a 262}
263
264void filter_destroy_walk(gpointer data, gpointer user_data)
265{
266 FilterViewerData *fvd = (FilterViewerData*)data;
267
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));
272}
273
274/**
275 * plugin's destroy function
276 *
277 * This function releases the memory reserved by the module and unregisters
278 * everything that has been registered in the gtkTraceSet API.
279 */
280static void destroy() {
281
2b99ec10 282 lttvwindow_unregister_constructor(h_guifilter);
91ad3f0a 283
284}
285
286
287LTTV_MODULE("guifilter", "Filter window", \
288 "Graphical module that let user specify their filtering options", \
289 init, destroy, "lttvwindow")
290
This page took 0.032645 seconds and 4 git commands to generate.