merge modifications for multiple viewer read at the same time, better expose handling...
[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 MainWindow * mw = control_flow_data->mw;
35 lttvwindow_report_focus(mw, gtk_widget_get_parent(control_flow_data->scrolled_window));
36 }
37
38
39 /*****************************************************************************
40 * Control Flow Viewer class implementation *
41 *****************************************************************************/
42 /**
43 * Control Flow Viewer's constructor
44 *
45 * This constructor is given as a parameter to the menuitem and toolbar button
46 * registration. It creates the drawing widget.
47 * @param ParentWindow A pointer to the parent window.
48 * @return The widget created.
49 */
50 ControlFlowData *
51 guicontrolflow(void)
52 {
53 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
54
55 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
56
57 /* Create the drawing */
58 control_flow_data->drawing = drawing_construct(control_flow_data);
59
60 drawing_widget =
61 drawing_get_widget(control_flow_data->drawing);
62
63 drawing_area =
64 drawing_get_drawing_area(control_flow_data->drawing);
65
66 control_flow_data->number_of_process = 0;
67
68 /* Create the Process list */
69 control_flow_data->process_list = processlist_construct();
70
71 process_list_widget =
72 processlist_get_widget(control_flow_data->process_list);
73
74 //control_flow_data->Inside_HBox_V = gtk_hbox_new(0, 0);
75 control_flow_data->h_paned = gtk_hpaned_new();
76
77 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), process_list_widget, FALSE, TRUE);
78 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), drawing_widget, TRUE, TRUE);
79
80 control_flow_data->v_adjust =
81 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
82 0.0, /* Lower */
83 0.0, /* Upper */
84 0.0, /* Step inc. */
85 0.0, /* Page inc. */
86 0.0)); /* page size */
87
88 control_flow_data->scrolled_window =
89 gtk_scrolled_window_new (NULL,
90 control_flow_data->v_adjust);
91
92 gtk_scrolled_window_set_policy(
93 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window) ,
94 GTK_POLICY_NEVER,
95 GTK_POLICY_AUTOMATIC);
96
97 gtk_scrolled_window_add_with_viewport(
98 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window),
99 control_flow_data->h_paned);
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 /* Create reading hooks */
108 control_flow_data->event = lttv_hooks_new();
109 control_flow_data->after_event = lttv_hooks_new();
110 control_flow_data->after_traceset = lttv_hooks_new();
111 control_flow_data->event_request = g_new(EventRequest, 1);
112
113
114 gtk_widget_show(drawing_widget);
115 gtk_widget_show(process_list_widget);
116 gtk_widget_show(control_flow_data->h_paned);
117 gtk_widget_show(control_flow_data->scrolled_window);
118
119 g_object_set_data_full(
120 G_OBJECT(control_flow_data->scrolled_window),
121 "control_flow_data",
122 control_flow_data,
123 (GDestroyNotify)guicontrolflow_destructor);
124
125 g_object_set_data(
126 G_OBJECT(drawing_area),
127 "control_flow_data",
128 control_flow_data);
129
130 g_control_flow_data_list = g_slist_append(
131 g_control_flow_data_list,
132 control_flow_data);
133
134 //WARNING : The widget must be
135 //inserted in the main window before the drawing area
136 //can be configured (and this must happend bedore sending
137 //data)
138
139 g_signal_connect (G_OBJECT (process_list_widget), "grab-focus",
140 G_CALLBACK (control_flow_grab_focus),
141 control_flow_data);
142
143
144 return control_flow_data;
145
146 }
147
148 /* Destroys widget also */
149 void
150 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
151 {
152 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
153 /* May already have been done by GTK window closing */
154 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
155 gtk_widget_destroy(control_flow_data->scrolled_window);
156 //control_flow_data->mw = NULL;
157 //FIXME guicontrolflow_destructor(control_flow_data);
158 }
159
160 /* When this destructor is called, the widgets are already disconnected */
161 void
162 guicontrolflow_destructor(ControlFlowData *control_flow_data)
163 {
164 guint index;
165
166 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
167 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, control_flow_data->mw);
168 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
169 g_info("widget still exists");
170
171 /* Process List is removed with it's widget */
172 //ProcessList_destroy(control_flow_data->process_list);
173 if(control_flow_data->mw != NULL)
174 {
175 /* Delete reading hooks */
176 lttv_hooks_destroy(control_flow_data->event);
177 lttv_hooks_destroy(control_flow_data->after_event);
178 lttv_hooks_destroy(control_flow_data->after_traceset);
179 g_free(control_flow_data->event_request);
180
181 lttvwindow_unregister_time_window_notify(control_flow_data->mw,
182 update_time_window_hook,
183 control_flow_data);
184
185 lttvwindow_unregister_current_time_notify(control_flow_data->mw,
186 update_current_time_hook,
187 control_flow_data);
188 }
189 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
190 g_slist_remove(g_control_flow_data_list,control_flow_data);
191 g_free(control_flow_data);
192 }
193
194 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
195 {
196 return control_flow_data->scrolled_window ;
197 }
198
199 ProcessList *guicontrolflow_get_process_list
200 (ControlFlowData *control_flow_data)
201 {
202 return control_flow_data->process_list ;
203 }
204
205
This page took 0.032768 seconds and 4 git commands to generate.