Update FSF address
[lttv.git] / lttv / modules / gui / histogram / histocfv.c
CommitLineData
1684ba2e 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa heidari (inspired from CFV by 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
b9ce0bad
YB
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
1684ba2e 17 */
18
19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
23#include <glib.h>
24#include <gtk/gtk.h>
25#include <gdk/gdk.h>
26#include <lttv/lttv.h>
27#include <lttvwindow/lttvwindow.h>
8d8c5ea7 28#include <lttvwindow/lttvwindowtraces.h>
1684ba2e 29
30#include "histocfv.h"
31#include "histodrawing.h"
32#include "histobuttonwidget.h"
33#include "histoeventhooks.h"
34
35#define PREDEFINED_HEIGHT 5000
36
37extern GSList *g_histo_control_flow_data_list;
38
1684ba2e 39
40/*****************************************************************************
41 * Histo Control Flow Viewer class implementation *
42 *****************************************************************************/
43/**
44 * Histo Control Flow Viewer's constructor
45 *
46 * This constructor is given as a parameter to the menuitem and toolbar button
47 * registration. It creates the drawing widget.
48 * @param ParentWindow A pointer to the parent window.
49 * @return The widget created.
50 */
51HistoControlFlowData *
e433e6d6 52guihistocontrolflow(LttvPluginTab *ptab)
1684ba2e 53{
54 GtkWidget *button_widget, *drawing_widget, *drawing_area;
1684ba2e 55 histoDrawing_t *drawing;
56 HistoControlFlowData* histo_control_flow_data = g_new(HistoControlFlowData,1) ;
57
e433e6d6 58 histo_control_flow_data->ptab = ptab;
59 histo_control_flow_data->tab = ptab->tab;
1684ba2e 60 histo_control_flow_data->max_height = PREDEFINED_HEIGHT;
61
62 /*histo_control_flow_data->v_adjust =
63 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, // Value
64 0.0, // Lower
65 0.0, // Upper
66 0.0, // Step inc.
67 0.0, // Page inc.
68 0.0)); // page size */
69
70 // Create the drawing
71 histo_control_flow_data->drawing = histo_drawing_construct(histo_control_flow_data);
72
73 drawing = histo_control_flow_data->drawing;
74 drawing_widget = histo_drawing_get_widget(drawing);
75
76 drawing_area = histo_drawing_get_drawing_area(drawing);
77
78 histo_control_flow_data->number_of_process = 0;
79
80 ///histo_control_flow_data->background_info_waiting = 0;
81
82 // Create the Button widget
83 histo_control_flow_data->buttonwidget = histo_buttonwidget_construct(histo_control_flow_data);
84
85 button_widget = histo_buttonwidget_get_widget( histo_control_flow_data-> buttonwidget);
1684ba2e 86
87 //set the size of ruler fix
88 gtk_widget_set_size_request(histo_control_flow_data->drawing->ruler, -1, 25);
89 gtk_container_check_resize(GTK_CONTAINER(histo_control_flow_data->drawing->ruler_hbox));
90
91/*//or set the size of ruler by button P
92 g_signal_connect (G_OBJECT(buttonP),
93 "size-allocate",
94 G_CALLBACK(header_size_allocate),
95 (gpointer)histo_control_flow_data->drawing);*/
96
97
98 ///histo_control_flow_data->h_paned = gtk_hpaned_new();
99
100 ///changed for histogram
101 histo_control_flow_data->box = gtk_hbox_new(FALSE, 0);
102 histo_control_flow_data->ev_box = gtk_event_box_new();
103
104 /// histo_control_flow_data->top_widget =gtk_event_box_new();
105 gtk_container_add(GTK_CONTAINER(histo_control_flow_data->ev_box),
106 drawing_widget);
107 ///Now add button widget and drawing area on the top_widget.
108 gtk_box_pack_start (GTK_BOX (histo_control_flow_data->box),
109 button_widget,FALSE,FALSE, 10);
110 gtk_box_pack_end (GTK_BOX (histo_control_flow_data->box),
111 histo_control_flow_data->ev_box,TRUE,TRUE, 0);
112 histo_control_flow_data->top_widget = histo_control_flow_data->box;
113
114 /*gtk_container_add(GTK_CONTAINER(histo_control_flow_data->box),
115 histo_control_flow_data->h_paned);
116
117 gtk_paned_pack1(GTK_PANED(histo_control_flow_data->h_paned),
118 button_widget->vbox1, FALSE, TRUE);
119 gtk_paned_pack2(GTK_PANED(histo_control_flow_data->h_paned),
120 drawing_widget, TRUE, TRUE);
121 */
122 gtk_container_set_border_width(GTK_CONTAINER(histo_control_flow_data->ev_box), 1);
123
124 // Set the size of the drawing area
125 //drawing_Resize(drawing, h, w);
126
127 // Get trace statistics
128 //histo_control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
129
130 gtk_widget_show(drawing_widget);
131 gtk_widget_show(button_widget);
132 /*gtk_widget_show(histo_control_flow_data->h_paned);*/
133 gtk_widget_show(histo_control_flow_data->box);
134 gtk_widget_show(histo_control_flow_data->ev_box);
135 gtk_widget_show(histo_control_flow_data->top_widget);
136 g_object_set_data_full(
137 G_OBJECT(histo_control_flow_data->top_widget),
138 "histo_control_flow_data",
139 histo_control_flow_data,
140 (GDestroyNotify)guihistocontrolflow_destructor);
141
142 g_object_set_data(
143 G_OBJECT(drawing_area),
144 "histo_control_flow_data",
145 histo_control_flow_data);
146
147 g_histo_control_flow_data_list = g_slist_append(
148 g_histo_control_flow_data_list,
149 histo_control_flow_data);
150 histo_control_flow_data->number_of_process =g_array_new (FALSE,
151 TRUE,
152 sizeof(guint));
153 g_array_set_size (histo_control_flow_data->number_of_process,
154 drawing_area->allocation.width);
155
156 //WARNING : The widget must be
157 //inserted in the main window before the drawing area
158 //can be configured (and this must happend before sending
159 //data)
160
161 return histo_control_flow_data;
162
163}
164
165/* Destroys widget also */
166void guihistocontrolflow_destructor_full(HistoControlFlowData *histo_control_flow_data)
167{
168 g_info("HISTOCFV.c : guihistocontrolflow_destructor_full, %p", histo_control_flow_data);
169 /* May already have been done by GTK window closing */
170 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data)))
171 gtk_widget_destroy(guihistocontrolflow_get_widget(histo_control_flow_data));
172 //histo_control_flow_data->mw = NULL;
173 //FIXME guihistocontrolflow_destructor(histo_control_flow_data);
174}
175
176/* When this destructor is called, the widgets are already disconnected */
177void guihistocontrolflow_destructor(HistoControlFlowData *histo_control_flow_data)
178{
179 Tab *tab = histo_control_flow_data->tab;
180
181 g_info("HISTOCFV.c : guihistocontrolflow_destructor, %p", histo_control_flow_data);
182 g_info("%p, %p, %p", histo_update_time_window_hook, histo_control_flow_data, tab);
183 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data)))
184 g_info("widget still exists");
185
186 /* ButtonWidget is removed with it's widget */
187 //buttonwidget_destroy(histo_control_flow_data->buttonwidget);
188 if(tab != NULL)
189 {
190 // Delete reading hooks
191 lttvwindow_unregister_traceset_notify(tab,
192 histo_traceset_notify,
193 histo_control_flow_data);
194
195 lttvwindow_unregister_time_window_notify(tab,
196 histo_update_time_window_hook,
197 histo_control_flow_data);
198
199 lttvwindow_unregister_current_time_notify(tab,
200 histo_update_current_time_hook,
201 histo_control_flow_data);
202
203 lttvwindow_unregister_redraw_notify(tab, histo_redraw_notify, histo_control_flow_data);
204 lttvwindow_unregister_continue_notify(tab,
205 histo_continue_notify,
206 histo_control_flow_data);
207
208 lttvwindow_events_request_remove_all(histo_control_flow_data->tab,
209 histo_control_flow_data);
210
211 lttvwindow_unregister_filter_notify(tab,
212 histo_filter_changed, histo_control_flow_data);
213
214 }
215 lttvwindowtraces_background_notify_remove(histo_control_flow_data);
216 g_histo_control_flow_data_list =
217 g_slist_remove(g_histo_control_flow_data_list,histo_control_flow_data);
218
219 g_array_free(histo_control_flow_data->number_of_process, TRUE);
220
221 g_info("HISTOCFV.c : guihistocontrolflow_destructor end, %p", histo_control_flow_data);
222 g_free(histo_control_flow_data);
223
224}
225
226
This page took 0.060208 seconds and 4 git commands to generate.