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,
25 #include "processlist.h"
26 #include "eventhooks.h"
27 #include "cfv-private.h"
28 #include <lttv/lttv.h>
30 extern GSList
*g_control_flow_data_list
;
33 header_size_allocate(GtkWidget
*widget
,
34 GtkAllocation
*allocation
,
37 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
39 gtk_widget_set_size_request(drawing
->ruler
, -1, allocation
->height
);
40 //gtk_widget_queue_resize(drawing->padding);
41 //gtk_widget_queue_resize(drawing->ruler);
42 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
48 /*****************************************************************************
49 * Control Flow Viewer class implementation *
50 *****************************************************************************/
52 * Control Flow Viewer's constructor
54 * This constructor is given as a parameter to the menuitem and toolbar button
55 * registration. It creates the drawing widget.
56 * @param ParentWindow A pointer to the parent window.
57 * @return The widget created.
62 GtkWidget
*process_list_widget
, *drawing_widget
, *drawing_area
;
64 ControlFlowData
* control_flow_data
= g_new(ControlFlowData
,1) ;
66 control_flow_data
->v_adjust
=
67 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
72 0.0)); /* page size */
74 /* Create the drawing */
75 control_flow_data
->drawing
= drawing_construct(control_flow_data
);
78 drawing_get_widget(control_flow_data
->drawing
);
81 drawing_get_drawing_area(control_flow_data
->drawing
);
83 control_flow_data
->number_of_process
= 0;
84 control_flow_data
->background_info_waiting
= 0;
86 /* Create the Process list */
87 control_flow_data
->process_list
= processlist_construct();
90 processlist_get_widget(control_flow_data
->process_list
);
92 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget
),
94 control_flow_data
->v_adjust
));
96 g_signal_connect (G_OBJECT(control_flow_data
->process_list
->button
),
98 G_CALLBACK(header_size_allocate
),
99 (gpointer
)control_flow_data
->drawing
);
103 control_flow_data
->h_paned
= gtk_hpaned_new();
104 control_flow_data
->box
= gtk_event_box_new();
105 control_flow_data
->top_widget
= control_flow_data
->box
;
106 gtk_container_add(GTK_CONTAINER(control_flow_data
->box
),
107 control_flow_data
->h_paned
);
109 gtk_paned_pack1(GTK_PANED(control_flow_data
->h_paned
),
110 process_list_widget
, FALSE
, TRUE
);
111 gtk_paned_pack2(GTK_PANED(control_flow_data
->h_paned
),
112 drawing_widget
, TRUE
, TRUE
);
114 /* Set the size of the drawing area */
115 //drawing_Resize(drawing, h, w);
117 /* Get trace statistics */
118 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
120 gtk_widget_show(drawing_widget
);
121 gtk_widget_show(process_list_widget
);
122 gtk_widget_show(control_flow_data
->h_paned
);
123 gtk_widget_show(control_flow_data
->box
);
125 g_object_set_data_full(
126 G_OBJECT(control_flow_data
->top_widget
),
129 (GDestroyNotify
)guicontrolflow_destructor
);
132 G_OBJECT(drawing_area
),
136 g_control_flow_data_list
= g_slist_append(
137 g_control_flow_data_list
,
140 //WARNING : The widget must be
141 //inserted in the main window before the drawing area
142 //can be configured (and this must happend bedore sending
146 return control_flow_data
;
150 /* Destroys widget also */
152 guicontrolflow_destructor_full(ControlFlowData
*control_flow_data
)
154 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data
);
155 /* May already have been done by GTK window closing */
156 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data
)))
157 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data
));
158 //control_flow_data->mw = NULL;
159 //FIXME guicontrolflow_destructor(control_flow_data);
162 /* When this destructor is called, the widgets are already disconnected */
164 guicontrolflow_destructor(ControlFlowData
*control_flow_data
)
166 Tab
*tab
= control_flow_data
->tab
;
168 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data
);
169 g_info("%p, %p, %p", update_time_window_hook
, control_flow_data
, tab
);
170 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data
)))
171 g_info("widget still exists");
173 /* Process List is removed with it's widget */
174 //ProcessList_destroy(control_flow_data->process_list);
177 /* Delete reading hooks */
178 lttvwindow_unregister_traceset_notify(tab
,
182 lttvwindow_unregister_time_window_notify(tab
,
183 update_time_window_hook
,
186 lttvwindow_unregister_current_time_notify(tab
,
187 update_current_time_hook
,
190 lttvwindow_unregister_redraw_notify(tab
, redraw_notify
, control_flow_data
);
191 lttvwindow_unregister_continue_notify(tab
,
195 lttvwindow_events_request_remove_all(control_flow_data
->tab
,
199 lttvwindowtraces_background_notify_remove(control_flow_data
);
200 g_control_flow_data_list
=
201 g_slist_remove(g_control_flow_data_list
,control_flow_data
);
203 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data
);
204 g_free(control_flow_data
);
208 GtkWidget
*guicontrolflow_get_widget(ControlFlowData
*control_flow_data
)
210 return control_flow_data
->top_widget
;
213 ProcessList
*guicontrolflow_get_process_list
214 (ControlFlowData
*control_flow_data
)
216 return control_flow_data
->process_list
;