Continued the gui filter module
[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 typedef struct _FilterViewerData FilterViewerData;
35
36 GtkWidget *guifilter_get_widget(FilterViewerData *fvd);
37 FilterViewerData *gui_filter(Tab *tab);
38 void gui_filter_destructor(FilterViewerData *fvd);
39 gboolean filter_traceset_changed(void * hook_data, void * call_data);
40 gboolean filter_viewer_data(void * hook_data, void * call_data);
41 GtkWidget* h_guifilter(Tab *tab);
42 void statistic_destroy_walk(gpointer data, gpointer user_data);
43
44 struct _FilterViewerData {
45 Tab *tab;
46
47 // temp widget -- still thinking about a formal structure
48 GtkWidget *hbox;
49 GtkWidget *f_textwnd;
50 GtkWidget *f_selectwnd;
51 GtkWidget *f_treewnd;
52
53 };
54
55 GtkWidget
56 *guifilter_get_widget(FilterViewerData *fvd)
57 {
58 return fvd->hbox;
59 }
60
61 /**
62 * Statistic Viewer's constructor
63 *
64 * This constructor is used to create StatisticViewerData data structure.
65 * @return The Statistic viewer data created.
66 */
67 FilterViewerData*
68 gui_filter(Tab *tab)
69 {
70 GtkCellRenderer *renderer;
71 GtkTreeViewColumn *column;
72
73 FilterViewerData* fvd = g_new(FilterViewerData,1);
74
75 fvd->tab = tab;
76
77 lttvwindow_register_traceset_notify(fvd->tab,
78 filter_traceset_changed,
79 filter_viewer_data);
80 // request_background_data(filter_viewer_data);
81
82 fvd->f_textwnd = gtk_entry_new(); //gtk_scrolled_window_new (NULL, NULL);
83 gtk_entry_set_text(fvd->f_textwnd,"this is a test");
84 gtk_widget_show (fvd->f_textwnd);
85
86 fvd->hbox = gtk_hbox_new(0, 0);
87 gtk_box_pack_start(GTK_BOX(fvd->hbox), fvd->f_textwnd, TRUE, TRUE, 0);
88
89 gtk_widget_show(fvd->hbox);
90
91 g_object_set_data_full(
92 G_OBJECT(guifilter_get_widget(fvd)),
93 "filter_viewer_data",
94 fvd,
95 (GDestroyNotify)gui_filter_destructor);
96
97 return fvd;
98 }
99
100 void
101 gui_filter_destructor(FilterViewerData *fvd)
102 {
103 Tab *tab = fvd->tab;
104
105 /* May already been done by GTK window closing */
106 if(GTK_IS_WIDGET(guifilter_get_widget(fvd))){
107 g_info("widget still exists");
108 }
109 if(tab != NULL) {
110 lttvwindow_unregister_traceset_notify(fvd->tab,
111 filter_traceset_changed,
112 filter_viewer_data);
113 }
114 lttvwindowtraces_background_notify_remove(fvd);
115
116 g_free(fvd);
117 }
118
119 gboolean
120 filter_traceset_changed(void * hook_data, void * call_data) {
121
122 return FALSE;
123 }
124
125 gboolean
126 filter_viewer_data(void * hook_data, void * call_data) {
127
128 return FALSE;
129 }
130
131 /**
132 * Filter Module's constructor hook
133 *
134 * This constructor is given as a parameter to the menuitem and toolbar button
135 * registration. It creates the list.
136 * @param parent_window A pointer to the parent window.
137 * @return The widget created.
138 */
139 GtkWidget *
140 h_guifilter(Tab *tab)
141 {
142 FilterViewerData* f = gui_filter(tab) ;
143
144 g_print("FilterViewerData:%p\n",f);
145 if(f)
146 return guifilter_get_widget(f);
147 else return NULL;
148
149 }
150
151
152
153 /**
154 * plugin's init function
155 *
156 * This function initializes the Statistic Viewer functionnality through the
157 * gtkTraceSet API.
158 */
159 static void init() {
160
161 lttvwindow_register_constructor("guifilter",
162 "/",
163 "Insert Filter Module",
164 hGuiFilterInsert_xpm,
165 "Insert Filter Module",
166 h_guifilter);
167 }
168
169 void filter_destroy_walk(gpointer data, gpointer user_data)
170 {
171 FilterViewerData *fvd = (FilterViewerData*)data;
172
173 g_debug("CFV.c : statistic_destroy_walk, %p", fvd);
174 /* May already have been done by GTK window closing */
175 if(GTK_IS_WIDGET(guifilter_get_widget(fvd)))
176 gtk_widget_destroy(guifilter_get_widget(fvd));
177 }
178
179 /**
180 * plugin's destroy function
181 *
182 * This function releases the memory reserved by the module and unregisters
183 * everything that has been registered in the gtkTraceSet API.
184 */
185 static void destroy() {
186
187 lttvwindow_unregister_constructor(h_guifilter);
188
189 }
190
191
192 LTTV_MODULE("guifilter", "Filter window", \
193 "Graphical module that let user specify their filtering options", \
194 init, destroy, "lttvwindow")
195
This page took 0.037577 seconds and 4 git commands to generate.