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