Update the README file to mark the project as unmaintained
[lttv.git] / lttv / modules / gui / resourceview / cfv.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <glib.h>
24 #include <gtk/gtk.h>
25 #include <gdk/gdk.h>
26 #include <lttv/lttv.h>
27 #include <lttvwindow/lttvwindow.h>
28 #include <lttvwindow/lttvwindowtraces.h>
29 #include <lttvwindow/support.h>
30
31 #include "cfv.h"
32 #include "drawing.h"
33 #include "processlist.h"
34 #include "eventhooks.h"
35 #include "lttv_plugin_cfv.h"
36
37 extern GSList *g_control_flow_data_list;
38
39 static gboolean
40 header_size_allocate(GtkWidget *widget,
41 GtkAllocation *allocation,
42 gpointer user_data)
43 {
44 Drawing_t *drawing = (Drawing_t*)user_data;
45
46 gtk_widget_set_size_request(drawing->ruler, -1, allocation->height);
47 //gtk_widget_queue_resize(drawing->padding);
48 //gtk_widget_queue_resize(drawing->ruler);
49 gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox));
50 return 0;
51 }
52
53 gboolean cfv_scroll_event(GtkWidget *widget, GdkEventScroll *event,
54 gpointer data)
55 {
56 ControlFlowData *control_flow_data = (ControlFlowData*)data;
57 unsigned int cell_height =
58 get_cell_height(
59 GTK_TREE_VIEW(control_flow_data->process_list->process_list_widget));
60 gdouble new;
61
62 switch(event->direction) {
63 case GDK_SCROLL_UP:
64 {
65 new = gtk_adjustment_get_value(control_flow_data->v_adjust)
66 - cell_height;
67 }
68 break;
69 case GDK_SCROLL_DOWN:
70 {
71 new = gtk_adjustment_get_value(control_flow_data->v_adjust)
72 + cell_height;
73 }
74 break;
75 default:
76 return FALSE;
77 }
78 if(new >= control_flow_data->v_adjust->lower &&
79 new <= control_flow_data->v_adjust->upper
80 - control_flow_data->v_adjust->page_size)
81 gtk_adjustment_set_value(control_flow_data->v_adjust, new);
82 return TRUE;
83 }
84
85
86 /*****************************************************************************
87 * Control Flow Viewer class implementation *
88 *****************************************************************************/
89 /**
90 * Control Flow Viewer's constructor
91 *
92 * This constructor is given as a parameter to the menuitem and toolbar button
93 * registration. It creates the drawing widget.
94 * @param ParentWindow A pointer to the parent window.
95 * @return The widget created.
96 */
97 ControlFlowData *
98 resourceview(LttvPluginTab *ptab)
99 {
100 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
101 LttvPluginCFV *plugin_cfv = g_object_new(LTTV_TYPE_PLUGIN_CFV, NULL);
102 ControlFlowData* control_flow_data = plugin_cfv->cfd;
103 control_flow_data->ptab = ptab;
104 control_flow_data->tab = ptab->tab;
105
106 control_flow_data->v_adjust =
107 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
108 0.0, /* Lower */
109 0.0, /* Upper */
110 0.0, /* Step inc. */
111 0.0, /* Page inc. */
112 0.0)); /* page size */
113
114 /* Create the drawing */
115 control_flow_data->drawing = drawing_construct(control_flow_data);
116
117 drawing_widget =
118 drawing_get_widget(control_flow_data->drawing);
119
120 drawing_area =
121 drawing_get_drawing_area(control_flow_data->drawing);
122
123 control_flow_data->number_of_process = 0;
124 control_flow_data->background_info_waiting = 0;
125
126 /* Create the Process list */
127 control_flow_data->process_list = processlist_construct();
128
129 process_list_widget =
130 processlist_get_widget(control_flow_data->process_list);
131
132 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget),
133 GTK_ADJUSTMENT(
134 control_flow_data->v_adjust));
135
136 g_signal_connect (G_OBJECT(process_list_widget),
137 "scroll-event",
138 G_CALLBACK (cfv_scroll_event),
139 (gpointer)control_flow_data);
140 g_signal_connect (G_OBJECT(drawing_area),
141 "scroll-event",
142 G_CALLBACK (cfv_scroll_event),
143 (gpointer)control_flow_data);
144
145 g_signal_connect (G_OBJECT(control_flow_data->process_list->button),
146 "size-allocate",
147 G_CALLBACK(header_size_allocate),
148 (gpointer)control_flow_data->drawing);
149 #if 0 /* not ready */
150 g_signal_connect (
151 // G_OBJECT(control_flow_data->process_list->process_list_widget),
152 G_OBJECT(control_flow_data->process_list->list_store),
153 "row-changed",
154 G_CALLBACK (tree_row_activated),
155 (gpointer)control_flow_data);
156 #endif //0
157
158 control_flow_data->hbox = gtk_hbox_new(FALSE, 1);
159 control_flow_data->toolbar = gtk_toolbar_new();
160 gtk_toolbar_set_orientation(GTK_TOOLBAR(control_flow_data->toolbar),
161 GTK_ORIENTATION_VERTICAL);
162
163 // tmp_toolbar_icon = create_pixmap (main_window_get_widget(tab),
164 // "properties.png");
165 // gtk_widget_show(tmp_toolbar_icon);
166 // control_flow_data->button_prop = gtk_tool_button_new(tmp_toolbar_icon,
167 // "Properties");
168 // g_signal_connect (G_OBJECT(control_flow_data->button_prop),
169 // "clicked",
170 // G_CALLBACK (property_button),
171 // (gpointer)control_flow_data);
172 // gtk_toolbar_insert(GTK_TOOLBAR(control_flow_data->toolbar),
173 // control_flow_data->button_prop,
174 // 1);
175
176 gtk_toolbar_set_style(GTK_TOOLBAR(control_flow_data->toolbar),
177 GTK_TOOLBAR_ICONS);
178
179 gtk_box_pack_start(GTK_BOX(control_flow_data->hbox),
180 control_flow_data->toolbar,
181 FALSE, FALSE, 0);
182 control_flow_data->h_paned = gtk_hpaned_new();
183 control_flow_data->box = gtk_event_box_new();
184 gtk_box_pack_end(GTK_BOX(control_flow_data->hbox),
185 control_flow_data->box,
186 TRUE, TRUE, 0);
187 control_flow_data->top_widget = control_flow_data->hbox;
188 plugin_cfv->parent.top_widget = control_flow_data->top_widget;
189 gtk_container_add(GTK_CONTAINER(control_flow_data->box),
190 control_flow_data->h_paned);
191
192 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned),
193 process_list_widget, FALSE, TRUE);
194 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned),
195 drawing_widget, TRUE, TRUE);
196
197 gtk_container_set_border_width(GTK_CONTAINER(control_flow_data->box), 1);
198
199 /* Set the size of the drawing area */
200 //drawing_Resize(drawing, h, w);
201
202 /* Get trace statistics */
203 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
204
205 gtk_widget_show(drawing_widget);
206 gtk_widget_show(process_list_widget);
207 gtk_widget_show(control_flow_data->h_paned);
208 gtk_widget_show(control_flow_data->box);
209 gtk_widget_show(control_flow_data->toolbar);
210 // gtk_widget_show(GTK_WIDGET(control_flow_data->button_prop));
211 gtk_widget_show(control_flow_data->hbox);
212
213 g_object_set_data_full(
214 G_OBJECT(control_flow_data->top_widget),
215 "plugin_data",
216 plugin_cfv,
217 (GDestroyNotify)guicontrolflow_destructor);
218
219 g_object_set_data(
220 G_OBJECT(drawing_area),
221 "resourceview_data",
222 control_flow_data);
223
224 g_object_set_data(
225 G_OBJECT(control_flow_data->process_list->process_list_widget),
226 "resourceview_data",
227 control_flow_data);
228
229 g_control_flow_data_list = g_slist_append(
230 g_control_flow_data_list,
231 plugin_cfv);
232
233 control_flow_data->filter = NULL;
234
235 //WARNING : The widget must be
236 //inserted in the main window before the drawing area
237 //can be configured (and this must happen before sending
238 //data)
239
240 return control_flow_data;
241
242 }
243
244 /* Destroys widget also */
245 void
246 guicontrolflow_destructor_full(gpointer data)
247 {
248 LttvPluginCFV *plugin_cfv = (LttvPluginCFV*)data;
249 g_info("CFV.c : guicontrolflow_destructor_full, %p", plugin_cfv);
250 /* May already have been done by GTK window closing */
251 if(GTK_IS_WIDGET(guicontrolflow_get_widget(plugin_cfv->cfd)))
252 gtk_widget_destroy(guicontrolflow_get_widget(plugin_cfv->cfd));
253 //control_flow_data->mw = NULL;
254 //FIXME guicontrolflow_destructor(control_flow_data);
255 }
256
257 /* When this destructor is called, the widgets are already disconnected */
258 void
259 guicontrolflow_destructor(gpointer data)
260 {
261 LttvPluginCFV *plugin_cfv = (LttvPluginCFV*)data;
262 Tab *tab = plugin_cfv->cfd->tab;
263 ControlFlowData *control_flow_data = plugin_cfv->cfd;
264
265 g_info("CFV.c : guicontrolflow_destructor, %p", plugin_cfv);
266 g_info("%p, %p, %p", update_time_window_hook, plugin_cfv, tab);
267 if(GTK_IS_WIDGET(guicontrolflow_get_widget(plugin_cfv->cfd)))
268 g_info("widget still exists");
269 #ifdef BABEL_CLEANUP
270 lttv_filter_destroy(plugin_cfv->cfd->filter);
271 #endif //babel_cleanup
272 /* Process List is removed with it's widget */
273 //ProcessList_destroy(control_flow_data->process_list);
274 if(tab != NULL)
275 {
276 /* Delete reading hooks */
277 lttvwindow_unregister_traceset_notify(tab,
278 traceset_notify,
279 control_flow_data);
280
281 lttvwindow_unregister_time_window_notify(tab,
282 update_time_window_hook,
283 control_flow_data);
284
285 lttvwindow_unregister_current_time_notify(tab,
286 update_current_time_hook,
287 control_flow_data);
288
289 lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
290 lttvwindow_unregister_continue_notify(tab,
291 continue_notify,
292 control_flow_data);
293
294 lttvwindow_events_request_remove_all(control_flow_data->tab,
295 control_flow_data);
296
297 }
298 lttvwindowtraces_background_notify_remove(control_flow_data);
299 g_control_flow_data_list =
300 g_slist_remove(g_control_flow_data_list, control_flow_data);
301
302 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
303 //g_free(control_flow_data);
304 g_object_unref(plugin_cfv);
305 }
306
307
This page took 0.037558 seconds and 5 git commands to generate.