fixes to control flow view GC
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / cfv.c
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 */
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 "cfv.h"
30 #include "drawing.h"
31 #include "processlist.h"
32 #include "eventhooks.h"
33
34 extern GSList *g_control_flow_data_list;
35
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
51 /*****************************************************************************
52 * Control Flow Viewer class implementation *
53 *****************************************************************************/
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 *
63 guicontrolflow(Tab *tab)
64 {
65 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
66
67 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
68
69 control_flow_data->tab = tab;
70
71 control_flow_data->v_adjust =
72 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
73 0.0, /* Lower */
74 0.0, /* Upper */
75 0.0, /* Step inc. */
76 0.0, /* Page inc. */
77 0.0)); /* page size */
78
79 /* Create the drawing */
80 control_flow_data->drawing = drawing_construct(control_flow_data);
81
82 drawing_widget =
83 drawing_get_widget(control_flow_data->drawing);
84
85 drawing_area =
86 drawing_get_drawing_area(control_flow_data->drawing);
87
88 control_flow_data->number_of_process = 0;
89 control_flow_data->background_info_waiting = 0;
90
91 /* Create the Process list */
92 control_flow_data->process_list = processlist_construct();
93
94 process_list_widget =
95 processlist_get_widget(control_flow_data->process_list);
96
97 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget),
98 GTK_ADJUSTMENT(
99 control_flow_data->v_adjust));
100
101 g_signal_connect (G_OBJECT(control_flow_data->process_list->button),
102 "size-allocate",
103 G_CALLBACK(header_size_allocate),
104 (gpointer)control_flow_data->drawing);
105 #if 0 /* not ready */
106 g_signal_connect (
107 // G_OBJECT(control_flow_data->process_list->process_list_widget),
108 G_OBJECT(control_flow_data->process_list->list_store),
109 "row-changed",
110 G_CALLBACK (tree_row_activated),
111 (gpointer)control_flow_data);
112 #endif //0
113
114 control_flow_data->h_paned = gtk_hpaned_new();
115 control_flow_data->box = gtk_event_box_new();
116 control_flow_data->top_widget = control_flow_data->box;
117 gtk_container_add(GTK_CONTAINER(control_flow_data->box),
118 control_flow_data->h_paned);
119
120 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned),
121 process_list_widget, FALSE, TRUE);
122 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned),
123 drawing_widget, TRUE, TRUE);
124
125 gtk_container_set_border_width(GTK_CONTAINER(control_flow_data->box), 1);
126
127 /* Set the size of the drawing area */
128 //drawing_Resize(drawing, h, w);
129
130 /* Get trace statistics */
131 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
132
133 gtk_widget_show(drawing_widget);
134 gtk_widget_show(process_list_widget);
135 gtk_widget_show(control_flow_data->h_paned);
136 gtk_widget_show(control_flow_data->box);
137
138 g_object_set_data_full(
139 G_OBJECT(control_flow_data->top_widget),
140 "control_flow_data",
141 control_flow_data,
142 (GDestroyNotify)guicontrolflow_destructor);
143
144 g_object_set_data(
145 G_OBJECT(drawing_area),
146 "control_flow_data",
147 control_flow_data);
148
149 g_control_flow_data_list = g_slist_append(
150 g_control_flow_data_list,
151 control_flow_data);
152
153 //WARNING : The widget must be
154 //inserted in the main window before the drawing area
155 //can be configured (and this must happend bedore sending
156 //data)
157
158 return control_flow_data;
159
160 }
161
162 /* Destroys widget also */
163 void
164 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
165 {
166 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
167 /* May already have been done by GTK window closing */
168 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
169 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data));
170 //control_flow_data->mw = NULL;
171 //FIXME guicontrolflow_destructor(control_flow_data);
172 }
173
174 /* When this destructor is called, the widgets are already disconnected */
175 void
176 guicontrolflow_destructor(ControlFlowData *control_flow_data)
177 {
178 Tab *tab = control_flow_data->tab;
179
180 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
181 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab);
182 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
183 g_info("widget still exists");
184
185 /* Process List is removed with it's widget */
186 //ProcessList_destroy(control_flow_data->process_list);
187 if(tab != NULL)
188 {
189 /* Delete reading hooks */
190 lttvwindow_unregister_traceset_notify(tab,
191 traceset_notify,
192 control_flow_data);
193
194 lttvwindow_unregister_time_window_notify(tab,
195 update_time_window_hook,
196 control_flow_data);
197
198 lttvwindow_unregister_current_time_notify(tab,
199 update_current_time_hook,
200 control_flow_data);
201
202 lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
203 lttvwindow_unregister_continue_notify(tab,
204 continue_notify,
205 control_flow_data);
206
207 lttvwindow_events_request_remove_all(control_flow_data->tab,
208 control_flow_data);
209
210 }
211 lttvwindowtraces_background_notify_remove(control_flow_data);
212 g_control_flow_data_list =
213 g_slist_remove(g_control_flow_data_list,control_flow_data);
214
215 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
216 g_free(control_flow_data);
217
218 }
219
220
This page took 0.034402 seconds and 4 git commands to generate.