ce0214a6 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 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 | */ |
f0d936c0 |
18 | |
4e4d11b3 |
19 | #ifdef HAVE_CONFIG_H |
20 | #include <config.h> |
21 | #endif |
22 | |
f0d936c0 |
23 | #include <glib.h> |
24 | #include <gtk/gtk.h> |
25 | #include <gdk/gdk.h> |
2eef04b5 |
26 | #include <lttv/lttv.h> |
27 | #include <lttvwindow/lttvwindow.h> |
f0d936c0 |
28 | |
f6310a5b |
29 | #include "cfv.h" |
30 | #include "drawing.h" |
d66666fe |
31 | #include "processlist.h" |
32 | #include "eventhooks.h" |
189a5d08 |
33 | |
68997a22 |
34 | extern GSList *g_control_flow_data_list; |
f0d936c0 |
35 | |
b9a010a2 |
36 | static gboolean |
37 | header_size_allocate(GtkWidget *widget, |
38 | GtkAllocation *allocation, |
39 | gpointer user_data) |
40 | { |
41 | Drawing_t *drawing = (Drawing_t*)user_data; |
42 | |
43 | gtk_widget_set_size_request(drawing->ruler, -1, allocation->height); |
44 | //gtk_widget_queue_resize(drawing->padding); |
45 | //gtk_widget_queue_resize(drawing->ruler); |
46 | gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox)); |
47 | return 0; |
48 | } |
49 | |
50 | |
f0d936c0 |
51 | /***************************************************************************** |
52 | * Control Flow Viewer class implementation * |
53 | *****************************************************************************/ |
f0d936c0 |
54 | /** |
55 | * Control Flow Viewer's constructor |
56 | * |
57 | * This constructor is given as a parameter to the menuitem and toolbar button |
58 | * registration. It creates the drawing widget. |
59 | * @param ParentWindow A pointer to the parent window. |
60 | * @return The widget created. |
61 | */ |
62 | ControlFlowData * |
4c69e0cc |
63 | guicontrolflow(void) |
f0d936c0 |
64 | { |
3cb8b205 |
65 | GtkWidget *process_list_widget, *drawing_widget, *drawing_area; |
a56a1ba4 |
66 | |
68997a22 |
67 | ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ; |
a56a1ba4 |
68 | |
51705146 |
69 | control_flow_data->v_adjust = |
70 | GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */ |
71 | 0.0, /* Lower */ |
72 | 0.0, /* Upper */ |
73 | 0.0, /* Step inc. */ |
74 | 0.0, /* Page inc. */ |
75 | 0.0)); /* page size */ |
76 | |
501d5405 |
77 | /* Create the drawing */ |
78 | control_flow_data->drawing = drawing_construct(control_flow_data); |
a56a1ba4 |
79 | |
68997a22 |
80 | drawing_widget = |
501d5405 |
81 | drawing_get_widget(control_flow_data->drawing); |
a56a1ba4 |
82 | |
3cb8b205 |
83 | drawing_area = |
84 | drawing_get_drawing_area(control_flow_data->drawing); |
85 | |
68997a22 |
86 | control_flow_data->number_of_process = 0; |
e800cf84 |
87 | control_flow_data->background_info_waiting = 0; |
a56a1ba4 |
88 | |
89 | /* Create the Process list */ |
68997a22 |
90 | control_flow_data->process_list = processlist_construct(); |
a56a1ba4 |
91 | |
68997a22 |
92 | process_list_widget = |
93 | processlist_get_widget(control_flow_data->process_list); |
a56a1ba4 |
94 | |
51705146 |
95 | gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget), |
96 | GTK_ADJUSTMENT( |
97 | control_flow_data->v_adjust)); |
ba90bc77 |
98 | |
b9a010a2 |
99 | g_signal_connect (G_OBJECT(control_flow_data->process_list->button), |
100 | "size-allocate", |
101 | G_CALLBACK(header_size_allocate), |
102 | (gpointer)control_flow_data->drawing); |
dbd243b1 |
103 | #if 0 /* not ready */ |
104 | g_signal_connect ( |
105 | // G_OBJECT(control_flow_data->process_list->process_list_widget), |
106 | G_OBJECT(control_flow_data->process_list->list_store), |
107 | "row-changed", |
108 | G_CALLBACK (tree_row_activated), |
109 | (gpointer)control_flow_data); |
110 | #endif //0 |
a56a1ba4 |
111 | |
6a9ba166 |
112 | control_flow_data->h_paned = gtk_hpaned_new(); |
113 | control_flow_data->box = gtk_event_box_new(); |
114 | control_flow_data->top_widget = control_flow_data->box; |
115 | gtk_container_add(GTK_CONTAINER(control_flow_data->box), |
116 | control_flow_data->h_paned); |
117 | |
51705146 |
118 | gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), |
119 | process_list_widget, FALSE, TRUE); |
120 | gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), |
121 | drawing_widget, TRUE, TRUE); |
203eb6f7 |
122 | |
123 | gtk_container_set_border_width(GTK_CONTAINER(control_flow_data->box), 1); |
124 | |
a56a1ba4 |
125 | /* Set the size of the drawing area */ |
501d5405 |
126 | //drawing_Resize(drawing, h, w); |
a56a1ba4 |
127 | |
128 | /* Get trace statistics */ |
68997a22 |
129 | //control_flow_data->Trace_Statistics = get_trace_statistics(Trace); |
a56a1ba4 |
130 | |
68997a22 |
131 | gtk_widget_show(drawing_widget); |
132 | gtk_widget_show(process_list_widget); |
133 | gtk_widget_show(control_flow_data->h_paned); |
6a9ba166 |
134 | gtk_widget_show(control_flow_data->box); |
a56a1ba4 |
135 | |
136 | g_object_set_data_full( |
51705146 |
137 | G_OBJECT(control_flow_data->top_widget), |
68997a22 |
138 | "control_flow_data", |
139 | control_flow_data, |
a56a1ba4 |
140 | (GDestroyNotify)guicontrolflow_destructor); |
141 | |
142 | g_object_set_data( |
3cb8b205 |
143 | G_OBJECT(drawing_area), |
68997a22 |
144 | "control_flow_data", |
145 | control_flow_data); |
a56a1ba4 |
146 | |
68997a22 |
147 | g_control_flow_data_list = g_slist_append( |
148 | g_control_flow_data_list, |
149 | control_flow_data); |
a56a1ba4 |
150 | |
151 | //WARNING : The widget must be |
501d5405 |
152 | //inserted in the main window before the drawing area |
a56a1ba4 |
153 | //can be configured (and this must happend bedore sending |
154 | //data) |
a43d67ba |
155 | |
68997a22 |
156 | return control_flow_data; |
f0d936c0 |
157 | |
158 | } |
159 | |
78417791 |
160 | /* Destroys widget also */ |
161 | void |
68997a22 |
162 | guicontrolflow_destructor_full(ControlFlowData *control_flow_data) |
78417791 |
163 | { |
68997a22 |
164 | g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data); |
a56a1ba4 |
165 | /* May already have been done by GTK window closing */ |
ca0f8a8e |
166 | if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data))) |
167 | gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data)); |
68997a22 |
168 | //control_flow_data->mw = NULL; |
169 | //FIXME guicontrolflow_destructor(control_flow_data); |
78417791 |
170 | } |
171 | |
189a5d08 |
172 | /* When this destructor is called, the widgets are already disconnected */ |
f0d936c0 |
173 | void |
68997a22 |
174 | guicontrolflow_destructor(ControlFlowData *control_flow_data) |
f0d936c0 |
175 | { |
ca0f8a8e |
176 | Tab *tab = control_flow_data->tab; |
a56a1ba4 |
177 | |
68997a22 |
178 | g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data); |
ca0f8a8e |
179 | g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab); |
180 | if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data))) |
a56a1ba4 |
181 | g_info("widget still exists"); |
182 | |
183 | /* Process List is removed with it's widget */ |
68997a22 |
184 | //ProcessList_destroy(control_flow_data->process_list); |
ca0f8a8e |
185 | if(tab != NULL) |
a56a1ba4 |
186 | { |
a43d67ba |
187 | /* Delete reading hooks */ |
6395d57c |
188 | lttvwindow_unregister_traceset_notify(tab, |
189 | traceset_notify, |
190 | control_flow_data); |
191 | |
ca0f8a8e |
192 | lttvwindow_unregister_time_window_notify(tab, |
224446ce |
193 | update_time_window_hook, |
194 | control_flow_data); |
a56a1ba4 |
195 | |
ca0f8a8e |
196 | lttvwindow_unregister_current_time_notify(tab, |
224446ce |
197 | update_current_time_hook, |
198 | control_flow_data); |
ca0f8a8e |
199 | |
200 | lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data); |
201 | lttvwindow_unregister_continue_notify(tab, |
202 | continue_notify, |
203 | control_flow_data); |
204 | |
205 | lttvwindow_events_request_remove_all(control_flow_data->tab, |
206 | control_flow_data); |
51705146 |
207 | |
a56a1ba4 |
208 | } |
b9a010a2 |
209 | lttvwindowtraces_background_notify_remove(control_flow_data); |
ca0f8a8e |
210 | g_control_flow_data_list = |
211 | g_slist_remove(g_control_flow_data_list,control_flow_data); |
212 | |
213 | g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data); |
68997a22 |
214 | g_free(control_flow_data); |
ca0f8a8e |
215 | |
f0d936c0 |
216 | } |
217 | |
f7afe191 |
218 | |