1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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,
26 #include <lttv/lttv.h>
27 #include <lttvwindow/lttvwindow.h>
28 #include <lttvwindow/lttvwindowtraces.h>
29 #include <lttvwindow/support.h>
33 #include "processlist.h"
34 #include "eventhooks.h"
35 #include "lttv_plugin_cfv.h"
37 extern GSList
*g_control_flow_data_list
;
40 header_size_allocate(GtkWidget
*widget
,
41 GtkAllocation
*allocation
,
44 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
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
));
53 gboolean
cfv_scroll_event(GtkWidget
*widget
, GdkEventScroll
*event
,
56 ControlFlowData
*control_flow_data
= (ControlFlowData
*)data
;
57 unsigned int cell_height
=
59 GTK_TREE_VIEW(control_flow_data
->process_list
->process_list_widget
));
62 switch(event
->direction
) {
65 new = gtk_adjustment_get_value(control_flow_data
->v_adjust
)
71 new = gtk_adjustment_get_value(control_flow_data
->v_adjust
)
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);
86 /* Toolbar callbacks */
87 static void property_button (GtkToolButton
*toolbutton
,
90 ControlFlowData
*control_flow_data
= (ControlFlowData
*)user_data
;
92 g_printf("CFV Property button clicked\n");
96 /* Toolbar callbacks */
97 static void filter_button (GtkToolButton
*toolbutton
,
100 LttvPluginCFV
*plugin_cfv
= (LttvPluginCFV
*)user_data
;
101 LttvAttribute
*attribute
;
102 LttvAttributeValue value
;
104 g_printf("Filter button clicked\n");
106 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
107 LTTV_IATTRIBUTE(lttv_global_attributes()),
108 LTTV_VIEWER_CONSTRUCTORS
));
111 ret
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
112 "guifilter", LTTV_POINTER
, &value
);
114 lttvwindow_viewer_constructor constructor
=
115 (lttvwindow_viewer_constructor
)*(value
.v_pointer
);
116 if(constructor
) constructor(&plugin_cfv
->parent
);
117 else g_warning("Filter module not loaded.");
119 //FIXME : viewer returned.
124 /*****************************************************************************
125 * Control Flow Viewer class implementation *
126 *****************************************************************************/
128 * Control Flow Viewer's constructor
130 * This constructor is given as a parameter to the menuitem and toolbar button
131 * registration. It creates the drawing widget.
132 * @param ParentWindow A pointer to the parent window.
133 * @return The widget created.
136 guicontrolflow(LttvPluginTab
*ptab
)
138 Tab
*tab
= ptab
->tab
;
139 GtkWidget
*tmp_toolbar_icon
;
140 GtkWidget
*process_list_widget
, *drawing_widget
, *drawing_area
;
141 //ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
142 LttvPluginCFV
*plugin_cfv
= g_object_new(LTTV_TYPE_PLUGIN_CFV
, NULL
);
143 GtkTooltips
*tooltips
= gtk_tooltips_new();
144 ControlFlowData
* control_flow_data
= plugin_cfv
->cfd
;
145 control_flow_data
->ptab
= ptab
;
146 control_flow_data
->tab
= ptab
->tab
;
148 control_flow_data
->v_adjust
=
149 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
154 0.0)); /* page size */
156 /* Create the drawing */
157 control_flow_data
->drawing
= drawing_construct(control_flow_data
);
160 drawing_get_widget(control_flow_data
->drawing
);
163 drawing_get_drawing_area(control_flow_data
->drawing
);
165 control_flow_data
->number_of_process
= 0;
166 control_flow_data
->background_info_waiting
= 0;
168 /* Create the Process list */
169 control_flow_data
->process_list
= processlist_construct();
171 process_list_widget
=
172 processlist_get_widget(control_flow_data
->process_list
);
174 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget
),
176 control_flow_data
->v_adjust
));
178 g_signal_connect (G_OBJECT(process_list_widget
),
180 G_CALLBACK (cfv_scroll_event
),
181 (gpointer
)control_flow_data
);
182 g_signal_connect (G_OBJECT(drawing_area
),
184 G_CALLBACK (cfv_scroll_event
),
185 (gpointer
)control_flow_data
);
187 g_signal_connect (G_OBJECT(control_flow_data
->process_list
->button
),
189 G_CALLBACK(header_size_allocate
),
190 (gpointer
)control_flow_data
->drawing
);
191 #if 0 /* not ready */
193 // G_OBJECT(control_flow_data->process_list->process_list_widget),
194 G_OBJECT(control_flow_data
->process_list
->list_store
),
196 G_CALLBACK (tree_row_activated
),
197 (gpointer
)control_flow_data
);
200 control_flow_data
->hbox
= gtk_hbox_new(FALSE
, 1);
201 control_flow_data
->toolbar
= gtk_toolbar_new();
202 gtk_toolbar_set_orientation(GTK_TOOLBAR(control_flow_data
->toolbar
),
203 GTK_ORIENTATION_VERTICAL
);
205 tmp_toolbar_icon
= create_pixmap (main_window_get_widget(tab
),
206 "guifilter16x16.png");
207 gtk_widget_show(tmp_toolbar_icon
);
208 control_flow_data
->button_filter
= gtk_tool_button_new(tmp_toolbar_icon
,
210 g_signal_connect (G_OBJECT(control_flow_data
->button_filter
),
212 G_CALLBACK (filter_button
),
213 (gpointer
)plugin_cfv
);
214 gtk_toolbar_insert(GTK_TOOLBAR(control_flow_data
->toolbar
),
215 control_flow_data
->button_filter
,
217 gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(control_flow_data
->button_filter
),
218 tooltips
, "Open the filter window", NULL
);
220 tmp_toolbar_icon
= create_pixmap (main_window_get_widget(tab
),
222 gtk_widget_show(tmp_toolbar_icon
);
223 control_flow_data
->button_prop
= gtk_tool_button_new(tmp_toolbar_icon
,
225 g_signal_connect (G_OBJECT(control_flow_data
->button_prop
),
227 G_CALLBACK (property_button
),
228 (gpointer
)control_flow_data
);
229 gtk_toolbar_insert(GTK_TOOLBAR(control_flow_data
->toolbar
),
230 control_flow_data
->button_prop
,
233 gtk_toolbar_set_style(GTK_TOOLBAR(control_flow_data
->toolbar
),
236 gtk_box_pack_start(GTK_BOX(control_flow_data
->hbox
),
237 control_flow_data
->toolbar
,
239 control_flow_data
->h_paned
= gtk_hpaned_new();
240 control_flow_data
->box
= gtk_event_box_new();
241 gtk_box_pack_end(GTK_BOX(control_flow_data
->hbox
),
242 control_flow_data
->box
,
244 control_flow_data
->top_widget
= control_flow_data
->hbox
;
245 plugin_cfv
->parent
.top_widget
= control_flow_data
->top_widget
;
246 gtk_container_add(GTK_CONTAINER(control_flow_data
->box
),
247 control_flow_data
->h_paned
);
249 gtk_paned_pack1(GTK_PANED(control_flow_data
->h_paned
),
250 process_list_widget
, FALSE
, TRUE
);
251 gtk_paned_pack2(GTK_PANED(control_flow_data
->h_paned
),
252 drawing_widget
, TRUE
, TRUE
);
254 gtk_container_set_border_width(GTK_CONTAINER(control_flow_data
->box
), 1);
256 /* Set the size of the drawing area */
257 //drawing_Resize(drawing, h, w);
259 /* Get trace statistics */
260 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
262 gtk_widget_show(drawing_widget
);
263 gtk_widget_show(process_list_widget
);
264 gtk_widget_show(control_flow_data
->h_paned
);
265 gtk_widget_show(control_flow_data
->box
);
266 gtk_widget_show(control_flow_data
->toolbar
);
267 gtk_widget_show(GTK_WIDGET(control_flow_data
->button_prop
));
268 gtk_widget_show(GTK_WIDGET(control_flow_data
->button_filter
));
269 gtk_widget_show(control_flow_data
->hbox
);
271 g_object_set_data_full(
272 G_OBJECT(control_flow_data
->top_widget
),
275 (GDestroyNotify
)guicontrolflow_destructor
);
278 G_OBJECT(drawing_area
),
282 g_control_flow_data_list
= g_slist_append(
283 g_control_flow_data_list
,
286 control_flow_data
->filter
= NULL
;
288 //WARNING : The widget must be
289 //inserted in the main window before the drawing area
290 //can be configured (and this must happend bedore sending
293 return control_flow_data
;
297 /* Destroys widget also */
299 guicontrolflow_destructor_full(gpointer data
)
301 LttvPluginCFV
*plugin_cfv
= (LttvPluginCFV
*)data
;
302 g_info("CFV.c : guicontrolflow_destructor_full, %p", plugin_cfv
);
303 /* May already have been done by GTK window closing */
304 if(GTK_IS_WIDGET(guicontrolflow_get_widget(plugin_cfv
->cfd
)))
305 gtk_widget_destroy(guicontrolflow_get_widget(plugin_cfv
->cfd
));
306 //control_flow_data->mw = NULL;
307 //FIXME guicontrolflow_destructor(control_flow_data);
310 /* When this destructor is called, the widgets are already disconnected */
312 guicontrolflow_destructor(gpointer data
)
314 LttvPluginCFV
*plugin_cfv
= (LttvPluginCFV
*)data
;
315 Tab
*tab
= plugin_cfv
->cfd
->tab
;
316 ControlFlowData
*control_flow_data
= plugin_cfv
->cfd
;
318 g_info("CFV.c : guicontrolflow_destructor, %p", plugin_cfv
);
319 g_info("%p, %p, %p", update_time_window_hook
, plugin_cfv
, tab
);
320 if(GTK_IS_WIDGET(guicontrolflow_get_widget(plugin_cfv
->cfd
)))
321 g_info("widget still exists");
323 lttv_filter_destroy(plugin_cfv
->cfd
->filter
);
324 /* Process List is removed with it's widget */
325 //ProcessList_destroy(control_flow_data->process_list);
328 /* Delete reading hooks */
329 lttvwindow_unregister_traceset_notify(tab
,
333 lttvwindow_unregister_time_window_notify(tab
,
334 update_time_window_hook
,
337 lttvwindow_unregister_current_time_notify(tab
,
338 update_current_time_hook
,
341 lttvwindow_unregister_redraw_notify(tab
, redraw_notify
, control_flow_data
);
342 lttvwindow_unregister_continue_notify(tab
,
346 lttvwindow_events_request_remove_all(control_flow_data
->tab
,
350 lttvwindowtraces_background_notify_remove(control_flow_data
);
351 g_control_flow_data_list
=
352 g_slist_remove(g_control_flow_data_list
, control_flow_data
);
354 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data
);
355 //g_free(control_flow_data);
356 g_object_unref(plugin_cfv
);