output warning message when trying to convert between LttTime and double with precisi...
[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 /*****************************************************************************
43 * Control Flow Viewer class implementation *
44 *****************************************************************************/
45 /**
46 * Control Flow Viewer's constructor
47 *
48 * This constructor is given as a parameter to the menuitem and toolbar button
49 * registration. It creates the drawing widget.
50 * @param ParentWindow A pointer to the parent window.
51 * @return The widget created.
52 */
53 ControlFlowData *
54 guicontrolflow(void)
55 {
56 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
57
58 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
59
60 control_flow_data->v_adjust =
61 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
62 0.0, /* Lower */
63 0.0, /* Upper */
64 0.0, /* Step inc. */
65 0.0, /* Page inc. */
66 0.0)); /* page size */
67
68 /* Create the drawing */
69 control_flow_data->drawing = drawing_construct(control_flow_data);
70
71 drawing_widget =
72 drawing_get_widget(control_flow_data->drawing);
73
74 drawing_area =
75 drawing_get_drawing_area(control_flow_data->drawing);
76
77 control_flow_data->number_of_process = 0;
78
79 /* Create the Process list */
80 control_flow_data->process_list = processlist_construct();
81
82 process_list_widget =
83 processlist_get_widget(control_flow_data->process_list);
84
85 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget),
86 GTK_ADJUSTMENT(
87 control_flow_data->v_adjust));
88
89
90 control_flow_data->h_paned = gtk_hpaned_new();
91 control_flow_data->box = gtk_event_box_new();
92 control_flow_data->top_widget = control_flow_data->box;
93 gtk_container_add(GTK_CONTAINER(control_flow_data->box),
94 control_flow_data->h_paned);
95
96 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned),
97 process_list_widget, FALSE, TRUE);
98 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned),
99 drawing_widget, TRUE, TRUE);
100
101 /* Set the size of the drawing area */
102 //drawing_Resize(drawing, h, w);
103
104 /* Get trace statistics */
105 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
106
107 gtk_widget_show(drawing_widget);
108 gtk_widget_show(process_list_widget);
109 gtk_widget_show(control_flow_data->h_paned);
110 gtk_widget_show(control_flow_data->box);
111
112 g_object_set_data_full(
113 G_OBJECT(control_flow_data->top_widget),
114 "control_flow_data",
115 control_flow_data,
116 (GDestroyNotify)guicontrolflow_destructor);
117
118 g_object_set_data(
119 G_OBJECT(drawing_area),
120 "control_flow_data",
121 control_flow_data);
122
123 g_control_flow_data_list = g_slist_append(
124 g_control_flow_data_list,
125 control_flow_data);
126
127 //WARNING : The widget must be
128 //inserted in the main window before the drawing area
129 //can be configured (and this must happend bedore sending
130 //data)
131
132 //g_signal_connect (G_OBJECT (process_list_widget), "grab-focus",
133 //g_signal_connect (G_OBJECT (control_flow_data->scrolled_window),
134 // "button-press-event",
135 // G_CALLBACK (control_flow_grab_focus),
136 // control_flow_data);
137
138 return control_flow_data;
139
140 }
141
142 /* Destroys widget also */
143 void
144 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
145 {
146 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
147 /* May already have been done by GTK window closing */
148 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
149 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data));
150 //control_flow_data->mw = NULL;
151 //FIXME guicontrolflow_destructor(control_flow_data);
152 }
153
154 /* When this destructor is called, the widgets are already disconnected */
155 void
156 guicontrolflow_destructor(ControlFlowData *control_flow_data)
157 {
158 guint index;
159 Tab *tab = control_flow_data->tab;
160
161 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
162 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab);
163 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
164 g_info("widget still exists");
165
166 /* Process List is removed with it's widget */
167 //ProcessList_destroy(control_flow_data->process_list);
168 if(tab != NULL)
169 {
170 /* Delete reading hooks */
171 lttvwindow_unregister_traceset_notify(tab,
172 traceset_notify,
173 control_flow_data);
174
175 lttvwindow_unregister_time_window_notify(tab,
176 update_time_window_hook,
177 control_flow_data);
178
179 lttvwindow_unregister_current_time_notify(tab,
180 update_current_time_hook,
181 control_flow_data);
182
183 lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
184 lttvwindow_unregister_continue_notify(tab,
185 continue_notify,
186 control_flow_data);
187
188 lttvwindow_events_request_remove_all(control_flow_data->tab,
189 control_flow_data);
190
191 lttvwindowtraces_background_notify_remove(control_flow_data);
192 }
193 g_control_flow_data_list =
194 g_slist_remove(g_control_flow_data_list,control_flow_data);
195
196 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
197 g_free(control_flow_data);
198
199 }
200
201 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
202 {
203 return control_flow_data->top_widget ;
204 }
205
206 ProcessList *guicontrolflow_get_process_list
207 (ControlFlowData *control_flow_data)
208 {
209 return control_flow_data->process_list ;
210 }
211
212
This page took 0.039783 seconds and 5 git commands to generate.