module release minor bugfix
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / cfv.c
CommitLineData
ce0214a6 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 */
f0d936c0 18
19#include <glib.h>
20#include <gtk/gtk.h>
21#include <gdk/gdk.h>
22
f6310a5b 23#include "cfv.h"
24#include "drawing.h"
d66666fe 25#include "processlist.h"
26#include "eventhooks.h"
f6310a5b 27#include "cfv-private.h"
2a2fa4f0 28#include <lttv/lttv.h>
189a5d08 29
68997a22 30extern GSList *g_control_flow_data_list;
f0d936c0 31
ebf4f735 32static void control_flow_grab_focus(GtkWidget *widget, gpointer data){
33 ControlFlowData * control_flow_data = (ControlFlowData *)data;
ca0f8a8e 34 Tab * tab = control_flow_data->tab;
35 lttvwindow_report_focus(tab, guicontrolflow_get_widget(control_flow_data));
51705146 36 //g_assert(GTK_WIDGET_CAN_FOCUS(widget));
37 //gtk_widget_grab_focus(widget);
38 g_debug("FOCUS GRABBED");
ebf4f735 39}
40
41
f0d936c0 42/*****************************************************************************
43 * Control Flow Viewer class implementation *
44 *****************************************************************************/
f0d936c0 45/**
46 * Control Flow Viewer's constructor
47 *
48 * This constructor is given as a parameter to the menuitem and toolbar button
49 * registration. It creates the drawing widget.
50 * @param ParentWindow A pointer to the parent window.
51 * @return The widget created.
52 */
53ControlFlowData *
4c69e0cc 54guicontrolflow(void)
f0d936c0 55{
3cb8b205 56 GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
a56a1ba4 57
68997a22 58 ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
a56a1ba4 59
51705146 60 control_flow_data->v_adjust =
61 GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
62 0.0, /* Lower */
63 0.0, /* Upper */
64 0.0, /* Step inc. */
65 0.0, /* Page inc. */
66 0.0)); /* page size */
67
501d5405 68 /* Create the drawing */
69 control_flow_data->drawing = drawing_construct(control_flow_data);
a56a1ba4 70
68997a22 71 drawing_widget =
501d5405 72 drawing_get_widget(control_flow_data->drawing);
a56a1ba4 73
3cb8b205 74 drawing_area =
75 drawing_get_drawing_area(control_flow_data->drawing);
76
68997a22 77 control_flow_data->number_of_process = 0;
a56a1ba4 78
79 /* Create the Process list */
68997a22 80 control_flow_data->process_list = processlist_construct();
a56a1ba4 81
68997a22 82 process_list_widget =
83 processlist_get_widget(control_flow_data->process_list);
a56a1ba4 84
51705146 85 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(process_list_widget),
86 GTK_ADJUSTMENT(
87 control_flow_data->v_adjust));
ba90bc77 88
a56a1ba4 89
51705146 90 //control_flow_data->Inside_HBox_V = gtk_hbox_new(0, 0);
91 control_flow_data->top_widget = control_flow_data->h_paned =
92 gtk_hpaned_new();
93
94 gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned),
95 process_list_widget, FALSE, TRUE);
96 gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned),
97 drawing_widget, TRUE, TRUE);
98
a56a1ba4 99 /* Set the size of the drawing area */
501d5405 100 //drawing_Resize(drawing, h, w);
a56a1ba4 101
102 /* Get trace statistics */
68997a22 103 //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
a56a1ba4 104
68997a22 105 gtk_widget_show(drawing_widget);
106 gtk_widget_show(process_list_widget);
107 gtk_widget_show(control_flow_data->h_paned);
a56a1ba4 108
109 g_object_set_data_full(
51705146 110 G_OBJECT(control_flow_data->top_widget),
68997a22 111 "control_flow_data",
112 control_flow_data,
a56a1ba4 113 (GDestroyNotify)guicontrolflow_destructor);
114
115 g_object_set_data(
3cb8b205 116 G_OBJECT(drawing_area),
68997a22 117 "control_flow_data",
118 control_flow_data);
a56a1ba4 119
68997a22 120 g_control_flow_data_list = g_slist_append(
121 g_control_flow_data_list,
122 control_flow_data);
a56a1ba4 123
124 //WARNING : The widget must be
501d5405 125 //inserted in the main window before the drawing area
a56a1ba4 126 //can be configured (and this must happend bedore sending
127 //data)
128
51705146 129 //g_signal_connect (G_OBJECT (process_list_widget), "grab-focus",
130 //g_signal_connect (G_OBJECT (control_flow_data->scrolled_window),
131 // "button-press-event",
132 // G_CALLBACK (control_flow_grab_focus),
133 // control_flow_data);
a43d67ba 134
68997a22 135 return control_flow_data;
f0d936c0 136
137}
138
78417791 139/* Destroys widget also */
140void
68997a22 141guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
78417791 142{
68997a22 143 g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
a56a1ba4 144 /* May already have been done by GTK window closing */
ca0f8a8e 145 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
146 gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data));
68997a22 147 //control_flow_data->mw = NULL;
148 //FIXME guicontrolflow_destructor(control_flow_data);
78417791 149}
150
189a5d08 151/* When this destructor is called, the widgets are already disconnected */
f0d936c0 152void
68997a22 153guicontrolflow_destructor(ControlFlowData *control_flow_data)
f0d936c0 154{
a56a1ba4 155 guint index;
ca0f8a8e 156 Tab *tab = control_flow_data->tab;
a56a1ba4 157
68997a22 158 g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
ca0f8a8e 159 g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab);
160 if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
a56a1ba4 161 g_info("widget still exists");
162
163 /* Process List is removed with it's widget */
68997a22 164 //ProcessList_destroy(control_flow_data->process_list);
ca0f8a8e 165 if(tab != NULL)
a56a1ba4 166 {
a43d67ba 167 /* Delete reading hooks */
6395d57c 168 lttvwindow_unregister_traceset_notify(tab,
169 traceset_notify,
170 control_flow_data);
171
ca0f8a8e 172 lttvwindow_unregister_time_window_notify(tab,
224446ce 173 update_time_window_hook,
174 control_flow_data);
a56a1ba4 175
ca0f8a8e 176 lttvwindow_unregister_current_time_notify(tab,
224446ce 177 update_current_time_hook,
178 control_flow_data);
ca0f8a8e 179
180 lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
181 lttvwindow_unregister_continue_notify(tab,
182 continue_notify,
183 control_flow_data);
184
185 lttvwindow_events_request_remove_all(control_flow_data->tab,
186 control_flow_data);
51705146 187
188 lttvwindowtraces_background_notify_remove(control_flow_data);
a56a1ba4 189 }
ca0f8a8e 190 g_control_flow_data_list =
191 g_slist_remove(g_control_flow_data_list,control_flow_data);
192
193 g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
68997a22 194 g_free(control_flow_data);
ca0f8a8e 195
f0d936c0 196}
197
68997a22 198GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
558aa013 199{
51705146 200 return control_flow_data->top_widget ;
558aa013 201}
f0d936c0 202
4c69e0cc 203ProcessList *guicontrolflow_get_process_list
68997a22 204 (ControlFlowData *control_flow_data)
f7afe191 205{
68997a22 206 return control_flow_data->process_list ;
f7afe191 207}
208
f7afe191 209
This page took 0.037823 seconds and 4 git commands to generate.