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