Added GPL copyrights to my files, MD
[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
29
30 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
31 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
32
33 extern GSList *g_control_flow_data_list;
34
35 /*****************************************************************************
36 * Control Flow Viewer class implementation *
37 *****************************************************************************/
38 /**
39 * Control Flow Viewer's constructor
40 *
41 * This constructor is given as a parameter to the menuitem and toolbar button
42 * registration. It creates the drawing widget.
43 * @param ParentWindow A pointer to the parent window.
44 * @return The widget created.
45 */
46 ControlFlowData *
47 guicontrolflow(void)
48 {
49 GtkWidget *process_list_widget, *drawing_widget;
50
51 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
52
53 /* Create the drawing */
54 control_flow_data->drawing = drawing_construct(control_flow_data);
55
56 drawing_widget =
57 drawing_get_widget(control_flow_data->drawing);
58
59 control_flow_data->number_of_process = 0;
60
61 /* Create the Process list */
62 control_flow_data->process_list = processlist_construct();
63
64 process_list_widget =
65 processlist_get_widget(control_flow_data->process_list);
66
67 //control_flow_data->Inside_HBox_V = gtk_hbox_new(0, 0);
68 control_flow_data->h_paned = gtk_hpaned_new();
69
70 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), process_list_widget, FALSE, TRUE);
71 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), drawing_widget, TRUE, TRUE);
72
73 control_flow_data->v_adjust =
74 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
75 0.0, /* Lower */
76 0.0, /* Upper */
77 0.0, /* Step inc. */
78 0.0, /* Page inc. */
79 0.0)); /* page size */
80
81 control_flow_data->scrolled_window =
82 gtk_scrolled_window_new (NULL,
83 control_flow_data->v_adjust);
84
85 gtk_scrolled_window_set_policy(
86 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window) ,
87 GTK_POLICY_NEVER,
88 GTK_POLICY_AUTOMATIC);
89
90 gtk_scrolled_window_add_with_viewport(
91 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window),
92 control_flow_data->h_paned);
93
94 /* Set the size of the drawing area */
95 //drawing_Resize(drawing, h, w);
96
97 /* Get trace statistics */
98 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
99
100
101 gtk_widget_show(drawing_widget);
102 gtk_widget_show(process_list_widget);
103 gtk_widget_show(control_flow_data->h_paned);
104 gtk_widget_show(control_flow_data->scrolled_window);
105
106 g_object_set_data_full(
107 G_OBJECT(control_flow_data->scrolled_window),
108 "control_flow_data",
109 control_flow_data,
110 (GDestroyNotify)guicontrolflow_destructor);
111
112 g_object_set_data(
113 G_OBJECT(drawing_widget),
114 "control_flow_data",
115 control_flow_data);
116
117 g_control_flow_data_list = g_slist_append(
118 g_control_flow_data_list,
119 control_flow_data);
120
121 //WARNING : The widget must be
122 //inserted in the main window before the drawing area
123 //can be configured (and this must happend bedore sending
124 //data)
125
126 return control_flow_data;
127
128 }
129
130 /* Destroys widget also */
131 void
132 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
133 {
134 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
135 /* May already have been done by GTK window closing */
136 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
137 gtk_widget_destroy(control_flow_data->scrolled_window);
138 //control_flow_data->mw = NULL;
139 //FIXME guicontrolflow_destructor(control_flow_data);
140 }
141
142 /* When this destructor is called, the widgets are already disconnected */
143 void
144 guicontrolflow_destructor(ControlFlowData *control_flow_data)
145 {
146 guint index;
147
148 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
149 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, control_flow_data->mw);
150 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
151 g_info("widget still exists");
152
153 /* Process List is removed with it's widget */
154 //ProcessList_destroy(control_flow_data->process_list);
155 if(control_flow_data->mw != NULL)
156 {
157 unreg_update_time_window(update_time_window_hook,
158 control_flow_data,
159 control_flow_data->mw);
160
161 unreg_update_current_time(update_current_time_hook,
162 control_flow_data,
163 control_flow_data->mw);
164 }
165 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
166 g_slist_remove(g_control_flow_data_list,control_flow_data);
167 g_free(control_flow_data);
168 }
169
170 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
171 {
172 return control_flow_data->scrolled_window ;
173 }
174
175 ProcessList *guicontrolflow_get_process_list
176 (ControlFlowData *control_flow_data)
177 {
178 return control_flow_data->process_list ;
179 }
180
181 TimeWindow *guicontrolflow_get_time_window(ControlFlowData *control_flow_data)
182 {
183 return &control_flow_data->time_window;
184 }
185 LttTime *guicontrolflow_get_current_time(ControlFlowData *control_flow_data)
186 {
187 return &control_flow_data->current_time;
188 }
189
190
This page took 0.032489 seconds and 4 git commands to generate.