basic time bar
[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, *drawing_area;
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 drawing_area =
60 drawing_get_drawing_area(control_flow_data->drawing);
61
62 control_flow_data->number_of_process = 0;
63
64 /* Create the Process list */
65 control_flow_data->process_list = processlist_construct();
66
67 process_list_widget =
68 processlist_get_widget(control_flow_data->process_list);
69
70 //control_flow_data->Inside_HBox_V = gtk_hbox_new(0, 0);
71 control_flow_data->h_paned = gtk_hpaned_new();
72
73 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), process_list_widget, FALSE, TRUE);
74 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), drawing_widget, TRUE, TRUE);
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 control_flow_data->scrolled_window =
85 gtk_scrolled_window_new (NULL,
86 control_flow_data->v_adjust);
87
88 gtk_scrolled_window_set_policy(
89 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window) ,
90 GTK_POLICY_NEVER,
91 GTK_POLICY_AUTOMATIC);
92
93 gtk_scrolled_window_add_with_viewport(
94 GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window),
95 control_flow_data->h_paned);
96
97 /* Set the size of the drawing area */
98 //drawing_Resize(drawing, h, w);
99
100 /* Get trace statistics */
101 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
102
103
104 gtk_widget_show(drawing_widget);
105 gtk_widget_show(process_list_widget);
106 gtk_widget_show(control_flow_data->h_paned);
107 gtk_widget_show(control_flow_data->scrolled_window);
108
109 g_object_set_data_full(
110 G_OBJECT(control_flow_data->scrolled_window),
111 "control_flow_data",
112 control_flow_data,
113 (GDestroyNotify)guicontrolflow_destructor);
114
115 g_object_set_data(
116 G_OBJECT(drawing_area),
117 "control_flow_data",
118 control_flow_data);
119
120 g_control_flow_data_list = g_slist_append(
121 g_control_flow_data_list,
122 control_flow_data);
123
124 //WARNING : The widget must be
125 //inserted in the main window before the drawing area
126 //can be configured (and this must happend bedore sending
127 //data)
128
129 return control_flow_data;
130
131 }
132
133 /* Destroys widget also */
134 void
135 guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
136 {
137 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
138 /* May already have been done by GTK window closing */
139 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
140 gtk_widget_destroy(control_flow_data->scrolled_window);
141 //control_flow_data->mw = NULL;
142 //FIXME guicontrolflow_destructor(control_flow_data);
143 }
144
145 /* When this destructor is called, the widgets are already disconnected */
146 void
147 guicontrolflow_destructor(ControlFlowData *control_flow_data)
148 {
149 guint index;
150
151 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
152 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, control_flow_data->mw);
153 if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
154 g_info("widget still exists");
155
156 /* Process List is removed with it's widget */
157 //ProcessList_destroy(control_flow_data->process_list);
158 if(control_flow_data->mw != NULL)
159 {
160 unreg_update_time_window(update_time_window_hook,
161 control_flow_data,
162 control_flow_data->mw);
163
164 unreg_update_current_time(update_current_time_hook,
165 control_flow_data,
166 control_flow_data->mw);
167 }
168 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
169 g_slist_remove(g_control_flow_data_list,control_flow_data);
170 g_free(control_flow_data);
171 }
172
173 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
174 {
175 return control_flow_data->scrolled_window ;
176 }
177
178 ProcessList *guicontrolflow_get_process_list
179 (ControlFlowData *control_flow_data)
180 {
181 return control_flow_data->process_list ;
182 }
183
184 TimeWindow *guicontrolflow_get_time_window(ControlFlowData *control_flow_data)
185 {
186 return &control_flow_data->time_window;
187 }
188 LttTime *guicontrolflow_get_current_time(ControlFlowData *control_flow_data)
189 {
190 return &control_flow_data->current_time;
191 }
192
193
This page took 0.032887 seconds and 4 git commands to generate.