1684ba2e |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2006 Parisa heidari (inspired from CFV by 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., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, 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 | |
29 | #include "histocfv.h" |
30 | #include "histodrawing.h" |
31 | #include "histobuttonwidget.h" |
32 | #include "histoeventhooks.h" |
33 | |
34 | #define PREDEFINED_HEIGHT 5000 |
35 | |
36 | extern GSList *g_histo_control_flow_data_list; |
37 | |
38 | static gboolean |
39 | header_size_allocate(GtkWidget *widget, |
40 | GtkAllocation *allocation, |
41 | gpointer user_data) |
42 | { |
43 | histoDrawing_t *drawing = (histoDrawing_t*)user_data; |
44 | |
45 | gtk_widget_set_size_request(drawing->ruler, -1, allocation->height); |
46 | //gtk_widget_queue_resize(drawing->padding); |
47 | //gtk_widget_queue_resize(drawing->ruler); |
48 | gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox)); |
49 | return 0; |
50 | } |
51 | |
52 | |
53 | /***************************************************************************** |
54 | * Histo Control Flow Viewer class implementation * |
55 | *****************************************************************************/ |
56 | /** |
57 | * Histo Control Flow Viewer's constructor |
58 | * |
59 | * This constructor is given as a parameter to the menuitem and toolbar button |
60 | * registration. It creates the drawing widget. |
61 | * @param ParentWindow A pointer to the parent window. |
62 | * @return The widget created. |
63 | */ |
64 | HistoControlFlowData * |
65 | guihistocontrolflow(Tab *tab) |
66 | { |
67 | GtkWidget *button_widget, *drawing_widget, *drawing_area; |
68 | GtkWidget *buttonP,*buttonM; |
69 | histoDrawing_t *drawing; |
70 | HistoControlFlowData* histo_control_flow_data = g_new(HistoControlFlowData,1) ; |
71 | |
72 | |
73 | histo_control_flow_data->tab = tab; |
74 | histo_control_flow_data->max_height = PREDEFINED_HEIGHT; |
75 | |
76 | /*histo_control_flow_data->v_adjust = |
77 | GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, // Value |
78 | 0.0, // Lower |
79 | 0.0, // Upper |
80 | 0.0, // Step inc. |
81 | 0.0, // Page inc. |
82 | 0.0)); // page size */ |
83 | |
84 | // Create the drawing |
85 | histo_control_flow_data->drawing = histo_drawing_construct(histo_control_flow_data); |
86 | |
87 | drawing = histo_control_flow_data->drawing; |
88 | drawing_widget = histo_drawing_get_widget(drawing); |
89 | |
90 | drawing_area = histo_drawing_get_drawing_area(drawing); |
91 | |
92 | histo_control_flow_data->number_of_process = 0; |
93 | |
94 | ///histo_control_flow_data->background_info_waiting = 0; |
95 | |
96 | // Create the Button widget |
97 | histo_control_flow_data->buttonwidget = histo_buttonwidget_construct(histo_control_flow_data); |
98 | |
99 | button_widget = histo_buttonwidget_get_widget( histo_control_flow_data-> buttonwidget); |
100 | buttonP =histo_control_flow_data-> buttonwidget->buttonP; |
101 | buttonM =histo_control_flow_data-> buttonwidget->buttonM; |
102 | |
103 | //set the size of ruler fix |
104 | gtk_widget_set_size_request(histo_control_flow_data->drawing->ruler, -1, 25); |
105 | gtk_container_check_resize(GTK_CONTAINER(histo_control_flow_data->drawing->ruler_hbox)); |
106 | |
107 | /*//or set the size of ruler by button P |
108 | g_signal_connect (G_OBJECT(buttonP), |
109 | "size-allocate", |
110 | G_CALLBACK(header_size_allocate), |
111 | (gpointer)histo_control_flow_data->drawing);*/ |
112 | |
113 | |
114 | ///histo_control_flow_data->h_paned = gtk_hpaned_new(); |
115 | |
116 | ///changed for histogram |
117 | histo_control_flow_data->box = gtk_hbox_new(FALSE, 0); |
118 | histo_control_flow_data->ev_box = gtk_event_box_new(); |
119 | |
120 | /// histo_control_flow_data->top_widget =gtk_event_box_new(); |
121 | gtk_container_add(GTK_CONTAINER(histo_control_flow_data->ev_box), |
122 | drawing_widget); |
123 | ///Now add button widget and drawing area on the top_widget. |
124 | gtk_box_pack_start (GTK_BOX (histo_control_flow_data->box), |
125 | button_widget,FALSE,FALSE, 10); |
126 | gtk_box_pack_end (GTK_BOX (histo_control_flow_data->box), |
127 | histo_control_flow_data->ev_box,TRUE,TRUE, 0); |
128 | histo_control_flow_data->top_widget = histo_control_flow_data->box; |
129 | |
130 | /*gtk_container_add(GTK_CONTAINER(histo_control_flow_data->box), |
131 | histo_control_flow_data->h_paned); |
132 | |
133 | gtk_paned_pack1(GTK_PANED(histo_control_flow_data->h_paned), |
134 | button_widget->vbox1, FALSE, TRUE); |
135 | gtk_paned_pack2(GTK_PANED(histo_control_flow_data->h_paned), |
136 | drawing_widget, TRUE, TRUE); |
137 | */ |
138 | gtk_container_set_border_width(GTK_CONTAINER(histo_control_flow_data->ev_box), 1); |
139 | |
140 | // Set the size of the drawing area |
141 | //drawing_Resize(drawing, h, w); |
142 | |
143 | // Get trace statistics |
144 | //histo_control_flow_data->Trace_Statistics = get_trace_statistics(Trace); |
145 | |
146 | gtk_widget_show(drawing_widget); |
147 | gtk_widget_show(button_widget); |
148 | /*gtk_widget_show(histo_control_flow_data->h_paned);*/ |
149 | gtk_widget_show(histo_control_flow_data->box); |
150 | gtk_widget_show(histo_control_flow_data->ev_box); |
151 | gtk_widget_show(histo_control_flow_data->top_widget); |
152 | g_object_set_data_full( |
153 | G_OBJECT(histo_control_flow_data->top_widget), |
154 | "histo_control_flow_data", |
155 | histo_control_flow_data, |
156 | (GDestroyNotify)guihistocontrolflow_destructor); |
157 | |
158 | g_object_set_data( |
159 | G_OBJECT(drawing_area), |
160 | "histo_control_flow_data", |
161 | histo_control_flow_data); |
162 | |
163 | g_histo_control_flow_data_list = g_slist_append( |
164 | g_histo_control_flow_data_list, |
165 | histo_control_flow_data); |
166 | histo_control_flow_data->number_of_process =g_array_new (FALSE, |
167 | TRUE, |
168 | sizeof(guint)); |
169 | g_array_set_size (histo_control_flow_data->number_of_process, |
170 | drawing_area->allocation.width); |
171 | |
172 | //WARNING : The widget must be |
173 | //inserted in the main window before the drawing area |
174 | //can be configured (and this must happend before sending |
175 | //data) |
176 | |
177 | return histo_control_flow_data; |
178 | |
179 | } |
180 | |
181 | /* Destroys widget also */ |
182 | void guihistocontrolflow_destructor_full(HistoControlFlowData *histo_control_flow_data) |
183 | { |
184 | g_info("HISTOCFV.c : guihistocontrolflow_destructor_full, %p", histo_control_flow_data); |
185 | /* May already have been done by GTK window closing */ |
186 | if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data))) |
187 | gtk_widget_destroy(guihistocontrolflow_get_widget(histo_control_flow_data)); |
188 | //histo_control_flow_data->mw = NULL; |
189 | //FIXME guihistocontrolflow_destructor(histo_control_flow_data); |
190 | } |
191 | |
192 | /* When this destructor is called, the widgets are already disconnected */ |
193 | void guihistocontrolflow_destructor(HistoControlFlowData *histo_control_flow_data) |
194 | { |
195 | Tab *tab = histo_control_flow_data->tab; |
196 | |
197 | g_info("HISTOCFV.c : guihistocontrolflow_destructor, %p", histo_control_flow_data); |
198 | g_info("%p, %p, %p", histo_update_time_window_hook, histo_control_flow_data, tab); |
199 | if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data))) |
200 | g_info("widget still exists"); |
201 | |
202 | /* ButtonWidget is removed with it's widget */ |
203 | //buttonwidget_destroy(histo_control_flow_data->buttonwidget); |
204 | if(tab != NULL) |
205 | { |
206 | // Delete reading hooks |
207 | lttvwindow_unregister_traceset_notify(tab, |
208 | histo_traceset_notify, |
209 | histo_control_flow_data); |
210 | |
211 | lttvwindow_unregister_time_window_notify(tab, |
212 | histo_update_time_window_hook, |
213 | histo_control_flow_data); |
214 | |
215 | lttvwindow_unregister_current_time_notify(tab, |
216 | histo_update_current_time_hook, |
217 | histo_control_flow_data); |
218 | |
219 | lttvwindow_unregister_redraw_notify(tab, histo_redraw_notify, histo_control_flow_data); |
220 | lttvwindow_unregister_continue_notify(tab, |
221 | histo_continue_notify, |
222 | histo_control_flow_data); |
223 | |
224 | lttvwindow_events_request_remove_all(histo_control_flow_data->tab, |
225 | histo_control_flow_data); |
226 | |
227 | lttvwindow_unregister_filter_notify(tab, |
228 | histo_filter_changed, histo_control_flow_data); |
229 | |
230 | } |
231 | lttvwindowtraces_background_notify_remove(histo_control_flow_data); |
232 | g_histo_control_flow_data_list = |
233 | g_slist_remove(g_histo_control_flow_data_list,histo_control_flow_data); |
234 | |
235 | g_array_free(histo_control_flow_data->number_of_process, TRUE); |
236 | |
237 | g_info("HISTOCFV.c : guihistocontrolflow_destructor end, %p", histo_control_flow_data); |
238 | g_free(histo_control_flow_data); |
239 | |
240 | } |
241 | |
242 | |