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>
32 #include "processlist.h"
33 #include "eventhooks.h"
35 extern GSList
*g_control_flow_data_list
;
38 header_size_allocate(GtkWidget
*widget
,
39 GtkAllocation
*allocation
,
42 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
44 gtk_widget_set_size_request(drawing
->ruler
, -1, allocation
->height
);
45 //gtk_widget_queue_resize(drawing->padding);
46 //gtk_widget_queue_resize(drawing->ruler);
47 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
51 gboolean
cfv_scroll_event(GtkWidget
*widget
, GdkEventScroll
*event
,
54 ControlFlowData
*control_flow_data
= (ControlFlowData
*)data
;
55 unsigned int cell_height
=
57 GTK_TREE_VIEW(control_flow_data
->process_list
->process_list_widget
));
60 switch(event
->direction
) {
63 new = gtk_adjustment_get_value(control_flow_data
->v_adjust
)
69 new = gtk_adjustment_get_value(control_flow_data
->v_adjust
)
76 if(new >= control_flow_data
->v_adjust
->lower
&&
77 new <= control_flow_data
->v_adjust
->upper
78 - control_flow_data
->v_adjust
->page_size
)
79 gtk_adjustment_set_value(control_flow_data
->v_adjust
, new);
84 /*****************************************************************************
85 * Control Flow Viewer class implementation *
86 *****************************************************************************/
88 * Control Flow Viewer's constructor
90 * This constructor is given as a parameter to the menuitem and toolbar button
91 * registration. It creates the drawing widget.
92 * @param ParentWindow A pointer to the parent window.
93 * @return The widget created.
96 guicontrolflow(Tab
*tab
)
98 GtkWidget
*process_list_widget
, *drawing_widget
, *drawing_area
;
100 ControlFlowData
* control_flow_data
= g_new(ControlFlowData
,1) ;
102 control_flow_data
->tab
= tab
;
104 control_flow_data
->v_adjust
=
105 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
110 0.0)); /* page size */
112 /* Create the drawing */
113 control_flow_data
->drawing
= drawing_construct(control_flow_data
);
116 drawing_get_widget(control_flow_data
->drawing
);
119 drawing_get_drawing_area(control_flow_data
->drawing
);
121 control_flow_data
->number_of_process
= 0;
122 control_flow_data
->background_info_waiting
= 0;
124 /* Create the Process list */
125 control_flow_data
->process_list
= processlist_construct();
127 process_list_widget
=
128 processlist_get_widget(control_flow_data
->process_list
);
130 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget
),
132 control_flow_data
->v_adjust
));
134 g_signal_connect (G_OBJECT(process_list_widget
),
136 G_CALLBACK (cfv_scroll_event
),
137 (gpointer
)control_flow_data
);
138 g_signal_connect (G_OBJECT(drawing_area
),
140 G_CALLBACK (cfv_scroll_event
),
141 (gpointer
)control_flow_data
);
143 g_signal_connect (G_OBJECT(control_flow_data
->process_list
->button
),
145 G_CALLBACK(header_size_allocate
),
146 (gpointer
)control_flow_data
->drawing
);
147 #if 0 /* not ready */
149 // G_OBJECT(control_flow_data->process_list->process_list_widget),
150 G_OBJECT(control_flow_data
->process_list
->list_store
),
152 G_CALLBACK (tree_row_activated
),
153 (gpointer
)control_flow_data
);
156 control_flow_data
->h_paned
= gtk_hpaned_new();
157 control_flow_data
->box
= gtk_event_box_new();
158 control_flow_data
->top_widget
= control_flow_data
->box
;
159 gtk_container_add(GTK_CONTAINER(control_flow_data
->box
),
160 control_flow_data
->h_paned
);
162 gtk_paned_pack1(GTK_PANED(control_flow_data
->h_paned
),
163 process_list_widget
, FALSE
, TRUE
);
164 gtk_paned_pack2(GTK_PANED(control_flow_data
->h_paned
),
165 drawing_widget
, TRUE
, TRUE
);
167 gtk_container_set_border_width(GTK_CONTAINER(control_flow_data
->box
), 1);
169 /* Set the size of the drawing area */
170 //drawing_Resize(drawing, h, w);
172 /* Get trace statistics */
173 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
175 gtk_widget_show(drawing_widget
);
176 gtk_widget_show(process_list_widget
);
177 gtk_widget_show(control_flow_data
->h_paned
);
178 gtk_widget_show(control_flow_data
->box
);
180 g_object_set_data_full(
181 G_OBJECT(control_flow_data
->top_widget
),
184 (GDestroyNotify
)guicontrolflow_destructor
);
187 G_OBJECT(drawing_area
),
191 g_control_flow_data_list
= g_slist_append(
192 g_control_flow_data_list
,
195 control_flow_data
->filter
= NULL
;
197 //WARNING : The widget must be
198 //inserted in the main window before the drawing area
199 //can be configured (and this must happend bedore sending
202 return control_flow_data
;
206 /* Destroys widget also */
208 guicontrolflow_destructor_full(ControlFlowData
*control_flow_data
)
210 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data
);
211 /* May already have been done by GTK window closing */
212 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data
)))
213 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data
));
214 //control_flow_data->mw = NULL;
215 //FIXME guicontrolflow_destructor(control_flow_data);
218 /* When this destructor is called, the widgets are already disconnected */
220 guicontrolflow_destructor(ControlFlowData
*control_flow_data
)
222 Tab
*tab
= control_flow_data
->tab
;
224 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data
);
225 g_info("%p, %p, %p", update_time_window_hook
, control_flow_data
, tab
);
226 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data
)))
227 g_info("widget still exists");
229 lttv_filter_destroy(control_flow_data
->filter
);
230 /* Process List is removed with it's widget */
231 //ProcessList_destroy(control_flow_data->process_list);
234 /* Delete reading hooks */
235 lttvwindow_unregister_traceset_notify(tab
,
239 lttvwindow_unregister_time_window_notify(tab
,
240 update_time_window_hook
,
243 lttvwindow_unregister_current_time_notify(tab
,
244 update_current_time_hook
,
247 lttvwindow_unregister_redraw_notify(tab
, redraw_notify
, control_flow_data
);
248 lttvwindow_unregister_continue_notify(tab
,
252 lttvwindow_events_request_remove_all(control_flow_data
->tab
,
256 lttvwindowtraces_background_notify_remove(control_flow_data
);
257 g_control_flow_data_list
=
258 g_slist_remove(g_control_flow_data_list
,control_flow_data
);
260 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data
);
261 g_free(control_flow_data
);