1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa heidari (inspired from CFV by 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>
31 #include "histodrawing.h"
32 #include "histobuttonwidget.h"
33 #include "histoeventhooks.h"
35 #define PREDEFINED_HEIGHT 5000
37 extern GSList
*g_histo_control_flow_data_list
;
40 /*****************************************************************************
41 * Histo Control Flow Viewer class implementation *
42 *****************************************************************************/
44 * Histo Control Flow Viewer's constructor
46 * This constructor is given as a parameter to the menuitem and toolbar button
47 * registration. It creates the drawing widget.
48 * @param ParentWindow A pointer to the parent window.
49 * @return The widget created.
51 HistoControlFlowData
*
52 guihistocontrolflow(LttvPluginTab
*ptab
)
54 GtkWidget
*button_widget
, *drawing_widget
, *drawing_area
;
55 histoDrawing_t
*drawing
;
56 HistoControlFlowData
* histo_control_flow_data
= g_new(HistoControlFlowData
,1) ;
58 histo_control_flow_data
->ptab
= ptab
;
59 histo_control_flow_data
->tab
= ptab
->tab
;
60 histo_control_flow_data
->max_height
= PREDEFINED_HEIGHT
;
62 /*histo_control_flow_data->v_adjust =
63 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, // Value
68 0.0)); // page size */
71 histo_control_flow_data
->drawing
= histo_drawing_construct(histo_control_flow_data
);
73 drawing
= histo_control_flow_data
->drawing
;
74 drawing_widget
= histo_drawing_get_widget(drawing
);
76 drawing_area
= histo_drawing_get_drawing_area(drawing
);
78 histo_control_flow_data
->number_of_process
= 0;
80 ///histo_control_flow_data->background_info_waiting = 0;
82 // Create the Button widget
83 histo_control_flow_data
->buttonwidget
= histo_buttonwidget_construct(histo_control_flow_data
);
85 button_widget
= histo_buttonwidget_get_widget( histo_control_flow_data
-> buttonwidget
);
87 //set the size of ruler fix
88 gtk_widget_set_size_request(histo_control_flow_data
->drawing
->ruler
, -1, 25);
89 gtk_container_check_resize(GTK_CONTAINER(histo_control_flow_data
->drawing
->ruler_hbox
));
91 /*//or set the size of ruler by button P
92 g_signal_connect (G_OBJECT(buttonP),
94 G_CALLBACK(header_size_allocate),
95 (gpointer)histo_control_flow_data->drawing);*/
98 ///histo_control_flow_data->h_paned = gtk_hpaned_new();
100 ///changed for histogram
101 histo_control_flow_data
->box
= gtk_hbox_new(FALSE
, 0);
102 histo_control_flow_data
->ev_box
= gtk_event_box_new();
104 /// histo_control_flow_data->top_widget =gtk_event_box_new();
105 gtk_container_add(GTK_CONTAINER(histo_control_flow_data
->ev_box
),
107 ///Now add button widget and drawing area on the top_widget.
108 gtk_box_pack_start (GTK_BOX (histo_control_flow_data
->box
),
109 button_widget
,FALSE
,FALSE
, 10);
110 gtk_box_pack_end (GTK_BOX (histo_control_flow_data
->box
),
111 histo_control_flow_data
->ev_box
,TRUE
,TRUE
, 0);
112 histo_control_flow_data
->top_widget
= histo_control_flow_data
->box
;
114 /*gtk_container_add(GTK_CONTAINER(histo_control_flow_data->box),
115 histo_control_flow_data->h_paned);
117 gtk_paned_pack1(GTK_PANED(histo_control_flow_data->h_paned),
118 button_widget->vbox1, FALSE, TRUE);
119 gtk_paned_pack2(GTK_PANED(histo_control_flow_data->h_paned),
120 drawing_widget, TRUE, TRUE);
122 gtk_container_set_border_width(GTK_CONTAINER(histo_control_flow_data
->ev_box
), 1);
124 // Set the size of the drawing area
125 //drawing_Resize(drawing, h, w);
127 // Get trace statistics
128 //histo_control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
130 gtk_widget_show(drawing_widget
);
131 gtk_widget_show(button_widget
);
132 /*gtk_widget_show(histo_control_flow_data->h_paned);*/
133 gtk_widget_show(histo_control_flow_data
->box
);
134 gtk_widget_show(histo_control_flow_data
->ev_box
);
135 gtk_widget_show(histo_control_flow_data
->top_widget
);
136 g_object_set_data_full(
137 G_OBJECT(histo_control_flow_data
->top_widget
),
138 "histo_control_flow_data",
139 histo_control_flow_data
,
140 (GDestroyNotify
)guihistocontrolflow_destructor
);
143 G_OBJECT(drawing_area
),
144 "histo_control_flow_data",
145 histo_control_flow_data
);
147 g_histo_control_flow_data_list
= g_slist_append(
148 g_histo_control_flow_data_list
,
149 histo_control_flow_data
);
150 histo_control_flow_data
->number_of_process
=g_array_new (FALSE
,
153 g_array_set_size (histo_control_flow_data
->number_of_process
,
154 drawing_area
->allocation
.width
);
156 //WARNING : The widget must be
157 //inserted in the main window before the drawing area
158 //can be configured (and this must happend before sending
161 return histo_control_flow_data
;
165 /* Destroys widget also */
166 void guihistocontrolflow_destructor_full(HistoControlFlowData
*histo_control_flow_data
)
168 g_info("HISTOCFV.c : guihistocontrolflow_destructor_full, %p", histo_control_flow_data
);
169 /* May already have been done by GTK window closing */
170 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data
)))
171 gtk_widget_destroy(guihistocontrolflow_get_widget(histo_control_flow_data
));
172 //histo_control_flow_data->mw = NULL;
173 //FIXME guihistocontrolflow_destructor(histo_control_flow_data);
176 /* When this destructor is called, the widgets are already disconnected */
177 void guihistocontrolflow_destructor(HistoControlFlowData
*histo_control_flow_data
)
179 Tab
*tab
= histo_control_flow_data
->tab
;
181 g_info("HISTOCFV.c : guihistocontrolflow_destructor, %p", histo_control_flow_data
);
182 g_info("%p, %p, %p", histo_update_time_window_hook
, histo_control_flow_data
, tab
);
183 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data
)))
184 g_info("widget still exists");
186 /* ButtonWidget is removed with it's widget */
187 //buttonwidget_destroy(histo_control_flow_data->buttonwidget);
190 // Delete reading hooks
191 lttvwindow_unregister_traceset_notify(tab
,
192 histo_traceset_notify
,
193 histo_control_flow_data
);
195 lttvwindow_unregister_time_window_notify(tab
,
196 histo_update_time_window_hook
,
197 histo_control_flow_data
);
199 lttvwindow_unregister_current_time_notify(tab
,
200 histo_update_current_time_hook
,
201 histo_control_flow_data
);
203 lttvwindow_unregister_redraw_notify(tab
, histo_redraw_notify
, histo_control_flow_data
);
204 lttvwindow_unregister_continue_notify(tab
,
205 histo_continue_notify
,
206 histo_control_flow_data
);
208 lttvwindow_events_request_remove_all(histo_control_flow_data
->tab
,
209 histo_control_flow_data
);
211 lttvwindow_unregister_filter_notify(tab
,
212 histo_filter_changed
, histo_control_flow_data
);
215 lttvwindowtraces_background_notify_remove(histo_control_flow_data
);
216 g_histo_control_flow_data_list
=
217 g_slist_remove(g_histo_control_flow_data_list
,histo_control_flow_data
);
219 g_array_free(histo_control_flow_data
->number_of_process
, TRUE
);
221 g_info("HISTOCFV.c : guihistocontrolflow_destructor end, %p", histo_control_flow_data
);
222 g_free(histo_control_flow_data
);