whole new time bar, plus some additions to control flow viewer.. this is work in...
[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 #include <glib.h>
20 #include <gtk/gtk.h>
21 #include <gdk/gdk.h>
22
23 #include "cfv.h"
24 #include "drawing.h"
25 #include "processlist.h"
26 #include "eventhooks.h"
27 #include "cfv-private.h"
28 #include <lttv/lttv.h>
29
30 extern GSList *g_control_flow_data_list;
31
32 static void control_flow_grab_focus(GtkWidget *widget, gpointer data){
33 ControlFlowData * control_flow_data = (ControlFlowData *)data;
34 Tab * tab = control_flow_data->tab;
35 lttvwindow_report_focus(tab, guicontrolflow_get_widget(control_flow_data));
36 //g_assert(GTK_WIDGET_CAN_FOCUS(widget));
37 //gtk_widget_grab_focus(widget);
38 g_debug("FOCUS GRABBED");
39 }
40
41
42 static gboolean
43 header_size_allocate(GtkWidget *widget,
44 GtkAllocation *allocation,
45 gpointer user_data)
46 {
47 Drawing_t *drawing = (Drawing_t*)user_data;
48
49 gtk_widget_set_size_request(drawing->ruler, -1, allocation->height);
50 //gtk_widget_queue_resize(drawing->padding);
51 //gtk_widget_queue_resize(drawing->ruler);
52 gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox));
53 return 0;
54 }
55
56
57
58 /*****************************************************************************
59 * Control Flow Viewer class implementation *
60 *****************************************************************************/
61 /**
62 * Control Flow Viewer's constructor
63 *
64 * This constructor is given as a parameter to the menuitem and toolbar button
65 * registration. It creates the drawing widget.
66 * @param ParentWindow A pointer to the parent window.
67 * @return The widget created.
68 */
69 ControlFlowData *
70 guicontrolflow(void)
71 {
72 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
73
74 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
75
76 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 control_flow_data->drawing = drawing_construct(control_flow_data);
86
87 drawing_widget =
88 drawing_get_widget(control_flow_data->drawing);
89
90 drawing_area =
91 drawing_get_drawing_area(control_flow_data->drawing);
92
93 control_flow_data->number_of_process = 0;
94 control_flow_data->background_info_waiting = 0;
95
96 /* Create the Process list */
97 control_flow_data->process_list = processlist_construct();
98
99 process_list_widget =
100 processlist_get_widget(control_flow_data->process_list);
101
102 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget),
103 GTK_ADJUSTMENT(
104 control_flow_data->v_adjust));
105
106 g_signal_connect (G_OBJECT(control_flow_data->process_list->button),
107 "size-allocate",
108 G_CALLBACK(header_size_allocate),
109 (gpointer)control_flow_data->drawing);
110
111
112
113 control_flow_data->h_paned = gtk_hpaned_new();
114 control_flow_data->box = gtk_event_box_new();
115 control_flow_data->top_widget = control_flow_data->box;
116 gtk_container_add(GTK_CONTAINER(control_flow_data->box),
117 control_flow_data->h_paned);
118
119 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned),
120 process_list_widget, FALSE, TRUE);
121 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned),
122 drawing_widget, TRUE, TRUE);
123
124 /* Set the size of the drawing area */
125 //drawing_Resize(drawing, h, w);
126
127 /* Get trace statistics */
128 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
129
130 gtk_widget_show(drawing_widget);
131 gtk_widget_show(process_list_widget);
132 gtk_widget_show(control_flow_data->h_paned);
133 gtk_widget_show(control_flow_data->box);
134
135 g_object_set_data_full(
136 G_OBJECT(control_flow_data->top_widget),
137 "control_flow_data",
138 control_flow_data,
139 (GDestroyNotify)guicontrolflow_destructor);
140
141 g_object_set_data(
142 G_OBJECT(drawing_area),
143 "control_flow_data",
144 control_flow_data);
145
146 g_control_flow_data_list = g_slist_append(
147 g_control_flow_data_list,
148 control_flow_data);
149
150 //WARNING : The widget must be
151 //inserted in the main window before the drawing area
152 //can be configured (and this must happend bedore sending
153 //data)
154
155 //g_signal_connect (G_OBJECT (process_list_widget), "grab-focus",
156 //g_signal_connect (G_OBJECT (control_flow_data->scrolled_window),
157 // "button-press-event",
158 // G_CALLBACK (control_flow_grab_focus),
159 // control_flow_data);
160
161 return control_flow_data;
162
163 }
164
165 /* Destroys widget also */
166 void
167 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
168 {
169 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
170 /* May already have been done by GTK window closing */
171 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
172 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data));
173 //control_flow_data->mw = NULL;
174 //FIXME guicontrolflow_destructor(control_flow_data);
175 }
176
177 /* When this destructor is called, the widgets are already disconnected */
178 void
179 guicontrolflow_destructor(ControlFlowData *control_flow_data)
180 {
181 Tab *tab = control_flow_data->tab;
182
183 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
184 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab);
185 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
186 g_info("widget still exists");
187
188 /* Process List is removed with it's widget */
189 //ProcessList_destroy(control_flow_data->process_list);
190 if(tab != NULL)
191 {
192 /* Delete reading hooks */
193 lttvwindow_unregister_traceset_notify(tab,
194 traceset_notify,
195 control_flow_data);
196
197 lttvwindow_unregister_time_window_notify(tab,
198 update_time_window_hook,
199 control_flow_data);
200
201 lttvwindow_unregister_current_time_notify(tab,
202 update_current_time_hook,
203 control_flow_data);
204
205 lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
206 lttvwindow_unregister_continue_notify(tab,
207 continue_notify,
208 control_flow_data);
209
210 lttvwindow_events_request_remove_all(control_flow_data->tab,
211 control_flow_data);
212
213 }
214 lttvwindowtraces_background_notify_remove(control_flow_data);
215 g_control_flow_data_list =
216 g_slist_remove(g_control_flow_data_list,control_flow_data);
217
218 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
219 g_free(control_flow_data);
220
221 }
222
223 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
224 {
225 return control_flow_data->top_widget ;
226 }
227
228 ProcessList *guicontrolflow_get_process_list
229 (ControlFlowData *control_flow_data)
230 {
231 return control_flow_data->process_list ;
232 }
233
234
This page took 0.034494 seconds and 4 git commands to generate.