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