Fix some warnings in lttv/modules/gui
[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
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
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;
55 GtkWidget *buttonP,*buttonM;
56 histoDrawing_t *drawing;
57 HistoControlFlowData* histo_control_flow_data = g_new(HistoControlFlowData,1) ;
58
e433e6d6 59 histo_control_flow_data->ptab = ptab;
60 histo_control_flow_data->tab = ptab->tab;
1684ba2e 61 histo_control_flow_data->max_height = PREDEFINED_HEIGHT;
62
63 /*histo_control_flow_data->v_adjust =
64 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, // Value
65 0.0, // Lower
66 0.0, // Upper
67 0.0, // Step inc.
68 0.0, // Page inc.
69 0.0)); // page size */
70
71 // Create the drawing
72 histo_control_flow_data->drawing = histo_drawing_construct(histo_control_flow_data);
73
74 drawing = histo_control_flow_data->drawing;
75 drawing_widget = histo_drawing_get_widget(drawing);
76
77 drawing_area = histo_drawing_get_drawing_area(drawing);
78
79 histo_control_flow_data->number_of_process = 0;
80
81 ///histo_control_flow_data->background_info_waiting = 0;
82
83 // Create the Button widget
84 histo_control_flow_data->buttonwidget = histo_buttonwidget_construct(histo_control_flow_data);
85
86 button_widget = histo_buttonwidget_get_widget( histo_control_flow_data-> buttonwidget);
87 buttonP =histo_control_flow_data-> buttonwidget->buttonP;
88 buttonM =histo_control_flow_data-> buttonwidget->buttonM;
89
90 //set the size of ruler fix
91 gtk_widget_set_size_request(histo_control_flow_data->drawing->ruler, -1, 25);
92 gtk_container_check_resize(GTK_CONTAINER(histo_control_flow_data->drawing->ruler_hbox));
93
94/*//or set the size of ruler by button P
95 g_signal_connect (G_OBJECT(buttonP),
96 "size-allocate",
97 G_CALLBACK(header_size_allocate),
98 (gpointer)histo_control_flow_data->drawing);*/
99
100
101 ///histo_control_flow_data->h_paned = gtk_hpaned_new();
102
103 ///changed for histogram
104 histo_control_flow_data->box = gtk_hbox_new(FALSE, 0);
105 histo_control_flow_data->ev_box = gtk_event_box_new();
106
107 /// histo_control_flow_data->top_widget =gtk_event_box_new();
108 gtk_container_add(GTK_CONTAINER(histo_control_flow_data->ev_box),
109 drawing_widget);
110 ///Now add button widget and drawing area on the top_widget.
111 gtk_box_pack_start (GTK_BOX (histo_control_flow_data->box),
112 button_widget,FALSE,FALSE, 10);
113 gtk_box_pack_end (GTK_BOX (histo_control_flow_data->box),
114 histo_control_flow_data->ev_box,TRUE,TRUE, 0);
115 histo_control_flow_data->top_widget = histo_control_flow_data->box;
116
117 /*gtk_container_add(GTK_CONTAINER(histo_control_flow_data->box),
118 histo_control_flow_data->h_paned);
119
120 gtk_paned_pack1(GTK_PANED(histo_control_flow_data->h_paned),
121 button_widget->vbox1, FALSE, TRUE);
122 gtk_paned_pack2(GTK_PANED(histo_control_flow_data->h_paned),
123 drawing_widget, TRUE, TRUE);
124 */
125 gtk_container_set_border_width(GTK_CONTAINER(histo_control_flow_data->ev_box), 1);
126
127 // Set the size of the drawing area
128 //drawing_Resize(drawing, h, w);
129
130 // Get trace statistics
131 //histo_control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
132
133 gtk_widget_show(drawing_widget);
134 gtk_widget_show(button_widget);
135 /*gtk_widget_show(histo_control_flow_data->h_paned);*/
136 gtk_widget_show(histo_control_flow_data->box);
137 gtk_widget_show(histo_control_flow_data->ev_box);
138 gtk_widget_show(histo_control_flow_data->top_widget);
139 g_object_set_data_full(
140 G_OBJECT(histo_control_flow_data->top_widget),
141 "histo_control_flow_data",
142 histo_control_flow_data,
143 (GDestroyNotify)guihistocontrolflow_destructor);
144
145 g_object_set_data(
146 G_OBJECT(drawing_area),
147 "histo_control_flow_data",
148 histo_control_flow_data);
149
150 g_histo_control_flow_data_list = g_slist_append(
151 g_histo_control_flow_data_list,
152 histo_control_flow_data);
153 histo_control_flow_data->number_of_process =g_array_new (FALSE,
154 TRUE,
155 sizeof(guint));
156 g_array_set_size (histo_control_flow_data->number_of_process,
157 drawing_area->allocation.width);
158
159 //WARNING : The widget must be
160 //inserted in the main window before the drawing area
161 //can be configured (and this must happend before sending
162 //data)
163
164 return histo_control_flow_data;
165
166}
167
168/* Destroys widget also */
169void guihistocontrolflow_destructor_full(HistoControlFlowData *histo_control_flow_data)
170{
171 g_info("HISTOCFV.c : guihistocontrolflow_destructor_full, %p", histo_control_flow_data);
172 /* May already have been done by GTK window closing */
173 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data)))
174 gtk_widget_destroy(guihistocontrolflow_get_widget(histo_control_flow_data));
175 //histo_control_flow_data->mw = NULL;
176 //FIXME guihistocontrolflow_destructor(histo_control_flow_data);
177}
178
179/* When this destructor is called, the widgets are already disconnected */
180void guihistocontrolflow_destructor(HistoControlFlowData *histo_control_flow_data)
181{
182 Tab *tab = histo_control_flow_data->tab;
183
184 g_info("HISTOCFV.c : guihistocontrolflow_destructor, %p", histo_control_flow_data);
185 g_info("%p, %p, %p", histo_update_time_window_hook, histo_control_flow_data, tab);
186 if(GTK_IS_WIDGET(guihistocontrolflow_get_widget(histo_control_flow_data)))
187 g_info("widget still exists");
188
189 /* ButtonWidget is removed with it's widget */
190 //buttonwidget_destroy(histo_control_flow_data->buttonwidget);
191 if(tab != NULL)
192 {
193 // Delete reading hooks
194 lttvwindow_unregister_traceset_notify(tab,
195 histo_traceset_notify,
196 histo_control_flow_data);
197
198 lttvwindow_unregister_time_window_notify(tab,
199 histo_update_time_window_hook,
200 histo_control_flow_data);
201
202 lttvwindow_unregister_current_time_notify(tab,
203 histo_update_current_time_hook,
204 histo_control_flow_data);
205
206 lttvwindow_unregister_redraw_notify(tab, histo_redraw_notify, histo_control_flow_data);
207 lttvwindow_unregister_continue_notify(tab,
208 histo_continue_notify,
209 histo_control_flow_data);
210
211 lttvwindow_events_request_remove_all(histo_control_flow_data->tab,
212 histo_control_flow_data);
213
214 lttvwindow_unregister_filter_notify(tab,
215 histo_filter_changed, histo_control_flow_data);
216
217 }
218 lttvwindowtraces_background_notify_remove(histo_control_flow_data);
219 g_histo_control_flow_data_list =
220 g_slist_remove(g_histo_control_flow_data_list,histo_control_flow_data);
221
222 g_array_free(histo_control_flow_data->number_of_process, TRUE);
223
224 g_info("HISTOCFV.c : guihistocontrolflow_destructor end, %p", histo_control_flow_data);
225 g_free(histo_control_flow_data);
226
227}
228
229
This page took 0.055133 seconds and 4 git commands to generate.